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/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "content/renderer/media/media_stream_extra_data.h" | 11 #include "content/renderer/media/media_stream_extra_data.h" |
12 #include "content/renderer/media/media_stream_source_extra_data.h" | 12 #include "content/renderer/media/media_stream_source_extra_data.h" |
| 13 #include "content/renderer/media/peer_connection_handler_jsep.h" |
| 14 #include "content/renderer/media/rtc_peer_connection_handler.h" |
13 #include "content/renderer/media/rtc_video_capturer.h" | 15 #include "content/renderer/media/rtc_video_capturer.h" |
14 #include "content/renderer/media/peer_connection_handler_jsep.h" | |
15 #include "content/renderer/media/video_capture_impl_manager.h" | 16 #include "content/renderer/media/video_capture_impl_manager.h" |
16 #include "content/renderer/media/webrtc_audio_device_impl.h" | 17 #include "content/renderer/media/webrtc_audio_device_impl.h" |
17 #include "content/renderer/media/webrtc_uma_histograms.h" | 18 #include "content/renderer/media/webrtc_uma_histograms.h" |
18 #include "content/renderer/p2p/ipc_network_manager.h" | 19 #include "content/renderer/p2p/ipc_network_manager.h" |
19 #include "content/renderer/p2p/ipc_socket_factory.h" | 20 #include "content/renderer/p2p/ipc_socket_factory.h" |
20 #include "content/renderer/p2p/port_allocator.h" | 21 #include "content/renderer/p2p/port_allocator.h" |
21 #include "jingle/glue/thread_wrapper.h" | 22 #include "jingle/glue/thread_wrapper.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amComponent.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amComponent.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amDescriptor.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amDescriptor.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 90 } |
90 | 91 |
91 WebKit::WebPeerConnection00Handler* | 92 WebKit::WebPeerConnection00Handler* |
92 MediaStreamDependencyFactory::CreatePeerConnectionHandlerJsep( | 93 MediaStreamDependencyFactory::CreatePeerConnectionHandlerJsep( |
93 WebKit::WebPeerConnection00HandlerClient* client) { | 94 WebKit::WebPeerConnection00HandlerClient* client) { |
94 // Save histogram data so we can see how much PeerConnetion is used. | 95 // Save histogram data so we can see how much PeerConnetion is used. |
95 // The histogram counts the number of calls to the JS API | 96 // The histogram counts the number of calls to the JS API |
96 // webKitPeerConnection00. | 97 // webKitPeerConnection00. |
97 UpdateWebRTCMethodCount(WEBKIT_PEER_CONNECTION); | 98 UpdateWebRTCMethodCount(WEBKIT_PEER_CONNECTION); |
98 | 99 |
99 if (!EnsurePeerConnectionFactory()) { | 100 if (!EnsurePeerConnectionFactory()) |
100 return NULL; | 101 return NULL; |
101 } | |
102 | 102 |
103 return new PeerConnectionHandlerJsep(client, this); | 103 return new PeerConnectionHandlerJsep(client, this); |
104 } | 104 } |
105 | 105 |
| 106 WebKit::WebRTCPeerConnectionHandler* |
| 107 MediaStreamDependencyFactory::CreateRTCPeerConnectionHandler( |
| 108 WebKit::WebRTCPeerConnectionHandlerClient* client) { |
| 109 // Save histogram data so we can see how much PeerConnetion is used. |
| 110 // The histogram counts the number of calls to the JS API |
| 111 // webKitRTCPeerConnection. |
| 112 UpdateWebRTCMethodCount(WEBKIT_RTC_PEER_CONNECTION); |
| 113 |
| 114 if (!EnsurePeerConnectionFactory()) |
| 115 return NULL; |
| 116 |
| 117 return new RTCPeerConnectionHandler(client, this); |
| 118 } |
| 119 |
106 bool MediaStreamDependencyFactory::CreateNativeLocalMediaStream( | 120 bool MediaStreamDependencyFactory::CreateNativeLocalMediaStream( |
107 WebKit::WebMediaStreamDescriptor* description) { | 121 WebKit::WebMediaStreamDescriptor* description) { |
108 // Creating the peer connection factory can fail if for example the audio | 122 // Creating the peer connection factory can fail if for example the audio |
109 // (input or output) or video device cannot be opened. Handling such cases | 123 // (input or output) or video device cannot be opened. Handling such cases |
110 // better is a higher level design discussion which involves the media | 124 // better is a higher level design discussion which involves the media |
111 // manager, webrtc and libjingle. We cannot create any native | 125 // manager, webrtc and libjingle. We cannot create any native |
112 // track objects however, so we'll just have to skip that. Furthermore, | 126 // track objects however, so we'll just have to skip that. Furthermore, |
113 // creating a peer connection later on will fail if we don't have a factory. | 127 // creating a peer connection later on will fail if we don't have a factory. |
114 if (!EnsurePeerConnectionFactory()) | 128 if (!EnsurePeerConnectionFactory()) |
115 return false; | 129 return false; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 return pc_factory_.get() != NULL; | 210 return pc_factory_.get() != NULL; |
197 } | 211 } |
198 | 212 |
199 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> | 213 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> |
200 MediaStreamDependencyFactory::CreatePeerConnection( | 214 MediaStreamDependencyFactory::CreatePeerConnection( |
201 const std::string& config, | 215 const std::string& config, |
202 webrtc::PeerConnectionObserver* observer) { | 216 webrtc::PeerConnectionObserver* observer) { |
203 return pc_factory_->CreatePeerConnection(config, observer); | 217 return pc_factory_->CreatePeerConnection(config, observer); |
204 } | 218 } |
205 | 219 |
| 220 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> |
| 221 MediaStreamDependencyFactory::CreatePeerConnection( |
| 222 const webrtc::JsepInterface::IceServers& ice_servers, |
| 223 const webrtc::MediaConstraintsInterface* constraints, |
| 224 webrtc::PeerConnectionObserver* observer) { |
| 225 return pc_factory_->CreatePeerConnection(ice_servers, constraints, observer); |
| 226 } |
| 227 |
206 talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> | 228 talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> |
207 MediaStreamDependencyFactory::CreateLocalMediaStream( | 229 MediaStreamDependencyFactory::CreateLocalMediaStream( |
208 const std::string& label) { | 230 const std::string& label) { |
209 return pc_factory_->CreateLocalMediaStream(label); | 231 return pc_factory_->CreateLocalMediaStream(label); |
210 } | 232 } |
211 | 233 |
212 talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> | 234 talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> |
213 MediaStreamDependencyFactory::CreateLocalVideoTrack( | 235 MediaStreamDependencyFactory::CreateLocalVideoTrack( |
214 const std::string& label, | 236 const std::string& label, |
215 int video_session_id) { | 237 int video_session_id) { |
(...skipping 10 matching lines...) Expand all Loading... |
226 const std::string& label, | 248 const std::string& label, |
227 webrtc::AudioDeviceModule* audio_device) { | 249 webrtc::AudioDeviceModule* audio_device) { |
228 return pc_factory_->CreateLocalAudioTrack(label, audio_device); | 250 return pc_factory_->CreateLocalAudioTrack(label, audio_device); |
229 } | 251 } |
230 | 252 |
231 webrtc::SessionDescriptionInterface* | 253 webrtc::SessionDescriptionInterface* |
232 MediaStreamDependencyFactory::CreateSessionDescription(const std::string& sdp) { | 254 MediaStreamDependencyFactory::CreateSessionDescription(const std::string& sdp) { |
233 return webrtc::CreateSessionDescription(sdp); | 255 return webrtc::CreateSessionDescription(sdp); |
234 } | 256 } |
235 | 257 |
| 258 webrtc::SessionDescriptionInterface* |
| 259 MediaStreamDependencyFactory::CreateSessionDescription(const std::string& type, |
| 260 const std::string& sdp) { |
| 261 return webrtc::CreateSessionDescription(type, sdp); |
| 262 } |
| 263 |
236 webrtc::IceCandidateInterface* MediaStreamDependencyFactory::CreateIceCandidate( | 264 webrtc::IceCandidateInterface* MediaStreamDependencyFactory::CreateIceCandidate( |
237 const std::string& sdp_mid, | 265 const std::string& sdp_mid, |
238 int sdp_mline_index, | 266 int sdp_mline_index, |
239 const std::string& sdp) { | 267 const std::string& sdp) { |
240 return webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, sdp); | 268 return webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, sdp); |
241 } | 269 } |
242 | 270 |
243 void MediaStreamDependencyFactory::SetAudioDeviceSessionId(int session_id) { | 271 void MediaStreamDependencyFactory::SetAudioDeviceSessionId(int session_id) { |
244 audio_device_->SetSessionId(session_id); | 272 audio_device_->SetSessionId(session_id); |
245 } | 273 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 base::Unretained(this))); | 361 base::Unretained(this))); |
334 // Stopping the thread will wait until all tasks have been | 362 // Stopping the thread will wait until all tasks have been |
335 // processed before returning. We wait for the above task to finish before | 363 // processed before returning. We wait for the above task to finish before |
336 // letting the the function continue to avoid any potential race issues. | 364 // letting the the function continue to avoid any potential race issues. |
337 chrome_worker_thread_.Stop(); | 365 chrome_worker_thread_.Stop(); |
338 } else { | 366 } else { |
339 NOTREACHED() << "Worker thread not running."; | 367 NOTREACHED() << "Worker thread not running."; |
340 } | 368 } |
341 } | 369 } |
342 } | 370 } |
OLD | NEW |