From a8d2a81423655bda9ba8029e827d9cabdc3db0ce Mon Sep 17 00:00:00 2001 From: "asapersson@webrtc.org" Date: Wed, 26 Sep 2012 07:51:16 +0000 Subject: [PATCH] Renamed constant and added comments. Review URL: https://webrtc-codereview.appspot.com/847004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2825 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../rtp_rtcp/source/transmission_bucket.cc | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/modules/rtp_rtcp/source/transmission_bucket.cc b/src/modules/rtp_rtcp/source/transmission_bucket.cc index 0d223b44a..6808b104d 100644 --- a/src/modules/rtp_rtcp/source/transmission_bucket.cc +++ b/src/modules/rtp_rtcp/source/transmission_bucket.cc @@ -15,6 +15,24 @@ #include "rtp_utility.h" namespace webrtc { +namespace { +// Factor that is applied to the target bitrate to calculate the number of +// bytes that can be transmitted per interval. +// Increasing this factor will result in lower delays in cases of bitrate +// overshoots. +const float kBytesPerIntervalMargin = 1.5f; + +// Time limit in ms between packets within a frame. +// A packet will be transmitted if the elapsed time since the last transmitted +// packet (for packets within same frames) has exceed this time limit. +const int kPacketLimitMs = 5; + +// Time limit factor between frames. +// A packet in a new frame will be transmitted if the elapsed time since the +// last transmitted packet in the previous frame has exceeded the time +// difference for when the packets were stored, multiplied by this factor. +const float kFrameLimitFactor = 1.2f; +} // namespace TransmissionBucket::TransmissionBucket(RtpRtcpClock* clock) : clock_(clock), @@ -57,9 +75,8 @@ void TransmissionBucket::UpdateBytesPerInterval( uint16_t target_bitrate_kbps) { webrtc::CriticalSectionScoped cs(*critsect_); - const float kMargin = 1.5f; uint32_t bytes_per_interval = - kMargin * (target_bitrate_kbps * delta_time_ms / 8); + kBytesPerIntervalMargin * (target_bitrate_kbps * delta_time_ms / 8); if (bytes_rem_interval_ < 0) { bytes_rem_interval_ += bytes_per_interval; @@ -109,7 +126,6 @@ bool TransmissionBucket::SameFrameAndPacketIntervalTimeElapsed( // Not same frame. return false; } - const int kPacketLimitMs = 5; if ((clock_->GetTimeInMS() - last_transmitted_packet_.transmitted_ms) < kPacketLimitMs) { // Time has not elapsed. @@ -128,7 +144,6 @@ bool TransmissionBucket::NewFrameAndFrameIntervalTimeElapsed( // Not a new frame. return false; } - const float kFrameLimitFactor = 1.2f; if ((clock_->GetTimeInMS() - last_transmitted_packet_.transmitted_ms) < kFrameLimitFactor * (current_packet.stored_ms - last_transmitted_packet_.stored_ms)) {