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 #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" | |
|
ossu
2016/05/03 16:13:22
This one should go.
ossu
2016/05/11 11:22:32
Not anymore!
| |
| 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 647 if (_outputFilePlayerPtr) { | 648 if (_outputFilePlayerPtr) { |
| 648 if (_outputFilePlayerPtr->Frequency() > highestNeeded) { | 649 if (_outputFilePlayerPtr->Frequency() > highestNeeded) { |
| 649 highestNeeded = _outputFilePlayerPtr->Frequency(); | 650 highestNeeded = _outputFilePlayerPtr->Frequency(); |
| 650 } | 651 } |
| 651 } | 652 } |
| 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( |
| 658 int32_t channelId, | 659 Channel*& channel, |
| 659 uint32_t instanceId, | 660 int32_t channelId, |
| 660 RtcEventLog* const event_log, | 661 uint32_t instanceId, |
| 661 const Config& config) { | 662 RtcEventLog* const event_log, |
| 663 const Config& config, | |
| 664 std::shared_ptr<AudioDecoderFactory> decoder_factory) { | |
| 662 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), | 665 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), |
| 663 "Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId, | 666 "Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId, |
| 664 instanceId); | 667 instanceId); |
| 665 | 668 |
| 666 channel = new Channel(channelId, instanceId, event_log, config); | 669 channel = new Channel(channelId, instanceId, event_log, config, |
| 670 std::move(decoder_factory)); | |
| 667 if (channel == NULL) { | 671 if (channel == NULL) { |
| 668 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), | 672 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), |
| 669 "Channel::CreateChannel() unable to allocate memory for" | 673 "Channel::CreateChannel() unable to allocate memory for" |
| 670 " channel"); | 674 " channel"); |
| 671 return -1; | 675 return -1; |
| 672 } | 676 } |
| 673 return 0; | 677 return 0; |
| 674 } | 678 } |
| 675 | 679 |
| 676 void Channel::PlayNotification(int32_t id, uint32_t durationMs) { | 680 void Channel::PlayNotification(int32_t id, uint32_t durationMs) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 716 | 720 |
| 717 _outputFileRecording = false; | 721 _outputFileRecording = false; |
| 718 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 722 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 719 "Channel::RecordFileEnded() => output file recorder module is" | 723 "Channel::RecordFileEnded() => output file recorder module is" |
| 720 " shutdown"); | 724 " shutdown"); |
| 721 } | 725 } |
| 722 | 726 |
| 723 Channel::Channel(int32_t channelId, | 727 Channel::Channel(int32_t channelId, |
| 724 uint32_t instanceId, | 728 uint32_t instanceId, |
| 725 RtcEventLog* const event_log, | 729 RtcEventLog* const event_log, |
| 726 const Config& config) | 730 const Config& config, |
| 731 std::shared_ptr<AudioDecoderFactory> decoder_factory) | |
|
the sun
2016/05/03 21:07:30
I think I'd rather avoid this and instead add a se
| |
| 727 : _instanceId(instanceId), | 732 : _instanceId(instanceId), |
| 728 _channelId(channelId), | 733 _channelId(channelId), |
| 729 event_log_(event_log), | 734 event_log_(event_log), |
| 730 rtp_header_parser_(RtpHeaderParser::Create()), | 735 rtp_header_parser_(RtpHeaderParser::Create()), |
| 731 rtp_payload_registry_( | 736 rtp_payload_registry_( |
| 732 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), | 737 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), |
| 733 rtp_receive_statistics_( | 738 rtp_receive_statistics_( |
| 734 ReceiveStatistics::Create(Clock::GetRealTimeClock())), | 739 ReceiveStatistics::Create(Clock::GetRealTimeClock())), |
| 735 rtp_receiver_( | 740 rtp_receiver_( |
| 736 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(), | 741 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(), |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 804 AudioCodingModule::Config acm_config; | 809 AudioCodingModule::Config acm_config; |
| 805 acm_config.id = VoEModuleId(instanceId, channelId); | 810 acm_config.id = VoEModuleId(instanceId, channelId); |
| 806 if (config.Get<NetEqCapacityConfig>().enabled) { | 811 if (config.Get<NetEqCapacityConfig>().enabled) { |
| 807 // Clamping the buffer capacity at 20 packets. While going lower will | 812 // Clamping the buffer capacity at 20 packets. While going lower will |
| 808 // probably work, it makes little sense. | 813 // probably work, it makes little sense. |
| 809 acm_config.neteq_config.max_packets_in_buffer = | 814 acm_config.neteq_config.max_packets_in_buffer = |
| 810 std::max(20, config.Get<NetEqCapacityConfig>().capacity); | 815 std::max(20, config.Get<NetEqCapacityConfig>().capacity); |
| 811 } | 816 } |
| 812 acm_config.neteq_config.enable_fast_accelerate = | 817 acm_config.neteq_config.enable_fast_accelerate = |
| 813 config.Get<NetEqFastAccelerate>().enabled; | 818 config.Get<NetEqFastAccelerate>().enabled; |
| 819 acm_config.decoder_factory = std::move(decoder_factory); | |
| 814 audio_coding_.reset(AudioCodingModule::Create(acm_config)); | 820 audio_coding_.reset(AudioCodingModule::Create(acm_config)); |
| 815 | 821 |
| 816 _outputAudioLevel.Clear(); | 822 _outputAudioLevel.Clear(); |
| 817 | 823 |
| 818 RtpRtcp::Configuration configuration; | 824 RtpRtcp::Configuration configuration; |
| 819 configuration.audio = true; | 825 configuration.audio = true; |
| 820 configuration.outgoing_transport = this; | 826 configuration.outgoing_transport = this; |
| 821 configuration.receive_statistics = rtp_receive_statistics_.get(); | 827 configuration.receive_statistics = rtp_receive_statistics_.get(); |
| 822 configuration.bandwidth_callback = rtcp_observer_.get(); | 828 configuration.bandwidth_callback = rtcp_observer_.get(); |
| 823 if (pacing_enabled_) { | 829 if (pacing_enabled_) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 return -1; | 1022 return -1; |
| 1017 } | 1023 } |
| 1018 if (rx_audioproc_->gain_control()->set_mode(kDefaultRxAgcMode) != 0) { | 1024 if (rx_audioproc_->gain_control()->set_mode(kDefaultRxAgcMode) != 0) { |
| 1019 LOG(LS_ERROR) << "gain_control()->set_mode(kDefaultRxAgcMode) failed."; | 1025 LOG(LS_ERROR) << "gain_control()->set_mode(kDefaultRxAgcMode) failed."; |
| 1020 return -1; | 1026 return -1; |
| 1021 } | 1027 } |
| 1022 | 1028 |
| 1023 return 0; | 1029 return 0; |
| 1024 } | 1030 } |
| 1025 | 1031 |
| 1026 int32_t Channel::SetEngineInformation(Statistics& engineStatistics, | 1032 int32_t Channel::SetEngineInformation( |
| 1027 OutputMixer& outputMixer, | 1033 Statistics& engineStatistics, |
| 1028 voe::TransmitMixer& transmitMixer, | 1034 OutputMixer& outputMixer, |
| 1029 ProcessThread& moduleProcessThread, | 1035 voe::TransmitMixer& transmitMixer, |
| 1030 AudioDeviceModule& audioDeviceModule, | 1036 ProcessThread& moduleProcessThread, |
| 1031 VoiceEngineObserver* voiceEngineObserver, | 1037 AudioDeviceModule& audioDeviceModule, |
| 1032 rtc::CriticalSection* callbackCritSect) { | 1038 VoiceEngineObserver* voiceEngineObserver, |
| 1039 rtc::CriticalSection* callbackCritSect) { | |
| 1033 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1040 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1034 "Channel::SetEngineInformation()"); | 1041 "Channel::SetEngineInformation()"); |
| 1035 _engineStatisticsPtr = &engineStatistics; | 1042 _engineStatisticsPtr = &engineStatistics; |
| 1036 _outputMixerPtr = &outputMixer; | 1043 _outputMixerPtr = &outputMixer; |
| 1037 _transmitMixerPtr = &transmitMixer, | 1044 _transmitMixerPtr = &transmitMixer, |
| 1038 _moduleProcessThreadPtr = &moduleProcessThread; | 1045 _moduleProcessThreadPtr = &moduleProcessThread; |
| 1039 _audioDeviceModulePtr = &audioDeviceModule; | 1046 _audioDeviceModulePtr = &audioDeviceModule; |
| 1040 _voiceEngineObserverPtr = voiceEngineObserver; | 1047 _voiceEngineObserverPtr = voiceEngineObserver; |
| 1041 _callbackCritSectPtr = callbackCritSect; | 1048 _callbackCritSectPtr = callbackCritSect; |
| 1042 return 0; | 1049 return 0; |
| (...skipping 2503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3546 int64_t min_rtt = 0; | 3553 int64_t min_rtt = 0; |
| 3547 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3554 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 3548 0) { | 3555 0) { |
| 3549 return 0; | 3556 return 0; |
| 3550 } | 3557 } |
| 3551 return rtt; | 3558 return rtt; |
| 3552 } | 3559 } |
| 3553 | 3560 |
| 3554 } // namespace voe | 3561 } // namespace voe |
| 3555 } // namespace webrtc | 3562 } // namespace webrtc |
| OLD | NEW |