Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: content/browser/renderer_host/media/video_capture_manager.h

Issue 2219813002: Revert of ImageCapture: Queue up requests while device not ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/media/video_capture_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // VideoCaptureManager is used to open/close, start/stop, enumerate available 5 // VideoCaptureManager is used to open/close, start/stop, enumerate available
6 // video capture devices, and manage VideoCaptureController's. 6 // video capture devices, and manage VideoCaptureController's.
7 // All functions are expected to be called from Browser::IO thread. Some helper 7 // All functions are expected to be called from Browser::IO thread. Some helper
8 // functions (*OnDeviceThread) will dispatch operations to the device thread. 8 // functions (*OnDeviceThread) will dispatch operations to the device thread.
9 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice. 9 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice.
10 // A device can only be opened once. 10 // A device can only be opened once.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 void GetPhotoCapabilities( 160 void GetPhotoCapabilities(
161 int session_id, 161 int session_id,
162 VideoCaptureDevice::GetPhotoCapabilitiesCallback callback); 162 VideoCaptureDevice::GetPhotoCapabilitiesCallback callback);
163 void SetPhotoOptions(int session_id, 163 void SetPhotoOptions(int session_id,
164 media::mojom::PhotoSettingsPtr settings, 164 media::mojom::PhotoSettingsPtr settings,
165 VideoCaptureDevice::SetPhotoOptionsCallback callback); 165 VideoCaptureDevice::SetPhotoOptionsCallback callback);
166 void TakePhoto(int session_id, 166 void TakePhoto(int session_id,
167 VideoCaptureDevice::TakePhotoCallback callback); 167 VideoCaptureDevice::TakePhotoCallback callback);
168
169 #if defined(OS_ANDROID) 168 #if defined(OS_ANDROID)
170 // Some devices had troubles when stopped and restarted quickly, so the device 169 // Some devices had troubles when stopped and restarted quickly, so the device
171 // is only stopped when Chrome is sent to background and not when, e.g., a tab 170 // is only stopped when Chrome is sent to background and not when, e.g., a tab
172 // is hidden, see http://crbug.com/582295. 171 // is hidden, see http://crbug.com/582295.
173 void OnApplicationStateChange(base::android::ApplicationState state); 172 void OnApplicationStateChange(base::android::ApplicationState state);
174 #endif 173 #endif
175 174
176 private: 175 private:
177 class CaptureDeviceStartRequest; 176 class CaptureDeviceStartRequest;
178 class DeviceEntry; 177 class DeviceEntry;
(...skipping 26 matching lines...) Expand all
205 base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback, 204 base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback,
206 MediaStreamType stream_type, 205 MediaStreamType stream_type,
207 const DeviceInfos& old_device_info_cache, 206 const DeviceInfos& old_device_info_cache,
208 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors_snapshot); 207 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors_snapshot);
209 208
210 // Checks to see if |entry| has no clients left on its controller. If so, 209 // Checks to see if |entry| has no clients left on its controller. If so,
211 // remove it from the list of devices, and delete it asynchronously. |entry| 210 // remove it from the list of devices, and delete it asynchronously. |entry|
212 // may be freed by this function. 211 // may be freed by this function.
213 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry); 212 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry);
214 213
215 // Finds a DeviceEntry in different ways: by |session_id|, by its |device_id| 214 // Retrieve the VideoCaptureDevice associated to |session_id|, or nullptr
216 // and |type| (if it is already opened), by its |controller| or by its 215 // if not found.
217 // |serial_id|. In all cases, if not found, nullptr is returned. 216 VideoCaptureDevice* GetVideoCaptureDeviceBySessionId(int session_id);
218 DeviceEntry* GetDeviceEntryBySessionId(int session_id); 217
218 // Finds a DeviceEntry in different ways: by its |device_id| and |type| (if it
219 // is already opened), by its |controller| or by its |serial_id|. In all
220 // cases, if not found, nullptr is returned.
219 DeviceEntry* GetDeviceEntryByTypeAndId(MediaStreamType type, 221 DeviceEntry* GetDeviceEntryByTypeAndId(MediaStreamType type,
220 const std::string& device_id) const; 222 const std::string& device_id) const;
221 DeviceEntry* GetDeviceEntryByController( 223 DeviceEntry* GetDeviceEntryByController(
222 const VideoCaptureController* controller) const; 224 const VideoCaptureController* controller) const;
223 DeviceEntry* GetDeviceEntryBySerialId(int serial_id) const; 225 DeviceEntry* GetDeviceEntryBySerialId(int serial_id) const;
224 226
225 // Finds the device info by |id| in |devices_info_cache_|, or nullptr. 227 // Finds the device info by |id| in |devices_info_cache_|, or nullptr.
226 DeviceInfo* GetDeviceInfoById(const std::string& id); 228 DeviceInfo* GetDeviceInfoById(const std::string& id);
227 229
228 // Finds a DeviceEntry entry for the indicated |capture_session_id|, creating 230 // Finds a DeviceEntry entry for the indicated |capture_session_id|, creating
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 std::unique_ptr<VideoCaptureDevice::Client> client); 268 std::unique_ptr<VideoCaptureDevice::Client> client);
267 269
268 // Stops and destroys the VideoCaptureDevice held in |device|. 270 // Stops and destroys the VideoCaptureDevice held in |device|.
269 void DoStopDeviceOnDeviceThread(std::unique_ptr<VideoCaptureDevice> device); 271 void DoStopDeviceOnDeviceThread(std::unique_ptr<VideoCaptureDevice> device);
270 272
271 void MaybePostDesktopCaptureWindowId(media::VideoCaptureSessionId session_id); 273 void MaybePostDesktopCaptureWindowId(media::VideoCaptureSessionId session_id);
272 void SetDesktopCaptureWindowIdOnDeviceThread( 274 void SetDesktopCaptureWindowIdOnDeviceThread(
273 media::VideoCaptureDevice* device, 275 media::VideoCaptureDevice* device,
274 gfx::NativeViewId window_id); 276 gfx::NativeViewId window_id);
275 277
276 // Internal versions of the Image Capture public ones, for delayed execution.
277 void DoGetPhotoCapabilities(
278 VideoCaptureDevice::GetPhotoCapabilitiesCallback callback,
279 VideoCaptureDevice* device);
280 void DoSetPhotoOptions(
281 VideoCaptureDevice::SetPhotoOptionsCallback callback,
282 media::mojom::PhotoSettingsPtr settings,
283 VideoCaptureDevice* device);
284 void DoTakePhoto(VideoCaptureDevice::TakePhotoCallback callback,
285 VideoCaptureDevice* device);
286
287 #if defined(OS_MACOSX) 278 #if defined(OS_MACOSX)
288 // Called on the IO thread after the device layer has been initialized on Mac. 279 // Called on the IO thread after the device layer has been initialized on Mac.
289 // Sets |capture_device_api_initialized_| to true and then executes and_then. 280 // Sets |capture_device_api_initialized_| to true and then executes and_then.
290 void OnDeviceLayerInitialized(const base::Closure& and_then); 281 void OnDeviceLayerInitialized(const base::Closure& and_then);
291 282
292 // Returns true if the current operation needs to be preempted by a call to 283 // Returns true if the current operation needs to be preempted by a call to
293 // InitializeCaptureDeviceApiOnUIThread. 284 // InitializeCaptureDeviceApiOnUIThread.
294 // Called on the IO thread. 285 // Called on the IO thread.
295 bool NeedToInitializeCaptureDeviceApi(MediaStreamType stream_type); 286 bool NeedToInitializeCaptureDeviceApi(MediaStreamType stream_type);
296 287
(...skipping 29 matching lines...) Expand all
326 // only on the IO thread. 317 // only on the IO thread.
327 SessionMap sessions_; 318 SessionMap sessions_;
328 319
329 // Currently opened DeviceEntry instances (each owning a VideoCaptureDevice - 320 // Currently opened DeviceEntry instances (each owning a VideoCaptureDevice -
330 // VideoCaptureController pair). The device may or may not be started. This 321 // VideoCaptureController pair). The device may or may not be started. This
331 // member is only accessed on IO thread. 322 // member is only accessed on IO thread.
332 DeviceEntries devices_; 323 DeviceEntries devices_;
333 324
334 DeviceStartQueue device_start_queue_; 325 DeviceStartQueue device_start_queue_;
335 326
336 // Queue to keep photo-associated requests waiting for a device to initialize,
337 // bundles a session id integer and an associated photo-related request.
338 std::list<std::pair<int, base::Callback<void(media::VideoCaptureDevice*)>>>
339 photo_request_queue_;
340
341 // Device creation factory injected on construction from MediaStreamManager or 327 // Device creation factory injected on construction from MediaStreamManager or
342 // from the test harness. 328 // from the test harness.
343 std::unique_ptr<media::VideoCaptureDeviceFactory> 329 std::unique_ptr<media::VideoCaptureDeviceFactory>
344 video_capture_device_factory_; 330 video_capture_device_factory_;
345 331
346 // Local cache of the enumerated video capture devices' names and capture 332 // Local cache of the enumerated video capture devices' names and capture
347 // supported formats. A snapshot of the current devices and their capabilities 333 // supported formats. A snapshot of the current devices and their capabilities
348 // is composed in VideoCaptureDeviceFactory::EnumerateDeviceNames() and 334 // is composed in VideoCaptureDeviceFactory::EnumerateDeviceNames() and
349 // ConsolidateDevicesInfoOnDeviceThread(), and this snapshot is used to update 335 // ConsolidateDevicesInfoOnDeviceThread(), and this snapshot is used to update
350 // this list in OnDevicesInfoEnumerated(). GetDeviceSupportedFormats() will 336 // this list in OnDevicesInfoEnumerated(). GetDeviceSupportedFormats() will
351 // use this list if the device is not started, otherwise it will retrieve the 337 // use this list if the device is not started, otherwise it will retrieve the
352 // active device capture format from the VideoCaptureController associated. 338 // active device capture format from the VideoCaptureController associated.
353 DeviceInfos devices_info_cache_; 339 DeviceInfos devices_info_cache_;
354 340
355 // Map used by DesktopCapture. 341 // Map used by DesktopCapture.
356 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> 342 std::map<media::VideoCaptureSessionId, gfx::NativeViewId>
357 notification_window_ids_; 343 notification_window_ids_;
358 344
359 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); 345 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager);
360 }; 346 };
361 347
362 } // namespace content 348 } // namespace content
363 349
364 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ 350 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/media/video_capture_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698