Chromium Code Reviews

Unified Diff: webrtc/voice_engine/channel.cc

Issue 2181383002: Add NACK rate throttling for audio channels. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« webrtc/video/end_to_end_tests.cc ('K') | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/voice_engine/channel.cc
diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc
index 424d291bcbb3a274dd5ce4a302bd014dad7bc5f4..db275e103d250335bc0a1cae2486a72ff4ba5a35 100644
--- a/webrtc/voice_engine/channel.cc
+++ b/webrtc/voice_engine/channel.cc
@@ -17,6 +17,7 @@
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/format_macros.h"
#include "webrtc/base/logging.h"
+#include "webrtc/base/rate_limiter.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/base/timeutils.h"
#include "webrtc/call/rtc_event_log.h"
@@ -47,6 +48,9 @@ namespace voe {
namespace {
+constexpr int64_t kMaxRetranmissionWindowMs = 1000;
+constexpr int64_t kMinRetranmissionWindowMs = 30;
+
bool RegisterReceiveCodec(std::unique_ptr<AudioCodingModule>* acm,
acm2::RentACodec* rac,
const CodecInst& ci) {
@@ -534,6 +538,13 @@ int32_t Channel::OnReceivedPayloadData(const uint8_t* payloadData,
int64_t round_trip_time = 0;
_rtpRtcpModule->RTT(rtp_receiver_->SSRC(), &round_trip_time, NULL, NULL,
NULL);
+ int64_t nack_window_ms = round_trip_time;
+ if (nack_window_ms < kMinRetranmissionWindowMs) {
+ nack_window_ms = kMinRetranmissionWindowMs;
+ } else if (nack_window_ms > kMaxRetranmissionWindowMs) {
+ nack_window_ms = kMaxRetranmissionWindowMs;
+ }
+ nack_rate_limiter_->SetWindowSize(nack_window_ms);
stefan-webrtc 2016/07/28 07:27:38 This seems like a slightly odd place for this. Wou
minyue-webrtc 2016/07/28 08:17:27 It might be good to put in VoERtcpObserver
sprang_webrtc 2016/07/28 13:00:58 Done.
std::vector<uint16_t> nack_list = audio_coding_->GetNackList(round_trip_time);
if (!nack_list.empty()) {
@@ -902,6 +913,8 @@ Channel::Channel(int32_t channelId,
feedback_observer_proxy_(new TransportFeedbackProxy()),
seq_num_allocator_proxy_(new TransportSequenceNumberProxy()),
rtp_packet_sender_proxy_(new RtpPacketSenderProxy()),
+ nack_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(),
+ kMaxRetranmissionWindowMs)),
decoder_factory_(decoder_factory) {
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::Channel() - ctor");
@@ -933,6 +946,7 @@ Channel::Channel(int32_t channelId,
configuration.transport_feedback_callback = feedback_observer_proxy_.get();
}
configuration.event_log = &(*event_log_proxy_);
+ configuration.retransmission_rate_limiter = nack_rate_limiter_.get();
stefan-webrtc 2016/07/28 07:27:38 should we rename it retransmission_rate_limiter_ i
sprang_webrtc 2016/07/28 13:00:58 Done.
_rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration));
_rtpRtcpModule->SetSendingMediaStatus(false);
@@ -1352,6 +1366,7 @@ void Channel::SetBitRate(int bitrate_bps) {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps);
audio_coding_->SetBitRate(bitrate_bps);
+ nack_rate_limiter_->SetMaxRate(bitrate_bps);
stefan-webrtc 2016/07/28 07:27:38 What will the default be if this is never called?
sprang_webrtc 2016/07/28 13:00:58 Rate limit defaults to maxint, so always allows re
stefan-webrtc 2016/07/28 15:06:15 Acknowledged.
}
void Channel::OnIncomingFractionLoss(int fraction_lost) {
« webrtc/video/end_to_end_tests.cc ('K') | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine