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/rtc_video_encoder_factory.h" |
20 #include "content/renderer/media/video_capture_impl_manager.h" | 20 #include "content/renderer/media/video_capture_impl_manager.h" |
21 #include "content/renderer/media/webaudio_capturer_source.h" | 21 #include "content/renderer/media/webaudio_capturer_source.h" |
22 #include "content/renderer/media/webrtc_audio_device_impl.h" | 22 #include "content/renderer/media/webrtc_audio_device_impl.h" |
23 #include "content/renderer/media/webrtc_local_audio_track.h" | 23 #include "content/renderer/media/webrtc_local_audio_track.h" |
24 #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_accelerator_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) |
42 #include "third_party/libjingle/source/talk/base/ssladapter.h" | 41 #include "third_party/libjingle/source/talk/base/ssladapter.h" |
43 #else | 42 #else |
44 #include "net/socket/nss_ssl_util.h" | 43 #include "net/socket/nss_ssl_util.h" |
45 #endif | 44 #endif |
46 | 45 |
47 #if defined(GOOGLE_TV) | 46 #if defined(GOOGLE_TV) |
48 #include "content/renderer/media/rtc_video_decoder_factory_tv.h" | 47 #include "content/renderer/media/rtc_video_decoder_factory_tv.h" |
49 #endif | 48 #endif |
50 | 49 |
51 namespace content { | 50 namespace content { |
52 | 51 |
53 // The constraint key for the PeerConnection constructor for enabling diagnostic | |
54 // WebRTC logging. It's a Google specific key, hence the "goog" prefix. | |
55 const char kWebRtcLoggingConstraint[] = "googLog"; | |
56 | |
57 // Constant constraint keys which enables default audio constraints on | 52 // Constant constraint keys which enables default audio constraints on |
58 // mediastreams with audio. | 53 // mediastreams with audio. |
59 struct { | 54 struct { |
60 const char* key; | 55 const char* key; |
61 const char* value; | 56 const char* value; |
62 } const kDefaultAudioConstraints[] = { | 57 } const kDefaultAudioConstraints[] = { |
63 { webrtc::MediaConstraintsInterface::kEchoCancellation, | 58 { webrtc::MediaConstraintsInterface::kEchoCancellation, |
64 webrtc::MediaConstraintsInterface::kValueTrue }, | 59 webrtc::MediaConstraintsInterface::kValueTrue }, |
65 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) | 60 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) |
66 // Enable the extended filter mode AEC on platforms with known echo issues. | 61 // Enable the extended filter mode AEC on platforms with known echo issues. |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 560 |
566 scoped_refptr<webrtc::PeerConnectionInterface> | 561 scoped_refptr<webrtc::PeerConnectionInterface> |
567 MediaStreamDependencyFactory::CreatePeerConnection( | 562 MediaStreamDependencyFactory::CreatePeerConnection( |
568 const webrtc::PeerConnectionInterface::IceServers& ice_servers, | 563 const webrtc::PeerConnectionInterface::IceServers& ice_servers, |
569 const webrtc::MediaConstraintsInterface* constraints, | 564 const webrtc::MediaConstraintsInterface* constraints, |
570 WebKit::WebFrame* web_frame, | 565 WebKit::WebFrame* web_frame, |
571 webrtc::PeerConnectionObserver* observer) { | 566 webrtc::PeerConnectionObserver* observer) { |
572 CHECK(web_frame); | 567 CHECK(web_frame); |
573 CHECK(observer); | 568 CHECK(observer); |
574 | 569 |
575 webrtc::MediaConstraintsInterface::Constraints optional_constraints = | |
576 constraints->GetOptional(); | |
577 std::string constraint_value; | |
578 if (optional_constraints.FindFirst(kWebRtcLoggingConstraint, | |
579 &constraint_value)) { | |
580 std::string url = web_frame->document().url().spec(); | |
581 RenderThreadImpl::current()->GetIOMessageLoopProxy()->PostTask( | |
582 FROM_HERE, base::Bind( | |
583 &InitWebRtcLogging, | |
584 constraint_value, | |
585 url)); | |
586 } | |
587 | |
588 scoped_refptr<P2PPortAllocatorFactory> pa_factory = | 570 scoped_refptr<P2PPortAllocatorFactory> pa_factory = |
589 new talk_base::RefCountedObject<P2PPortAllocatorFactory>( | 571 new talk_base::RefCountedObject<P2PPortAllocatorFactory>( |
590 p2p_socket_dispatcher_.get(), | 572 p2p_socket_dispatcher_.get(), |
591 network_manager_, | 573 network_manager_, |
592 socket_factory_.get(), | 574 socket_factory_.get(), |
593 web_frame); | 575 web_frame); |
594 | 576 |
595 PeerConnectionIdentityService* identity_service = | 577 PeerConnectionIdentityService* identity_service = |
596 PeerConnectionIdentityService::Create( | 578 PeerConnectionIdentityService::Create( |
597 GURL(web_frame->document().url().spec()).GetOrigin()); | 579 GURL(web_frame->document().url().spec()).GetOrigin()); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 } | 837 } |
856 | 838 |
857 // Add the capturer to the WebRtcAudioDeviceImpl if it is a new capturer. | 839 // Add the capturer to the WebRtcAudioDeviceImpl if it is a new capturer. |
858 if (is_new_capturer) | 840 if (is_new_capturer) |
859 GetWebRtcAudioDevice()->AddAudioCapturer(capturer); | 841 GetWebRtcAudioDevice()->AddAudioCapturer(capturer); |
860 | 842 |
861 return capturer; | 843 return capturer; |
862 } | 844 } |
863 | 845 |
864 } // namespace content | 846 } // namespace content |
OLD | NEW |