| 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/peer_connection_dependency_factory.h" | 5 #include "content/renderer/media/webrtc/peer_connection_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" |
| 11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 12 #include "content/common/media/media_stream_messages.h" | 12 #include "content/common/media/media_stream_messages.h" |
| 13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 14 #include "content/renderer/media/media_stream.h" | 14 #include "content/renderer/media/media_stream.h" |
| 15 #include "content/renderer/media/media_stream_audio_processor.h" | 15 #include "content/renderer/media/media_stream_audio_processor.h" |
| 16 #include "content/renderer/media/media_stream_audio_processor_options.h" | 16 #include "content/renderer/media/media_stream_audio_processor_options.h" |
| 17 #include "content/renderer/media/media_stream_audio_source.h" | 17 #include "content/renderer/media/media_stream_audio_source.h" |
| 18 #include "content/renderer/media/media_stream_video_source.h" | 18 #include "content/renderer/media/media_stream_video_source.h" |
| 19 #include "content/renderer/media/media_stream_video_track.h" | 19 #include "content/renderer/media/media_stream_video_track.h" |
| 20 #include "content/renderer/media/peer_connection_identity_service.h" | 20 #include "content/renderer/media/peer_connection_identity_service.h" |
| 21 #include "content/renderer/media/rtc_media_constraints.h" | 21 #include "content/renderer/media/rtc_media_constraints.h" |
| 22 #include "content/renderer/media/rtc_peer_connection_handler.h" | 22 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| 23 #include "content/renderer/media/rtc_video_decoder_factory.h" | 23 #include "content/renderer/media/rtc_video_decoder_factory.h" |
| 24 #include "content/renderer/media/rtc_video_encoder_factory.h" | 24 #include "content/renderer/media/rtc_video_encoder_factory.h" |
| 25 #include "content/renderer/media/webaudio_capturer_source.h" | 25 #include "content/renderer/media/webaudio_capturer_source.h" |
| 26 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 26 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
| 27 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" | 27 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" |
| 28 #include "content/renderer/media/webrtc_audio_device_impl.h" | 28 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 29 #include "content/renderer/media/webrtc_local_audio_track.h" | 29 #include "content/renderer/media/webrtc_local_audio_track.h" |
| 30 #include "content/renderer/media/webrtc_logging.h" |
| 30 #include "content/renderer/media/webrtc_uma_histograms.h" | 31 #include "content/renderer/media/webrtc_uma_histograms.h" |
| 31 #include "content/renderer/p2p/ipc_network_manager.h" | 32 #include "content/renderer/p2p/ipc_network_manager.h" |
| 32 #include "content/renderer/p2p/ipc_socket_factory.h" | 33 #include "content/renderer/p2p/ipc_socket_factory.h" |
| 33 #include "content/renderer/p2p/port_allocator.h" | 34 #include "content/renderer/p2p/port_allocator.h" |
| 34 #include "content/renderer/render_thread_impl.h" | 35 #include "content/renderer/render_thread_impl.h" |
| 35 #include "jingle/glue/thread_wrapper.h" | 36 #include "jingle/glue/thread_wrapper.h" |
| 36 #include "media/filters/gpu_video_accelerator_factories.h" | 37 #include "media/filters/gpu_video_accelerator_factories.h" |
| 37 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 38 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
| 38 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 39 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 39 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 40 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 StreamDeviceInfo device_info = source_data->device_info(); | 210 StreamDeviceInfo device_info = source_data->device_info(); |
| 210 RTCMediaConstraints constraints = native_audio_constraints; | 211 RTCMediaConstraints constraints = native_audio_constraints; |
| 211 // May modify both |constraints| and |effects|. | 212 // May modify both |constraints| and |effects|. |
| 212 HarmonizeConstraintsAndEffects(&constraints, | 213 HarmonizeConstraintsAndEffects(&constraints, |
| 213 &device_info.device.input.effects); | 214 &device_info.device.input.effects); |
| 214 | 215 |
| 215 scoped_refptr<WebRtcAudioCapturer> capturer( | 216 scoped_refptr<WebRtcAudioCapturer> capturer( |
| 216 CreateAudioCapturer(render_view_id, device_info, audio_constraints, | 217 CreateAudioCapturer(render_view_id, device_info, audio_constraints, |
| 217 source_data)); | 218 source_data)); |
| 218 if (!capturer.get()) { | 219 if (!capturer.get()) { |
| 219 DLOG(WARNING) << "Failed to create the capturer for device " | 220 const std::string log_string = |
| 220 << device_info.device.id; | 221 "PCDF::InitializeMediaStreamAudioSource: fails to create capturer"; |
| 222 WebRtcLogMessage(log_string); |
| 223 DVLOG(1) << log_string; |
| 221 // TODO(xians): Don't we need to check if source_observer is observing | 224 // TODO(xians): Don't we need to check if source_observer is observing |
| 222 // something? If not, then it looks like we have a leak here. | 225 // something? If not, then it looks like we have a leak here. |
| 223 // OTOH, if it _is_ observing something, then the callback might | 226 // OTOH, if it _is_ observing something, then the callback might |
| 224 // be called multiple times which is likely also a bug. | 227 // be called multiple times which is likely also a bug. |
| 225 return false; | 228 return false; |
| 226 } | 229 } |
| 227 source_data->SetAudioCapturer(capturer.get()); | 230 source_data->SetAudioCapturer(capturer.get()); |
| 228 | 231 |
| 229 // Creates a LocalAudioSource object which holds audio options. | 232 // Creates a LocalAudioSource object which holds audio options. |
| 230 // TODO(xians): The option should apply to the track instead of the source. | 233 // TODO(xians): The option should apply to the track instead of the source. |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 } | 657 } |
| 655 | 658 |
| 656 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { | 659 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { |
| 657 if (audio_device_.get()) | 660 if (audio_device_.get()) |
| 658 return; | 661 return; |
| 659 | 662 |
| 660 audio_device_ = new WebRtcAudioDeviceImpl(); | 663 audio_device_ = new WebRtcAudioDeviceImpl(); |
| 661 } | 664 } |
| 662 | 665 |
| 663 } // namespace content | 666 } // namespace content |
| OLD | NEW |