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

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

Issue 1479023002: Prepare the AudioSendStream to be hooked up to send-side BWE. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Reverted back to using a proxy and fixed an issue related to audio nack. Created 5 years 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
11 #include "webrtc/voice_engine/channel.h" 11 #include "webrtc/voice_engine/channel.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/base/format_macros.h" 16 #include "webrtc/base/format_macros.h"
17 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
18 #include "webrtc/base/thread_checker.h"
18 #include "webrtc/base/timeutils.h" 19 #include "webrtc/base/timeutils.h"
19 #include "webrtc/common.h" 20 #include "webrtc/common.h"
20 #include "webrtc/config.h" 21 #include "webrtc/config.h"
21 #include "webrtc/modules/audio_device/include/audio_device.h" 22 #include "webrtc/modules/audio_device/include/audio_device.h"
22 #include "webrtc/modules/audio_processing/include/audio_processing.h" 23 #include "webrtc/modules/audio_processing/include/audio_processing.h"
23 #include "webrtc/modules/include/module_common_types.h" 24 #include "webrtc/modules/include/module_common_types.h"
25 #include "webrtc/modules/pacing/packet_router.h"
24 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" 26 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
25 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" 27 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
26 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" 28 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
27 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" 29 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h"
28 #include "webrtc/modules/utility/include/audio_frame_operations.h" 30 #include "webrtc/modules/utility/include/audio_frame_operations.h"
29 #include "webrtc/modules/utility/include/process_thread.h" 31 #include "webrtc/modules/utility/include/process_thread.h"
30 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 32 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
31 #include "webrtc/system_wrappers/include/trace.h" 33 #include "webrtc/system_wrappers/include/trace.h"
32 #include "webrtc/voice_engine/include/voe_base.h" 34 #include "webrtc/voice_engine/include/voe_base.h"
33 #include "webrtc/voice_engine/include/voe_external_media.h" 35 #include "webrtc/voice_engine/include/voe_external_media.h"
34 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" 36 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
35 #include "webrtc/voice_engine/output_mixer.h" 37 #include "webrtc/voice_engine/output_mixer.h"
36 #include "webrtc/voice_engine/statistics.h" 38 #include "webrtc/voice_engine/statistics.h"
37 #include "webrtc/voice_engine/transmit_mixer.h" 39 #include "webrtc/voice_engine/transmit_mixer.h"
38 #include "webrtc/voice_engine/utility.h" 40 #include "webrtc/voice_engine/utility.h"
39 41
40 #if defined(_WIN32) 42 #if defined(_WIN32)
41 #include <Qos.h> 43 #include <Qos.h>
42 #endif 44 #endif
43 45
44 namespace webrtc { 46 namespace webrtc {
45 namespace voe { 47 namespace voe {
48 namespace {
49
50 class TransportFeedbackProxy : public TransportFeedbackObserver {
51 public:
52 TransportFeedbackProxy() : feedback_observer_(nullptr) {
53 pacer_thread_.DetachFromThread();
54 network_thread_.DetachFromThread();
55 }
56
57 void SetTransportFeedbackObserver(
58 TransportFeedbackObserver* feedback_observer) {
59 RTC_DCHECK(thread_checker_.CalledOnValidThread());
60 rtc::CritScope lock(&crit_);
61 feedback_observer_ = feedback_observer;
62 }
63
64 // Implements TransportFeedbackObserver.
65 void AddPacket(uint16_t sequence_number,
66 size_t length,
67 bool was_paced) override {
68 RTC_DCHECK(pacer_thread_.CalledOnValidThread());
69 rtc::CritScope lock(&crit_);
70 feedback_observer_->AddPacket(sequence_number, length, was_paced);
71 }
72 void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override {
73 RTC_DCHECK(network_thread_.CalledOnValidThread());
74 rtc::CritScope lock(&crit_);
75 feedback_observer_->OnTransportFeedback(feedback);
76 }
77
78 private:
79 rtc::CriticalSection crit_;
80 rtc::ThreadChecker thread_checker_;
81 rtc::ThreadChecker pacer_thread_;
82 rtc::ThreadChecker network_thread_;
83 TransportFeedbackObserver* feedback_observer_ GUARDED_BY(&crit_);
84 };
85
86 class TransportSequenceNumberProxy : public TransportSequenceNumberAllocator {
87 public:
88 TransportSequenceNumberProxy() : seq_num_allocator_(nullptr) {
89 pacer_thread_.DetachFromThread();
90 }
91
92 void SetSequenceNumberAllocator(
93 TransportSequenceNumberAllocator* seq_num_allocator) {
94 RTC_DCHECK(thread_checker_.CalledOnValidThread());
95 rtc::CritScope lock(&crit_);
96 seq_num_allocator_ = seq_num_allocator;
97 }
98
99 // Implements TransportSequenceNumberAllocator.
100 uint16_t AllocateSequenceNumber() override {
101 RTC_DCHECK(pacer_thread_.CalledOnValidThread());
102 rtc::CritScope lock(&crit_);
103 RTC_DCHECK(seq_num_allocator_ != nullptr);
104 return seq_num_allocator_->AllocateSequenceNumber();
105 }
106
107 private:
108 rtc::CriticalSection crit_;
109 rtc::ThreadChecker thread_checker_;
110 rtc::ThreadChecker pacer_thread_;
111 TransportSequenceNumberAllocator* seq_num_allocator_ GUARDED_BY(&crit_);
112 };
113
114 class PacketSenderProxy : public RtpPacketSender {
115 public:
116 PacketSenderProxy() : packet_sender_(nullptr) {
117 encoder_thread_.DetachFromThread();
118 }
119
120 void SetPacketSender(RtpPacketSender* rtp_packet_sender) {
121 RTC_DCHECK(thread_checker_.CalledOnValidThread());
122 rtc::CritScope lock(&crit_);
123 packet_sender_ = rtp_packet_sender;
124 }
125
126 // Implements RtpPacketSender.
127 void InsertPacket(Priority priority,
128 uint32_t ssrc,
129 uint16_t sequence_number,
130 int64_t capture_time_ms,
131 size_t bytes,
132 bool retransmission) override {
133 RTC_DCHECK(encoder_thread_.CalledOnValidThread());
134 RtpPacketSender* packet_sender;
135 {
136 rtc::CritScope lock(&crit_);
137 if (packet_sender_ == nullptr)
138 return;
139 packet_sender = packet_sender_;
140 }
141 packet_sender->InsertPacket(priority, ssrc, sequence_number,
142 capture_time_ms, bytes, retransmission);
143 }
144
145 private:
146 rtc::ThreadChecker thread_checker_;
147 rtc::ThreadChecker encoder_thread_;
148 rtc::CriticalSection crit_;
149 RtpPacketSender* packet_sender_ GUARDED_BY(&crit_);
150 };
151 } // namespace
46 152
47 // Extend the default RTCP statistics struct with max_jitter, defined as the 153 // Extend the default RTCP statistics struct with max_jitter, defined as the
48 // maximum jitter value seen in an RTCP report block. 154 // maximum jitter value seen in an RTCP report block.
49 struct ChannelStatistics : public RtcpStatistics { 155 struct ChannelStatistics : public RtcpStatistics {
50 ChannelStatistics() : rtcp(), max_jitter(0) {} 156 ChannelStatistics() : rtcp(), max_jitter(0) {}
51 157
52 RtcpStatistics rtcp; 158 RtcpStatistics rtcp;
53 uint32_t max_jitter; 159 uint32_t max_jitter;
54 }; 160 };
55 161
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, 789 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
684 VoEId(_instanceId,_channelId), 790 VoEId(_instanceId,_channelId),
685 "Channel::RecordFileEnded() => output file recorder module is" 791 "Channel::RecordFileEnded() => output file recorder module is"
686 " shutdown"); 792 " shutdown");
687 } 793 }
688 794
689 Channel::Channel(int32_t channelId, 795 Channel::Channel(int32_t channelId,
690 uint32_t instanceId, 796 uint32_t instanceId,
691 RtcEventLog* const event_log, 797 RtcEventLog* const event_log,
692 const Config& config) 798 const Config& config)
693 : _fileCritSect(*CriticalSectionWrapper::CreateCriticalSection()), 799 : _fileCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
694 _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()), 800 _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
695 volume_settings_critsect_(*CriticalSectionWrapper::CreateCriticalSection()), 801 volume_settings_critsect_(
696 _instanceId(instanceId), 802 *CriticalSectionWrapper::CreateCriticalSection()),
697 _channelId(channelId), 803 _instanceId(instanceId),
698 event_log_(event_log), 804 _channelId(channelId),
699 rtp_header_parser_(RtpHeaderParser::Create()), 805 event_log_(event_log),
700 rtp_payload_registry_( 806 rtp_header_parser_(RtpHeaderParser::Create()),
701 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), 807 rtp_payload_registry_(
702 rtp_receive_statistics_( 808 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))),
703 ReceiveStatistics::Create(Clock::GetRealTimeClock())), 809 rtp_receive_statistics_(
704 rtp_receiver_( 810 ReceiveStatistics::Create(Clock::GetRealTimeClock())),
705 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(), 811 rtp_receiver_(
706 this, 812 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(),
707 this, 813 this,
708 this, 814 this,
709 rtp_payload_registry_.get())), 815 this,
710 telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()), 816 rtp_payload_registry_.get())),
711 _outputAudioLevel(), 817 telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()),
712 _externalTransport(false), 818 _outputAudioLevel(),
713 _inputFilePlayerPtr(NULL), 819 _externalTransport(false),
714 _outputFilePlayerPtr(NULL), 820 _inputFilePlayerPtr(NULL),
715 _outputFileRecorderPtr(NULL), 821 _outputFilePlayerPtr(NULL),
716 // Avoid conflict with other channels by adding 1024 - 1026, 822 _outputFileRecorderPtr(NULL),
717 // won't use as much as 1024 channels. 823 // Avoid conflict with other channels by adding 1024 - 1026,
718 _inputFilePlayerId(VoEModuleId(instanceId, channelId) + 1024), 824 // won't use as much as 1024 channels.
719 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025), 825 _inputFilePlayerId(VoEModuleId(instanceId, channelId) + 1024),
720 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026), 826 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025),
721 _outputFileRecording(false), 827 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026),
722 _inbandDtmfQueue(VoEModuleId(instanceId, channelId)), 828 _outputFileRecording(false),
723 _inbandDtmfGenerator(VoEModuleId(instanceId, channelId)), 829 _inbandDtmfQueue(VoEModuleId(instanceId, channelId)),
724 _outputExternalMedia(false), 830 _inbandDtmfGenerator(VoEModuleId(instanceId, channelId)),
725 _inputExternalMediaCallbackPtr(NULL), 831 _outputExternalMedia(false),
726 _outputExternalMediaCallbackPtr(NULL), 832 _inputExternalMediaCallbackPtr(NULL),
727 _timeStamp(0), // This is just an offset, RTP module will add it's own 833 _outputExternalMediaCallbackPtr(NULL),
728 // random offset 834 _timeStamp(0), // This is just an offset, RTP module will add it's own
729 _sendTelephoneEventPayloadType(106), 835 // random offset
730 ntp_estimator_(Clock::GetRealTimeClock()), 836 _sendTelephoneEventPayloadType(106),
731 jitter_buffer_playout_timestamp_(0), 837 ntp_estimator_(Clock::GetRealTimeClock()),
732 playout_timestamp_rtp_(0), 838 jitter_buffer_playout_timestamp_(0),
733 playout_timestamp_rtcp_(0), 839 playout_timestamp_rtp_(0),
734 playout_delay_ms_(0), 840 playout_timestamp_rtcp_(0),
735 _numberOfDiscardedPackets(0), 841 playout_delay_ms_(0),
736 send_sequence_number_(0), 842 _numberOfDiscardedPackets(0),
737 ts_stats_lock_(CriticalSectionWrapper::CreateCriticalSection()), 843 send_sequence_number_(0),
738 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), 844 ts_stats_lock_(CriticalSectionWrapper::CreateCriticalSection()),
739 capture_start_rtp_time_stamp_(-1), 845 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()),
740 capture_start_ntp_time_ms_(-1), 846 capture_start_rtp_time_stamp_(-1),
741 _engineStatisticsPtr(NULL), 847 capture_start_ntp_time_ms_(-1),
742 _outputMixerPtr(NULL), 848 _engineStatisticsPtr(NULL),
743 _transmitMixerPtr(NULL), 849 _outputMixerPtr(NULL),
744 _moduleProcessThreadPtr(NULL), 850 _transmitMixerPtr(NULL),
745 _audioDeviceModulePtr(NULL), 851 _moduleProcessThreadPtr(NULL),
746 _voiceEngineObserverPtr(NULL), 852 _audioDeviceModulePtr(NULL),
747 _callbackCritSectPtr(NULL), 853 _voiceEngineObserverPtr(NULL),
748 _transportPtr(NULL), 854 _callbackCritSectPtr(NULL),
749 _rxVadObserverPtr(NULL), 855 _transportPtr(NULL),
750 _oldVadDecision(-1), 856 _rxVadObserverPtr(NULL),
751 _sendFrameType(0), 857 _oldVadDecision(-1),
752 _externalMixing(false), 858 _sendFrameType(0),
753 _mixFileWithMicrophone(false), 859 _externalMixing(false),
754 _mute(false), 860 _mixFileWithMicrophone(false),
755 _panLeft(1.0f), 861 _mute(false),
756 _panRight(1.0f), 862 _panLeft(1.0f),
757 _outputGain(1.0f), 863 _panRight(1.0f),
758 _playOutbandDtmfEvent(false), 864 _outputGain(1.0f),
759 _playInbandDtmfEvent(false), 865 _playOutbandDtmfEvent(false),
760 _lastLocalTimeStamp(0), 866 _playInbandDtmfEvent(false),
761 _lastPayloadType(0), 867 _lastLocalTimeStamp(0),
762 _includeAudioLevelIndication(false), 868 _lastPayloadType(0),
763 _outputSpeechType(AudioFrame::kNormalSpeech), 869 _includeAudioLevelIndication(false),
764 video_sync_lock_(CriticalSectionWrapper::CreateCriticalSection()), 870 _outputSpeechType(AudioFrame::kNormalSpeech),
765 _average_jitter_buffer_delay_us(0), 871 video_sync_lock_(CriticalSectionWrapper::CreateCriticalSection()),
766 _previousTimestamp(0), 872 _average_jitter_buffer_delay_us(0),
767 _recPacketDelayMs(20), 873 _previousTimestamp(0),
768 _RxVadDetection(false), 874 _recPacketDelayMs(20),
769 _rxAgcIsEnabled(false), 875 _RxVadDetection(false),
770 _rxNsIsEnabled(false), 876 _rxAgcIsEnabled(false),
771 restored_packet_in_use_(false), 877 _rxNsIsEnabled(false),
772 rtcp_observer_(new VoERtcpObserver(this)), 878 restored_packet_in_use_(false),
773 network_predictor_(new NetworkPredictor(Clock::GetRealTimeClock())), 879 rtcp_observer_(new VoERtcpObserver(this)),
774 assoc_send_channel_lock_(CriticalSectionWrapper::CreateCriticalSection()), 880 network_predictor_(new NetworkPredictor(Clock::GetRealTimeClock())),
775 associate_send_channel_(ChannelOwner(nullptr)) { 881 assoc_send_channel_lock_(CriticalSectionWrapper::CreateCriticalSection()),
882 associate_send_channel_(ChannelOwner(nullptr)),
883 pacing_enabled_(config.Get<VoicePacing>().enabled),
884 feedback_observer_proxy_(pacing_enabled_ ? new TransportFeedbackProxy()
885 : nullptr),
886 seq_num_allocator_proxy_(
887 pacing_enabled_ ? new TransportSequenceNumberProxy() : nullptr),
888 packet_sender_proxy_(pacing_enabled_ ? new PacketSenderProxy()
889 : nullptr) {
776 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,_channelId), 890 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,_channelId),
777 "Channel::Channel() - ctor"); 891 "Channel::Channel() - ctor");
778 AudioCodingModule::Config acm_config; 892 AudioCodingModule::Config acm_config;
779 acm_config.id = VoEModuleId(instanceId, channelId); 893 acm_config.id = VoEModuleId(instanceId, channelId);
780 if (config.Get<NetEqCapacityConfig>().enabled) { 894 if (config.Get<NetEqCapacityConfig>().enabled) {
781 // Clamping the buffer capacity at 20 packets. While going lower will 895 // Clamping the buffer capacity at 20 packets. While going lower will
782 // probably work, it makes little sense. 896 // probably work, it makes little sense.
783 acm_config.neteq_config.max_packets_in_buffer = 897 acm_config.neteq_config.max_packets_in_buffer =
784 std::max(20, config.Get<NetEqCapacityConfig>().capacity); 898 std::max(20, config.Get<NetEqCapacityConfig>().capacity);
785 } 899 }
786 acm_config.neteq_config.enable_fast_accelerate = 900 acm_config.neteq_config.enable_fast_accelerate =
787 config.Get<NetEqFastAccelerate>().enabled; 901 config.Get<NetEqFastAccelerate>().enabled;
788 audio_coding_.reset(AudioCodingModule::Create(acm_config)); 902 audio_coding_.reset(AudioCodingModule::Create(acm_config));
789 903
790 _inbandDtmfQueue.ResetDtmf(); 904 _inbandDtmfQueue.ResetDtmf();
791 _inbandDtmfGenerator.Init(); 905 _inbandDtmfGenerator.Init();
792 _outputAudioLevel.Clear(); 906 _outputAudioLevel.Clear();
793 907
794 RtpRtcp::Configuration configuration; 908 RtpRtcp::Configuration configuration;
795 configuration.audio = true; 909 configuration.audio = true;
796 configuration.outgoing_transport = this; 910 configuration.outgoing_transport = this;
797 configuration.audio_messages = this; 911 configuration.audio_messages = this;
798 configuration.receive_statistics = rtp_receive_statistics_.get(); 912 configuration.receive_statistics = rtp_receive_statistics_.get();
799 configuration.bandwidth_callback = rtcp_observer_.get(); 913 configuration.bandwidth_callback = rtcp_observer_.get();
914 configuration.paced_sender = packet_sender_proxy_.get();
915 configuration.transport_sequence_number_allocator =
916 seq_num_allocator_proxy_.get();
917 configuration.transport_feedback_callback = feedback_observer_proxy_.get();
800 918
801 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); 919 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration));
802 920
803 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); 921 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC()));
804 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( 922 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(
805 statistics_proxy_.get()); 923 statistics_proxy_.get());
806 924
807 Config audioproc_config; 925 Config audioproc_config;
808 audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); 926 audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false));
809 rx_audioproc_.reset(AudioProcessing::Create(audioproc_config)); 927 rx_audioproc_.reset(AudioProcessing::Create(audioproc_config));
(...skipping 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after
2777 int Channel::SetReceiveAbsoluteSenderTimeStatus(bool enable, unsigned char id) { 2895 int Channel::SetReceiveAbsoluteSenderTimeStatus(bool enable, unsigned char id) {
2778 rtp_header_parser_->DeregisterRtpHeaderExtension( 2896 rtp_header_parser_->DeregisterRtpHeaderExtension(
2779 kRtpExtensionAbsoluteSendTime); 2897 kRtpExtensionAbsoluteSendTime);
2780 if (enable && !rtp_header_parser_->RegisterRtpHeaderExtension( 2898 if (enable && !rtp_header_parser_->RegisterRtpHeaderExtension(
2781 kRtpExtensionAbsoluteSendTime, id)) { 2899 kRtpExtensionAbsoluteSendTime, id)) {
2782 return -1; 2900 return -1;
2783 } 2901 }
2784 return 0; 2902 return 0;
2785 } 2903 }
2786 2904
2905 void Channel::EnableSendTransportSequenceNumber(int id) {
2906 int ret =
2907 SetSendRtpHeaderExtension(true, kRtpExtensionTransportSequenceNumber, id);
2908 RTC_DCHECK_EQ(0, ret);
2909 }
2910
2787 void Channel::SetRTCPStatus(bool enable) { 2911 void Channel::SetRTCPStatus(bool enable) {
2788 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 2912 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
2789 "Channel::SetRTCPStatus()"); 2913 "Channel::SetRTCPStatus()");
2790 _rtpRtcpModule->SetRTCPStatus(enable ? RtcpMode::kCompound : RtcpMode::kOff); 2914 _rtpRtcpModule->SetRTCPStatus(enable ? RtcpMode::kCompound : RtcpMode::kOff);
2791 } 2915 }
2792 2916
2917 void Channel::SetCongestionControlObjects(
2918 RtpPacketSender* rtp_packet_sender,
2919 TransportFeedbackObserver* transport_feedback_observer,
2920 PacketRouter* packet_router) {
2921 RTC_DCHECK(feedback_observer_proxy_.get());
2922 RTC_DCHECK(seq_num_allocator_proxy_.get());
2923 RTC_DCHECK(packet_sender_proxy_.get());
2924 RTC_DCHECK(packet_router != nullptr || packet_router_ != nullptr);
2925 feedback_observer_proxy_->SetTransportFeedbackObserver(
2926 transport_feedback_observer);
2927 seq_num_allocator_proxy_->SetSequenceNumberAllocator(packet_router);
2928 packet_sender_proxy_->SetPacketSender(rtp_packet_sender);
2929 _rtpRtcpModule->SetStorePacketsStatus(rtp_packet_sender != nullptr, 600);
2930 if (packet_router != nullptr) {
2931 packet_router->AddRtpModule(_rtpRtcpModule.get());
2932 } else {
2933 packet_router_->RemoveRtpModule(_rtpRtcpModule.get());
2934 }
2935 packet_router_ = packet_router;
2936 }
2937
2793 int 2938 int
2794 Channel::GetRTCPStatus(bool& enabled) 2939 Channel::GetRTCPStatus(bool& enabled)
2795 { 2940 {
2796 RtcpMode method = _rtpRtcpModule->RTCP(); 2941 RtcpMode method = _rtpRtcpModule->RTCP();
2797 enabled = (method != RtcpMode::kOff); 2942 enabled = (method != RtcpMode::kOff);
2798 return 0; 2943 return 0;
2799 } 2944 }
2800 2945
2801 int 2946 int
2802 Channel::SetRTCP_CNAME(const char cName[256]) 2947 Channel::SetRTCP_CNAME(const char cName[256])
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
3155 return 0; 3300 return 0;
3156 } 3301 }
3157 3302
3158 bool Channel::GetCodecFECStatus() { 3303 bool Channel::GetCodecFECStatus() {
3159 bool enabled = audio_coding_->CodecFEC(); 3304 bool enabled = audio_coding_->CodecFEC();
3160 return enabled; 3305 return enabled;
3161 } 3306 }
3162 3307
3163 void Channel::SetNACKStatus(bool enable, int maxNumberOfPackets) { 3308 void Channel::SetNACKStatus(bool enable, int maxNumberOfPackets) {
3164 // None of these functions can fail. 3309 // None of these functions can fail.
3165 _rtpRtcpModule->SetStorePacketsStatus(enable, maxNumberOfPackets); 3310 // If pacing is enabled we always store packets.
3311 if (!pacing_enabled_)
3312 _rtpRtcpModule->SetStorePacketsStatus(enable, maxNumberOfPackets);
3166 rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets); 3313 rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets);
3167 rtp_receiver_->SetNACKStatus(enable ? kNackRtcp : kNackOff); 3314 rtp_receiver_->SetNACKStatus(enable ? kNackRtcp : kNackOff);
3168 if (enable) 3315 if (enable)
3169 audio_coding_->EnableNack(maxNumberOfPackets); 3316 audio_coding_->EnableNack(maxNumberOfPackets);
3170 else 3317 else
3171 audio_coding_->DisableNack(); 3318 audio_coding_->DisableNack();
3172 } 3319 }
3173 3320
3174 // Called when we are missing one or more packets. 3321 // Called when we are missing one or more packets.
3175 int Channel::ResendPackets(const uint16_t* sequence_numbers, int length) { 3322 int Channel::ResendPackets(const uint16_t* sequence_numbers, int length) {
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
3942 int64_t min_rtt = 0; 4089 int64_t min_rtt = 0;
3943 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) 4090 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt)
3944 != 0) { 4091 != 0) {
3945 return 0; 4092 return 0;
3946 } 4093 }
3947 return rtt; 4094 return rtt;
3948 } 4095 }
3949 4096
3950 } // namespace voe 4097 } // namespace voe
3951 } // namespace webrtc 4098 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698