| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 RTCMediaConstraints native_audio_constraints(audio_constraints); | 198 RTCMediaConstraints native_audio_constraints(audio_constraints); |
| 199 ApplyFixedAudioConstraints(&native_audio_constraints); | 199 ApplyFixedAudioConstraints(&native_audio_constraints); |
| 200 | 200 |
| 201 StreamDeviceInfo device_info = source_data->device_info(); | 201 StreamDeviceInfo device_info = source_data->device_info(); |
| 202 RTCMediaConstraints constraints = native_audio_constraints; | 202 RTCMediaConstraints constraints = native_audio_constraints; |
| 203 // May modify both |constraints| and |effects|. | 203 // May modify both |constraints| and |effects|. |
| 204 HarmonizeConstraintsAndEffects(&constraints, | 204 HarmonizeConstraintsAndEffects(&constraints, |
| 205 &device_info.device.input.effects); | 205 &device_info.device.input.effects); |
| 206 | 206 |
| 207 scoped_refptr<WebRtcAudioCapturer> capturer( | 207 scoped_refptr<WebRtcAudioCapturer> capturer( |
| 208 CreateAudioCapturer(render_view_id, device_info, audio_constraints)); | 208 CreateAudioCapturer(render_view_id, device_info, audio_constraints, |
| 209 source_data)); |
| 209 if (!capturer.get()) { | 210 if (!capturer.get()) { |
| 210 DLOG(WARNING) << "Failed to create the capturer for device " | 211 DLOG(WARNING) << "Failed to create the capturer for device " |
| 211 << device_info.device.id; | 212 << device_info.device.id; |
| 212 // TODO(xians): Don't we need to check if source_observer is observing | 213 // TODO(xians): Don't we need to check if source_observer is observing |
| 213 // something? If not, then it looks like we have a leak here. | 214 // something? If not, then it looks like we have a leak here. |
| 214 // OTOH, if it _is_ observing something, then the callback might | 215 // OTOH, if it _is_ observing something, then the callback might |
| 215 // be called multiple times which is likely also a bug. | 216 // be called multiple times which is likely also a bug. |
| 216 return false; | 217 return false; |
| 217 } | 218 } |
| 218 source_data->SetAudioCapturer(capturer); | 219 source_data->SetAudioCapturer(capturer); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 } else { | 660 } else { |
| 660 NOTREACHED() << "Worker thread not running."; | 661 NOTREACHED() << "Worker thread not running."; |
| 661 } | 662 } |
| 662 } | 663 } |
| 663 } | 664 } |
| 664 | 665 |
| 665 scoped_refptr<WebRtcAudioCapturer> | 666 scoped_refptr<WebRtcAudioCapturer> |
| 666 MediaStreamDependencyFactory::CreateAudioCapturer( | 667 MediaStreamDependencyFactory::CreateAudioCapturer( |
| 667 int render_view_id, | 668 int render_view_id, |
| 668 const StreamDeviceInfo& device_info, | 669 const StreamDeviceInfo& device_info, |
| 669 const blink::WebMediaConstraints& constraints) { | 670 const blink::WebMediaConstraints& constraints, |
| 671 MediaStreamAudioSource* audio_source) { |
| 670 // TODO(xians): Handle the cases when gUM is called without a proper render | 672 // TODO(xians): Handle the cases when gUM is called without a proper render |
| 671 // view, for example, by an extension. | 673 // view, for example, by an extension. |
| 672 DCHECK_GE(render_view_id, 0); | 674 DCHECK_GE(render_view_id, 0); |
| 673 | 675 |
| 674 EnsureWebRtcAudioDeviceImpl(); | 676 EnsureWebRtcAudioDeviceImpl(); |
| 675 DCHECK(GetWebRtcAudioDevice()); | 677 DCHECK(GetWebRtcAudioDevice()); |
| 676 return WebRtcAudioCapturer::CreateCapturer(render_view_id, device_info, | 678 return WebRtcAudioCapturer::CreateCapturer(render_view_id, device_info, |
| 677 constraints, | 679 constraints, |
| 678 GetWebRtcAudioDevice()); | 680 GetWebRtcAudioDevice(), |
| 681 audio_source); |
| 679 } | 682 } |
| 680 | 683 |
| 681 void MediaStreamDependencyFactory::AddNativeAudioTrackToBlinkTrack( | 684 void MediaStreamDependencyFactory::AddNativeAudioTrackToBlinkTrack( |
| 682 webrtc::MediaStreamTrackInterface* native_track, | 685 webrtc::MediaStreamTrackInterface* native_track, |
| 683 const blink::WebMediaStreamTrack& webkit_track, | 686 const blink::WebMediaStreamTrack& webkit_track, |
| 684 bool is_local_track) { | 687 bool is_local_track) { |
| 685 DCHECK(!webkit_track.isNull() && !webkit_track.extraData()); | 688 DCHECK(!webkit_track.isNull() && !webkit_track.extraData()); |
| 686 DCHECK_EQ(blink::WebMediaStreamSource::TypeAudio, | 689 DCHECK_EQ(blink::WebMediaStreamSource::TypeAudio, |
| 687 webkit_track.source().type()); | 690 webkit_track.source().type()); |
| 688 blink::WebMediaStreamTrack track = webkit_track; | 691 blink::WebMediaStreamTrack track = webkit_track; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 } | 753 } |
| 751 | 754 |
| 752 void MediaStreamDependencyFactory::EnsureWebRtcAudioDeviceImpl() { | 755 void MediaStreamDependencyFactory::EnsureWebRtcAudioDeviceImpl() { |
| 753 if (audio_device_) | 756 if (audio_device_) |
| 754 return; | 757 return; |
| 755 | 758 |
| 756 audio_device_ = new WebRtcAudioDeviceImpl(); | 759 audio_device_ = new WebRtcAudioDeviceImpl(); |
| 757 } | 760 } |
| 758 | 761 |
| 759 } // namespace content | 762 } // namespace content |
| OLD | NEW |