Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: webrtc/voice_engine/channel.cc

Issue 2638083002: Attach TransportFeedbackPacketLossTracker to ANA (PLR only) (Closed)
Patch Set: TODO replaced by task (7173). Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 14 matching lines...) Expand all
25 #include "webrtc/config.h" 25 #include "webrtc/config.h"
26 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 26 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
27 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" 27 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
28 #include "webrtc/modules/audio_device/include/audio_device.h" 28 #include "webrtc/modules/audio_device/include/audio_device.h"
29 #include "webrtc/modules/audio_processing/include/audio_processing.h" 29 #include "webrtc/modules/audio_processing/include/audio_processing.h"
30 #include "webrtc/modules/include/module_common_types.h" 30 #include "webrtc/modules/include/module_common_types.h"
31 #include "webrtc/modules/pacing/packet_router.h" 31 #include "webrtc/modules/pacing/packet_router.h"
32 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" 32 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
33 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" 33 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
34 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" 34 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
35 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" 36 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h"
36 #include "webrtc/modules/utility/include/process_thread.h" 37 #include "webrtc/modules/utility/include/process_thread.h"
37 #include "webrtc/system_wrappers/include/trace.h" 38 #include "webrtc/system_wrappers/include/trace.h"
38 #include "webrtc/voice_engine/include/voe_external_media.h" 39 #include "webrtc/voice_engine/include/voe_external_media.h"
39 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" 40 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
40 #include "webrtc/voice_engine/output_mixer.h" 41 #include "webrtc/voice_engine/output_mixer.h"
41 #include "webrtc/voice_engine/statistics.h" 42 #include "webrtc/voice_engine/statistics.h"
42 #include "webrtc/voice_engine/transmit_mixer.h" 43 #include "webrtc/voice_engine/transmit_mixer.h"
43 #include "webrtc/voice_engine/utility.h" 44 #include "webrtc/voice_engine/utility.h"
44 45
45 namespace webrtc { 46 namespace webrtc {
46 namespace voe { 47 namespace voe {
47 48
48 namespace { 49 namespace {
49 50
50 constexpr int64_t kMaxRetransmissionWindowMs = 1000; 51 constexpr int64_t kMaxRetransmissionWindowMs = 1000;
51 constexpr int64_t kMinRetransmissionWindowMs = 30; 52 constexpr int64_t kMinRetransmissionWindowMs = 30;
52 53
54 // TODO(elad.alon): Subsequent CL will make these values experiment-dependent.
55 constexpr size_t kPacketLossTrackerMinWindowSize = 100;
56 constexpr size_t kPacketLossTrackerMaxWindowSize = 200;
57 constexpr size_t kPacketLossTrackerMinPairsNumForRplr = 50;
58
53 } // namespace 59 } // namespace
54 60
55 const int kTelephoneEventAttenuationdB = 10; 61 const int kTelephoneEventAttenuationdB = 10;
56 62
57 class RtcEventLogProxy final : public webrtc::RtcEventLog { 63 class RtcEventLogProxy final : public webrtc::RtcEventLog {
58 public: 64 public:
59 RtcEventLogProxy() : event_log_(nullptr) {} 65 RtcEventLogProxy() : event_log_(nullptr) {}
60 66
61 bool StartLogging(const std::string& file_name, 67 bool StartLogging(const std::string& file_name,
62 int64_t max_size_bytes) override { 68 int64_t max_size_bytes) override {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 201 }
196 202
197 void SetTransportFeedbackObserver( 203 void SetTransportFeedbackObserver(
198 TransportFeedbackObserver* feedback_observer) { 204 TransportFeedbackObserver* feedback_observer) {
199 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 205 RTC_DCHECK(thread_checker_.CalledOnValidThread());
200 rtc::CritScope lock(&crit_); 206 rtc::CritScope lock(&crit_);
201 feedback_observer_ = feedback_observer; 207 feedback_observer_ = feedback_observer;
202 } 208 }
203 209
204 // Implements TransportFeedbackObserver. 210 // Implements TransportFeedbackObserver.
205 void AddPacket(uint16_t sequence_number, 211 void AddPacket(uint32_t ssrc,
212 uint16_t sequence_number,
206 size_t length, 213 size_t length,
207 int probe_cluster_id) override { 214 int probe_cluster_id) override {
208 RTC_DCHECK(pacer_thread_.CalledOnValidThread()); 215 RTC_DCHECK(pacer_thread_.CalledOnValidThread());
209 rtc::CritScope lock(&crit_); 216 rtc::CritScope lock(&crit_);
210 if (feedback_observer_) 217 if (feedback_observer_)
211 feedback_observer_->AddPacket(sequence_number, length, probe_cluster_id); 218 feedback_observer_->AddPacket(ssrc, sequence_number, length,
219 probe_cluster_id);
212 } 220 }
213 void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override { 221 void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override {
214 RTC_DCHECK(network_thread_.CalledOnValidThread()); 222 RTC_DCHECK(network_thread_.CalledOnValidThread());
215 rtc::CritScope lock(&crit_); 223 rtc::CritScope lock(&crit_);
216 if (feedback_observer_) 224 if (feedback_observer_)
217 feedback_observer_->OnTransportFeedback(feedback); 225 feedback_observer_->OnTransportFeedback(feedback);
218 } 226 }
219 std::vector<PacketInfo> GetTransportFeedbackVector() const override { 227 std::vector<PacketInfo> GetTransportFeedbackVector() const override {
220 RTC_NOTREACHED(); 228 RTC_NOTREACHED();
221 return std::vector<PacketInfo>(); 229 return std::vector<PacketInfo>();
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 _outputSpeechType(AudioFrame::kNormalSpeech), 935 _outputSpeechType(AudioFrame::kNormalSpeech),
928 restored_packet_in_use_(false), 936 restored_packet_in_use_(false),
929 rtcp_observer_(new VoERtcpObserver(this)), 937 rtcp_observer_(new VoERtcpObserver(this)),
930 associate_send_channel_(ChannelOwner(nullptr)), 938 associate_send_channel_(ChannelOwner(nullptr)),
931 pacing_enabled_(config.enable_voice_pacing), 939 pacing_enabled_(config.enable_voice_pacing),
932 feedback_observer_proxy_(new TransportFeedbackProxy()), 940 feedback_observer_proxy_(new TransportFeedbackProxy()),
933 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), 941 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()),
934 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), 942 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()),
935 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), 943 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(),
936 kMaxRetransmissionWindowMs)), 944 kMaxRetransmissionWindowMs)),
937 decoder_factory_(config.acm_config.decoder_factory) { 945 decoder_factory_(config.acm_config.decoder_factory),
946 // TODO(elad.alon): Subsequent CL experiments with PLR source.
947 use_twcc_plr_for_ana_(false),
948 packet_loss_tracker_(kPacketLossTrackerMaxWindowSize,
949 kPacketLossTrackerMinWindowSize,
950 kPacketLossTrackerMinPairsNumForRplr) {
938 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), 951 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId),
939 "Channel::Channel() - ctor"); 952 "Channel::Channel() - ctor");
940 AudioCodingModule::Config acm_config(config.acm_config); 953 AudioCodingModule::Config acm_config(config.acm_config);
941 acm_config.id = VoEModuleId(instanceId, channelId); 954 acm_config.id = VoEModuleId(instanceId, channelId);
942 acm_config.neteq_config.enable_muted_state = true; 955 acm_config.neteq_config.enable_muted_state = true;
943 audio_coding_.reset(AudioCodingModule::Create(acm_config)); 956 audio_coding_.reset(AudioCodingModule::Create(acm_config));
944 957
945 _outputAudioLevel.Clear(); 958 _outputAudioLevel.Clear();
946 959
947 RtpRtcp::Configuration configuration; 960 RtpRtcp::Configuration configuration;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { 1353 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1341 if (*encoder) { 1354 if (*encoder) {
1342 (*encoder)->OnReceivedUplinkBandwidth( 1355 (*encoder)->OnReceivedUplinkBandwidth(
1343 bitrate_bps, rtc::Optional<int64_t>(probing_interval_ms)); 1356 bitrate_bps, rtc::Optional<int64_t>(probing_interval_ms));
1344 } 1357 }
1345 }); 1358 });
1346 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); 1359 retransmission_rate_limiter_->SetMaxRate(bitrate_bps);
1347 } 1360 }
1348 1361
1349 void Channel::OnIncomingFractionLoss(int fraction_lost) { 1362 void Channel::OnIncomingFractionLoss(int fraction_lost) {
1363 if (use_twcc_plr_for_ana_)
1364 return;
1350 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { 1365 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1351 if (*encoder) 1366 if (*encoder)
1352 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); 1367 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f);
1353 }); 1368 });
1354 } 1369 }
1355 1370
1356 int32_t Channel::SetVADStatus(bool enableVAD, 1371 int32_t Channel::SetVADStatus(bool enableVAD,
1357 ACMVADMode mode, 1372 ACMVADMode mode,
1358 bool disableDTX) { 1373 bool disableDTX) {
1359 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1374 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 void Channel::SetTransportOverhead(size_t transport_overhead_per_packet) { 2913 void Channel::SetTransportOverhead(size_t transport_overhead_per_packet) {
2899 transport_overhead_per_packet_ = transport_overhead_per_packet; 2914 transport_overhead_per_packet_ = transport_overhead_per_packet;
2900 UpdateOverheadForEncoder(); 2915 UpdateOverheadForEncoder();
2901 } 2916 }
2902 2917
2903 void Channel::OnOverheadChanged(size_t overhead_bytes_per_packet) { 2918 void Channel::OnOverheadChanged(size_t overhead_bytes_per_packet) {
2904 rtp_overhead_per_packet_ = overhead_bytes_per_packet; 2919 rtp_overhead_per_packet_ = overhead_bytes_per_packet;
2905 UpdateOverheadForEncoder(); 2920 UpdateOverheadForEncoder();
2906 } 2921 }
2907 2922
2923 void Channel::HandleTransportFeedback(
2924 const std::vector<uint16_t>& packets_sent_since_last_feedback,
2925 const rtcp::TransportFeedback& feedback) {
2926 for (uint16_t sent_sequence_number : packets_sent_since_last_feedback) {
2927 packet_loss_tracker_.OnPacketAdded(sent_sequence_number);
2928 }
2929
2930 // TODO(elad.alon): Needed even when !use_twcc_plr_for_ana_, because
2931 // subsequent CLs will introduce pushing RPLR down to ANA, too, and that
2932 // would happen unconditionally.
2933 // (Rationale for unconditionality: it's cheap enough, and once
2934 // experimentation is over, we either always do it or never do it, in which
2935 // case the code involved will just be deleted.)
2936 packet_loss_tracker_.OnReceivedTransportFeedback(feedback);
2937
2938 if (use_twcc_plr_for_ana_) {
2939 rtc::Optional<float> plr = packet_loss_tracker_.GetPacketLossRate();
2940 if (plr) {
2941 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
2942 if (*encoder)
2943 (*encoder)->OnReceivedUplinkPacketLossFraction(*plr);
2944 });
2945 }
2946 }
2947 }
2948
2908 int Channel::RegisterExternalMediaProcessing(ProcessingTypes type, 2949 int Channel::RegisterExternalMediaProcessing(ProcessingTypes type,
2909 VoEMediaProcess& processObject) { 2950 VoEMediaProcess& processObject) {
2910 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 2951 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
2911 "Channel::RegisterExternalMediaProcessing()"); 2952 "Channel::RegisterExternalMediaProcessing()");
2912 2953
2913 rtc::CritScope cs(&_callbackCritSect); 2954 rtc::CritScope cs(&_callbackCritSect);
2914 2955
2915 if (kPlaybackPerChannel == type) { 2956 if (kPlaybackPerChannel == type) {
2916 if (_outputExternalMediaCallbackPtr) { 2957 if (_outputExternalMediaCallbackPtr) {
2917 _engineStatisticsPtr->SetLastError( 2958 _engineStatisticsPtr->SetLastError(
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
3303 int64_t min_rtt = 0; 3344 int64_t min_rtt = 0;
3304 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3345 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3305 0) { 3346 0) {
3306 return 0; 3347 return 0;
3307 } 3348 }
3308 return rtt; 3349 return rtt;
3309 } 3350 }
3310 3351
3311 } // namespace voe 3352 } // namespace voe
3312 } // namespace webrtc 3353 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698