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_encoding_video_capturer_factory.h" |
14 #include "content/renderer/media/rtc_media_constraints.h" | 15 #include "content/renderer/media/rtc_media_constraints.h" |
15 #include "content/renderer/media/rtc_peer_connection_handler.h" | 16 #include "content/renderer/media/rtc_peer_connection_handler.h" |
16 #include "content/renderer/media/rtc_video_capturer.h" | 17 #include "content/renderer/media/rtc_video_capturer.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" |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); | 481 native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); |
481 } | 482 } |
482 | 483 |
483 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { | 484 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { |
484 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; | 485 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; |
485 if (!pc_factory_.get()) { | 486 if (!pc_factory_.get()) { |
486 DCHECK(!audio_device_.get()); | 487 DCHECK(!audio_device_.get()); |
487 audio_device_ = new WebRtcAudioDeviceImpl(); | 488 audio_device_ = new WebRtcAudioDeviceImpl(); |
488 | 489 |
489 cricket::WebRtcVideoDecoderFactory* decoder_factory = NULL; | 490 cricket::WebRtcVideoDecoderFactory* decoder_factory = NULL; |
| 491 cricket::WebRtcVideoEncoderFactory* encoder_factory = NULL; |
| 492 |
490 #if defined(GOOGLE_TV) | 493 #if defined(GOOGLE_TV) |
491 // PeerConnectionFactory will hold the ownership of this | 494 // PeerConnectionFactory will hold the ownership of this |
492 // VideoDecoderFactory. | 495 // VideoDecoderFactory. |
493 decoder_factory = decoder_factory_tv_ = new RTCVideoDecoderFactoryTv; | 496 decoder_factory = decoder_factory_tv_ = new RTCVideoDecoderFactoryTv; |
494 #endif | 497 #endif |
495 | 498 |
| 499 #if defined(OS_CHROMEOS) |
| 500 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 501 if (command_line.HasSwitch(switches::kEnableEncodedScreenCapture)) { |
| 502 // PeerConnectionFactory owns the encoder factory. Pass a weak pointer of |
| 503 // encoder factory to |vc_manager_| because the manager outlives it. |
| 504 RtcEncodingVideoCapturerFactory* rtc_encoding_capturer_factory = |
| 505 new RtcEncodingVideoCapturerFactory(); |
| 506 encoder_factory = rtc_encoding_capturer_factory; |
| 507 vc_manager_->set_encoding_capturer_factory( |
| 508 rtc_encoding_capturer_factory->AsWeakPtr()); |
| 509 } |
| 510 #endif |
| 511 |
496 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( | 512 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( |
497 webrtc::CreatePeerConnectionFactory(worker_thread_, | 513 webrtc::CreatePeerConnectionFactory(worker_thread_, |
498 signaling_thread_, | 514 signaling_thread_, |
499 audio_device_.get(), | 515 audio_device_.get(), |
500 NULL, | 516 encoder_factory, |
501 decoder_factory)); | 517 decoder_factory)); |
502 if (factory.get()) | 518 if (factory.get()) |
503 pc_factory_ = factory; | 519 pc_factory_ = factory; |
504 else | 520 else |
505 audio_device_ = NULL; | 521 audio_device_ = NULL; |
506 } | 522 } |
507 return pc_factory_.get() != NULL; | 523 return pc_factory_.get() != NULL; |
508 } | 524 } |
509 | 525 |
510 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { | 526 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 // processed before returning. We wait for the above task to finish before | 813 // processed before returning. We wait for the above task to finish before |
798 // letting the the function continue to avoid any potential race issues. | 814 // letting the the function continue to avoid any potential race issues. |
799 chrome_worker_thread_.Stop(); | 815 chrome_worker_thread_.Stop(); |
800 } else { | 816 } else { |
801 NOTREACHED() << "Worker thread not running."; | 817 NOTREACHED() << "Worker thread not running."; |
802 } | 818 } |
803 } | 819 } |
804 } | 820 } |
805 | 821 |
806 } // namespace content | 822 } // namespace content |
OLD | NEW |