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 #include <utility> | 14 #include <utility> |
15 | 15 |
16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/criticalsection.h" | 17 #include "webrtc/base/criticalsection.h" |
18 #include "webrtc/base/format_macros.h" | 18 #include "webrtc/base/format_macros.h" |
19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
20 #include "webrtc/base/thread_checker.h" | 20 #include "webrtc/base/thread_checker.h" |
21 #include "webrtc/base/timeutils.h" | 21 #include "webrtc/base/timeutils.h" |
22 #include "webrtc/common.h" | 22 #include "webrtc/common.h" |
23 #include "webrtc/config.h" | 23 #include "webrtc/config.h" |
| 24 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" |
24 #include "webrtc/modules/audio_device/include/audio_device.h" | 25 #include "webrtc/modules/audio_device/include/audio_device.h" |
25 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 26 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
26 #include "webrtc/modules/include/module_common_types.h" | 27 #include "webrtc/modules/include/module_common_types.h" |
27 #include "webrtc/modules/pacing/packet_router.h" | 28 #include "webrtc/modules/pacing/packet_router.h" |
28 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 29 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
29 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 30 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
30 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 31 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
31 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" | 32 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" |
32 #include "webrtc/modules/utility/include/audio_frame_operations.h" | 33 #include "webrtc/modules/utility/include/audio_frame_operations.h" |
33 #include "webrtc/modules/utility/include/process_thread.h" | 34 #include "webrtc/modules/utility/include/process_thread.h" |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 } | 653 } |
653 | 654 |
654 return (highestNeeded); | 655 return (highestNeeded); |
655 } | 656 } |
656 | 657 |
657 int32_t Channel::CreateChannel(Channel*& channel, | 658 int32_t Channel::CreateChannel(Channel*& channel, |
658 int32_t channelId, | 659 int32_t channelId, |
659 uint32_t instanceId, | 660 uint32_t instanceId, |
660 RtcEventLog* const event_log, | 661 RtcEventLog* const event_log, |
661 const Config& config) { | 662 const Config& config) { |
| 663 return CreateChannel(channel, channelId, instanceId, event_log, config, |
| 664 CreateBuiltinAudioDecoderFactory()); |
| 665 } |
| 666 |
| 667 int32_t Channel::CreateChannel( |
| 668 Channel*& channel, |
| 669 int32_t channelId, |
| 670 uint32_t instanceId, |
| 671 RtcEventLog* const event_log, |
| 672 const Config& config, |
| 673 std::shared_ptr<AudioDecoderFactory> decoder_factory) { |
662 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), | 674 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), |
663 "Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId, | 675 "Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId, |
664 instanceId); | 676 instanceId); |
665 | 677 |
666 channel = new Channel(channelId, instanceId, event_log, config); | 678 channel = new Channel(channelId, instanceId, event_log, config, |
| 679 std::move(decoder_factory)); |
667 if (channel == NULL) { | 680 if (channel == NULL) { |
668 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), | 681 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), |
669 "Channel::CreateChannel() unable to allocate memory for" | 682 "Channel::CreateChannel() unable to allocate memory for" |
670 " channel"); | 683 " channel"); |
671 return -1; | 684 return -1; |
672 } | 685 } |
673 return 0; | 686 return 0; |
674 } | 687 } |
675 | 688 |
676 void Channel::PlayNotification(int32_t id, uint32_t durationMs) { | 689 void Channel::PlayNotification(int32_t id, uint32_t durationMs) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 729 |
717 _outputFileRecording = false; | 730 _outputFileRecording = false; |
718 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 731 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
719 "Channel::RecordFileEnded() => output file recorder module is" | 732 "Channel::RecordFileEnded() => output file recorder module is" |
720 " shutdown"); | 733 " shutdown"); |
721 } | 734 } |
722 | 735 |
723 Channel::Channel(int32_t channelId, | 736 Channel::Channel(int32_t channelId, |
724 uint32_t instanceId, | 737 uint32_t instanceId, |
725 RtcEventLog* const event_log, | 738 RtcEventLog* const event_log, |
726 const Config& config) | 739 const Config& config, |
| 740 std::shared_ptr<AudioDecoderFactory> decoder_factory) |
727 : _instanceId(instanceId), | 741 : _instanceId(instanceId), |
728 _channelId(channelId), | 742 _channelId(channelId), |
729 event_log_(event_log), | 743 event_log_(event_log), |
730 rtp_header_parser_(RtpHeaderParser::Create()), | 744 rtp_header_parser_(RtpHeaderParser::Create()), |
731 rtp_payload_registry_( | 745 rtp_payload_registry_( |
732 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), | 746 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), |
733 rtp_receive_statistics_( | 747 rtp_receive_statistics_( |
734 ReceiveStatistics::Create(Clock::GetRealTimeClock())), | 748 ReceiveStatistics::Create(Clock::GetRealTimeClock())), |
735 rtp_receiver_( | 749 rtp_receiver_( |
736 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(), | 750 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 _RxVadDetection(false), | 805 _RxVadDetection(false), |
792 _rxAgcIsEnabled(false), | 806 _rxAgcIsEnabled(false), |
793 _rxNsIsEnabled(false), | 807 _rxNsIsEnabled(false), |
794 restored_packet_in_use_(false), | 808 restored_packet_in_use_(false), |
795 rtcp_observer_(new VoERtcpObserver(this)), | 809 rtcp_observer_(new VoERtcpObserver(this)), |
796 network_predictor_(new NetworkPredictor(Clock::GetRealTimeClock())), | 810 network_predictor_(new NetworkPredictor(Clock::GetRealTimeClock())), |
797 associate_send_channel_(ChannelOwner(nullptr)), | 811 associate_send_channel_(ChannelOwner(nullptr)), |
798 pacing_enabled_(config.Get<VoicePacing>().enabled), | 812 pacing_enabled_(config.Get<VoicePacing>().enabled), |
799 feedback_observer_proxy_(new TransportFeedbackProxy()), | 813 feedback_observer_proxy_(new TransportFeedbackProxy()), |
800 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), | 814 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), |
801 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()) { | 815 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), |
| 816 decoder_factory_(decoder_factory) { |
802 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), | 817 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
803 "Channel::Channel() - ctor"); | 818 "Channel::Channel() - ctor"); |
804 AudioCodingModule::Config acm_config; | 819 AudioCodingModule::Config acm_config; |
805 acm_config.id = VoEModuleId(instanceId, channelId); | 820 acm_config.id = VoEModuleId(instanceId, channelId); |
806 if (config.Get<NetEqCapacityConfig>().enabled) { | 821 if (config.Get<NetEqCapacityConfig>().enabled) { |
807 // Clamping the buffer capacity at 20 packets. While going lower will | 822 // Clamping the buffer capacity at 20 packets. While going lower will |
808 // probably work, it makes little sense. | 823 // probably work, it makes little sense. |
809 acm_config.neteq_config.max_packets_in_buffer = | 824 acm_config.neteq_config.max_packets_in_buffer = |
810 std::max(20, config.Get<NetEqCapacityConfig>().capacity); | 825 std::max(20, config.Get<NetEqCapacityConfig>().capacity); |
811 } | 826 } |
812 acm_config.neteq_config.enable_fast_accelerate = | 827 acm_config.neteq_config.enable_fast_accelerate = |
813 config.Get<NetEqFastAccelerate>().enabled; | 828 config.Get<NetEqFastAccelerate>().enabled; |
| 829 acm_config.decoder_factory = std::move(decoder_factory); |
814 audio_coding_.reset(AudioCodingModule::Create(acm_config)); | 830 audio_coding_.reset(AudioCodingModule::Create(acm_config)); |
815 | 831 |
816 _outputAudioLevel.Clear(); | 832 _outputAudioLevel.Clear(); |
817 | 833 |
818 RtpRtcp::Configuration configuration; | 834 RtpRtcp::Configuration configuration; |
819 configuration.audio = true; | 835 configuration.audio = true; |
820 configuration.outgoing_transport = this; | 836 configuration.outgoing_transport = this; |
821 configuration.receive_statistics = rtp_receive_statistics_.get(); | 837 configuration.receive_statistics = rtp_receive_statistics_.get(); |
822 configuration.bandwidth_callback = rtcp_observer_.get(); | 838 configuration.bandwidth_callback = rtcp_observer_.get(); |
823 if (pacing_enabled_) { | 839 if (pacing_enabled_) { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 int32_t Channel::UpdateLocalTimeStamp() { | 1061 int32_t Channel::UpdateLocalTimeStamp() { |
1046 _timeStamp += static_cast<uint32_t>(_audioFrame.samples_per_channel_); | 1062 _timeStamp += static_cast<uint32_t>(_audioFrame.samples_per_channel_); |
1047 return 0; | 1063 return 0; |
1048 } | 1064 } |
1049 | 1065 |
1050 void Channel::SetSink(std::unique_ptr<AudioSinkInterface> sink) { | 1066 void Channel::SetSink(std::unique_ptr<AudioSinkInterface> sink) { |
1051 rtc::CritScope cs(&_callbackCritSect); | 1067 rtc::CritScope cs(&_callbackCritSect); |
1052 audio_sink_ = std::move(sink); | 1068 audio_sink_ = std::move(sink); |
1053 } | 1069 } |
1054 | 1070 |
| 1071 const std::shared_ptr<AudioDecoderFactory>& |
| 1072 Channel::GetAudioDecoderFactory() const { |
| 1073 return decoder_factory_; |
| 1074 } |
1055 int32_t Channel::StartPlayout() { | 1075 int32_t Channel::StartPlayout() { |
1056 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1076 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
1057 "Channel::StartPlayout()"); | 1077 "Channel::StartPlayout()"); |
1058 if (channel_state_.Get().playing) { | 1078 if (channel_state_.Get().playing) { |
1059 return 0; | 1079 return 0; |
1060 } | 1080 } |
1061 | 1081 |
1062 if (!_externalMixing) { | 1082 if (!_externalMixing) { |
1063 // Add participant as candidates for mixing. | 1083 // Add participant as candidates for mixing. |
1064 if (_outputMixerPtr->SetMixabilityStatus(*this, true) != 0) { | 1084 if (_outputMixerPtr->SetMixabilityStatus(*this, true) != 0) { |
(...skipping 2481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3546 int64_t min_rtt = 0; | 3566 int64_t min_rtt = 0; |
3547 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3567 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3548 0) { | 3568 0) { |
3549 return 0; | 3569 return 0; |
3550 } | 3570 } |
3551 return rtt; | 3571 return rtt; |
3552 } | 3572 } |
3553 | 3573 |
3554 } // namespace voe | 3574 } // namespace voe |
3555 } // namespace webrtc | 3575 } // namespace webrtc |
OLD | NEW |