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