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

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

Issue 1628683002: Use separate rtp module lists for send and receive in PacketRouter. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comments addressed. Created 4 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
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/channel_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 class RtpPacketSenderProxy : public RtpPacketSender { 117 class RtpPacketSenderProxy : public RtpPacketSender {
118 public: 118 public:
119 RtpPacketSenderProxy() : rtp_packet_sender_(nullptr) {} 119 RtpPacketSenderProxy() : rtp_packet_sender_(nullptr) {}
120 120
121 void SetPacketSender(RtpPacketSender* rtp_packet_sender) { 121 void SetPacketSender(RtpPacketSender* rtp_packet_sender) {
122 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 122 RTC_DCHECK(thread_checker_.CalledOnValidThread());
123 rtc::CritScope lock(&crit_); 123 rtc::CritScope lock(&crit_);
124 rtp_packet_sender_ = rtp_packet_sender; 124 rtp_packet_sender_ = rtp_packet_sender;
125 } 125 }
126 126
127 bool HasPacketSender() const {
128 RTC_DCHECK(thread_checker_.CalledOnValidThread());
129 rtc::CritScope lock(&crit_);
130 return rtp_packet_sender_ != nullptr;
131 }
132
127 // Implements RtpPacketSender. 133 // Implements RtpPacketSender.
128 void InsertPacket(Priority priority, 134 void InsertPacket(Priority priority,
129 uint32_t ssrc, 135 uint32_t ssrc,
130 uint16_t sequence_number, 136 uint16_t sequence_number,
131 int64_t capture_time_ms, 137 int64_t capture_time_ms,
132 size_t bytes, 138 size_t bytes,
133 bool retransmission) override { 139 bool retransmission) override {
134 rtc::CritScope lock(&crit_); 140 rtc::CritScope lock(&crit_);
135 if (rtp_packet_sender_) { 141 if (rtp_packet_sender_) {
136 rtp_packet_sender_->InsertPacket(priority, ssrc, sequence_number, 142 rtp_packet_sender_->InsertPacket(priority, ssrc, sequence_number,
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 _previousTimestamp(0), 812 _previousTimestamp(0),
807 _recPacketDelayMs(20), 813 _recPacketDelayMs(20),
808 _RxVadDetection(false), 814 _RxVadDetection(false),
809 _rxAgcIsEnabled(false), 815 _rxAgcIsEnabled(false),
810 _rxNsIsEnabled(false), 816 _rxNsIsEnabled(false),
811 restored_packet_in_use_(false), 817 restored_packet_in_use_(false),
812 rtcp_observer_(new VoERtcpObserver(this)), 818 rtcp_observer_(new VoERtcpObserver(this)),
813 network_predictor_(new NetworkPredictor(Clock::GetRealTimeClock())), 819 network_predictor_(new NetworkPredictor(Clock::GetRealTimeClock())),
814 associate_send_channel_(ChannelOwner(nullptr)), 820 associate_send_channel_(ChannelOwner(nullptr)),
815 pacing_enabled_(config.Get<VoicePacing>().enabled), 821 pacing_enabled_(config.Get<VoicePacing>().enabled),
816 feedback_observer_proxy_(pacing_enabled_ ? new TransportFeedbackProxy() 822 feedback_observer_proxy_(new TransportFeedbackProxy()),
817 : nullptr), 823 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()),
818 seq_num_allocator_proxy_( 824 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()) {
819 pacing_enabled_ ? new TransportSequenceNumberProxy() : nullptr),
820 rtp_packet_sender_proxy_(pacing_enabled_ ? new RtpPacketSenderProxy()
821 : nullptr) {
822 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), 825 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId),
823 "Channel::Channel() - ctor"); 826 "Channel::Channel() - ctor");
824 AudioCodingModule::Config acm_config; 827 AudioCodingModule::Config acm_config;
825 acm_config.id = VoEModuleId(instanceId, channelId); 828 acm_config.id = VoEModuleId(instanceId, channelId);
826 if (config.Get<NetEqCapacityConfig>().enabled) { 829 if (config.Get<NetEqCapacityConfig>().enabled) {
827 // Clamping the buffer capacity at 20 packets. While going lower will 830 // Clamping the buffer capacity at 20 packets. While going lower will
828 // probably work, it makes little sense. 831 // probably work, it makes little sense.
829 acm_config.neteq_config.max_packets_in_buffer = 832 acm_config.neteq_config.max_packets_in_buffer =
830 std::max(20, config.Get<NetEqCapacityConfig>().capacity); 833 std::max(20, config.Get<NetEqCapacityConfig>().capacity);
831 } 834 }
832 acm_config.neteq_config.enable_fast_accelerate = 835 acm_config.neteq_config.enable_fast_accelerate =
833 config.Get<NetEqFastAccelerate>().enabled; 836 config.Get<NetEqFastAccelerate>().enabled;
834 audio_coding_.reset(AudioCodingModule::Create(acm_config)); 837 audio_coding_.reset(AudioCodingModule::Create(acm_config));
835 838
836 _inbandDtmfQueue.ResetDtmf(); 839 _inbandDtmfQueue.ResetDtmf();
837 _inbandDtmfGenerator.Init(); 840 _inbandDtmfGenerator.Init();
838 _outputAudioLevel.Clear(); 841 _outputAudioLevel.Clear();
839 842
840 RtpRtcp::Configuration configuration; 843 RtpRtcp::Configuration configuration;
841 configuration.audio = true; 844 configuration.audio = true;
842 configuration.outgoing_transport = this; 845 configuration.outgoing_transport = this;
843 configuration.audio_messages = this; 846 configuration.audio_messages = this;
844 configuration.receive_statistics = rtp_receive_statistics_.get(); 847 configuration.receive_statistics = rtp_receive_statistics_.get();
845 configuration.bandwidth_callback = rtcp_observer_.get(); 848 configuration.bandwidth_callback = rtcp_observer_.get();
846 configuration.paced_sender = rtp_packet_sender_proxy_.get(); 849 if (pacing_enabled_) {
847 configuration.transport_sequence_number_allocator = 850 configuration.paced_sender = rtp_packet_sender_proxy_.get();
848 seq_num_allocator_proxy_.get(); 851 configuration.transport_sequence_number_allocator =
849 configuration.transport_feedback_callback = feedback_observer_proxy_.get(); 852 seq_num_allocator_proxy_.get();
853 configuration.transport_feedback_callback = feedback_observer_proxy_.get();
854 }
850 configuration.event_log = event_log; 855 configuration.event_log = event_log;
851 856
852 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); 857 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration));
853 858
854 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); 859 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC()));
855 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( 860 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(
856 statistics_proxy_.get()); 861 statistics_proxy_.get());
857 862
858 Config audioproc_config; 863 Config audioproc_config;
859 audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); 864 audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false));
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 } 2580 }
2576 2581
2577 void Channel::EnableReceiveTransportSequenceNumber(int id) { 2582 void Channel::EnableReceiveTransportSequenceNumber(int id) {
2578 rtp_header_parser_->DeregisterRtpHeaderExtension( 2583 rtp_header_parser_->DeregisterRtpHeaderExtension(
2579 kRtpExtensionTransportSequenceNumber); 2584 kRtpExtensionTransportSequenceNumber);
2580 bool ret = rtp_header_parser_->RegisterRtpHeaderExtension( 2585 bool ret = rtp_header_parser_->RegisterRtpHeaderExtension(
2581 kRtpExtensionTransportSequenceNumber, id); 2586 kRtpExtensionTransportSequenceNumber, id);
2582 RTC_DCHECK(ret); 2587 RTC_DCHECK(ret);
2583 } 2588 }
2584 2589
2585 void Channel::SetCongestionControlObjects( 2590 void Channel::RegisterSenderCongestionControlObjects(
2586 RtpPacketSender* rtp_packet_sender, 2591 RtpPacketSender* rtp_packet_sender,
2587 TransportFeedbackObserver* transport_feedback_observer, 2592 TransportFeedbackObserver* transport_feedback_observer,
2588 PacketRouter* packet_router) { 2593 PacketRouter* packet_router) {
2589 RTC_DCHECK(packet_router != nullptr || packet_router_ != nullptr); 2594 RTC_DCHECK(rtp_packet_sender);
2590 if (transport_feedback_observer) { 2595 RTC_DCHECK(transport_feedback_observer);
2591 RTC_DCHECK(feedback_observer_proxy_.get()); 2596 RTC_DCHECK(packet_router && !packet_router_);
2592 feedback_observer_proxy_->SetTransportFeedbackObserver( 2597 feedback_observer_proxy_->SetTransportFeedbackObserver(
2593 transport_feedback_observer); 2598 transport_feedback_observer);
2594 } 2599 seq_num_allocator_proxy_->SetSequenceNumberAllocator(packet_router);
2595 if (rtp_packet_sender) { 2600 rtp_packet_sender_proxy_->SetPacketSender(rtp_packet_sender);
2596 RTC_DCHECK(rtp_packet_sender_proxy_.get()); 2601 _rtpRtcpModule->SetStorePacketsStatus(true, 600);
2597 rtp_packet_sender_proxy_->SetPacketSender(rtp_packet_sender); 2602 packet_router->AddRtpModule(_rtpRtcpModule.get(), true);
2598 }
2599 if (seq_num_allocator_proxy_.get()) {
2600 seq_num_allocator_proxy_->SetSequenceNumberAllocator(packet_router);
2601 }
2602 _rtpRtcpModule->SetStorePacketsStatus(rtp_packet_sender != nullptr, 600);
2603 if (packet_router != nullptr) {
2604 packet_router->AddRtpModule(_rtpRtcpModule.get());
2605 } else {
2606 packet_router_->RemoveRtpModule(_rtpRtcpModule.get());
2607 }
2608 packet_router_ = packet_router; 2603 packet_router_ = packet_router;
2609 } 2604 }
2610 2605
2606 void Channel::RegisterReceiverCongestionControlObjects(
2607 PacketRouter* packet_router) {
2608 RTC_DCHECK(packet_router && !packet_router_);
2609 packet_router->AddRtpModule(_rtpRtcpModule.get(), false);
2610 packet_router_ = packet_router;
2611 }
2612
2613 void Channel::ResetCongestionControlObjects() {
2614 RTC_DCHECK(packet_router_);
2615 _rtpRtcpModule->SetStorePacketsStatus(false, 600);
2616 feedback_observer_proxy_->SetTransportFeedbackObserver(nullptr);
2617 seq_num_allocator_proxy_->SetSequenceNumberAllocator(nullptr);
2618 const bool sender = rtp_packet_sender_proxy_->HasPacketSender();
2619 packet_router_->RemoveRtpModule(_rtpRtcpModule.get(), sender);
2620 packet_router_ = nullptr;
2621 rtp_packet_sender_proxy_->SetPacketSender(nullptr);
2622 }
2623
2611 void Channel::SetRTCPStatus(bool enable) { 2624 void Channel::SetRTCPStatus(bool enable) {
2612 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 2625 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
2613 "Channel::SetRTCPStatus()"); 2626 "Channel::SetRTCPStatus()");
2614 _rtpRtcpModule->SetRTCPStatus(enable ? RtcpMode::kCompound : RtcpMode::kOff); 2627 _rtpRtcpModule->SetRTCPStatus(enable ? RtcpMode::kCompound : RtcpMode::kOff);
2615 } 2628 }
2616 2629
2617 int Channel::GetRTCPStatus(bool& enabled) { 2630 int Channel::GetRTCPStatus(bool& enabled) {
2618 RtcpMode method = _rtpRtcpModule->RTCP(); 2631 RtcpMode method = _rtpRtcpModule->RTCP();
2619 enabled = (method != RtcpMode::kOff); 2632 enabled = (method != RtcpMode::kOff);
2620 return 0; 2633 return 0;
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
3641 int64_t min_rtt = 0; 3654 int64_t min_rtt = 0;
3642 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3655 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3643 0) { 3656 0) {
3644 return 0; 3657 return 0;
3645 } 3658 }
3646 return rtt; 3659 return rtt;
3647 } 3660 }
3648 3661
3649 } // namespace voe 3662 } // namespace voe
3650 } // namespace webrtc 3663 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/channel_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698