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

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 17444005: Remove MediaStreamDeviceThread in favor of using AudioThread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix one more test. Created 7 years, 6 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/browser/renderer_host/media/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/threading/thread.h"
15 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 14 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
16 #include "content/browser/renderer_host/media/media_stream_requester.h" 15 #include "content/browser/renderer_host/media/media_stream_requester.h"
17 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" 16 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
18 #include "content/browser/renderer_host/media/video_capture_manager.h" 17 #include "content/browser/renderer_host/media/video_capture_manager.h"
19 #include "content/browser/renderer_host/media/web_contents_capture_util.h" 18 #include "content/browser/renderer_host/media/web_contents_capture_util.h"
20 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/content_browser_client.h" 20 #include "content/public/browser/content_browser_client.h"
22 #include "content/public/browser/media_observer.h" 21 #include "content/public/browser/media_observer.h"
23 #include "content/public/browser/media_request_state.h" 22 #include "content/public/browser/media_request_state.h"
24 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } else { 141 } else {
143 BrowserThread::PostTask( 142 BrowserThread::PostTask(
144 BrowserThread::IO, FROM_HERE, 143 BrowserThread::IO, FROM_HERE,
145 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread, 144 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread,
146 base::Unretained(this))); 145 base::Unretained(this)));
147 } 146 }
148 } 147 }
149 148
150 MediaStreamManager::~MediaStreamManager() { 149 MediaStreamManager::~MediaStreamManager() {
151 DCHECK(requests_.empty()); 150 DCHECK(requests_.empty());
152 DCHECK(!device_thread_.get()); 151 DCHECK(!device_loop_);
153 DCHECK(!io_loop_); 152 DCHECK(!io_loop_);
154 } 153 }
155 154
156 VideoCaptureManager* MediaStreamManager::video_capture_manager() { 155 VideoCaptureManager* MediaStreamManager::video_capture_manager() {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
158 DCHECK(video_capture_manager_.get()); 157 DCHECK(video_capture_manager_.get());
159 return video_capture_manager_.get(); 158 return video_capture_manager_.get();
160 } 159 }
161 160
162 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() { 161 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() {
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 if (IsAudioMediaType(audio_type)) 574 if (IsAudioMediaType(audio_type))
576 request->SetState(audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); 575 request->SetState(audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
577 if (IsVideoMediaType(video_type)) 576 if (IsVideoMediaType(video_type))
578 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); 577 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
579 578
580 PostRequestToUI(label); 579 PostRequestToUI(label);
581 } 580 }
582 581
583 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { 582 void MediaStreamManager::InitializeDeviceManagersOnIOThread() {
584 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 583 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
585 if (device_thread_) 584 if (device_loop_)
586 return; 585 return;
587 586 device_loop_ = audio_manager_->GetMessageLoop();
588 device_thread_.reset(new base::Thread("MediaStreamDeviceThread"));
589 #if defined(OS_WIN)
590 device_thread_->init_com_with_mta(true);
591 #endif
592 CHECK(device_thread_->Start());
593 587
594 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_); 588 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_);
595 audio_input_device_manager_->Register( 589 audio_input_device_manager_->Register(this, device_loop_);
596 this, device_thread_->message_loop_proxy().get());
597 590
598 video_capture_manager_ = new VideoCaptureManager(); 591 video_capture_manager_ = new VideoCaptureManager();
599 video_capture_manager_->Register(this, 592 video_capture_manager_->Register(this, device_loop_);
600 device_thread_->message_loop_proxy().get());
601 593
602 // We want to be notified of IO message loop destruction to delete the thread 594 // We want to be notified of IO message loop destruction to delete the thread
603 // and the device managers. 595 // and the device managers.
604 io_loop_ = base::MessageLoop::current(); 596 io_loop_ = base::MessageLoop::current();
605 io_loop_->AddDestructionObserver(this); 597 io_loop_->AddDestructionObserver(this);
606 } 598 }
607 599
608 void MediaStreamManager::Opened(MediaStreamType stream_type, 600 void MediaStreamManager::Opened(MediaStreamType stream_type,
609 int capture_session_id) { 601 int capture_session_id) {
610 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 602 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 927
936 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) { 928 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) {
937 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 929 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
938 use_fake_ui_ = true; 930 use_fake_ui_ = true;
939 fake_ui_ = fake_ui.Pass(); 931 fake_ui_ = fake_ui.Pass();
940 } 932 }
941 933
942 void MediaStreamManager::WillDestroyCurrentMessageLoop() { 934 void MediaStreamManager::WillDestroyCurrentMessageLoop() {
943 DCHECK_EQ(base::MessageLoop::current(), io_loop_); 935 DCHECK_EQ(base::MessageLoop::current(), io_loop_);
944 DCHECK(requests_.empty()); 936 DCHECK(requests_.empty());
945 if (device_thread_) { 937 if (device_loop_) {
946 StopMonitoring(); 938 StopMonitoring();
947 939
948 video_capture_manager_->Unregister(); 940 video_capture_manager_->Unregister();
949 audio_input_device_manager_->Unregister(); 941 audio_input_device_manager_->Unregister();
950 device_thread_.reset(); 942 device_loop_ = NULL;
951 } 943 }
952 944
953 audio_input_device_manager_ = NULL; 945 audio_input_device_manager_ = NULL;
954 video_capture_manager_ = NULL; 946 video_capture_manager_ = NULL;
955 io_loop_ = NULL; 947 io_loop_ = NULL;
956 } 948 }
957 949
958 void MediaStreamManager::NotifyDevicesChanged( 950 void MediaStreamManager::NotifyDevicesChanged(
959 MediaStreamType stream_type, 951 MediaStreamType stream_type,
960 const StreamDeviceInfoArray& devices) { 952 const StreamDeviceInfoArray& devices) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 } 1033 }
1042 1034
1043 // Always do enumeration even though some enumeration is in progress, 1035 // Always do enumeration even though some enumeration is in progress,
1044 // because those enumeration commands could be sent before these devices 1036 // because those enumeration commands could be sent before these devices
1045 // change. 1037 // change.
1046 ++active_enumeration_ref_count_[stream_type]; 1038 ++active_enumeration_ref_count_[stream_type];
1047 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); 1039 GetDeviceManager(stream_type)->EnumerateDevices(stream_type);
1048 } 1040 }
1049 1041
1050 } // namespace content 1042 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698