OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media_stream_dependency_factory.h" | 5 #include "content/renderer/media/media_stream_dependency_factory.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 278 |
279 scoped_refptr<webrtc::AudioTrackInterface> | 279 scoped_refptr<webrtc::AudioTrackInterface> |
280 MediaStreamDependencyFactory::CreateNativeAudioMediaStreamTrack( | 280 MediaStreamDependencyFactory::CreateNativeAudioMediaStreamTrack( |
281 const blink::WebMediaStreamTrack& track) { | 281 const blink::WebMediaStreamTrack& track) { |
282 blink::WebMediaStreamSource source = track.source(); | 282 blink::WebMediaStreamSource source = track.source(); |
283 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeAudio); | 283 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeAudio); |
284 MediaStreamAudioSource* source_data = | 284 MediaStreamAudioSource* source_data = |
285 static_cast<MediaStreamAudioSource*>(source.extraData()); | 285 static_cast<MediaStreamAudioSource*>(source.extraData()); |
286 | 286 |
287 scoped_refptr<WebAudioCapturerSource> webaudio_source; | 287 scoped_refptr<WebAudioCapturerSource> webaudio_source; |
288 if (!source_data) { | 288 scoped_refptr<WebRtcAudioCapturer> capturer; |
| 289 if (source_data) { |
| 290 capturer = source_data->GetAudioCapturer(); |
| 291 } else { |
289 if (source.requiresAudioConsumer()) { | 292 if (source.requiresAudioConsumer()) { |
290 // We're adding a WebAudio MediaStream. | 293 // We're adding a WebAudio MediaStream. |
291 // Create a specific capturer for each WebAudio consumer. | 294 // Create a specific capturer for each WebAudio consumer. |
292 webaudio_source = CreateWebAudioSource(&source); | 295 webaudio_source = CreateWebAudioSource(&source); |
293 source_data = | 296 source_data = |
294 static_cast<MediaStreamAudioSource*>(source.extraData()); | 297 static_cast<MediaStreamAudioSource*>(source.extraData()); |
| 298 |
| 299 // Use the current default capturer for the WebAudio track so that the |
| 300 // WebAudio track can pass a valid delay value and |need_audio_processing| |
| 301 // flag to PeerConnection. |
| 302 // TODO(xians): Remove this after moving APM to Chrome. |
| 303 if (GetWebRtcAudioDevice()) |
| 304 capturer = GetWebRtcAudioDevice()->GetDefaultCapturer(); |
295 } else { | 305 } else { |
296 // TODO(perkj): Implement support for sources from | 306 // TODO(perkj): Implement support for sources from |
297 // remote MediaStreams. | 307 // remote MediaStreams. |
298 NOTIMPLEMENTED(); | 308 NOTIMPLEMENTED(); |
299 return NULL; | 309 return NULL; |
300 } | 310 } |
301 } | 311 } |
302 | 312 |
303 return CreateLocalAudioTrack(track, | 313 return CreateLocalAudioTrack(track, |
304 source_data->GetAudioCapturer(), | 314 capturer, |
305 webaudio_source.get(), | 315 webaudio_source.get(), |
306 source_data->local_audio_source()); | 316 source_data->local_audio_source()); |
307 } | 317 } |
308 | 318 |
309 scoped_refptr<webrtc::VideoTrackInterface> | 319 scoped_refptr<webrtc::VideoTrackInterface> |
310 MediaStreamDependencyFactory::CreateNativeVideoMediaStreamTrack( | 320 MediaStreamDependencyFactory::CreateNativeVideoMediaStreamTrack( |
311 const blink::WebMediaStreamTrack& track) { | 321 const blink::WebMediaStreamTrack& track) { |
312 DCHECK(track.extraData() == NULL); | 322 DCHECK(track.extraData() == NULL); |
313 blink::WebMediaStreamSource source = track.source(); | 323 blink::WebMediaStreamSource source = track.source(); |
314 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeVideo); | 324 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeVideo); |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 } | 846 } |
837 | 847 |
838 void MediaStreamDependencyFactory::EnsureWebRtcAudioDeviceImpl() { | 848 void MediaStreamDependencyFactory::EnsureWebRtcAudioDeviceImpl() { |
839 if (audio_device_) | 849 if (audio_device_) |
840 return; | 850 return; |
841 | 851 |
842 audio_device_ = new WebRtcAudioDeviceImpl(); | 852 audio_device_ = new WebRtcAudioDeviceImpl(); |
843 } | 853 } |
844 | 854 |
845 } // namespace content | 855 } // namespace content |
OLD | NEW |