| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #include "media/filters/ffmpeg_glue.h" | 55 #include "media/filters/ffmpeg_glue.h" |
| 56 #include "media/renderers/gpu_video_accelerator_factories.h" | 56 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 57 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 57 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
| 58 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 58 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 59 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 59 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 60 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 60 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 61 #include "third_party/WebKit/public/platform/WebURL.h" | 61 #include "third_party/WebKit/public/platform/WebURL.h" |
| 62 #include "third_party/WebKit/public/web/WebDocument.h" | 62 #include "third_party/WebKit/public/web/WebDocument.h" |
| 63 #include "third_party/WebKit/public/web/WebFrame.h" | 63 #include "third_party/WebKit/public/web/WebFrame.h" |
| 64 #include "third_party/webrtc/api/mediaconstraintsinterface.h" | 64 #include "third_party/webrtc/api/mediaconstraintsinterface.h" |
| 65 #include "third_party/webrtc/api/videosourceproxy.h" |
| 65 #include "third_party/webrtc/base/ssladapter.h" | 66 #include "third_party/webrtc/base/ssladapter.h" |
| 66 #include "third_party/webrtc/modules/video_coding/codecs/h264/include/h264.h" | 67 #include "third_party/webrtc/modules/video_coding/codecs/h264/include/h264.h" |
| 67 | 68 |
| 68 #if defined(OS_ANDROID) | 69 #if defined(OS_ANDROID) |
| 69 #include "media/base/android/media_codec_util.h" | 70 #include "media/base/android/media_codec_util.h" |
| 70 #endif | 71 #endif |
| 71 | 72 |
| 72 namespace content { | 73 namespace content { |
| 73 | 74 |
| 74 namespace { | 75 namespace { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 PeerConnectionDependencyFactory::CreateRTCPeerConnectionHandler( | 119 PeerConnectionDependencyFactory::CreateRTCPeerConnectionHandler( |
| 119 blink::WebRTCPeerConnectionHandlerClient* client) { | 120 blink::WebRTCPeerConnectionHandlerClient* client) { |
| 120 // Save histogram data so we can see how much PeerConnetion is used. | 121 // Save histogram data so we can see how much PeerConnetion is used. |
| 121 // The histogram counts the number of calls to the JS API | 122 // The histogram counts the number of calls to the JS API |
| 122 // webKitRTCPeerConnection. | 123 // webKitRTCPeerConnection. |
| 123 UpdateWebRTCMethodCount(WEBKIT_RTC_PEER_CONNECTION); | 124 UpdateWebRTCMethodCount(WEBKIT_RTC_PEER_CONNECTION); |
| 124 | 125 |
| 125 return new RTCPeerConnectionHandler(client, this); | 126 return new RTCPeerConnectionHandler(client, this); |
| 126 } | 127 } |
| 127 | 128 |
| 128 WebRtcVideoCapturerAdapter* | |
| 129 PeerConnectionDependencyFactory::CreateVideoCapturer( | |
| 130 bool is_screeencast) { | |
| 131 // We need to make sure the libjingle thread wrappers have been created | |
| 132 // before we can use an instance of a WebRtcVideoCapturerAdapter. This is | |
| 133 // since the base class of WebRtcVideoCapturerAdapter is a | |
| 134 // cricket::VideoCapturer and it uses the libjingle thread wrappers. | |
| 135 if (!GetPcFactory().get()) | |
| 136 return NULL; | |
| 137 return new WebRtcVideoCapturerAdapter(is_screeencast); | |
| 138 } | |
| 139 | |
| 140 scoped_refptr<webrtc::VideoTrackSourceInterface> | |
| 141 PeerConnectionDependencyFactory::CreateVideoSource( | |
| 142 cricket::VideoCapturer* capturer) { | |
| 143 scoped_refptr<webrtc::VideoTrackSourceInterface> source = | |
| 144 GetPcFactory()->CreateVideoSource(capturer).get(); | |
| 145 return source; | |
| 146 } | |
| 147 | |
| 148 const scoped_refptr<webrtc::PeerConnectionFactoryInterface>& | 129 const scoped_refptr<webrtc::PeerConnectionFactoryInterface>& |
| 149 PeerConnectionDependencyFactory::GetPcFactory() { | 130 PeerConnectionDependencyFactory::GetPcFactory() { |
| 150 if (!pc_factory_.get()) | 131 if (!pc_factory_.get()) |
| 151 CreatePeerConnectionFactory(); | 132 CreatePeerConnectionFactory(); |
| 152 CHECK(pc_factory_.get()); | 133 CHECK(pc_factory_.get()); |
| 153 return pc_factory_; | 134 return pc_factory_; |
| 154 } | 135 } |
| 155 | 136 |
| 156 void PeerConnectionDependencyFactory::WillDestroyCurrentMessageLoop() { | 137 void PeerConnectionDependencyFactory::WillDestroyCurrentMessageLoop() { |
| 157 CleanupPeerConnectionFactory(); | 138 CleanupPeerConnectionFactory(); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 nullptr, observer) | 396 nullptr, observer) |
| 416 .get(); | 397 .get(); |
| 417 } | 398 } |
| 418 | 399 |
| 419 scoped_refptr<webrtc::MediaStreamInterface> | 400 scoped_refptr<webrtc::MediaStreamInterface> |
| 420 PeerConnectionDependencyFactory::CreateLocalMediaStream( | 401 PeerConnectionDependencyFactory::CreateLocalMediaStream( |
| 421 const std::string& label) { | 402 const std::string& label) { |
| 422 return GetPcFactory()->CreateLocalMediaStream(label).get(); | 403 return GetPcFactory()->CreateLocalMediaStream(label).get(); |
| 423 } | 404 } |
| 424 | 405 |
| 406 scoped_refptr<webrtc::VideoTrackSourceInterface> |
| 407 PeerConnectionDependencyFactory::CreateVideoTrackSourceProxy( |
| 408 webrtc::VideoTrackSourceInterface* source) { |
| 409 // PeerConnectionFactory needs to be instantiated to make sure that |
| 410 // signaling_thread_ and worker_thread_ exist. |
| 411 if (!PeerConnectionFactoryCreated()) |
| 412 CreatePeerConnectionFactory(); |
| 413 |
| 414 return webrtc::VideoTrackSourceProxy::Create(signaling_thread_, |
| 415 worker_thread_, source) |
| 416 .get(); |
| 417 } |
| 418 |
| 425 scoped_refptr<webrtc::VideoTrackInterface> | 419 scoped_refptr<webrtc::VideoTrackInterface> |
| 426 PeerConnectionDependencyFactory::CreateLocalVideoTrack( | 420 PeerConnectionDependencyFactory::CreateLocalVideoTrack( |
| 427 const std::string& id, | 421 const std::string& id, |
| 428 webrtc::VideoTrackSourceInterface* source) { | 422 webrtc::VideoTrackSourceInterface* source) { |
| 429 return GetPcFactory()->CreateVideoTrack(id, source).get(); | 423 return GetPcFactory()->CreateVideoTrack(id, source).get(); |
| 430 } | 424 } |
| 431 | 425 |
| 432 scoped_refptr<webrtc::VideoTrackInterface> | |
| 433 PeerConnectionDependencyFactory::CreateLocalVideoTrack( | |
| 434 const std::string& id, cricket::VideoCapturer* capturer) { | |
| 435 if (!capturer) { | |
| 436 LOG(ERROR) << "CreateLocalVideoTrack called with null VideoCapturer."; | |
| 437 return NULL; | |
| 438 } | |
| 439 | |
| 440 // Create video source from the |capturer|. | |
| 441 scoped_refptr<webrtc::VideoTrackSourceInterface> source = | |
| 442 GetPcFactory()->CreateVideoSource(capturer, NULL).get(); | |
| 443 | |
| 444 // Create native track from the source. | |
| 445 return GetPcFactory()->CreateVideoTrack(id, source.get()).get(); | |
| 446 } | |
| 447 | |
| 448 webrtc::SessionDescriptionInterface* | 426 webrtc::SessionDescriptionInterface* |
| 449 PeerConnectionDependencyFactory::CreateSessionDescription( | 427 PeerConnectionDependencyFactory::CreateSessionDescription( |
| 450 const std::string& type, | 428 const std::string& type, |
| 451 const std::string& sdp, | 429 const std::string& sdp, |
| 452 webrtc::SdpParseError* error) { | 430 webrtc::SdpParseError* error) { |
| 453 return webrtc::CreateSessionDescription(type, sdp, error); | 431 return webrtc::CreateSessionDescription(type, sdp, error); |
| 454 } | 432 } |
| 455 | 433 |
| 456 webrtc::IceCandidateInterface* | 434 webrtc::IceCandidateInterface* |
| 457 PeerConnectionDependencyFactory::CreateIceCandidate( | 435 PeerConnectionDependencyFactory::CreateIceCandidate( |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 553 |
| 576 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { | 554 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { |
| 577 DCHECK(CalledOnValidThread()); | 555 DCHECK(CalledOnValidThread()); |
| 578 if (audio_device_.get()) | 556 if (audio_device_.get()) |
| 579 return; | 557 return; |
| 580 | 558 |
| 581 audio_device_ = new WebRtcAudioDeviceImpl(); | 559 audio_device_ = new WebRtcAudioDeviceImpl(); |
| 582 } | 560 } |
| 583 | 561 |
| 584 } // namespace content | 562 } // namespace content |
| OLD | NEW |