| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/webrtc/peer_connection_dependency_factory.h" | 5 #include "content/renderer/media/webrtc/peer_connection_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" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 37 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
| 38 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 38 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 39 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 39 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 40 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 40 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 41 #include "third_party/WebKit/public/platform/WebURL.h" | 41 #include "third_party/WebKit/public/platform/WebURL.h" |
| 42 #include "third_party/WebKit/public/web/WebDocument.h" | 42 #include "third_party/WebKit/public/web/WebDocument.h" |
| 43 #include "third_party/WebKit/public/web/WebFrame.h" | 43 #include "third_party/WebKit/public/web/WebFrame.h" |
| 44 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" | 44 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" |
| 45 | 45 |
| 46 #if defined(USE_OPENSSL) | 46 #if defined(USE_OPENSSL) |
| 47 #include "third_party/libjingle/source/talk/base/ssladapter.h" | 47 #include "third_party/webrtc/base/ssladapter.h" |
| 48 #else | 48 #else |
| 49 #include "net/socket/nss_ssl_util.h" | 49 #include "net/socket/nss_ssl_util.h" |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) |
| 53 #include "media/base/android/media_codec_bridge.h" | 53 #include "media/base/android/media_codec_bridge.h" |
| 54 #endif | 54 #endif |
| 55 | 55 |
| 56 namespace content { | 56 namespace content { |
| 57 | 57 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 DCHECK((*effects & media::AudioParameters::DUCKING) == 0); | 108 DCHECK((*effects & media::AudioParameters::DUCKING) == 0); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 class P2PPortAllocatorFactory : public webrtc::PortAllocatorFactoryInterface { | 114 class P2PPortAllocatorFactory : public webrtc::PortAllocatorFactoryInterface { |
| 115 public: | 115 public: |
| 116 P2PPortAllocatorFactory( | 116 P2PPortAllocatorFactory( |
| 117 P2PSocketDispatcher* socket_dispatcher, | 117 P2PSocketDispatcher* socket_dispatcher, |
| 118 talk_base::NetworkManager* network_manager, | 118 rtc::NetworkManager* network_manager, |
| 119 talk_base::PacketSocketFactory* socket_factory, | 119 rtc::PacketSocketFactory* socket_factory, |
| 120 blink::WebFrame* web_frame) | 120 blink::WebFrame* web_frame) |
| 121 : socket_dispatcher_(socket_dispatcher), | 121 : socket_dispatcher_(socket_dispatcher), |
| 122 network_manager_(network_manager), | 122 network_manager_(network_manager), |
| 123 socket_factory_(socket_factory), | 123 socket_factory_(socket_factory), |
| 124 web_frame_(web_frame) { | 124 web_frame_(web_frame) { |
| 125 } | 125 } |
| 126 | 126 |
| 127 virtual cricket::PortAllocator* CreatePortAllocator( | 127 virtual cricket::PortAllocator* CreatePortAllocator( |
| 128 const std::vector<StunConfiguration>& stun_servers, | 128 const std::vector<StunConfiguration>& stun_servers, |
| 129 const std::vector<TurnConfiguration>& turn_configurations) OVERRIDE { | 129 const std::vector<TurnConfiguration>& turn_configurations) OVERRIDE { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 156 socket_factory_, config); | 156 socket_factory_, config); |
| 157 } | 157 } |
| 158 | 158 |
| 159 protected: | 159 protected: |
| 160 virtual ~P2PPortAllocatorFactory() {} | 160 virtual ~P2PPortAllocatorFactory() {} |
| 161 | 161 |
| 162 private: | 162 private: |
| 163 scoped_refptr<P2PSocketDispatcher> socket_dispatcher_; | 163 scoped_refptr<P2PSocketDispatcher> socket_dispatcher_; |
| 164 // |network_manager_| and |socket_factory_| are a weak references, owned by | 164 // |network_manager_| and |socket_factory_| are a weak references, owned by |
| 165 // PeerConnectionDependencyFactory. | 165 // PeerConnectionDependencyFactory. |
| 166 talk_base::NetworkManager* network_manager_; | 166 rtc::NetworkManager* network_manager_; |
| 167 talk_base::PacketSocketFactory* socket_factory_; | 167 rtc::PacketSocketFactory* socket_factory_; |
| 168 // Raw ptr to the WebFrame that created the P2PPortAllocatorFactory. | 168 // Raw ptr to the WebFrame that created the P2PPortAllocatorFactory. |
| 169 blink::WebFrame* web_frame_; | 169 blink::WebFrame* web_frame_; |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 PeerConnectionDependencyFactory::PeerConnectionDependencyFactory( | 172 PeerConnectionDependencyFactory::PeerConnectionDependencyFactory( |
| 173 P2PSocketDispatcher* p2p_socket_dispatcher) | 173 P2PSocketDispatcher* p2p_socket_dispatcher) |
| 174 : network_manager_(NULL), | 174 : network_manager_(NULL), |
| 175 p2p_socket_dispatcher_(p2p_socket_dispatcher), | 175 p2p_socket_dispatcher_(p2p_socket_dispatcher), |
| 176 signaling_thread_(NULL), | 176 signaling_thread_(NULL), |
| 177 worker_thread_(NULL), | 177 worker_thread_(NULL), |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 &PeerConnectionDependencyFactory::CreateIpcNetworkManagerOnWorkerThread, | 302 &PeerConnectionDependencyFactory::CreateIpcNetworkManagerOnWorkerThread, |
| 303 base::Unretained(this), | 303 base::Unretained(this), |
| 304 &create_network_manager_event)); | 304 &create_network_manager_event)); |
| 305 create_network_manager_event.Wait(); | 305 create_network_manager_event.Wait(); |
| 306 | 306 |
| 307 socket_factory_.reset( | 307 socket_factory_.reset( |
| 308 new IpcPacketSocketFactory(p2p_socket_dispatcher_.get())); | 308 new IpcPacketSocketFactory(p2p_socket_dispatcher_.get())); |
| 309 | 309 |
| 310 // Init SSL, which will be needed by PeerConnection. | 310 // Init SSL, which will be needed by PeerConnection. |
| 311 #if defined(USE_OPENSSL) | 311 #if defined(USE_OPENSSL) |
| 312 if (!talk_base::InitializeSSL()) { | 312 if (!rtc::InitializeSSL()) { |
| 313 LOG(ERROR) << "Failed on InitializeSSL."; | 313 LOG(ERROR) << "Failed on InitializeSSL."; |
| 314 NOTREACHED(); | 314 NOTREACHED(); |
| 315 return; | 315 return; |
| 316 } | 316 } |
| 317 #else | 317 #else |
| 318 // TODO(ronghuawu): Replace this call with InitializeSSL. | 318 // TODO(ronghuawu): Replace this call with InitializeSSL. |
| 319 net::EnsureNSSSSLInit(); | 319 net::EnsureNSSSSLInit(); |
| 320 #endif | 320 #endif |
| 321 | 321 |
| 322 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory; | 322 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 const webrtc::PeerConnectionInterface::RTCConfiguration& config, | 378 const webrtc::PeerConnectionInterface::RTCConfiguration& config, |
| 379 const webrtc::MediaConstraintsInterface* constraints, | 379 const webrtc::MediaConstraintsInterface* constraints, |
| 380 blink::WebFrame* web_frame, | 380 blink::WebFrame* web_frame, |
| 381 webrtc::PeerConnectionObserver* observer) { | 381 webrtc::PeerConnectionObserver* observer) { |
| 382 CHECK(web_frame); | 382 CHECK(web_frame); |
| 383 CHECK(observer); | 383 CHECK(observer); |
| 384 if (!GetPcFactory()) | 384 if (!GetPcFactory()) |
| 385 return NULL; | 385 return NULL; |
| 386 | 386 |
| 387 scoped_refptr<P2PPortAllocatorFactory> pa_factory = | 387 scoped_refptr<P2PPortAllocatorFactory> pa_factory = |
| 388 new talk_base::RefCountedObject<P2PPortAllocatorFactory>( | 388 new rtc::RefCountedObject<P2PPortAllocatorFactory>( |
| 389 p2p_socket_dispatcher_.get(), | 389 p2p_socket_dispatcher_.get(), |
| 390 network_manager_, | 390 network_manager_, |
| 391 socket_factory_.get(), | 391 socket_factory_.get(), |
| 392 web_frame); | 392 web_frame); |
| 393 | 393 |
| 394 PeerConnectionIdentityService* identity_service = | 394 PeerConnectionIdentityService* identity_service = |
| 395 new PeerConnectionIdentityService( | 395 new PeerConnectionIdentityService( |
| 396 GURL(web_frame->document().url().spec()).GetOrigin()); | 396 GURL(web_frame->document().url().spec()).GetOrigin()); |
| 397 | 397 |
| 398 return GetPcFactory()->CreatePeerConnection(config, | 398 return GetPcFactory()->CreatePeerConnection(config, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 const std::string& sdp) { | 542 const std::string& sdp) { |
| 543 return webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, sdp); | 543 return webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, sdp); |
| 544 } | 544 } |
| 545 | 545 |
| 546 WebRtcAudioDeviceImpl* | 546 WebRtcAudioDeviceImpl* |
| 547 PeerConnectionDependencyFactory::GetWebRtcAudioDevice() { | 547 PeerConnectionDependencyFactory::GetWebRtcAudioDevice() { |
| 548 return audio_device_.get(); | 548 return audio_device_.get(); |
| 549 } | 549 } |
| 550 | 550 |
| 551 void PeerConnectionDependencyFactory::InitializeWorkerThread( | 551 void PeerConnectionDependencyFactory::InitializeWorkerThread( |
| 552 talk_base::Thread** thread, | 552 rtc::Thread** thread, |
| 553 base::WaitableEvent* event) { | 553 base::WaitableEvent* event) { |
| 554 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 554 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
| 555 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); | 555 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); |
| 556 *thread = jingle_glue::JingleThreadWrapper::current(); | 556 *thread = jingle_glue::JingleThreadWrapper::current(); |
| 557 event->Signal(); | 557 event->Signal(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 void PeerConnectionDependencyFactory::CreateIpcNetworkManagerOnWorkerThread( | 560 void PeerConnectionDependencyFactory::CreateIpcNetworkManagerOnWorkerThread( |
| 561 base::WaitableEvent* event) { | 561 base::WaitableEvent* event) { |
| 562 DCHECK_EQ(base::MessageLoop::current(), chrome_worker_thread_.message_loop()); | 562 DCHECK_EQ(base::MessageLoop::current(), chrome_worker_thread_.message_loop()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 } | 656 } |
| 657 | 657 |
| 658 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { | 658 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { |
| 659 if (audio_device_) | 659 if (audio_device_) |
| 660 return; | 660 return; |
| 661 | 661 |
| 662 audio_device_ = new WebRtcAudioDeviceImpl(); | 662 audio_device_ = new WebRtcAudioDeviceImpl(); |
| 663 } | 663 } |
| 664 | 664 |
| 665 } // namespace content | 665 } // namespace content |
| OLD | NEW |