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" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // webKitRTCPeerConnection. | 218 // webKitRTCPeerConnection. |
219 UpdateWebRTCMethodCount(WEBKIT_RTC_PEER_CONNECTION); | 219 UpdateWebRTCMethodCount(WEBKIT_RTC_PEER_CONNECTION); |
220 | 220 |
221 if (!EnsurePeerConnectionFactory()) | 221 if (!EnsurePeerConnectionFactory()) |
222 return NULL; | 222 return NULL; |
223 | 223 |
224 return new RTCPeerConnectionHandler(client, this); | 224 return new RTCPeerConnectionHandler(client, this); |
225 } | 225 } |
226 | 226 |
227 void MediaStreamDependencyFactory::CreateNativeMediaSources( | 227 void MediaStreamDependencyFactory::CreateNativeMediaSources( |
| 228 int render_view_id, |
228 const WebKit::WebMediaConstraints& audio_constraints, | 229 const WebKit::WebMediaConstraints& audio_constraints, |
229 const WebKit::WebMediaConstraints& video_constraints, | 230 const WebKit::WebMediaConstraints& video_constraints, |
230 WebKit::WebMediaStream* description, | 231 WebKit::WebMediaStream* description, |
231 const MediaSourcesCreatedCallback& sources_created) { | 232 const MediaSourcesCreatedCallback& sources_created) { |
232 DVLOG(1) << "MediaStreamDependencyFactory::CreateNativeMediaSources()"; | 233 DVLOG(1) << "MediaStreamDependencyFactory::CreateNativeMediaSources()"; |
233 if (!EnsurePeerConnectionFactory()) { | 234 if (!EnsurePeerConnectionFactory()) { |
234 sources_created.Run(description, false); | 235 sources_created.Run(description, false); |
235 return; | 236 return; |
236 } | 237 } |
237 | 238 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 MediaStreamSourceExtraData* source_data = | 273 MediaStreamSourceExtraData* source_data = |
273 static_cast<MediaStreamSourceExtraData*>(source.extraData()); | 274 static_cast<MediaStreamSourceExtraData*>(source.extraData()); |
274 if (!source_data) { | 275 if (!source_data) { |
275 // TODO(henrika): Implement support for sources from remote MediaStreams. | 276 // TODO(henrika): Implement support for sources from remote MediaStreams. |
276 NOTIMPLEMENTED(); | 277 NOTIMPLEMENTED(); |
277 continue; | 278 continue; |
278 } | 279 } |
279 | 280 |
280 const StreamDeviceInfo device_info = source_data->device_info(); | 281 const StreamDeviceInfo device_info = source_data->device_info(); |
281 if (IsAudioMediaType(device_info.device.type)) { | 282 if (IsAudioMediaType(device_info.device.type)) { |
282 if (!InitializeAudioSource(device_info)) { | 283 if (!InitializeAudioSource(render_view_id, device_info)) { |
283 DLOG(WARNING) << "Unsupported audio source"; | 284 DLOG(WARNING) << "Unsupported audio source"; |
284 sources_created.Run(description, false); | 285 sources_created.Run(description, false); |
285 return; | 286 return; |
286 } | 287 } |
287 } | 288 } |
288 | 289 |
289 // Creates a LocalAudioSource object which holds audio options. | 290 // Creates a LocalAudioSource object which holds audio options. |
290 source_data->SetLocalAudioSource( | 291 source_data->SetLocalAudioSource( |
291 CreateLocalAudioSource(&native_audio_constraints)); | 292 CreateLocalAudioSource(&native_audio_constraints)); |
292 source_observer->AddSource(source_data->local_audio_source()); | 293 source_observer->AddSource(source_data->local_audio_source()); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 RtcVideoCapturer* capturer = new RtcVideoCapturer( | 442 RtcVideoCapturer* capturer = new RtcVideoCapturer( |
442 video_session_id, vc_manager_.get(), is_screencast); | 443 video_session_id, vc_manager_.get(), is_screencast); |
443 | 444 |
444 // The video source takes ownership of |capturer|. | 445 // The video source takes ownership of |capturer|. |
445 scoped_refptr<webrtc::VideoSourceInterface> source = | 446 scoped_refptr<webrtc::VideoSourceInterface> source = |
446 pc_factory_->CreateVideoSource(capturer, constraints).get(); | 447 pc_factory_->CreateVideoSource(capturer, constraints).get(); |
447 return source; | 448 return source; |
448 } | 449 } |
449 | 450 |
450 bool MediaStreamDependencyFactory::InitializeAudioSource( | 451 bool MediaStreamDependencyFactory::InitializeAudioSource( |
451 const StreamDeviceInfo& device_info) { | 452 int render_view_id, |
| 453 const StreamDeviceInfo& device_info) { |
452 DVLOG(1) << "MediaStreamDependencyFactory::InitializeAudioSource()"; | 454 DVLOG(1) << "MediaStreamDependencyFactory::InitializeAudioSource()"; |
453 const MediaStreamDevice device = device_info.device; | 455 const MediaStreamDevice device = device_info.device; |
454 | 456 |
455 // Initialize the source using audio parameters for the selected | 457 // Initialize the source using audio parameters for the selected |
456 // capture device. | 458 // capture device. |
457 WebRtcAudioCapturer* capturer = GetWebRtcAudioDevice()->capturer(); | 459 WebRtcAudioCapturer* capturer = GetWebRtcAudioDevice()->capturer(); |
458 // TODO(henrika): refactor \content\public\common\media_stream_request.h | 460 // TODO(henrika): refactor \content\public\common\media_stream_request.h |
459 // to allow dependency of media::ChannelLayout and avoid static_cast. | 461 // to allow dependency of media::ChannelLayout and avoid static_cast. |
460 if (!capturer->Initialize( | 462 if (!capturer->Initialize( |
| 463 render_view_id, |
461 static_cast<media::ChannelLayout>(device.channel_layout), | 464 static_cast<media::ChannelLayout>(device.channel_layout), |
462 device.sample_rate)) | 465 device.sample_rate)) |
463 return false; | 466 return false; |
464 | 467 |
465 // Specify which capture device to use. The acquired session id is used | 468 // Specify which capture device to use. The acquired session id is used |
466 // for identification. | 469 // for identification. |
467 // TODO(henrika): the current design does not support a uniqe source | 470 // TODO(henrika): the current design does not support a uniqe source |
468 // for each audio track. | 471 // for each audio track. |
469 if (device_info.session_id <= 0) | 472 if (device_info.session_id <= 0) |
470 return false; | 473 return false; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 // processed before returning. We wait for the above task to finish before | 637 // processed before returning. We wait for the above task to finish before |
635 // letting the the function continue to avoid any potential race issues. | 638 // letting the the function continue to avoid any potential race issues. |
636 chrome_worker_thread_.Stop(); | 639 chrome_worker_thread_.Stop(); |
637 } else { | 640 } else { |
638 NOTREACHED() << "Worker thread not running."; | 641 NOTREACHED() << "Worker thread not running."; |
639 } | 642 } |
640 } | 643 } |
641 } | 644 } |
642 | 645 |
643 } // namespace content | 646 } // namespace content |
OLD | NEW |