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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 | 455 |
456 // The video source takes ownership of |capturer|. | 456 // The video source takes ownership of |capturer|. |
457 scoped_refptr<webrtc::VideoSourceInterface> source = | 457 scoped_refptr<webrtc::VideoSourceInterface> source = |
458 pc_factory_->CreateVideoSource(capturer, constraints).get(); | 458 pc_factory_->CreateVideoSource(capturer, constraints).get(); |
459 return source; | 459 return source; |
460 } | 460 } |
461 | 461 |
462 bool MediaStreamDependencyFactory::InitializeAudioSource( | 462 bool MediaStreamDependencyFactory::InitializeAudioSource( |
463 const StreamDeviceInfo& device_info) { | 463 const StreamDeviceInfo& device_info) { |
464 DVLOG(1) << "MediaStreamDependencyFactory::InitializeAudioSource()"; | 464 DVLOG(1) << "MediaStreamDependencyFactory::InitializeAudioSource()"; |
465 const MediaStreamDevice device = device_info.device; | 465 |
| 466 // TODO(henrika): the current design does not support a unique source |
| 467 // for each audio track. |
| 468 if (device_info.session_id <= 0) |
| 469 return false; |
466 | 470 |
467 // Initialize the source using audio parameters for the selected | 471 // Initialize the source using audio parameters for the selected |
468 // capture device. | 472 // capture device. |
469 WebRtcAudioCapturer* capturer = GetWebRtcAudioDevice()->capturer(); | 473 WebRtcAudioCapturer* capturer = GetWebRtcAudioDevice()->capturer(); |
470 // TODO(henrika): refactor \content\public\common\media_stream_request.h | 474 // TODO(henrika): refactor \content\public\common\media_stream_request.h |
471 // to allow dependency of media::ChannelLayout and avoid static_cast. | 475 // to allow dependency of media::ChannelLayout and avoid static_cast. |
472 if (!capturer->Initialize( | 476 if (!capturer->Initialize( |
473 static_cast<media::ChannelLayout>(device.channel_layout), | 477 static_cast<media::ChannelLayout>(device_info.device.channel_layout), |
474 device.sample_rate)) | 478 device_info.device.sample_rate, device_info.session_id)) |
475 return false; | 479 return false; |
476 | 480 |
477 // Specify which capture device to use. The acquired session id is used | |
478 // for identification. | |
479 // TODO(henrika): the current design does not support a uniqe source | |
480 // for each audio track. | |
481 if (device_info.session_id <= 0) | |
482 return false; | |
483 | |
484 capturer->SetDevice(device_info.session_id); | |
485 return true; | 481 return true; |
486 } | 482 } |
487 | 483 |
488 bool MediaStreamDependencyFactory::CreateWebAudioSource( | 484 bool MediaStreamDependencyFactory::CreateWebAudioSource( |
489 WebKit::WebMediaStreamSource* source) { | 485 WebKit::WebMediaStreamSource* source) { |
490 DVLOG(1) << "MediaStreamDependencyFactory::CreateWebAudioSource()"; | 486 DVLOG(1) << "MediaStreamDependencyFactory::CreateWebAudioSource()"; |
491 DCHECK(GetWebRtcAudioDevice()); | 487 DCHECK(GetWebRtcAudioDevice()); |
492 | 488 |
493 // WebAudio needs the WebRtcAudioCapturer to be able to send its data | 489 // WebAudio needs the WebRtcAudioCapturer to be able to send its data |
494 // over a PeerConnection. The microphone source is not utilized in this | 490 // over a PeerConnection. The microphone source is not utilized in this |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 // processed before returning. We wait for the above task to finish before | 648 // processed before returning. We wait for the above task to finish before |
653 // letting the the function continue to avoid any potential race issues. | 649 // letting the the function continue to avoid any potential race issues. |
654 chrome_worker_thread_.Stop(); | 650 chrome_worker_thread_.Stop(); |
655 } else { | 651 } else { |
656 NOTREACHED() << "Worker thread not running."; | 652 NOTREACHED() << "Worker thread not running."; |
657 } | 653 } |
658 } | 654 } |
659 } | 655 } |
660 | 656 |
661 } // namespace content | 657 } // namespace content |
OLD | NEW |