| 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" |
| 11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "content/renderer/media/media_stream_source_extra_data.h" | 13 #include "content/renderer/media/media_stream_source_extra_data.h" |
| 14 #include "content/renderer/media/peer_connection_identity_service.h" | 14 #include "content/renderer/media/peer_connection_identity_service.h" |
| 15 #include "content/renderer/media/rtc_media_constraints.h" | 15 #include "content/renderer/media/rtc_media_constraints.h" |
| 16 #include "content/renderer/media/rtc_peer_connection_handler.h" | 16 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| 17 #include "content/renderer/media/rtc_video_capturer.h" | 17 #include "content/renderer/media/rtc_video_capturer.h" |
| 18 #include "content/renderer/media/rtc_video_decoder_factory.h" | 18 #include "content/renderer/media/rtc_video_decoder_factory.h" |
| 19 #include "content/renderer/media/rtc_video_encoder_factory.h" |
| 19 #include "content/renderer/media/video_capture_impl_manager.h" | 20 #include "content/renderer/media/video_capture_impl_manager.h" |
| 20 #include "content/renderer/media/webaudio_capturer_source.h" | 21 #include "content/renderer/media/webaudio_capturer_source.h" |
| 21 #include "content/renderer/media/webrtc_audio_device_impl.h" | 22 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 22 #include "content/renderer/media/webrtc_local_audio_track.h" | 23 #include "content/renderer/media/webrtc_local_audio_track.h" |
| 23 #include "content/renderer/media/webrtc_logging_initializer.h" | 24 #include "content/renderer/media/webrtc_logging_initializer.h" |
| 24 #include "content/renderer/media/webrtc_uma_histograms.h" | 25 #include "content/renderer/media/webrtc_uma_histograms.h" |
| 25 #include "content/renderer/p2p/ipc_network_manager.h" | 26 #include "content/renderer/p2p/ipc_network_manager.h" |
| 26 #include "content/renderer/p2p/ipc_socket_factory.h" | 27 #include "content/renderer/p2p/ipc_socket_factory.h" |
| 27 #include "content/renderer/p2p/port_allocator.h" | 28 #include "content/renderer/p2p/port_allocator.h" |
| 28 #include "content/renderer/render_thread_impl.h" | 29 #include "content/renderer/render_thread_impl.h" |
| 29 #include "jingle/glue/thread_wrapper.h" | 30 #include "jingle/glue/thread_wrapper.h" |
| 30 #include "media/filters/gpu_video_decoder_factories.h" | 31 #include "media/filters/gpu_video_accelerator_factories.h" |
| 31 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 32 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
| 32 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 33 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 33 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 34 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 34 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 35 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 35 #include "third_party/WebKit/public/platform/WebURL.h" | 36 #include "third_party/WebKit/public/platform/WebURL.h" |
| 36 #include "third_party/WebKit/public/web/WebDocument.h" | 37 #include "third_party/WebKit/public/web/WebDocument.h" |
| 37 #include "third_party/WebKit/public/web/WebFrame.h" | 38 #include "third_party/WebKit/public/web/WebFrame.h" |
| 38 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" | 39 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" |
| 39 | 40 |
| 40 #if defined(USE_OPENSSL) | 41 #if defined(USE_OPENSSL) |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); | 482 native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); |
| 482 } | 483 } |
| 483 | 484 |
| 484 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { | 485 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { |
| 485 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; | 486 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; |
| 486 if (!pc_factory_.get()) { | 487 if (!pc_factory_.get()) { |
| 487 DCHECK(!audio_device_.get()); | 488 DCHECK(!audio_device_.get()); |
| 488 audio_device_ = new WebRtcAudioDeviceImpl(); | 489 audio_device_ = new WebRtcAudioDeviceImpl(); |
| 489 | 490 |
| 490 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory; | 491 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory; |
| 492 scoped_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory; |
| 491 | 493 |
| 492 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 494 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 493 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWDecoding)) { | 495 scoped_refptr<base::MessageLoopProxy> media_loop_proxy = |
| 494 scoped_refptr<base::MessageLoopProxy> media_loop_proxy = | 496 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(); |
| 495 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(); | 497 scoped_refptr<RendererGpuVideoAcceleratorFactories> gpu_factories = |
| 496 scoped_refptr<RendererGpuVideoDecoderFactories> gpu_factories = | 498 RenderThreadImpl::current()->GetGpuFactories(media_loop_proxy); |
| 497 RenderThreadImpl::current()->GetGpuFactories(media_loop_proxy); | 499 #if !defined(GOOGLE_TV) |
| 498 if (gpu_factories.get() != NULL) | 500 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWDecoding)) |
| 501 if (gpu_factories) |
| 499 decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories)); | 502 decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories)); |
| 500 } | 503 #else |
| 501 #if defined(GOOGLE_TV) | |
| 502 // PeerConnectionFactory will hold the ownership of this | 504 // PeerConnectionFactory will hold the ownership of this |
| 503 // VideoDecoderFactory. | 505 // VideoDecoderFactory. |
| 504 decoder_factory.reset(decoder_factory_tv_ = new RTCVideoDecoderFactoryTv); | 506 decoder_factory.reset(decoder_factory_tv_ = new RTCVideoDecoderFactoryTv()); |
| 505 #endif | 507 #endif |
| 506 | 508 |
| 509 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWEncoding)) |
| 510 if (gpu_factories) |
| 511 encoder_factory.reset(new RTCVideoEncoderFactory(gpu_factories)); |
| 512 |
| 507 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( | 513 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( |
| 508 webrtc::CreatePeerConnectionFactory(worker_thread_, | 514 webrtc::CreatePeerConnectionFactory(worker_thread_, |
| 509 signaling_thread_, | 515 signaling_thread_, |
| 510 audio_device_.get(), | 516 audio_device_.get(), |
| 511 NULL, | 517 encoder_factory.release(), |
| 512 decoder_factory.release())); | 518 decoder_factory.release())); |
| 513 if (factory.get()) | 519 if (factory.get()) |
| 514 pc_factory_ = factory; | 520 pc_factory_ = factory; |
| 515 else | 521 else |
| 516 audio_device_ = NULL; | 522 audio_device_ = NULL; |
| 517 } | 523 } |
| 518 return pc_factory_.get() != NULL; | 524 return pc_factory_.get() != NULL; |
| 519 } | 525 } |
| 520 | 526 |
| 521 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { | 527 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 } | 823 } |
| 818 | 824 |
| 819 // Add the capturer to the WebRtcAudioDeviceImpl if it is a new capturer. | 825 // Add the capturer to the WebRtcAudioDeviceImpl if it is a new capturer. |
| 820 if (is_new_capturer) | 826 if (is_new_capturer) |
| 821 GetWebRtcAudioDevice()->AddAudioCapturer(capturer); | 827 GetWebRtcAudioDevice()->AddAudioCapturer(capturer); |
| 822 | 828 |
| 823 return capturer; | 829 return capturer; |
| 824 } | 830 } |
| 825 | 831 |
| 826 } // namespace content | 832 } // namespace content |
| OLD | NEW |