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