| OLD | NEW |
| 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 15 matching lines...) Expand all Loading... |
| 26 #include "webrtc/config.h" | 26 #include "webrtc/config.h" |
| 27 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 27 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| 28 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" | 28 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" |
| 29 #include "webrtc/modules/audio_device/include/audio_device.h" | 29 #include "webrtc/modules/audio_device/include/audio_device.h" |
| 30 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 30 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 31 #include "webrtc/modules/include/module_common_types.h" | 31 #include "webrtc/modules/include/module_common_types.h" |
| 32 #include "webrtc/modules/pacing/packet_router.h" | 32 #include "webrtc/modules/pacing/packet_router.h" |
| 33 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 33 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
| 34 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 34 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
| 35 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 35 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
| 36 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
| 36 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | 37 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" |
| 37 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" | 38 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" |
| 38 #include "webrtc/modules/utility/include/process_thread.h" | 39 #include "webrtc/modules/utility/include/process_thread.h" |
| 39 #include "webrtc/system_wrappers/include/trace.h" | 40 #include "webrtc/system_wrappers/include/trace.h" |
| 40 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" | 41 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
| 41 #include "webrtc/voice_engine/output_mixer.h" | 42 #include "webrtc/voice_engine/output_mixer.h" |
| 42 #include "webrtc/voice_engine/statistics.h" | 43 #include "webrtc/voice_engine/statistics.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 kPacketLossTrackerMaxWindowSizeMs = 15000; |
| 56 constexpr size_t kPlrMinNumAckedPackets = 50; |
| 57 constexpr size_t kRplrMinNumAckedPairs = 40; |
| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 246 } |
| 241 | 247 |
| 242 void SetTransportFeedbackObserver( | 248 void SetTransportFeedbackObserver( |
| 243 TransportFeedbackObserver* feedback_observer) { | 249 TransportFeedbackObserver* feedback_observer) { |
| 244 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 250 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 245 rtc::CritScope lock(&crit_); | 251 rtc::CritScope lock(&crit_); |
| 246 feedback_observer_ = feedback_observer; | 252 feedback_observer_ = feedback_observer; |
| 247 } | 253 } |
| 248 | 254 |
| 249 // Implements TransportFeedbackObserver. | 255 // Implements TransportFeedbackObserver. |
| 250 void AddPacket(uint16_t sequence_number, | 256 void AddPacket(uint32_t ssrc, |
| 257 uint16_t sequence_number, |
| 251 size_t length, | 258 size_t length, |
| 252 const PacedPacketInfo& pacing_info) override { | 259 const PacedPacketInfo& pacing_info) override { |
| 253 RTC_DCHECK(pacer_thread_.CalledOnValidThread()); | 260 RTC_DCHECK(pacer_thread_.CalledOnValidThread()); |
| 254 rtc::CritScope lock(&crit_); | 261 rtc::CritScope lock(&crit_); |
| 255 if (feedback_observer_) | 262 if (feedback_observer_) |
| 256 feedback_observer_->AddPacket(sequence_number, length, pacing_info); | 263 feedback_observer_->AddPacket(ssrc, sequence_number, length, pacing_info); |
| 257 } | 264 } |
| 258 | 265 |
| 259 void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override { | 266 void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override { |
| 260 RTC_DCHECK(network_thread_.CalledOnValidThread()); | 267 RTC_DCHECK(network_thread_.CalledOnValidThread()); |
| 261 rtc::CritScope lock(&crit_); | 268 rtc::CritScope lock(&crit_); |
| 262 if (feedback_observer_) | 269 if (feedback_observer_) |
| 263 feedback_observer_->OnTransportFeedback(feedback); | 270 feedback_observer_->OnTransportFeedback(feedback); |
| 264 } | 271 } |
| 265 std::vector<PacketFeedback> GetTransportFeedbackVector() const override { | 272 std::vector<PacketFeedback> GetTransportFeedbackVector() const override { |
| 266 RTC_NOTREACHED(); | 273 RTC_NOTREACHED(); |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 _outputSpeechType(AudioFrame::kNormalSpeech), | 913 _outputSpeechType(AudioFrame::kNormalSpeech), |
| 907 restored_packet_in_use_(false), | 914 restored_packet_in_use_(false), |
| 908 rtcp_observer_(new VoERtcpObserver(this)), | 915 rtcp_observer_(new VoERtcpObserver(this)), |
| 909 associate_send_channel_(ChannelOwner(nullptr)), | 916 associate_send_channel_(ChannelOwner(nullptr)), |
| 910 pacing_enabled_(config.enable_voice_pacing), | 917 pacing_enabled_(config.enable_voice_pacing), |
| 911 feedback_observer_proxy_(new TransportFeedbackProxy()), | 918 feedback_observer_proxy_(new TransportFeedbackProxy()), |
| 912 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), | 919 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), |
| 913 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), | 920 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), |
| 914 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), | 921 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), |
| 915 kMaxRetransmissionWindowMs)), | 922 kMaxRetransmissionWindowMs)), |
| 916 decoder_factory_(config.acm_config.decoder_factory) { | 923 decoder_factory_(config.acm_config.decoder_factory), |
| 924 // TODO(elad.alon): Subsequent CL experiments with PLR source. |
| 925 use_twcc_plr_for_ana_(false), |
| 926 packet_loss_tracker_(kPacketLossTrackerMaxWindowSizeMs, |
| 927 kPlrMinNumAckedPackets, |
| 928 kRplrMinNumAckedPairs) { |
| 917 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), | 929 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
| 918 "Channel::Channel() - ctor"); | 930 "Channel::Channel() - ctor"); |
| 919 AudioCodingModule::Config acm_config(config.acm_config); | 931 AudioCodingModule::Config acm_config(config.acm_config); |
| 920 acm_config.id = VoEModuleId(instanceId, channelId); | 932 acm_config.id = VoEModuleId(instanceId, channelId); |
| 921 acm_config.neteq_config.enable_muted_state = true; | 933 acm_config.neteq_config.enable_muted_state = true; |
| 922 audio_coding_.reset(AudioCodingModule::Create(acm_config)); | 934 audio_coding_.reset(AudioCodingModule::Create(acm_config)); |
| 923 | 935 |
| 924 _outputAudioLevel.Clear(); | 936 _outputAudioLevel.Clear(); |
| 925 | 937 |
| 926 RtpRtcp::Configuration configuration; | 938 RtpRtcp::Configuration configuration; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1309 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1298 if (*encoder) { | 1310 if (*encoder) { |
| 1299 (*encoder)->OnReceivedUplinkBandwidth( | 1311 (*encoder)->OnReceivedUplinkBandwidth( |
| 1300 bitrate_bps, rtc::Optional<int64_t>(probing_interval_ms)); | 1312 bitrate_bps, rtc::Optional<int64_t>(probing_interval_ms)); |
| 1301 } | 1313 } |
| 1302 }); | 1314 }); |
| 1303 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); | 1315 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); |
| 1304 } | 1316 } |
| 1305 | 1317 |
| 1306 void Channel::OnIncomingFractionLoss(int fraction_lost) { | 1318 void Channel::OnIncomingFractionLoss(int fraction_lost) { |
| 1319 if (use_twcc_plr_for_ana_) |
| 1320 return; |
| 1307 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1321 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1308 if (*encoder) | 1322 if (*encoder) |
| 1309 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); | 1323 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); |
| 1310 }); | 1324 }); |
| 1311 } | 1325 } |
| 1312 | 1326 |
| 1313 int32_t Channel::SetVADStatus(bool enableVAD, | 1327 int32_t Channel::SetVADStatus(bool enableVAD, |
| 1314 ACMVADMode mode, | 1328 ACMVADMode mode, |
| 1315 bool disableDTX) { | 1329 bool disableDTX) { |
| 1316 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1330 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| (...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2724 UpdateOverheadForEncoder(); | 2738 UpdateOverheadForEncoder(); |
| 2725 } | 2739 } |
| 2726 | 2740 |
| 2727 // TODO(solenberg): Make AudioSendStream an OverheadObserver instead. | 2741 // TODO(solenberg): Make AudioSendStream an OverheadObserver instead. |
| 2728 void Channel::OnOverheadChanged(size_t overhead_bytes_per_packet) { | 2742 void Channel::OnOverheadChanged(size_t overhead_bytes_per_packet) { |
| 2729 rtc::CritScope cs(&overhead_per_packet_lock_); | 2743 rtc::CritScope cs(&overhead_per_packet_lock_); |
| 2730 rtp_overhead_per_packet_ = overhead_bytes_per_packet; | 2744 rtp_overhead_per_packet_ = overhead_bytes_per_packet; |
| 2731 UpdateOverheadForEncoder(); | 2745 UpdateOverheadForEncoder(); |
| 2732 } | 2746 } |
| 2733 | 2747 |
| 2748 void Channel::HandleTransportFeedback( |
| 2749 const std::vector<SentTransportPacketRecord>& |
| 2750 packets_sent_since_last_feedback, |
| 2751 const rtcp::TransportFeedback& feedback) { |
| 2752 for (const auto& sent_packet : packets_sent_since_last_feedback) { |
| 2753 packet_loss_tracker_.OnPacketAdded(sent_packet.sequence_number, |
| 2754 sent_packet.sent_time_ms); |
| 2755 } |
| 2756 |
| 2757 // TODO(elad.alon): Needed even when !use_twcc_plr_for_ana_, because |
| 2758 // subsequent CLs will introduce pushing RPLR down to ANA, too, and that |
| 2759 // would happen unconditionally. |
| 2760 // (Rationale for unconditionality: it's cheap enough, and once |
| 2761 // experimentation is over, we either always do it or never do it, in which |
| 2762 // case the code involved will just be deleted.) |
| 2763 packet_loss_tracker_.OnReceivedTransportFeedback(feedback); |
| 2764 |
| 2765 if (use_twcc_plr_for_ana_) { |
| 2766 rtc::Optional<float> plr = packet_loss_tracker_.GetPacketLossRate(); |
| 2767 if (plr) { |
| 2768 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 2769 if (*encoder) |
| 2770 (*encoder)->OnReceivedUplinkPacketLossFraction(*plr); |
| 2771 }); |
| 2772 } |
| 2773 } |
| 2774 } |
| 2775 |
| 2734 int Channel::GetNetworkStatistics(NetworkStatistics& stats) { | 2776 int Channel::GetNetworkStatistics(NetworkStatistics& stats) { |
| 2735 return audio_coding_->GetNetworkStatistics(&stats); | 2777 return audio_coding_->GetNetworkStatistics(&stats); |
| 2736 } | 2778 } |
| 2737 | 2779 |
| 2738 void Channel::GetDecodingCallStatistics(AudioDecodingCallStats* stats) const { | 2780 void Channel::GetDecodingCallStatistics(AudioDecodingCallStats* stats) const { |
| 2739 audio_coding_->GetDecodingCallStatistics(stats); | 2781 audio_coding_->GetDecodingCallStatistics(stats); |
| 2740 } | 2782 } |
| 2741 | 2783 |
| 2742 uint32_t Channel::GetDelayEstimate() const { | 2784 uint32_t Channel::GetDelayEstimate() const { |
| 2743 rtc::CritScope lock(&video_sync_lock_); | 2785 rtc::CritScope lock(&video_sync_lock_); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3010 int64_t min_rtt = 0; | 3052 int64_t min_rtt = 0; |
| 3011 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3053 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 3012 0) { | 3054 0) { |
| 3013 return 0; | 3055 return 0; |
| 3014 } | 3056 } |
| 3015 return rtt; | 3057 return rtt; |
| 3016 } | 3058 } |
| 3017 | 3059 |
| 3018 } // namespace voe | 3060 } // namespace voe |
| 3019 } // namespace webrtc | 3061 } // namespace webrtc |
| OLD | NEW |