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