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() { |
| 799 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 800 BrowserMainLoop* browser_main_loop = content::BrowserMainLoop::GetInstance(); |
| 801 if (browser_main_loop) |
| 802 browser_main_loop->device_monitor_mac()->StartMonitoring(); |
| 803 } |
| 804 #endif |
| 805 |
789 void MediaStreamManager::StopMonitoring() { | 806 void MediaStreamManager::StopMonitoring() { |
790 DCHECK_EQ(base::MessageLoop::current(), io_loop_); | 807 DCHECK_EQ(base::MessageLoop::current(), io_loop_); |
791 if (monitoring_started_) { | 808 if (monitoring_started_) { |
792 base::SystemMonitor::Get()->RemoveDevicesChangedObserver(this); | 809 base::SystemMonitor::Get()->RemoveDevicesChangedObserver(this); |
793 monitoring_started_ = false; | 810 monitoring_started_ = false; |
794 ClearEnumerationCache(&audio_enumeration_cache_); | 811 ClearEnumerationCache(&audio_enumeration_cache_); |
795 ClearEnumerationCache(&video_enumeration_cache_); | 812 ClearEnumerationCache(&video_enumeration_cache_); |
796 } | 813 } |
797 } | 814 } |
798 | 815 |
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1816 } | 1833 } |
1817 | 1834 |
1818 // Always do enumeration even though some enumeration is in progress, | 1835 // Always do enumeration even though some enumeration is in progress, |
1819 // because those enumeration commands could be sent before these devices | 1836 // because those enumeration commands could be sent before these devices |
1820 // change. | 1837 // change. |
1821 ++active_enumeration_ref_count_[stream_type]; | 1838 ++active_enumeration_ref_count_[stream_type]; |
1822 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); | 1839 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); |
1823 } | 1840 } |
1824 | 1841 |
1825 } // namespace content | 1842 } // namespace content |
OLD | NEW |