| 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/power_monitor/power_monitor.h" | 14 #include "base/power_monitor/power_monitor.h" |
| 15 #include "base/profiler/scoped_tracker.h" |
| 15 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
| 16 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 18 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 19 #include "content/browser/browser_main_loop.h" | 20 #include "content/browser/browser_main_loop.h" |
| 20 #include "content/browser/media/capture/web_contents_capture_util.h" | 21 #include "content/browser/media/capture/web_contents_capture_util.h" |
| 21 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 22 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
| 22 #include "content/browser/renderer_host/media/media_capture_devices_impl.h" | 23 #include "content/browser/renderer_host/media/media_capture_devices_impl.h" |
| 23 #include "content/browser/renderer_host/media/media_stream_requester.h" | 24 #include "content/browser/renderer_host/media/media_stream_requester.h" |
| 24 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" | 25 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 } | 959 } |
| 959 | 960 |
| 960 std::ostringstream oss; | 961 std::ostringstream oss; |
| 961 oss << "Media input device removed: type = " << | 962 oss << "Media input device removed: type = " << |
| 962 (device.type == MEDIA_DEVICE_AUDIO_CAPTURE ? "audio" : "video") << | 963 (device.type == MEDIA_DEVICE_AUDIO_CAPTURE ? "audio" : "video") << |
| 963 ", id = " << device.id << ", name = " << device.name; | 964 ", id = " << device.id << ", name = " << device.name; |
| 964 AddLogMessageOnIOThread(oss.str()); | 965 AddLogMessageOnIOThread(oss.str()); |
| 965 } | 966 } |
| 966 | 967 |
| 967 void MediaStreamManager::StartMonitoring() { | 968 void MediaStreamManager::StartMonitoring() { |
| 969 // TODO(erikchen): Remove ScopedTracker below once crbug.com/458404 is fixed. |
| 970 tracked_objects::ScopedTracker tracking_profile1( |
| 971 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 972 "458404 MediaStreamManager::StartMonitoring")); |
| 973 |
| 968 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 974 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 969 if (monitoring_started_) | 975 if (monitoring_started_) |
| 970 return; | 976 return; |
| 971 | 977 |
| 972 if (!base::SystemMonitor::Get()) | 978 if (!base::SystemMonitor::Get()) |
| 973 return; | 979 return; |
| 974 | 980 |
| 975 monitoring_started_ = true; | 981 monitoring_started_ = true; |
| 976 base::SystemMonitor::Get()->AddDevicesChangedObserver(this); | 982 base::SystemMonitor::Get()->AddDevicesChangedObserver(this); |
| 977 | 983 |
| 984 // TODO(erikchen): Remove ScopedTracker below once crbug.com/458404 is fixed. |
| 985 tracked_objects::ScopedTracker tracking_profile2( |
| 986 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 987 "458404 MediaStreamManager::StartMonitoring::EnumerateAudio")); |
| 978 // Enumerate both the audio and video devices to cache the device lists | 988 // Enumerate both the audio and video devices to cache the device lists |
| 979 // and send them to media observer. | 989 // and send them to media observer. |
| 980 ++active_enumeration_ref_count_[MEDIA_DEVICE_AUDIO_CAPTURE]; | 990 ++active_enumeration_ref_count_[MEDIA_DEVICE_AUDIO_CAPTURE]; |
| 981 audio_input_device_manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); | 991 audio_input_device_manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); |
| 992 |
| 993 // TODO(erikchen): Remove ScopedTracker below once crbug.com/458404 is fixed. |
| 994 tracked_objects::ScopedTracker tracking_profile3( |
| 995 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 996 "458404 MediaStreamManager::StartMonitoring::EnumerateVideo")); |
| 982 ++active_enumeration_ref_count_[MEDIA_DEVICE_VIDEO_CAPTURE]; | 997 ++active_enumeration_ref_count_[MEDIA_DEVICE_VIDEO_CAPTURE]; |
| 983 video_capture_manager_->EnumerateDevices(MEDIA_DEVICE_VIDEO_CAPTURE); | 998 video_capture_manager_->EnumerateDevices(MEDIA_DEVICE_VIDEO_CAPTURE); |
| 984 | 999 |
| 985 #if defined(OS_MACOSX) | 1000 #if defined(OS_MACOSX) |
| 986 BrowserThread::PostTask( | 1001 BrowserThread::PostTask( |
| 987 BrowserThread::UI, FROM_HERE, | 1002 BrowserThread::UI, FROM_HERE, |
| 988 base::Bind(&MediaStreamManager::StartMonitoringOnUIThread, | 1003 base::Bind(&MediaStreamManager::StartMonitoringOnUIThread, |
| 989 base::Unretained(this))); | 1004 base::Unretained(this))); |
| 990 #endif | 1005 #endif |
| 991 } | 1006 } |
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2161 } | 2176 } |
| 2162 } | 2177 } |
| 2163 | 2178 |
| 2164 void MediaStreamManager::SetKeyboardMicOnDeviceThread() { | 2179 void MediaStreamManager::SetKeyboardMicOnDeviceThread() { |
| 2165 DCHECK(device_task_runner_->BelongsToCurrentThread()); | 2180 DCHECK(device_task_runner_->BelongsToCurrentThread()); |
| 2166 audio_manager_->SetHasKeyboardMic(); | 2181 audio_manager_->SetHasKeyboardMic(); |
| 2167 } | 2182 } |
| 2168 #endif | 2183 #endif |
| 2169 | 2184 |
| 2170 } // namespace content | 2185 } // namespace content |
| OLD | NEW |