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/call/rtc_event_log.h" | |
22 #include "webrtc/common.h" | 23 #include "webrtc/common.h" |
23 #include "webrtc/config.h" | 24 #include "webrtc/config.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" |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 return false; | 488 return false; |
488 } | 489 } |
489 header.payload_type_frequency = | 490 header.payload_type_frequency = |
490 rtp_payload_registry_->GetPayloadTypeFrequency(header.payloadType); | 491 rtp_payload_registry_->GetPayloadTypeFrequency(header.payloadType); |
491 if (header.payload_type_frequency < 0) | 492 if (header.payload_type_frequency < 0) |
492 return false; | 493 return false; |
493 return ReceivePacket(rtp_packet, rtp_packet_length, header, false); | 494 return ReceivePacket(rtp_packet, rtp_packet_length, header, false); |
494 } | 495 } |
495 | 496 |
496 int32_t Channel::GetAudioFrame(int32_t id, AudioFrame* audioFrame) { | 497 int32_t Channel::GetAudioFrame(int32_t id, AudioFrame* audioFrame) { |
497 if (event_log_) { | 498 { |
498 unsigned int ssrc; | 499 rtc::CritScope lock(&event_log_lock_); |
499 RTC_CHECK_EQ(GetLocalSSRC(ssrc), 0); | 500 if (event_log_) { |
500 event_log_->LogAudioPlayout(ssrc); | 501 unsigned int ssrc; |
502 RTC_CHECK_EQ(GetLocalSSRC(ssrc), 0); | |
503 { event_log_->LogAudioPlayout(ssrc); } | |
the sun
2016/03/03 09:25:13
Remove the { } on this line.
ivoc
2016/03/10 13:15:36
Hmm, not sure what happened there :-)
| |
504 } | |
501 } | 505 } |
502 // Get 10ms raw PCM data from the ACM (mixer limits output frequency) | 506 // Get 10ms raw PCM data from the ACM (mixer limits output frequency) |
503 if (audio_coding_->PlayoutData10Ms(audioFrame->sample_rate_hz_, audioFrame) == | 507 if (audio_coding_->PlayoutData10Ms(audioFrame->sample_rate_hz_, audioFrame) == |
504 -1) { | 508 -1) { |
505 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | 509 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
506 "Channel::GetAudioFrame() PlayoutData10Ms() failed!"); | 510 "Channel::GetAudioFrame() PlayoutData10Ms() failed!"); |
507 // In all likelihood, the audio in this frame is garbage. We return an | 511 // In all likelihood, the audio in this frame is garbage. We return an |
508 // error so that the audio mixer module doesn't add it to the mix. As | 512 // error so that the audio mixer module doesn't add it to the mix. As |
509 // a result, it won't be played out and the actions skipped here are | 513 // a result, it won't be played out and the actions skipped here are |
510 // irrelevant. | 514 // irrelevant. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
667 } | 671 } |
668 } | 672 } |
669 } | 673 } |
670 | 674 |
671 return (highestNeeded); | 675 return (highestNeeded); |
672 } | 676 } |
673 | 677 |
674 int32_t Channel::CreateChannel(Channel*& channel, | 678 int32_t Channel::CreateChannel(Channel*& channel, |
675 int32_t channelId, | 679 int32_t channelId, |
676 uint32_t instanceId, | 680 uint32_t instanceId, |
677 RtcEventLog* const event_log, | |
678 const Config& config) { | 681 const Config& config) { |
679 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), | 682 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), |
680 "Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId, | 683 "Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId, |
681 instanceId); | 684 instanceId); |
682 | 685 |
683 channel = new Channel(channelId, instanceId, event_log, config); | 686 channel = new Channel(channelId, instanceId, config); |
684 if (channel == NULL) { | 687 if (channel == NULL) { |
685 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), | 688 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), |
686 "Channel::CreateChannel() unable to allocate memory for" | 689 "Channel::CreateChannel() unable to allocate memory for" |
687 " channel"); | 690 " channel"); |
688 return -1; | 691 return -1; |
689 } | 692 } |
690 return 0; | 693 return 0; |
691 } | 694 } |
692 | 695 |
693 void Channel::PlayNotification(int32_t id, uint32_t durationMs) { | 696 void Channel::PlayNotification(int32_t id, uint32_t durationMs) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
730 assert(id == _outputFileRecorderId); | 733 assert(id == _outputFileRecorderId); |
731 | 734 |
732 rtc::CritScope cs(&_fileCritSect); | 735 rtc::CritScope cs(&_fileCritSect); |
733 | 736 |
734 _outputFileRecording = false; | 737 _outputFileRecording = false; |
735 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 738 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
736 "Channel::RecordFileEnded() => output file recorder module is" | 739 "Channel::RecordFileEnded() => output file recorder module is" |
737 " shutdown"); | 740 " shutdown"); |
738 } | 741 } |
739 | 742 |
740 Channel::Channel(int32_t channelId, | 743 Channel::Channel(int32_t channelId, uint32_t instanceId, const Config& config) |
741 uint32_t instanceId, | |
742 RtcEventLog* const event_log, | |
743 const Config& config) | |
744 : _instanceId(instanceId), | 744 : _instanceId(instanceId), |
745 _channelId(channelId), | 745 _channelId(channelId), |
746 event_log_(event_log), | 746 event_log_(nullptr), |
747 rtp_header_parser_(RtpHeaderParser::Create()), | 747 rtp_header_parser_(RtpHeaderParser::Create()), |
748 rtp_payload_registry_( | 748 rtp_payload_registry_( |
749 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), | 749 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), |
750 rtp_receive_statistics_( | 750 rtp_receive_statistics_( |
751 ReceiveStatistics::Create(Clock::GetRealTimeClock())), | 751 ReceiveStatistics::Create(Clock::GetRealTimeClock())), |
752 rtp_receiver_( | 752 rtp_receiver_( |
753 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(), | 753 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(), |
754 this, | 754 this, |
755 this, | 755 this, |
756 this, | 756 this, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
845 configuration.outgoing_transport = this; | 845 configuration.outgoing_transport = this; |
846 configuration.audio_messages = this; | 846 configuration.audio_messages = this; |
847 configuration.receive_statistics = rtp_receive_statistics_.get(); | 847 configuration.receive_statistics = rtp_receive_statistics_.get(); |
848 configuration.bandwidth_callback = rtcp_observer_.get(); | 848 configuration.bandwidth_callback = rtcp_observer_.get(); |
849 if (pacing_enabled_) { | 849 if (pacing_enabled_) { |
850 configuration.paced_sender = rtp_packet_sender_proxy_.get(); | 850 configuration.paced_sender = rtp_packet_sender_proxy_.get(); |
851 configuration.transport_sequence_number_allocator = | 851 configuration.transport_sequence_number_allocator = |
852 seq_num_allocator_proxy_.get(); | 852 seq_num_allocator_proxy_.get(); |
853 configuration.transport_feedback_callback = feedback_observer_proxy_.get(); | 853 configuration.transport_feedback_callback = feedback_observer_proxy_.get(); |
854 } | 854 } |
855 configuration.event_log = event_log; | |
856 | 855 |
857 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); | 856 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); |
858 | 857 |
859 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); | 858 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); |
860 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( | 859 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( |
861 statistics_proxy_.get()); | 860 statistics_proxy_.get()); |
862 | 861 |
863 Config audioproc_config; | 862 Config audioproc_config; |
864 audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); | 863 audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); |
865 rx_audioproc_.reset(AudioProcessing::Create(audioproc_config)); | 864 rx_audioproc_.reset(AudioProcessing::Create(audioproc_config)); |
(...skipping 2784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3650 int64_t min_rtt = 0; | 3649 int64_t min_rtt = 0; |
3651 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3650 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3652 0) { | 3651 0) { |
3653 return 0; | 3652 return 0; |
3654 } | 3653 } |
3655 return rtt; | 3654 return rtt; |
3656 } | 3655 } |
3657 | 3656 |
3658 } // namespace voe | 3657 } // namespace voe |
3659 } // namespace webrtc | 3658 } // namespace webrtc |
OLD | NEW |