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 MediaStreamUIController for permission to | 9 // 2. MediaStreamManager will ask MediaStreamUIController for permission to |
10 // use devices and for which device to use. | 10 // use devices and for which device to use. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // The request is identified using string returned to the caller. | 131 // The request is identified using string returned to the caller. |
132 std::string OpenDevice(MediaStreamRequester* requester, | 132 std::string OpenDevice(MediaStreamRequester* requester, |
133 int render_process_id, | 133 int render_process_id, |
134 int render_view_id, | 134 int render_view_id, |
135 ResourceContext* rc, | 135 ResourceContext* rc, |
136 int page_request_id, | 136 int page_request_id, |
137 const std::string& device_id, | 137 const std::string& device_id, |
138 MediaStreamType type, | 138 MediaStreamType type, |
139 const GURL& security_origin); | 139 const GURL& security_origin); |
140 | 140 |
141 // Implements MediaStreamProviderListener. | 141 // Start the device monitor. |
142 virtual void Opened(MediaStreamType stream_type, | 142 void StartMonitoring(); |
143 int capture_session_id) OVERRIDE; | |
144 virtual void Closed(MediaStreamType stream_type, | |
145 int capture_session_id) OVERRIDE; | |
146 virtual void DevicesEnumerated(MediaStreamType stream_type, | |
147 const StreamDeviceInfoArray& devices) OVERRIDE; | |
148 | |
149 // Implements base::SystemMonitor::DevicesChangedObserver. | |
150 virtual void OnDevicesChanged( | |
151 base::SystemMonitor::DeviceType device_type) OVERRIDE; | |
152 | 143 |
153 // Used by unit test to make sure fake devices are used instead of a real | 144 // Used by unit test to make sure fake devices are used instead of a real |
154 // devices, which is needed for server based testing or certain tests (which | 145 // devices, which is needed for server based testing or certain tests (which |
155 // can pass --use-fake-device-for-media-stream). | 146 // can pass --use-fake-device-for-media-stream). |
156 void UseFakeDevice(); | 147 void UseFakeDevice(); |
157 | 148 |
158 // Called by the tests to specify a fake UI that should be used for next | 149 // Called by the tests to specify a fake UI that should be used for next |
159 // generated stream (or when using --use-fake-ui-for-media-stream). | 150 // generated stream (or when using --use-fake-ui-for-media-stream). |
160 void UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui); | 151 void UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui); |
161 | 152 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 bool valid; | 185 bool valid; |
195 StreamDeviceInfoArray devices; | 186 StreamDeviceInfoArray devices; |
196 }; | 187 }; |
197 | 188 |
198 typedef std::map<std::string, DeviceRequest*> DeviceRequests; | 189 typedef std::map<std::string, DeviceRequest*> DeviceRequests; |
199 | 190 |
200 // Initializes the device managers on IO thread. Auto-starts the device | 191 // Initializes the device managers on IO thread. Auto-starts the device |
201 // thread and registers this as a listener with the device managers. | 192 // thread and registers this as a listener with the device managers. |
202 void InitializeDeviceManagersOnIOThread(); | 193 void InitializeDeviceManagersOnIOThread(); |
203 | 194 |
| 195 // Implements MediaStreamProviderListener. |
| 196 virtual void Opened(MediaStreamType stream_type, |
| 197 int capture_session_id) OVERRIDE; |
| 198 virtual void Closed(MediaStreamType stream_type, |
| 199 int capture_session_id) OVERRIDE; |
| 200 virtual void DevicesEnumerated(MediaStreamType stream_type, |
| 201 const StreamDeviceInfoArray& devices) OVERRIDE; |
| 202 |
| 203 // Implements base::SystemMonitor::DevicesChangedObserver. |
| 204 virtual void OnDevicesChanged( |
| 205 base::SystemMonitor::DeviceType device_type) OVERRIDE; |
| 206 |
204 // Helper for sending up-to-date device lists to media observer when a | 207 // Helper for sending up-to-date device lists to media observer when a |
205 // capture device is plugged in or unplugged. | 208 // capture device is plugged in or unplugged. |
206 void NotifyDevicesChanged(MediaStreamType stream_type, | 209 void NotifyDevicesChanged(MediaStreamType stream_type, |
207 const StreamDeviceInfoArray& devices); | 210 const StreamDeviceInfoArray& devices); |
208 | 211 |
209 void HandleAccessRequestResponse(const std::string& label, | 212 void HandleAccessRequestResponse(const std::string& label, |
210 const MediaStreamDevices& devices); | 213 const MediaStreamDevices& devices); |
211 void StopStreamFromUI(const std::string& label); | 214 void StopStreamFromUI(const std::string& label); |
212 | 215 |
213 void DoCancelRequest(const std::string& label); | 216 void DoCancelRequest(const std::string& label); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 void FinalizeRequestFailed(const std::string& label, | 255 void FinalizeRequestFailed(const std::string& label, |
253 DeviceRequest* request); | 256 DeviceRequest* request); |
254 void FinalizeOpenDevice(const std::string& label, | 257 void FinalizeOpenDevice(const std::string& label, |
255 DeviceRequest* request); | 258 DeviceRequest* request); |
256 void FinalizeMediaAccessRequest(const std::string& label, | 259 void FinalizeMediaAccessRequest(const std::string& label, |
257 DeviceRequest* request, | 260 DeviceRequest* request, |
258 const MediaStreamDevices& devices); | 261 const MediaStreamDevices& devices); |
259 void FinalizeEnumerateDevices(const std::string& label, | 262 void FinalizeEnumerateDevices(const std::string& label, |
260 DeviceRequest* request); | 263 DeviceRequest* request); |
261 | 264 |
262 // Helpers to start and stop monitoring devices. | 265 // Helpers to stop monitoring devices. |
263 void StartMonitoring(); | |
264 void StopMonitoring(); | 266 void StopMonitoring(); |
265 | 267 |
266 bool TranslateRequestedSourceIdToDeviceId(DeviceRequest* request); | 268 bool TranslateRequestedSourceIdToDeviceId(DeviceRequest* request); |
267 void TranslateDeviceIdToSourceId(DeviceRequest* request, | 269 void TranslateDeviceIdToSourceId(DeviceRequest* request, |
268 MediaStreamDevice* device); | 270 MediaStreamDevice* device); |
269 | 271 |
270 // Finds and returns the device id corresponding to the given | 272 // Finds and returns the device id corresponding to the given |
271 // |source_id|. Returns true if there was a raw device id that matched the | 273 // |source_id|. Returns true if there was a raw device id that matched the |
272 // given |source_id|, false if nothing matched it. | 274 // given |source_id|, false if nothing matched it. |
273 bool TranslateSourceIdToDeviceId( | 275 bool TranslateSourceIdToDeviceId( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 312 |
311 bool use_fake_ui_; | 313 bool use_fake_ui_; |
312 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_; | 314 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_; |
313 | 315 |
314 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); | 316 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); |
315 }; | 317 }; |
316 | 318 |
317 } // namespace content | 319 } // namespace content |
318 | 320 |
319 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 321 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
OLD | NEW |