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(ENABLE_WEBRTC) | 41 #if defined(ENABLE_WEBRTC) |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { | 491 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { |
491 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; | 492 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; |
492 if (!pc_factory_.get()) { | 493 if (!pc_factory_.get()) { |
493 DCHECK(!audio_device_.get()); | 494 DCHECK(!audio_device_.get()); |
494 audio_device_ = new WebRtcAudioDeviceImpl(); | 495 audio_device_ = new WebRtcAudioDeviceImpl(); |
495 | 496 |
496 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory; | 497 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory; |
497 scoped_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory; | 498 scoped_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory; |
498 | 499 |
499 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 500 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
500 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWDecoding)) { | 501 scoped_refptr<base::MessageLoopProxy> media_loop_proxy = |
501 scoped_refptr<base::MessageLoopProxy> media_loop_proxy = | 502 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(); |
502 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(); | 503 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories = |
503 scoped_refptr<RendererGpuVideoDecoderFactories> gpu_factories = | 504 RenderThreadImpl::current()->GetGpuFactories(media_loop_proxy); |
504 RenderThreadImpl::current()->GetGpuFactories(media_loop_proxy); | 505 #if !defined(GOOGLE_TV) |
505 if (gpu_factories.get() != NULL) | 506 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWDecoding)) |
| 507 if (gpu_factories) |
506 decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories)); | 508 decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories)); |
507 } | 509 #else |
508 #if defined(GOOGLE_TV) | |
509 // PeerConnectionFactory will hold the ownership of this | 510 // PeerConnectionFactory will hold the ownership of this |
510 // VideoDecoderFactory. | 511 // VideoDecoderFactory. |
511 decoder_factory.reset(decoder_factory_tv_ = new RTCVideoDecoderFactoryTv); | 512 decoder_factory.reset(decoder_factory_tv_ = new RTCVideoDecoderFactoryTv()); |
512 #endif | 513 #endif |
513 | 514 |
| 515 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
514 #if defined(ENABLE_WEBRTC) && defined(OS_CHROMEOS) | 516 #if defined(ENABLE_WEBRTC) && defined(OS_CHROMEOS) |
515 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
516 if (command_line.HasSwitch(switches::kEnableEncodedScreenCapture)) { | 517 if (command_line.HasSwitch(switches::kEnableEncodedScreenCapture)) { |
517 // PeerConnectionFactory owns the encoder factory. Pass a weak pointer of | 518 // PeerConnectionFactory owns the encoder factory. Pass a weak pointer of |
518 // encoder factory to |vc_manager_| because the manager outlives it. | 519 // encoder factory to |vc_manager_| because the manager outlives it. |
519 RtcEncodingVideoCapturerFactory* rtc_encoding_capturer_factory = | 520 RtcEncodingVideoCapturerFactory* rtc_encoding_capturer_factory = |
520 new RtcEncodingVideoCapturerFactory(); | 521 new RtcEncodingVideoCapturerFactory(); |
521 encoder_factory.reset(rtc_encoding_capturer_factory); | 522 encoder_factory.reset(rtc_encoding_capturer_factory); |
522 vc_manager_->set_encoding_capturer_factory( | 523 vc_manager_->set_encoding_capturer_factory( |
523 rtc_encoding_capturer_factory->AsWeakPtr()); | 524 rtc_encoding_capturer_factory->AsWeakPtr()); |
| 525 } else |
| 526 #endif |
| 527 { |
| 528 if (command_line.HasSwitch(switches::kEnableWebRtcHWEncoding)) |
| 529 if (gpu_factories) |
| 530 encoder_factory.reset(new RTCVideoEncoderFactory(gpu_factories)); |
524 } | 531 } |
525 #endif | |
526 | 532 |
527 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( | 533 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( |
528 webrtc::CreatePeerConnectionFactory(worker_thread_, | 534 webrtc::CreatePeerConnectionFactory(worker_thread_, |
529 signaling_thread_, | 535 signaling_thread_, |
530 audio_device_.get(), | 536 audio_device_.get(), |
531 encoder_factory.release(), | 537 encoder_factory.release(), |
532 decoder_factory.release())); | 538 decoder_factory.release())); |
533 if (factory.get()) | 539 if (factory.get()) |
534 pc_factory_ = factory; | 540 pc_factory_ = factory; |
535 else | 541 else |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 // processed before returning. We wait for the above task to finish before | 841 // processed before returning. We wait for the above task to finish before |
836 // letting the the function continue to avoid any potential race issues. | 842 // letting the the function continue to avoid any potential race issues. |
837 chrome_worker_thread_.Stop(); | 843 chrome_worker_thread_.Stop(); |
838 } else { | 844 } else { |
839 NOTREACHED() << "Worker thread not running."; | 845 NOTREACHED() << "Worker thread not running."; |
840 } | 846 } |
841 } | 847 } |
842 } | 848 } |
843 | 849 |
844 } // namespace content | 850 } // namespace content |
OLD | NEW |