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/rtc_media_constraints.h" | 14 #include "content/renderer/media/rtc_media_constraints.h" |
15 #include "content/renderer/media/rtc_peer_connection_handler.h" | 15 #include "content/renderer/media/rtc_peer_connection_handler.h" |
16 #include "content/renderer/media/rtc_video_capturer.h" | 16 #include "content/renderer/media/rtc_video_capturer.h" |
| 17 #include "content/renderer/media/rtc_video_decoder_factory.h" |
17 #include "content/renderer/media/video_capture_impl_manager.h" | 18 #include "content/renderer/media/video_capture_impl_manager.h" |
18 #include "content/renderer/media/webaudio_capturer_source.h" | 19 #include "content/renderer/media/webaudio_capturer_source.h" |
19 #include "content/renderer/media/webrtc_audio_device_impl.h" | 20 #include "content/renderer/media/webrtc_audio_device_impl.h" |
20 #include "content/renderer/media/webrtc_local_audio_track.h" | 21 #include "content/renderer/media/webrtc_local_audio_track.h" |
21 #include "content/renderer/media/webrtc_logging_initializer.h" | 22 #include "content/renderer/media/webrtc_logging_initializer.h" |
22 #include "content/renderer/media/webrtc_uma_histograms.h" | 23 #include "content/renderer/media/webrtc_uma_histograms.h" |
23 #include "content/renderer/p2p/ipc_network_manager.h" | 24 #include "content/renderer/p2p/ipc_network_manager.h" |
24 #include "content/renderer/p2p/ipc_socket_factory.h" | 25 #include "content/renderer/p2p/ipc_socket_factory.h" |
25 #include "content/renderer/p2p/port_allocator.h" | 26 #include "content/renderer/p2p/port_allocator.h" |
26 #include "content/renderer/render_thread_impl.h" | 27 #include "content/renderer/render_thread_impl.h" |
27 #include "jingle/glue/thread_wrapper.h" | 28 #include "jingle/glue/thread_wrapper.h" |
| 29 #include "media/filters/gpu_video_decoder.h" |
28 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 30 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
29 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 31 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
30 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 32 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
31 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 33 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
32 #include "third_party/WebKit/public/platform/WebURL.h" | 34 #include "third_party/WebKit/public/platform/WebURL.h" |
33 #include "third_party/WebKit/public/web/WebDocument.h" | 35 #include "third_party/WebKit/public/web/WebDocument.h" |
34 #include "third_party/WebKit/public/web/WebFrame.h" | 36 #include "third_party/WebKit/public/web/WebFrame.h" |
35 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" | 37 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" |
36 | 38 |
37 #if defined(ENABLE_WEBRTC) | 39 #if defined(ENABLE_WEBRTC) |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 native_stream->RemoveTrack(native_stream->FindAudioTrack(track_id)) : | 485 native_stream->RemoveTrack(native_stream->FindAudioTrack(track_id)) : |
484 native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); | 486 native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); |
485 } | 487 } |
486 | 488 |
487 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { | 489 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { |
488 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; | 490 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; |
489 if (!pc_factory_.get()) { | 491 if (!pc_factory_.get()) { |
490 DCHECK(!audio_device_.get()); | 492 DCHECK(!audio_device_.get()); |
491 audio_device_ = new WebRtcAudioDeviceImpl(); | 493 audio_device_ = new WebRtcAudioDeviceImpl(); |
492 | 494 |
493 cricket::WebRtcVideoDecoderFactory* decoder_factory = NULL; | 495 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory; |
494 cricket::WebRtcVideoEncoderFactory* encoder_factory = NULL; | 496 scoped_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory; |
495 | 497 |
| 498 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 499 if (cmd_line->HasSwitch(switches::kEnableWebRtcHWDecoding)) { |
| 500 scoped_refptr<media::GpuVideoDecoder::Factories> gpu_factories = |
| 501 RenderThreadImpl::current()->GetGpuFactories(); |
| 502 if (gpu_factories.get() != NULL) |
| 503 decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories)); |
| 504 } |
496 #if defined(GOOGLE_TV) | 505 #if defined(GOOGLE_TV) |
497 // PeerConnectionFactory will hold the ownership of this | 506 // PeerConnectionFactory will hold the ownership of this |
498 // VideoDecoderFactory. | 507 // VideoDecoderFactory. |
499 decoder_factory = decoder_factory_tv_ = new RTCVideoDecoderFactoryTv; | 508 decoder_factory.reset(decoder_factory_tv_ = new RTCVideoDecoderFactoryTv); |
500 #endif | 509 #endif |
501 | 510 |
502 #if defined(ENABLE_WEBRTC) && defined(OS_CHROMEOS) | 511 #if defined(ENABLE_WEBRTC) && defined(OS_CHROMEOS) |
503 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 512 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
504 if (command_line.HasSwitch(switches::kEnableEncodedScreenCapture)) { | 513 if (command_line.HasSwitch(switches::kEnableEncodedScreenCapture)) { |
505 // PeerConnectionFactory owns the encoder factory. Pass a weak pointer of | 514 // PeerConnectionFactory owns the encoder factory. Pass a weak pointer of |
506 // encoder factory to |vc_manager_| because the manager outlives it. | 515 // encoder factory to |vc_manager_| because the manager outlives it. |
507 RtcEncodingVideoCapturerFactory* rtc_encoding_capturer_factory = | 516 RtcEncodingVideoCapturerFactory* rtc_encoding_capturer_factory = |
508 new RtcEncodingVideoCapturerFactory(); | 517 new RtcEncodingVideoCapturerFactory(); |
509 encoder_factory = rtc_encoding_capturer_factory; | 518 encoder_factory.reset(rtc_encoding_capturer_factory); |
510 vc_manager_->set_encoding_capturer_factory( | 519 vc_manager_->set_encoding_capturer_factory( |
511 rtc_encoding_capturer_factory->AsWeakPtr()); | 520 rtc_encoding_capturer_factory->AsWeakPtr()); |
512 } | 521 } |
513 #endif | 522 #endif |
514 | 523 |
515 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( | 524 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( |
516 webrtc::CreatePeerConnectionFactory(worker_thread_, | 525 webrtc::CreatePeerConnectionFactory(worker_thread_, |
517 signaling_thread_, | 526 signaling_thread_, |
518 audio_device_.get(), | 527 audio_device_.get(), |
519 encoder_factory, | 528 encoder_factory.release(), |
520 decoder_factory)); | 529 decoder_factory.release())); |
521 if (factory.get()) | 530 if (factory.get()) |
522 pc_factory_ = factory; | 531 pc_factory_ = factory; |
523 else | 532 else |
524 audio_device_ = NULL; | 533 audio_device_ = NULL; |
525 } | 534 } |
526 return pc_factory_.get() != NULL; | 535 return pc_factory_.get() != NULL; |
527 } | 536 } |
528 | 537 |
529 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { | 538 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { |
530 return pc_factory_.get() != NULL; | 539 return pc_factory_.get() != NULL; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 // processed before returning. We wait for the above task to finish before | 825 // processed before returning. We wait for the above task to finish before |
817 // letting the the function continue to avoid any potential race issues. | 826 // letting the the function continue to avoid any potential race issues. |
818 chrome_worker_thread_.Stop(); | 827 chrome_worker_thread_.Stop(); |
819 } else { | 828 } else { |
820 NOTREACHED() << "Worker thread not running."; | 829 NOTREACHED() << "Worker thread not running."; |
821 } | 830 } |
822 } | 831 } |
823 } | 832 } |
824 | 833 |
825 } // namespace content | 834 } // namespace content |
OLD | NEW |