OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 5 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/renderer/media/media_stream_audio_processor.h" | 8 #include "content/renderer/media/media_stream_audio_processor.h" |
9 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 9 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
10 #include "content/renderer/media/webrtc/webrtc_audio_sink_adapter.h" | 10 #include "content/renderer/media/webrtc/webrtc_audio_sink_adapter.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 owner_->RemoveSink(*it); | 120 owner_->RemoveSink(*it); |
121 sink_adapters_.erase(it); | 121 sink_adapters_.erase(it); |
122 return; | 122 return; |
123 } | 123 } |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 bool WebRtcLocalAudioTrackAdapter::GetSignalLevel(int* level) { | 127 bool WebRtcLocalAudioTrackAdapter::GetSignalLevel(int* level) { |
128 DCHECK(signaling_thread_checker_.CalledOnValidThread()); | 128 DCHECK(signaling_thread_checker_.CalledOnValidThread()); |
129 | 129 |
130 // It is required to provide the signal level after audio processing. In | |
131 // case the audio processing is not enabled for the track, we return | |
132 // false here in order not to overwrite the value from WebRTC. | |
133 // TODO(xians): Remove this after we turn on the APM in Chrome by default. | |
134 // http://crbug/365672 . | |
135 if (!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) | |
136 return false; | |
137 | |
138 base::AutoLock auto_lock(lock_); | 130 base::AutoLock auto_lock(lock_); |
139 *level = signal_level_; | 131 *level = signal_level_; |
140 return true; | 132 return true; |
141 } | 133 } |
142 | 134 |
143 rtc::scoped_refptr<webrtc::AudioProcessorInterface> | 135 rtc::scoped_refptr<webrtc::AudioProcessorInterface> |
144 WebRtcLocalAudioTrackAdapter::GetAudioProcessor() { | 136 WebRtcLocalAudioTrackAdapter::GetAudioProcessor() { |
145 DCHECK(signaling_thread_checker_.CalledOnValidThread()); | 137 DCHECK(signaling_thread_checker_.CalledOnValidThread()); |
146 base::AutoLock auto_lock(lock_); | 138 base::AutoLock auto_lock(lock_); |
147 return audio_processor_.get(); | 139 return audio_processor_.get(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 DCHECK(iter != voe_channels_.end()); | 176 DCHECK(iter != voe_channels_.end()); |
185 voe_channels_.erase(iter); | 177 voe_channels_.erase(iter); |
186 } | 178 } |
187 | 179 |
188 webrtc::AudioSourceInterface* WebRtcLocalAudioTrackAdapter::GetSource() const { | 180 webrtc::AudioSourceInterface* WebRtcLocalAudioTrackAdapter::GetSource() const { |
189 DCHECK(signaling_thread_checker_.CalledOnValidThread()); | 181 DCHECK(signaling_thread_checker_.CalledOnValidThread()); |
190 return track_source_; | 182 return track_source_; |
191 } | 183 } |
192 | 184 |
193 cricket::AudioRenderer* WebRtcLocalAudioTrackAdapter::GetRenderer() { | 185 cricket::AudioRenderer* WebRtcLocalAudioTrackAdapter::GetRenderer() { |
194 // When the audio track processing is enabled, return a NULL so that capture | 186 return NULL; |
195 // data goes through Libjingle LocalAudioTrackHandler::LocalAudioSinkAdapter | |
196 // ==> WebRtcVoiceMediaChannel::WebRtcVoiceChannelRenderer ==> WebRTC. | |
197 // When the audio track processing is disabled, WebRtcLocalAudioTrackAdapter | |
198 // is used to pass the channel ids to WebRtcAudioDeviceImpl, the data flow | |
199 // becomes WebRtcAudioDeviceImpl ==> WebRTC. | |
200 // TODO(xians): Only return NULL after the APM in WebRTC is deprecated. | |
201 // See See http://crbug/365672 for details. | |
202 return MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()? | |
203 NULL : this; | |
204 } | 187 } |
205 | 188 |
206 } // namespace content | 189 } // namespace content |
OLD | NEW |