| 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/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" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } else { | 141 } else { |
| 142 BrowserThread::PostTask( | 142 BrowserThread::PostTask( |
| 143 BrowserThread::IO, FROM_HERE, | 143 BrowserThread::IO, FROM_HERE, |
| 144 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread, | 144 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread, |
| 145 base::Unretained(this))); | 145 base::Unretained(this))); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 MediaStreamManager::~MediaStreamManager() { | 149 MediaStreamManager::~MediaStreamManager() { |
| 150 DCHECK(requests_.empty()); | 150 DCHECK(requests_.empty()); |
| 151 DCHECK(!device_loop_); | 151 DCHECK(!device_loop_.get()); |
| 152 DCHECK(!io_loop_); | 152 DCHECK(!io_loop_); |
| 153 } | 153 } |
| 154 | 154 |
| 155 VideoCaptureManager* MediaStreamManager::video_capture_manager() { | 155 VideoCaptureManager* MediaStreamManager::video_capture_manager() { |
| 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 157 DCHECK(video_capture_manager_.get()); | 157 DCHECK(video_capture_manager_.get()); |
| 158 return video_capture_manager_.get(); | 158 return video_capture_manager_.get(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() { | 161 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() { |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 if (IsAudioMediaType(audio_type)) | 578 if (IsAudioMediaType(audio_type)) |
| 579 request->SetState(audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); | 579 request->SetState(audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); |
| 580 if (IsVideoMediaType(video_type)) | 580 if (IsVideoMediaType(video_type)) |
| 581 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); | 581 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); |
| 582 | 582 |
| 583 PostRequestToUI(label); | 583 PostRequestToUI(label); |
| 584 } | 584 } |
| 585 | 585 |
| 586 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { | 586 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { |
| 587 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 587 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 588 if (device_loop_) | 588 if (device_loop_.get()) |
| 589 return; | 589 return; |
| 590 device_loop_ = audio_manager_->GetMessageLoop(); | 590 device_loop_ = audio_manager_->GetMessageLoop(); |
| 591 | 591 |
| 592 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_); | 592 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_); |
| 593 audio_input_device_manager_->Register(this, device_loop_); | 593 audio_input_device_manager_->Register(this, device_loop_.get()); |
| 594 | 594 |
| 595 video_capture_manager_ = new VideoCaptureManager(); | 595 video_capture_manager_ = new VideoCaptureManager(); |
| 596 video_capture_manager_->Register(this, device_loop_); | 596 video_capture_manager_->Register(this, device_loop_.get()); |
| 597 | 597 |
| 598 // We want to be notified of IO message loop destruction to delete the thread | 598 // We want to be notified of IO message loop destruction to delete the thread |
| 599 // and the device managers. | 599 // and the device managers. |
| 600 io_loop_ = base::MessageLoop::current(); | 600 io_loop_ = base::MessageLoop::current(); |
| 601 io_loop_->AddDestructionObserver(this); | 601 io_loop_->AddDestructionObserver(this); |
| 602 } | 602 } |
| 603 | 603 |
| 604 void MediaStreamManager::Opened(MediaStreamType stream_type, | 604 void MediaStreamManager::Opened(MediaStreamType stream_type, |
| 605 int capture_session_id) { | 605 int capture_session_id) { |
| 606 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 606 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 | 930 |
| 931 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) { | 931 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) { |
| 932 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 932 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 933 use_fake_ui_ = true; | 933 use_fake_ui_ = true; |
| 934 fake_ui_ = fake_ui.Pass(); | 934 fake_ui_ = fake_ui.Pass(); |
| 935 } | 935 } |
| 936 | 936 |
| 937 void MediaStreamManager::WillDestroyCurrentMessageLoop() { | 937 void MediaStreamManager::WillDestroyCurrentMessageLoop() { |
| 938 DCHECK_EQ(base::MessageLoop::current(), io_loop_); | 938 DCHECK_EQ(base::MessageLoop::current(), io_loop_); |
| 939 DCHECK(requests_.empty()); | 939 DCHECK(requests_.empty()); |
| 940 if (device_loop_) { | 940 if (device_loop_.get()) { |
| 941 StopMonitoring(); | 941 StopMonitoring(); |
| 942 | 942 |
| 943 video_capture_manager_->Unregister(); | 943 video_capture_manager_->Unregister(); |
| 944 audio_input_device_manager_->Unregister(); | 944 audio_input_device_manager_->Unregister(); |
| 945 device_loop_ = NULL; | 945 device_loop_ = NULL; |
| 946 } | 946 } |
| 947 | 947 |
| 948 audio_input_device_manager_ = NULL; | 948 audio_input_device_manager_ = NULL; |
| 949 video_capture_manager_ = NULL; | 949 video_capture_manager_ = NULL; |
| 950 io_loop_ = NULL; | 950 io_loop_ = NULL; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 // Always do enumeration even though some enumeration is in progress, | 1038 // Always do enumeration even though some enumeration is in progress, |
| 1039 // because those enumeration commands could be sent before these devices | 1039 // because those enumeration commands could be sent before these devices |
| 1040 // change. | 1040 // change. |
| 1041 ++active_enumeration_ref_count_[stream_type]; | 1041 ++active_enumeration_ref_count_[stream_type]; |
| 1042 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); | 1042 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 } // namespace content | 1045 } // namespace content |
| OLD | NEW |