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 11 matching lines...) Expand all Loading... | |
22 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 22 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
23 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 23 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
24 | 24 |
25 #include <map> | 25 #include <map> |
26 #include <string> | 26 #include <string> |
27 #include <vector> | 27 #include <vector> |
28 | 28 |
29 #include "base/basictypes.h" | 29 #include "base/basictypes.h" |
30 #include "base/memory/scoped_ptr.h" | 30 #include "base/memory/scoped_ptr.h" |
31 #include "base/memory/ref_counted.h" | 31 #include "base/memory/ref_counted.h" |
32 #include "base/message_loop.h" | |
32 #include "base/threading/thread.h" | 33 #include "base/threading/thread.h" |
33 #include "content/browser/renderer_host/media/media_stream_provider.h" | 34 #include "content/browser/renderer_host/media/media_stream_provider.h" |
34 #include "content/browser/renderer_host/media/media_stream_settings_requester.h" | 35 #include "content/browser/renderer_host/media/media_stream_settings_requester.h" |
35 #include "content/common/media/media_stream_options.h" | 36 #include "content/common/media/media_stream_options.h" |
36 #include "content/common/content_export.h" | 37 #include "content/common/content_export.h" |
37 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
38 | 39 |
39 namespace base { | 40 namespace base { |
40 namespace win { | 41 namespace win { |
41 class ScopedCOMInitializer; | 42 class ScopedCOMInitializer; |
(...skipping 21 matching lines...) Expand all Loading... | |
63 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_; | 64 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_; |
64 DISALLOW_COPY_AND_ASSIGN(DeviceThread); | 65 DISALLOW_COPY_AND_ASSIGN(DeviceThread); |
65 }; | 66 }; |
66 | 67 |
67 // MediaStreamManager is used to generate and close new media devices, not to | 68 // MediaStreamManager is used to generate and close new media devices, not to |
68 // start the media flow. | 69 // start the media flow. |
69 // The classes requesting new media streams are answered using | 70 // The classes requesting new media streams are answered using |
70 // MediaStreamManager::Listener. | 71 // MediaStreamManager::Listener. |
71 class CONTENT_EXPORT MediaStreamManager | 72 class CONTENT_EXPORT MediaStreamManager |
72 : public MediaStreamProviderListener, | 73 : public MediaStreamProviderListener, |
74 public MessageLoop::DestructionObserver, | |
73 public SettingsRequester { | 75 public SettingsRequester { |
74 public: | 76 public: |
75 // This class takes the ownerships of the |audio_input_device_manager| | 77 // This class takes the ownerships of the |audio_input_device_manager| |
76 // and |video_capture_manager|. | 78 // and |video_capture_manager|. |
77 MediaStreamManager(AudioInputDeviceManager* audio_input_device_manager, | 79 MediaStreamManager(AudioInputDeviceManager* audio_input_device_manager, |
78 VideoCaptureManager* video_capture_manager); | 80 VideoCaptureManager* video_capture_manager); |
79 | 81 |
80 virtual ~MediaStreamManager(); | 82 virtual ~MediaStreamManager(); |
81 | 83 |
82 // Used to access VideoCaptureManager. | 84 // Used to access VideoCaptureManager. |
83 VideoCaptureManager* video_capture_manager(); | 85 VideoCaptureManager* video_capture_manager(); |
84 | 86 |
85 // Used to access AudioInputDeviceManager. | 87 // Used to access AudioInputDeviceManager. |
86 AudioInputDeviceManager* audio_input_device_manager(); | 88 AudioInputDeviceManager* audio_input_device_manager(); |
87 | 89 |
88 // GenerateStream opens new media devices according to |components|. The | 90 // GenerateStream opens new media devices according to |components|. It |
89 // request is identified using |label|, which is pointing to an already | 91 // creates a new request which is identified by a unique |label|. |
tommi (sloooow) - chröme
2012/07/17 15:36:58
Thanks for fixing. Previously the documentation wa
no longer working on chromium
2012/07/17 17:18:25
Done.
| |
90 // created std::string. | |
91 void GenerateStream(MediaStreamRequester* requester, int render_process_id, | 92 void GenerateStream(MediaStreamRequester* requester, int render_process_id, |
92 int render_view_id, const StreamOptions& options, | 93 int render_view_id, const StreamOptions& options, |
93 const GURL& security_origin, std::string* label); | 94 const GURL& security_origin, std::string* label); |
94 | 95 |
95 // Cancels all non-finished GenerateStream request, i.e. request for which | 96 // Cancels all non-finished GenerateStream request, i.e. request for which |
96 // StreamGenerated hasn't been called. | 97 // StreamGenerated hasn't been called. |
97 void CancelRequests(MediaStreamRequester* requester); | 98 void CancelRequests(MediaStreamRequester* requester); |
98 | 99 |
99 // Cancel generate stream. | 100 // Cancel generate stream. |
100 void CancelGenerateStream(const std::string& label); | 101 void CancelGenerateStream(const std::string& label); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 virtual void DevicesAccepted(const std::string& label, | 139 virtual void DevicesAccepted(const std::string& label, |
139 const StreamDeviceInfoArray& devices) OVERRIDE; | 140 const StreamDeviceInfoArray& devices) OVERRIDE; |
140 virtual void SettingsError(const std::string& label) OVERRIDE; | 141 virtual void SettingsError(const std::string& label) OVERRIDE; |
141 | 142 |
142 // Used by unit test to make sure fake devices are used instead of a real | 143 // Used by unit test to make sure fake devices are used instead of a real |
143 // devices, which is needed for server based testing. | 144 // devices, which is needed for server based testing. |
144 // TODO(xians): Remove this hack since we can create our own | 145 // TODO(xians): Remove this hack since we can create our own |
145 // MediaStreamManager in our unit tests. | 146 // MediaStreamManager in our unit tests. |
146 void UseFakeDevice(); | 147 void UseFakeDevice(); |
147 | 148 |
149 // This object gets deleted on the UI thread, and IO thread is destroyed it | |
tommi (sloooow) - chröme
2012/07/17 15:36:58
"gets deleted on the UI thread, and IO thread is d
no longer working on chromium
2012/07/17 17:18:25
Thanks. I missed a "before" in my comment.
| |
150 // goes away. So we need to know when IO thread is being destroyed and we can | |
tommi (sloooow) - chröme
2012/07/17 15:36:58
"So we need to know when the IO thread is destroye
no longer working on chromium
2012/07/17 17:18:25
Done.
| |
151 // delete VideoCaptureManager and AudioInputDeviceManager. | |
152 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | |
153 | |
148 private: | 154 private: |
149 // Contains all data needed to keep track of requests. | 155 // Contains all data needed to keep track of requests. |
150 struct DeviceRequest; | 156 struct DeviceRequest; |
151 | 157 |
152 // Helpers for signaling the media observer that new capture devices are | 158 // Helpers for signaling the media observer that new capture devices are |
153 // opened/closed. | 159 // opened/closed. |
154 void NotifyObserverDevicesOpened(DeviceRequest* request); | 160 void NotifyObserverDevicesOpened(DeviceRequest* request); |
155 void NotifyObserverDevicesClosed(DeviceRequest* request); | 161 void NotifyObserverDevicesClosed(DeviceRequest* request); |
156 void DevicesFromRequest(DeviceRequest* request, | 162 void DevicesFromRequest(DeviceRequest* request, |
157 content::MediaStreamDevices* devices); | 163 content::MediaStreamDevices* devices); |
(...skipping 16 matching lines...) Expand all Loading... | |
174 scoped_refptr<VideoCaptureManager> video_capture_manager_; | 180 scoped_refptr<VideoCaptureManager> video_capture_manager_; |
175 | 181 |
176 // Keeps track of device types currently being enumerated to not enumerate | 182 // Keeps track of device types currently being enumerated to not enumerate |
177 // when not necessary. | 183 // when not necessary. |
178 std::vector<bool> enumeration_in_progress_; | 184 std::vector<bool> enumeration_in_progress_; |
179 | 185 |
180 // All non-closed request. | 186 // All non-closed request. |
181 typedef std::map<std::string, DeviceRequest> DeviceRequests; | 187 typedef std::map<std::string, DeviceRequest> DeviceRequests; |
182 DeviceRequests requests_; | 188 DeviceRequests requests_; |
183 | 189 |
190 // Hold a pointer to the IO loop to check we delete the device thread and | |
191 // managers on the right thread. | |
192 MessageLoop* io_loop_; | |
193 | |
184 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); | 194 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); |
185 }; | 195 }; |
186 | 196 |
187 } // namespace media_stream | 197 } // namespace media_stream |
188 | 198 |
189 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 199 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
OLD | NEW |