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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 if (!source_data) { | 314 if (!source_data) { |
315 // TODO(henrika): Implement support for sources from remote MediaStreams. | 315 // TODO(henrika): Implement support for sources from remote MediaStreams. |
316 NOTIMPLEMENTED(); | 316 NOTIMPLEMENTED(); |
317 continue; | 317 continue; |
318 } | 318 } |
319 | 319 |
320 // TODO(xians): Create a new capturer for difference microphones when we | 320 // TODO(xians): Create a new capturer for difference microphones when we |
321 // support multiple microphones. See issue crbug/262117 . | 321 // support multiple microphones. See issue crbug/262117 . |
322 const StreamDeviceInfo device_info = source_data->device_info(); | 322 const StreamDeviceInfo device_info = source_data->device_info(); |
323 scoped_refptr<WebRtcAudioCapturer> capturer( | 323 scoped_refptr<WebRtcAudioCapturer> capturer( |
324 MaybeCreateAudioCapturer(render_view_id, device_info)); | 324 MaybeCreateAudioCapturer(render_view_id, device_info, |
| 325 &native_audio_constraints)); |
325 if (!capturer.get()) { | 326 if (!capturer.get()) { |
326 DLOG(WARNING) << "Failed to create the capturer for device " | 327 DLOG(WARNING) << "Failed to create the capturer for device " |
327 << device_info.device.id; | 328 << device_info.device.id; |
328 sources_created.Run(web_stream, false); | 329 sources_created.Run(web_stream, false); |
329 // TODO(xians): Don't we need to check if source_observer is observing | 330 // TODO(xians): Don't we need to check if source_observer is observing |
330 // something? If not, then it looks like we have a leak here. | 331 // something? If not, then it looks like we have a leak here. |
331 // OTOH, if it _is_ observing something, then the callback might | 332 // OTOH, if it _is_ observing something, then the callback might |
332 // be called multiple times which is likely also a bug. | 333 // be called multiple times which is likely also a bug. |
333 return; | 334 return; |
334 } | 335 } |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 chrome_worker_thread_.Stop(); | 801 chrome_worker_thread_.Stop(); |
801 } else { | 802 } else { |
802 NOTREACHED() << "Worker thread not running."; | 803 NOTREACHED() << "Worker thread not running."; |
803 } | 804 } |
804 } | 805 } |
805 } | 806 } |
806 | 807 |
807 scoped_refptr<WebRtcAudioCapturer> | 808 scoped_refptr<WebRtcAudioCapturer> |
808 MediaStreamDependencyFactory::MaybeCreateAudioCapturer( | 809 MediaStreamDependencyFactory::MaybeCreateAudioCapturer( |
809 int render_view_id, | 810 int render_view_id, |
810 const StreamDeviceInfo& device_info) { | 811 const StreamDeviceInfo& device_info, |
| 812 const RTCMediaConstraints* constraints) { |
811 // TODO(xians): Handle the cases when gUM is called without a proper render | 813 // TODO(xians): Handle the cases when gUM is called without a proper render |
812 // view, for example, by an extension. | 814 // view, for example, by an extension. |
813 DCHECK_GE(render_view_id, 0); | 815 DCHECK_GE(render_view_id, 0); |
814 | 816 |
815 scoped_refptr<WebRtcAudioCapturer> capturer = | 817 scoped_refptr<WebRtcAudioCapturer> capturer = |
816 GetWebRtcAudioDevice()->GetDefaultCapturer(); | 818 GetWebRtcAudioDevice()->GetDefaultCapturer(); |
817 | 819 |
818 // If the default capturer does not exist or |render_view_id| == -1, create | 820 // If the default capturer does not exist or |render_view_id| == -1, create |
819 // a new capturer. | 821 // a new capturer. |
820 bool is_new_capturer = false; | 822 bool is_new_capturer = false; |
821 if (!capturer.get()) { | 823 if (!capturer.get()) { |
822 capturer = WebRtcAudioCapturer::CreateCapturer(); | 824 capturer = WebRtcAudioCapturer::CreateCapturer(); |
823 is_new_capturer = true; | 825 is_new_capturer = true; |
824 } | 826 } |
825 | 827 |
826 if (!capturer->Initialize( | 828 if (!capturer->Initialize( |
827 render_view_id, | 829 render_view_id, |
828 static_cast<media::ChannelLayout>( | 830 static_cast<media::ChannelLayout>( |
829 device_info.device.input.channel_layout), | 831 device_info.device.input.channel_layout), |
830 device_info.device.input.sample_rate, | 832 device_info.device.input.sample_rate, |
831 device_info.device.input.frames_per_buffer, | 833 device_info.device.input.frames_per_buffer, |
832 device_info.session_id, | 834 device_info.session_id, |
833 device_info.device.id, | 835 device_info.device.id, |
834 device_info.device.matched_output.sample_rate, | 836 device_info.device.matched_output.sample_rate, |
835 device_info.device.matched_output.frames_per_buffer)) { | 837 device_info.device.matched_output.frames_per_buffer, |
| 838 constraints)) { |
836 return NULL; | 839 return NULL; |
837 } | 840 } |
838 | 841 |
839 // Add the capturer to the WebRtcAudioDeviceImpl if it is a new capturer. | 842 // Add the capturer to the WebRtcAudioDeviceImpl if it is a new capturer. |
840 if (is_new_capturer) | 843 if (is_new_capturer) |
841 GetWebRtcAudioDevice()->AddAudioCapturer(capturer); | 844 GetWebRtcAudioDevice()->AddAudioCapturer(capturer); |
842 | 845 |
843 return capturer; | 846 return capturer; |
844 } | 847 } |
845 | 848 |
846 } // namespace content | 849 } // namespace content |
OLD | NEW |