Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: webrtc/voice_engine/channel.cc

Issue 2111813002: Revert of Move RtcEventLog object from inside VoiceEngine to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/channel_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
23 #include "webrtc/common.h" 22 #include "webrtc/common.h"
24 #include "webrtc/config.h" 23 #include "webrtc/config.h"
25 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" 24 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
26 #include "webrtc/modules/audio_device/include/audio_device.h" 25 #include "webrtc/modules/audio_device/include/audio_device.h"
27 #include "webrtc/modules/audio_processing/include/audio_processing.h" 26 #include "webrtc/modules/audio_processing/include/audio_processing.h"
28 #include "webrtc/modules/include/module_common_types.h" 27 #include "webrtc/modules/include/module_common_types.h"
29 #include "webrtc/modules/pacing/packet_router.h" 28 #include "webrtc/modules/pacing/packet_router.h"
30 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" 29 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
31 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" 30 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
32 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" 31 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
(...skipping 19 matching lines...) Expand all
52 const CodecInst& ci) { 51 const CodecInst& ci) {
53 const int result = (*acm)->RegisterReceiveCodec( 52 const int result = (*acm)->RegisterReceiveCodec(
54 ci, [&] { return rac->RentIsacDecoder(ci.plfreq); }); 53 ci, [&] { return rac->RentIsacDecoder(ci.plfreq); });
55 return result == 0; 54 return result == 0;
56 } 55 }
57 56
58 } // namespace 57 } // namespace
59 58
60 const int kTelephoneEventAttenuationdB = 10; 59 const int kTelephoneEventAttenuationdB = 10;
61 60
62 class RtcEventLogProxy final : public webrtc::RtcEventLog {
63 public:
64 RtcEventLogProxy() : event_log_(nullptr) {}
65
66 bool StartLogging(const std::string& file_name,
67 int64_t max_size_bytes) override {
68 RTC_NOTREACHED();
69 return false;
70 }
71
72 bool StartLogging(rtc::PlatformFile log_file,
73 int64_t max_size_bytes) override {
74 RTC_NOTREACHED();
75 return false;
76 }
77
78 void StopLogging() override { RTC_NOTREACHED(); }
79
80 void LogVideoReceiveStreamConfig(
81 const webrtc::VideoReceiveStream::Config& config) override {
82 rtc::CritScope lock(&crit_);
83 if (event_log_) {
84 event_log_->LogVideoReceiveStreamConfig(config);
85 }
86 }
87
88 void LogVideoSendStreamConfig(
89 const webrtc::VideoSendStream::Config& config) override {
90 rtc::CritScope lock(&crit_);
91 if (event_log_) {
92 event_log_->LogVideoSendStreamConfig(config);
93 }
94 }
95
96 void LogRtpHeader(webrtc::PacketDirection direction,
97 webrtc::MediaType media_type,
98 const uint8_t* header,
99 size_t packet_length) override {
100 rtc::CritScope lock(&crit_);
101 if (event_log_) {
102 event_log_->LogRtpHeader(direction, media_type, header, packet_length);
103 }
104 }
105
106 void LogRtcpPacket(webrtc::PacketDirection direction,
107 webrtc::MediaType media_type,
108 const uint8_t* packet,
109 size_t length) override {
110 rtc::CritScope lock(&crit_);
111 if (event_log_) {
112 event_log_->LogRtcpPacket(direction, media_type, packet, length);
113 }
114 }
115
116 void LogAudioPlayout(uint32_t ssrc) override {
117 rtc::CritScope lock(&crit_);
118 if (event_log_) {
119 event_log_->LogAudioPlayout(ssrc);
120 }
121 }
122
123 void LogBwePacketLossEvent(int32_t bitrate,
124 uint8_t fraction_loss,
125 int32_t total_packets) override {
126 rtc::CritScope lock(&crit_);
127 if (event_log_) {
128 event_log_->LogBwePacketLossEvent(bitrate, fraction_loss, total_packets);
129 }
130 }
131
132 void SetEventLog(RtcEventLog* event_log) {
133 rtc::CritScope lock(&crit_);
134 event_log_ = event_log;
135 }
136
137 private:
138 rtc::CriticalSection crit_;
139 RtcEventLog* event_log_ GUARDED_BY(crit_);
140 RTC_DISALLOW_COPY_AND_ASSIGN(RtcEventLogProxy);
141 };
142
143 class TransportFeedbackProxy : public TransportFeedbackObserver { 61 class TransportFeedbackProxy : public TransportFeedbackObserver {
144 public: 62 public:
145 TransportFeedbackProxy() : feedback_observer_(nullptr) { 63 TransportFeedbackProxy() : feedback_observer_(nullptr) {
146 pacer_thread_.DetachFromThread(); 64 pacer_thread_.DetachFromThread();
147 network_thread_.DetachFromThread(); 65 network_thread_.DetachFromThread();
148 } 66 }
149 67
150 void SetTransportFeedbackObserver( 68 void SetTransportFeedbackObserver(
151 TransportFeedbackObserver* feedback_observer) { 69 TransportFeedbackObserver* feedback_observer) {
152 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 70 RTC_DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 header.payload_type_frequency = 473 header.payload_type_frequency =
556 rtp_payload_registry_->GetPayloadTypeFrequency(header.payloadType); 474 rtp_payload_registry_->GetPayloadTypeFrequency(header.payloadType);
557 if (header.payload_type_frequency < 0) 475 if (header.payload_type_frequency < 0)
558 return false; 476 return false;
559 return ReceivePacket(rtp_packet, rtp_packet_length, header, false); 477 return ReceivePacket(rtp_packet, rtp_packet_length, header, false);
560 } 478 }
561 479
562 MixerParticipant::AudioFrameInfo Channel::GetAudioFrameWithMuted( 480 MixerParticipant::AudioFrameInfo Channel::GetAudioFrameWithMuted(
563 int32_t id, 481 int32_t id,
564 AudioFrame* audioFrame) { 482 AudioFrame* audioFrame) {
565 unsigned int ssrc; 483 if (event_log_) {
566 RTC_CHECK_EQ(GetLocalSSRC(ssrc), 0); 484 unsigned int ssrc;
567 event_log_proxy_->LogAudioPlayout(ssrc); 485 RTC_CHECK_EQ(GetLocalSSRC(ssrc), 0);
486 event_log_->LogAudioPlayout(ssrc);
487 }
568 // Get 10ms raw PCM data from the ACM (mixer limits output frequency) 488 // Get 10ms raw PCM data from the ACM (mixer limits output frequency)
569 bool muted; 489 bool muted;
570 if (audio_coding_->PlayoutData10Ms(audioFrame->sample_rate_hz_, audioFrame, 490 if (audio_coding_->PlayoutData10Ms(audioFrame->sample_rate_hz_, audioFrame,
571 &muted) == -1) { 491 &muted) == -1) {
572 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), 492 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
573 "Channel::GetAudioFrame() PlayoutData10Ms() failed!"); 493 "Channel::GetAudioFrame() PlayoutData10Ms() failed!");
574 // In all likelihood, the audio in this frame is garbage. We return an 494 // In all likelihood, the audio in this frame is garbage. We return an
575 // error so that the audio mixer module doesn't add it to the mix. As 495 // error so that the audio mixer module doesn't add it to the mix. As
576 // a result, it won't be played out and the actions skipped here are 496 // a result, it won't be played out and the actions skipped here are
577 // irrelevant. 497 // irrelevant.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 } 664 }
745 } 665 }
746 } 666 }
747 667
748 return (highestNeeded); 668 return (highestNeeded);
749 } 669 }
750 670
751 int32_t Channel::CreateChannel(Channel*& channel, 671 int32_t Channel::CreateChannel(Channel*& channel,
752 int32_t channelId, 672 int32_t channelId,
753 uint32_t instanceId, 673 uint32_t instanceId,
674 RtcEventLog* const event_log,
754 const Config& config) { 675 const Config& config) {
755 return CreateChannel(channel, channelId, instanceId, config, 676 return CreateChannel(channel, channelId, instanceId, event_log, config,
756 CreateBuiltinAudioDecoderFactory()); 677 CreateBuiltinAudioDecoderFactory());
757 } 678 }
758 679
759 int32_t Channel::CreateChannel( 680 int32_t Channel::CreateChannel(
760 Channel*& channel, 681 Channel*& channel,
761 int32_t channelId, 682 int32_t channelId,
762 uint32_t instanceId, 683 uint32_t instanceId,
684 RtcEventLog* const event_log,
763 const Config& config, 685 const Config& config,
764 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) { 686 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
765 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), 687 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId),
766 "Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId, 688 "Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId,
767 instanceId); 689 instanceId);
768 690
769 channel = new Channel(channelId, instanceId, config, decoder_factory); 691 channel =
692 new Channel(channelId, instanceId, event_log, config, decoder_factory);
770 if (channel == NULL) { 693 if (channel == NULL) {
771 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), 694 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId),
772 "Channel::CreateChannel() unable to allocate memory for" 695 "Channel::CreateChannel() unable to allocate memory for"
773 " channel"); 696 " channel");
774 return -1; 697 return -1;
775 } 698 }
776 return 0; 699 return 0;
777 } 700 }
778 701
779 void Channel::PlayNotification(int32_t id, uint32_t durationMs) { 702 void Channel::PlayNotification(int32_t id, uint32_t durationMs) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 rtc::CritScope cs(&_fileCritSect); 741 rtc::CritScope cs(&_fileCritSect);
819 742
820 _outputFileRecording = false; 743 _outputFileRecording = false;
821 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, _channelId), 744 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, _channelId),
822 "Channel::RecordFileEnded() => output file recorder module is" 745 "Channel::RecordFileEnded() => output file recorder module is"
823 " shutdown"); 746 " shutdown");
824 } 747 }
825 748
826 Channel::Channel(int32_t channelId, 749 Channel::Channel(int32_t channelId,
827 uint32_t instanceId, 750 uint32_t instanceId,
751 RtcEventLog* const event_log,
828 const Config& config, 752 const Config& config,
829 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) 753 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory)
830 : _instanceId(instanceId), 754 : _instanceId(instanceId),
831 _channelId(channelId), 755 _channelId(channelId),
832 event_log_proxy_(new RtcEventLogProxy()), 756 event_log_(event_log),
833 rtp_header_parser_(RtpHeaderParser::Create()), 757 rtp_header_parser_(RtpHeaderParser::Create()),
834 rtp_payload_registry_( 758 rtp_payload_registry_(
835 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), 759 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))),
836 rtp_receive_statistics_( 760 rtp_receive_statistics_(
837 ReceiveStatistics::Create(Clock::GetRealTimeClock())), 761 ReceiveStatistics::Create(Clock::GetRealTimeClock())),
838 rtp_receiver_( 762 rtp_receiver_(
839 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(), 763 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(),
840 this, 764 this,
841 this, 765 this,
842 rtp_payload_registry_.get())), 766 rtp_payload_registry_.get())),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 configuration.audio = true; 849 configuration.audio = true;
926 configuration.outgoing_transport = this; 850 configuration.outgoing_transport = this;
927 configuration.receive_statistics = rtp_receive_statistics_.get(); 851 configuration.receive_statistics = rtp_receive_statistics_.get();
928 configuration.bandwidth_callback = rtcp_observer_.get(); 852 configuration.bandwidth_callback = rtcp_observer_.get();
929 if (pacing_enabled_) { 853 if (pacing_enabled_) {
930 configuration.paced_sender = rtp_packet_sender_proxy_.get(); 854 configuration.paced_sender = rtp_packet_sender_proxy_.get();
931 configuration.transport_sequence_number_allocator = 855 configuration.transport_sequence_number_allocator =
932 seq_num_allocator_proxy_.get(); 856 seq_num_allocator_proxy_.get();
933 configuration.transport_feedback_callback = feedback_observer_proxy_.get(); 857 configuration.transport_feedback_callback = feedback_observer_proxy_.get();
934 } 858 }
935 configuration.event_log = &(*event_log_proxy_); 859 configuration.event_log = event_log;
936 860
937 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); 861 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration));
938 _rtpRtcpModule->SetSendingMediaStatus(false); 862 _rtpRtcpModule->SetSendingMediaStatus(false);
939 863
940 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); 864 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC()));
941 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( 865 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(
942 statistics_proxy_.get()); 866 statistics_proxy_.get());
943 867
944 Config audioproc_config; 868 Config audioproc_config;
945 audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); 869 audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false));
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after
3077 rtc::CritScope lock(&assoc_send_channel_lock_); 3001 rtc::CritScope lock(&assoc_send_channel_lock_);
3078 Channel* channel = associate_send_channel_.channel(); 3002 Channel* channel = associate_send_channel_.channel();
3079 if (channel && channel->ChannelId() == channel_id) { 3003 if (channel && channel->ChannelId() == channel_id) {
3080 // If this channel is associated with a send channel of the specified 3004 // If this channel is associated with a send channel of the specified
3081 // Channel ID, disassociate with it. 3005 // Channel ID, disassociate with it.
3082 ChannelOwner ref(NULL); 3006 ChannelOwner ref(NULL);
3083 associate_send_channel_ = ref; 3007 associate_send_channel_ = ref;
3084 } 3008 }
3085 } 3009 }
3086 3010
3087 void Channel::SetRtcEventLog(RtcEventLog* event_log) {
3088 event_log_proxy_->SetEventLog(event_log);
3089 }
3090
3091 int Channel::RegisterExternalMediaProcessing(ProcessingTypes type, 3011 int Channel::RegisterExternalMediaProcessing(ProcessingTypes type,
3092 VoEMediaProcess& processObject) { 3012 VoEMediaProcess& processObject) {
3093 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 3013 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
3094 "Channel::RegisterExternalMediaProcessing()"); 3014 "Channel::RegisterExternalMediaProcessing()");
3095 3015
3096 rtc::CritScope cs(&_callbackCritSect); 3016 rtc::CritScope cs(&_callbackCritSect);
3097 3017
3098 if (kPlaybackPerChannel == type) { 3018 if (kPlaybackPerChannel == type) {
3099 if (_outputExternalMediaCallbackPtr) { 3019 if (_outputExternalMediaCallbackPtr) {
3100 _engineStatisticsPtr->SetLastError( 3020 _engineStatisticsPtr->SetLastError(
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
3562 int64_t min_rtt = 0; 3482 int64_t min_rtt = 0;
3563 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3483 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3564 0) { 3484 0) {
3565 return 0; 3485 return 0;
3566 } 3486 }
3567 return rtt; 3487 return rtt;
3568 } 3488 }
3569 3489
3570 } // namespace voe 3490 } // namespace voe
3571 } // namespace webrtc 3491 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/channel_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698