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/format_macros.h" | 16 #include "webrtc/base/format_macros.h" |
16 #include "webrtc/base/timeutils.h" | 17 #include "webrtc/base/timeutils.h" |
17 #include "webrtc/common.h" | 18 #include "webrtc/common.h" |
18 #include "webrtc/config.h" | 19 #include "webrtc/config.h" |
19 #include "webrtc/modules/audio_device/include/audio_device.h" | 20 #include "webrtc/modules/audio_device/include/audio_device.h" |
20 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 21 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
21 #include "webrtc/modules/interface/module_common_types.h" | 22 #include "webrtc/modules/interface/module_common_types.h" |
22 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" | 23 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" |
23 #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" | 24 #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" |
24 #include "webrtc/modules/rtp_rtcp/interface/rtp_receiver.h" | 25 #include "webrtc/modules/rtp_rtcp/interface/rtp_receiver.h" |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 if (header.payload_type_frequency < 0) | 444 if (header.payload_type_frequency < 0) |
444 return false; | 445 return false; |
445 return ReceivePacket(rtp_packet, rtp_packet_length, header, false); | 446 return ReceivePacket(rtp_packet, rtp_packet_length, header, false); |
446 } | 447 } |
447 | 448 |
448 int32_t Channel::GetAudioFrame(int32_t id, AudioFrame* audioFrame) | 449 int32_t Channel::GetAudioFrame(int32_t id, AudioFrame* audioFrame) |
449 { | 450 { |
450 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), | 451 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), |
451 "Channel::GetAudioFrame(id=%d)", id); | 452 "Channel::GetAudioFrame(id=%d)", id); |
452 | 453 |
| 454 if (event_log_) { |
| 455 unsigned int ssrc; |
| 456 RTC_CHECK_EQ(GetLocalSSRC(ssrc), 0); |
| 457 event_log_->LogAudioPlayout(ssrc); |
| 458 } |
453 // Get 10ms raw PCM data from the ACM (mixer limits output frequency) | 459 // Get 10ms raw PCM data from the ACM (mixer limits output frequency) |
454 if (audio_coding_->PlayoutData10Ms(audioFrame->sample_rate_hz_, | 460 if (audio_coding_->PlayoutData10Ms(audioFrame->sample_rate_hz_, |
455 audioFrame) == -1) | 461 audioFrame) == -1) |
456 { | 462 { |
457 WEBRTC_TRACE(kTraceError, kTraceVoice, | 463 WEBRTC_TRACE(kTraceError, kTraceVoice, |
458 VoEId(_instanceId,_channelId), | 464 VoEId(_instanceId,_channelId), |
459 "Channel::GetAudioFrame() PlayoutData10Ms() failed!"); | 465 "Channel::GetAudioFrame() PlayoutData10Ms() failed!"); |
460 // In all likelihood, the audio in this frame is garbage. We return an | 466 // In all likelihood, the audio in this frame is garbage. We return an |
461 // error so that the audio mixer module doesn't add it to the mix. As | 467 // error so that the audio mixer module doesn't add it to the mix. As |
462 // a result, it won't be played out and the actions skipped here are | 468 // a result, it won't be played out and the actions skipped here are |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 | 718 |
713 Channel::Channel(int32_t channelId, | 719 Channel::Channel(int32_t channelId, |
714 uint32_t instanceId, | 720 uint32_t instanceId, |
715 RtcEventLog* const event_log, | 721 RtcEventLog* const event_log, |
716 const Config& config) | 722 const Config& config) |
717 : _fileCritSect(*CriticalSectionWrapper::CreateCriticalSection()), | 723 : _fileCritSect(*CriticalSectionWrapper::CreateCriticalSection()), |
718 _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()), | 724 _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()), |
719 volume_settings_critsect_(*CriticalSectionWrapper::CreateCriticalSection()), | 725 volume_settings_critsect_(*CriticalSectionWrapper::CreateCriticalSection()), |
720 _instanceId(instanceId), | 726 _instanceId(instanceId), |
721 _channelId(channelId), | 727 _channelId(channelId), |
| 728 event_log_(event_log), |
722 rtp_header_parser_(RtpHeaderParser::Create()), | 729 rtp_header_parser_(RtpHeaderParser::Create()), |
723 rtp_payload_registry_( | 730 rtp_payload_registry_( |
724 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), | 731 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), |
725 rtp_receive_statistics_( | 732 rtp_receive_statistics_( |
726 ReceiveStatistics::Create(Clock::GetRealTimeClock())), | 733 ReceiveStatistics::Create(Clock::GetRealTimeClock())), |
727 rtp_receiver_( | 734 rtp_receiver_( |
728 RtpReceiver::CreateAudioReceiver(VoEModuleId(instanceId, channelId), | 735 RtpReceiver::CreateAudioReceiver(VoEModuleId(instanceId, channelId), |
729 Clock::GetRealTimeClock(), | 736 Clock::GetRealTimeClock(), |
730 this, | 737 this, |
731 this, | 738 this, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 AudioCodingModule::Config acm_config; | 809 AudioCodingModule::Config acm_config; |
803 acm_config.id = VoEModuleId(instanceId, channelId); | 810 acm_config.id = VoEModuleId(instanceId, channelId); |
804 if (config.Get<NetEqCapacityConfig>().enabled) { | 811 if (config.Get<NetEqCapacityConfig>().enabled) { |
805 // Clamping the buffer capacity at 20 packets. While going lower will | 812 // Clamping the buffer capacity at 20 packets. While going lower will |
806 // probably work, it makes little sense. | 813 // probably work, it makes little sense. |
807 acm_config.neteq_config.max_packets_in_buffer = | 814 acm_config.neteq_config.max_packets_in_buffer = |
808 std::max(20, config.Get<NetEqCapacityConfig>().capacity); | 815 std::max(20, config.Get<NetEqCapacityConfig>().capacity); |
809 } | 816 } |
810 acm_config.neteq_config.enable_fast_accelerate = | 817 acm_config.neteq_config.enable_fast_accelerate = |
811 config.Get<NetEqFastAccelerate>().enabled; | 818 config.Get<NetEqFastAccelerate>().enabled; |
812 acm_config.event_log = event_log; | |
813 audio_coding_.reset(AudioCodingModule::Create(acm_config)); | 819 audio_coding_.reset(AudioCodingModule::Create(acm_config)); |
814 | 820 |
815 _inbandDtmfQueue.ResetDtmf(); | 821 _inbandDtmfQueue.ResetDtmf(); |
816 _inbandDtmfGenerator.Init(); | 822 _inbandDtmfGenerator.Init(); |
817 _outputAudioLevel.Clear(); | 823 _outputAudioLevel.Clear(); |
818 | 824 |
819 RtpRtcp::Configuration configuration; | 825 RtpRtcp::Configuration configuration; |
820 configuration.id = VoEModuleId(instanceId, channelId); | 826 configuration.id = VoEModuleId(instanceId, channelId); |
821 configuration.audio = true; | 827 configuration.audio = true; |
822 configuration.outgoing_transport = this; | 828 configuration.outgoing_transport = this; |
(...skipping 3325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4148 int64_t min_rtt = 0; | 4154 int64_t min_rtt = 0; |
4149 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) | 4155 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) |
4150 != 0) { | 4156 != 0) { |
4151 return 0; | 4157 return 0; |
4152 } | 4158 } |
4153 return rtt; | 4159 return rtt; |
4154 } | 4160 } |
4155 | 4161 |
4156 } // namespace voe | 4162 } // namespace voe |
4157 } // namespace webrtc | 4163 } // namespace webrtc |
OLD | NEW |