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 | 37 |
36 #if defined(USE_OPENSSL) | 38 #if defined(USE_OPENSSL) |
37 #include "third_party/libjingle/source/talk/base/ssladapter.h" | 39 #include "third_party/libjingle/source/talk/base/ssladapter.h" |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 native_stream->RemoveTrack(native_stream->FindAudioTrack(track_id)) : | 479 native_stream->RemoveTrack(native_stream->FindAudioTrack(track_id)) : |
478 native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); | 480 native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); |
479 } | 481 } |
480 | 482 |
481 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { | 483 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { |
482 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; | 484 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; |
483 if (!pc_factory_.get()) { | 485 if (!pc_factory_.get()) { |
484 DCHECK(!audio_device_.get()); | 486 DCHECK(!audio_device_.get()); |
485 audio_device_ = new WebRtcAudioDeviceImpl(); | 487 audio_device_ = new WebRtcAudioDeviceImpl(); |
486 | 488 |
487 cricket::WebRtcVideoDecoderFactory* decoder_factory = NULL; | 489 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory; |
488 #if defined(GOOGLE_TV) | 490 #if defined(GOOGLE_TV) |
489 // PeerConnectionFactory will hold the ownership of this | 491 // PeerConnectionFactory will hold the ownership of this |
490 // VideoDecoderFactory. | 492 // VideoDecoderFactory. |
491 decoder_factory = decoder_factory_tv_ = new RTCVideoDecoderFactoryTv; | 493 decoder_factory.reset(decoder_factory_tv_ = new RTCVideoDecoderFactoryTv); |
492 #endif | 494 #endif |
495 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | |
496 if (cmd_line->HasSwitch(switches::kEnableWebRTCHWDecoding)) { | |
497 scoped_refptr<media::GpuVideoDecoder::Factories> gpu_factories = | |
498 RenderThreadImpl::current()->GetGpuFactories(); | |
499 if (gpu_factories.get() != NULL) | |
Ami GONE FROM CHROMIUM
2013/06/19 18:28:58
Is the .get() really required?
wuchengli
2013/06/20 07:27:04
Some people are changing refptr to get() universal
| |
500 decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories)); | |
501 } | |
493 | 502 |
494 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( | 503 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( |
495 webrtc::CreatePeerConnectionFactory(worker_thread_, | 504 webrtc::CreatePeerConnectionFactory(worker_thread_, |
496 signaling_thread_, | 505 signaling_thread_, |
497 audio_device_.get(), | 506 audio_device_.get(), |
498 NULL, | 507 NULL, |
499 decoder_factory)); | 508 decoder_factory.release())); |
500 if (factory.get()) | 509 if (factory.get()) |
501 pc_factory_ = factory; | 510 pc_factory_ = factory; |
502 else | 511 else |
503 audio_device_ = NULL; | 512 audio_device_ = NULL; |
504 } | 513 } |
505 return pc_factory_.get() != NULL; | 514 return pc_factory_.get() != NULL; |
506 } | 515 } |
507 | 516 |
508 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { | 517 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { |
509 return pc_factory_.get() != NULL; | 518 return pc_factory_.get() != NULL; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
795 // processed before returning. We wait for the above task to finish before | 804 // processed before returning. We wait for the above task to finish before |
796 // letting the the function continue to avoid any potential race issues. | 805 // letting the the function continue to avoid any potential race issues. |
797 chrome_worker_thread_.Stop(); | 806 chrome_worker_thread_.Stop(); |
798 } else { | 807 } else { |
799 NOTREACHED() << "Worker thread not running."; | 808 NOTREACHED() << "Worker thread not running."; |
800 } | 809 } |
801 } | 810 } |
802 } | 811 } |
803 | 812 |
804 } // namespace content | 813 } // namespace content |
OLD | NEW |