Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: content/renderer/media/media_stream_dependency_factory.cc

Issue 12440027: Do not pass the string device_id via IPC message to create an audio input stream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Per's comments. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 int sdp_mline_index, 544 int sdp_mline_index,
549 const std::string& sdp) { 545 const std::string& sdp) {
550 return webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, sdp); 546 return webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, sdp);
551 } 547 }
552 548
553 WebRtcAudioDeviceImpl* 549 WebRtcAudioDeviceImpl*
554 MediaStreamDependencyFactory::GetWebRtcAudioDevice() { 550 MediaStreamDependencyFactory::GetWebRtcAudioDevice() {
555 return audio_device_; 551 return audio_device_;
556 } 552 }
557 553
554 void MediaStreamDependencyFactory::StopLocalAudioSource(
555 const WebKit::WebMediaStream& description) {
556 MediaStreamExtraData* extra_data = static_cast<MediaStreamExtraData*>(
557 description.extraData());
558 if (extra_data && extra_data->is_local() && extra_data->stream() &&
559 !extra_data->stream()->GetAudioTracks().empty()) {
560 if (GetWebRtcAudioDevice()) {
561 scoped_refptr<WebRtcAudioCapturer> capturer =
562 GetWebRtcAudioDevice()->capturer();
563 if (capturer)
564 capturer->Stop();
565 }
566 }
567 }
568
558 void MediaStreamDependencyFactory::InitializeWorkerThread( 569 void MediaStreamDependencyFactory::InitializeWorkerThread(
559 talk_base::Thread** thread, 570 talk_base::Thread** thread,
560 base::WaitableEvent* event) { 571 base::WaitableEvent* event) {
561 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); 572 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
562 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); 573 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true);
563 *thread = jingle_glue::JingleThreadWrapper::current(); 574 *thread = jingle_glue::JingleThreadWrapper::current();
564 event->Signal(); 575 event->Signal();
565 } 576 }
566 577
567 void MediaStreamDependencyFactory::CreateIpcNetworkManagerOnWorkerThread( 578 void MediaStreamDependencyFactory::CreateIpcNetworkManagerOnWorkerThread(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 // processed before returning. We wait for the above task to finish before 663 // processed before returning. We wait for the above task to finish before
653 // letting the the function continue to avoid any potential race issues. 664 // letting the the function continue to avoid any potential race issues.
654 chrome_worker_thread_.Stop(); 665 chrome_worker_thread_.Stop();
655 } else { 666 } else {
656 NOTREACHED() << "Worker thread not running."; 667 NOTREACHED() << "Worker thread not running.";
657 } 668 }
658 } 669 }
659 } 670 }
660 671
661 } // namespace content 672 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_dependency_factory.h ('k') | content/renderer/media/media_stream_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698