Fix bug in how send timestamps are converted to 24 bits.

BUG=webrtc:4173
R=sprang@webrtc.org

Review URL: https://codereview.webrtc.org/1412683004 .

Cr-Commit-Position: refs/heads/master@{#10356}
This commit is contained in:
Stefan Holmer 2015-10-21 13:41:48 +02:00
parent e37870297f
commit 0a87ffcaad
4 changed files with 27 additions and 11 deletions

View File

@ -36,7 +36,7 @@ class BweSimulation : public BweTest,
VerboseLogging(true);
}
Random random_;
test::Random random_;
private:
RTC_DISALLOW_COPY_AND_ASSIGN(BweSimulation);

View File

@ -64,6 +64,15 @@ std::vector<K> Keys(const std::map<K, V>& map) {
return keys;
}
uint32_t ConvertMsTo24Bits(int64_t time_ms) {
uint32_t time_24_bits =
static_cast<uint32_t>(
((static_cast<uint64_t>(time_ms) << kAbsSendTimeFraction) + 500) /
1000) &
0x00FFFFFF;
return time_24_bits;
}
bool RemoteBitrateEstimatorAbsSendTime::IsWithinClusterBounds(
int send_delta_ms,
const Cluster& cluster_aggregate) {
@ -219,12 +228,8 @@ bool RemoteBitrateEstimatorAbsSendTime::IsBitrateImproving(
void RemoteBitrateEstimatorAbsSendTime::IncomingPacketFeedbackVector(
const std::vector<PacketInfo>& packet_feedback_vector) {
for (const auto& packet_info : packet_feedback_vector) {
// TODO(holmer): We should get rid of this conversion if possible as we may
// lose precision.
uint32_t send_time_32bits = (packet_info.send_time_ms) / kTimestampToMs;
uint32_t send_time_24bits =
send_time_32bits >> kAbsSendTimeInterArrivalUpshift;
IncomingPacketInfo(packet_info.arrival_time_ms, send_time_24bits,
IncomingPacketInfo(packet_info.arrival_time_ms,
ConvertMsTo24Bits(packet_info.send_time_ms),
packet_info.payload_size, 0, packet_info.was_paced);
}
}

View File

@ -26,8 +26,9 @@
namespace webrtc {
// Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP.
const size_t kMaxPaddingLength = 224;
const int kSendSideDelayWindowMs = 1000;
static const size_t kMaxPaddingLength = 224;
static const int kSendSideDelayWindowMs = 1000;
static const uint32_t kAbsSendTimeFraction = 18;
namespace {
@ -45,6 +46,16 @@ const char* FrameTypeToString(FrameType frame_type) {
return "";
}
// TODO(holmer): Merge this with the implementation in
// remote_bitrate_estimator_abs_send_time.cc.
uint32_t ConvertMsTo24Bits(int64_t time_ms) {
uint32_t time_24_bits =
static_cast<uint32_t>(
((static_cast<uint64_t>(time_ms) << kAbsSendTimeFraction) + 500) /
1000) &
0x00FFFFFF;
return time_24_bits;
}
} // namespace
class BitrateAggregator {
@ -1596,7 +1607,7 @@ void RTPSender::UpdateAbsoluteSendTime(uint8_t* rtp_packet,
// Update absolute send time field (convert ms to 24-bit unsigned with 18 bit
// fractional part).
ByteWriter<uint32_t, 3>::WriteBigEndian(rtp_packet + offset + 1,
((now_ms << 18) / 1000) & 0x00ffffff);
ConvertMsTo24Bits(now_ms));
}
uint16_t RTPSender::UpdateTransportSequenceNumber(

View File

@ -64,7 +64,7 @@ size_t GetPayloadDataLength(const RTPHeader& rtp_header,
}
uint64_t ConvertMsToAbsSendTime(int64_t time_ms) {
return 0x00fffffful & ((time_ms << 18) / 1000);
return (((time_ms << 18) + 500) / 1000) & 0x00ffffff;
}
class LoopbackTransportTest : public webrtc::Transport {