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 // MediaStreamManager is used to open/enumerate media capture devices (video | 5 // MediaStreamManager is used to open/enumerate media capture devices (video |
6 // supported now). Call flow: | 6 // supported now). Call flow: |
7 // 1. GenerateStream is called when a render process wants to use a capture | 7 // 1. GenerateStream is called when a render process wants to use a capture |
8 // device. | 8 // device. |
9 // 2. MediaStreamManager will ask MediaStreamDeviceSettings for permission to | 9 // 2. MediaStreamManager will ask MediaStreamDeviceSettings for permission to |
10 // use devices and for which device to use. | 10 // use devices and for which device to use. |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "base/memory/ref_counted.h" | 30 #include "base/memory/ref_counted.h" |
31 #include "base/message_loop.h" | 31 #include "base/message_loop.h" |
32 #include "base/system_monitor/system_monitor.h" | 32 #include "base/system_monitor/system_monitor.h" |
33 #include "base/threading/thread.h" | 33 #include "base/threading/thread.h" |
34 #include "content/browser/renderer_host/media/media_stream_provider.h" | 34 #include "content/browser/renderer_host/media/media_stream_provider.h" |
35 #include "content/browser/renderer_host/media/media_stream_settings_requester.h" | 35 #include "content/browser/renderer_host/media/media_stream_settings_requester.h" |
36 #include "content/common/media/media_stream_options.h" | 36 #include "content/common/media/media_stream_options.h" |
37 #include "content/common/content_export.h" | 37 #include "content/common/content_export.h" |
38 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
39 | 39 |
| 40 #if defined(OS_WIN) |
40 namespace base { | 41 namespace base { |
41 namespace win { | 42 namespace win { |
42 class ScopedCOMInitializer; | 43 class ScopedCOMInitializer; |
43 } | 44 } |
44 } | 45 } |
| 46 #endif |
45 | 47 |
46 namespace media { | 48 namespace media { |
47 class AudioManager; | 49 class AudioManager; |
48 } | 50 } |
49 | 51 |
50 namespace media_stream { | 52 namespace media_stream { |
51 | 53 |
52 class AudioInputDeviceManager; | 54 class AudioInputDeviceManager; |
53 class MediaStreamDeviceSettings; | 55 class MediaStreamDeviceSettings; |
54 class MediaStreamRequester; | 56 class MediaStreamRequester; |
55 class VideoCaptureManager; | 57 class VideoCaptureManager; |
56 | 58 |
57 // Thread that enters MTA on windows, and is base::Thread on linux and mac. | 59 // Thread that enters MTA on Windows. |
| 60 #if defined(OS_WIN) |
58 class DeviceThread : public base::Thread { | 61 class DeviceThread : public base::Thread { |
59 public: | 62 public: |
60 explicit DeviceThread(const char* name); | 63 explicit DeviceThread(const char* name); |
61 virtual ~DeviceThread(); | 64 virtual ~DeviceThread(); |
62 | 65 |
63 protected: | 66 protected: |
64 virtual void Init() OVERRIDE; | 67 virtual void Init() OVERRIDE; |
65 virtual void CleanUp() OVERRIDE; | 68 virtual void CleanUp() OVERRIDE; |
66 | 69 |
67 private: | 70 private: |
68 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_; | 71 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_; |
| 72 |
69 DISALLOW_COPY_AND_ASSIGN(DeviceThread); | 73 DISALLOW_COPY_AND_ASSIGN(DeviceThread); |
70 }; | 74 }; |
| 75 #else |
| 76 typedef base::Thread DeviceThread; |
| 77 #endif |
71 | 78 |
72 // MediaStreamManager is used to generate and close new media devices, not to | 79 // MediaStreamManager is used to generate and close new media devices, not to |
73 // start the media flow. | 80 // start the media flow. |
74 // The classes requesting new media streams are answered using | 81 // The classes requesting new media streams are answered using |
75 // MediaStreamManager::Listener. | 82 // MediaStreamManager::Listener. |
76 class CONTENT_EXPORT MediaStreamManager | 83 class CONTENT_EXPORT MediaStreamManager |
77 : public MediaStreamProviderListener, | 84 : public MediaStreamProviderListener, |
78 public MessageLoop::DestructionObserver, | 85 public MessageLoop::DestructionObserver, |
79 public SettingsRequester, | 86 public SettingsRequester, |
80 public base::SystemMonitor::DevicesChangedObserver { | 87 public base::SystemMonitor::DevicesChangedObserver { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 void SendCachedDeviceList(EnumerationCache* cache, const std::string& label); | 215 void SendCachedDeviceList(EnumerationCache* cache, const std::string& label); |
209 | 216 |
210 // Stop the request of enumerating devices indentified by |label|. | 217 // Stop the request of enumerating devices indentified by |label|. |
211 void StopEnumerateDevices(const std::string& label); | 218 void StopEnumerateDevices(const std::string& label); |
212 | 219 |
213 // Helpers to start and stop monitoring devices. | 220 // Helpers to start and stop monitoring devices. |
214 void StartMonitoring(); | 221 void StartMonitoring(); |
215 void StopMonitoring(); | 222 void StopMonitoring(); |
216 | 223 |
217 // Device thread shared by VideoCaptureManager and AudioInputDeviceManager. | 224 // Device thread shared by VideoCaptureManager and AudioInputDeviceManager. |
218 scoped_ptr<base::Thread> device_thread_; | 225 scoped_ptr<DeviceThread> device_thread_; |
219 | 226 |
220 scoped_ptr<MediaStreamDeviceSettings> device_settings_; | 227 scoped_ptr<MediaStreamDeviceSettings> device_settings_; |
221 | 228 |
222 media::AudioManager* const audio_manager_; // not owned | 229 media::AudioManager* const audio_manager_; // not owned |
223 scoped_refptr<AudioInputDeviceManager> audio_input_device_manager_; | 230 scoped_refptr<AudioInputDeviceManager> audio_input_device_manager_; |
224 scoped_refptr<VideoCaptureManager> video_capture_manager_; | 231 scoped_refptr<VideoCaptureManager> video_capture_manager_; |
225 | 232 |
226 // Indicator of device monitoring state. | 233 // Indicator of device monitoring state. |
227 bool monitoring_started_; | 234 bool monitoring_started_; |
228 | 235 |
(...skipping 16 matching lines...) Expand all Loading... |
245 | 252 |
246 // Static members. | 253 // Static members. |
247 static bool always_use_fake_devices_; | 254 static bool always_use_fake_devices_; |
248 | 255 |
249 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); | 256 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); |
250 }; | 257 }; |
251 | 258 |
252 } // namespace media_stream | 259 } // namespace media_stream |
253 | 260 |
254 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 261 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
OLD | NEW |