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 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
18 #include "content/browser/browser_main_loop.h" | 18 #include "content/browser/browser_main_loop.h" |
19 #include "content/browser/device_monitor_mac.h" | |
19 #include "content/browser/media/capture/web_contents_capture_util.h" | 20 #include "content/browser/media/capture/web_contents_capture_util.h" |
20 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 21 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
21 #include "content/browser/renderer_host/media/device_request_message_filter.h" | 22 #include "content/browser/renderer_host/media/device_request_message_filter.h" |
22 #include "content/browser/renderer_host/media/media_stream_requester.h" | 23 #include "content/browser/renderer_host/media/media_stream_requester.h" |
23 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" | 24 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" |
24 #include "content/browser/renderer_host/media/video_capture_manager.h" | 25 #include "content/browser/renderer_host/media/video_capture_manager.h" |
25 #include "content/browser/renderer_host/render_process_host_impl.h" | 26 #include "content/browser/renderer_host/render_process_host_impl.h" |
26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/content_browser_client.h" | 28 #include "content/public/browser/content_browser_client.h" |
28 #include "content/public/browser/media_device_id.h" | 29 #include "content/public/browser/media_device_id.h" |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
777 | 778 |
778 monitoring_started_ = true; | 779 monitoring_started_ = true; |
779 base::SystemMonitor::Get()->AddDevicesChangedObserver(this); | 780 base::SystemMonitor::Get()->AddDevicesChangedObserver(this); |
780 | 781 |
781 // Enumerate both the audio and video devices to cache the device lists | 782 // Enumerate both the audio and video devices to cache the device lists |
782 // and send them to media observer. | 783 // and send them to media observer. |
783 ++active_enumeration_ref_count_[MEDIA_DEVICE_AUDIO_CAPTURE]; | 784 ++active_enumeration_ref_count_[MEDIA_DEVICE_AUDIO_CAPTURE]; |
784 audio_input_device_manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); | 785 audio_input_device_manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); |
785 ++active_enumeration_ref_count_[MEDIA_DEVICE_VIDEO_CAPTURE]; | 786 ++active_enumeration_ref_count_[MEDIA_DEVICE_VIDEO_CAPTURE]; |
786 video_capture_manager_->EnumerateDevices(MEDIA_DEVICE_VIDEO_CAPTURE); | 787 video_capture_manager_->EnumerateDevices(MEDIA_DEVICE_VIDEO_CAPTURE); |
788 | |
789 #if defined(OS_MACOSX) | |
790 BrowserThread::PostTask( | |
791 BrowserThread::UI, FROM_HERE, | |
792 base::Bind(&MediaStreamManager::StartMonitoringOnUIThread, | |
793 base::Unretained(this))); | |
794 #endif | |
787 } | 795 } |
788 | 796 |
797 #if defined(OS_MACOSX) | |
798 void MediaStreamManager::StartMonitoringOnUIThread() { | |
Robert Sesek
2014/03/10 17:22:46
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::U
mcasas
2014/03/10 18:19:45
Done.
| |
799 if (content::BrowserMainLoop::GetInstance()) { | |
800 BrowserThread::PostTask( | |
Robert Sesek
2014/03/10 17:22:46
Why do you need to post a task to do this?
mcasas
2014/03/10 18:19:45
Not needed now with the accessor device_monitor_ma
| |
801 BrowserThread::UI, | |
802 FROM_HERE, | |
803 base::Bind(&BrowserMainLoop::StartMonitoring, | |
804 base::Unretained(content::BrowserMainLoop::GetInstance()))); | |
805 } | |
806 } | |
807 #endif | |
808 | |
789 void MediaStreamManager::StopMonitoring() { | 809 void MediaStreamManager::StopMonitoring() { |
790 DCHECK_EQ(base::MessageLoop::current(), io_loop_); | 810 DCHECK_EQ(base::MessageLoop::current(), io_loop_); |
791 if (monitoring_started_) { | 811 if (monitoring_started_) { |
792 base::SystemMonitor::Get()->RemoveDevicesChangedObserver(this); | 812 base::SystemMonitor::Get()->RemoveDevicesChangedObserver(this); |
793 monitoring_started_ = false; | 813 monitoring_started_ = false; |
794 ClearEnumerationCache(&audio_enumeration_cache_); | 814 ClearEnumerationCache(&audio_enumeration_cache_); |
795 ClearEnumerationCache(&video_enumeration_cache_); | 815 ClearEnumerationCache(&video_enumeration_cache_); |
796 } | 816 } |
797 } | 817 } |
798 | 818 |
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1816 } | 1836 } |
1817 | 1837 |
1818 // Always do enumeration even though some enumeration is in progress, | 1838 // Always do enumeration even though some enumeration is in progress, |
1819 // because those enumeration commands could be sent before these devices | 1839 // because those enumeration commands could be sent before these devices |
1820 // change. | 1840 // change. |
1821 ++active_enumeration_ref_count_[stream_type]; | 1841 ++active_enumeration_ref_count_[stream_type]; |
1822 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); | 1842 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); |
1823 } | 1843 } |
1824 | 1844 |
1825 } // namespace content | 1845 } // namespace content |
OLD | NEW |