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

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

Issue 2212343003: Reland: ImageCapture: Queue up requests while device not ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable Android tests with bug and explanation 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
168 #if defined(OS_ANDROID) 169 #if defined(OS_ANDROID)
169 // Some devices had troubles when stopped and restarted quickly, so the device 170 // Some devices had troubles when stopped and restarted quickly, so the device
170 // is only stopped when Chrome is sent to background and not when, e.g., a tab 171 // is only stopped when Chrome is sent to background and not when, e.g., a tab
171 // is hidden, see http://crbug.com/582295. 172 // is hidden, see http://crbug.com/582295.
172 void OnApplicationStateChange(base::android::ApplicationState state); 173 void OnApplicationStateChange(base::android::ApplicationState state);
173 #endif 174 #endif
174 175
175 private: 176 private:
176 class CaptureDeviceStartRequest; 177 class CaptureDeviceStartRequest;
177 class DeviceEntry; 178 class DeviceEntry;
(...skipping 26 matching lines...) Expand all
204 base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback, 205 base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback,
205 MediaStreamType stream_type, 206 MediaStreamType stream_type,
206 const DeviceInfos& old_device_info_cache, 207 const DeviceInfos& old_device_info_cache,
207 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors_snapshot); 208 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors_snapshot);
208 209
209 // Checks to see if |entry| has no clients left on its controller. If so, 210 // Checks to see if |entry| has no clients left on its controller. If so,
210 // remove it from the list of devices, and delete it asynchronously. |entry| 211 // remove it from the list of devices, and delete it asynchronously. |entry|
211 // may be freed by this function. 212 // may be freed by this function.
212 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry); 213 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry);
213 214
214 // Retrieve the VideoCaptureDevice associated to |session_id|, or nullptr 215 // Finds a DeviceEntry in different ways: by |session_id|, by its |device_id|
215 // if not found. 216 // and |type| (if it is already opened), by its |controller| or by its
216 VideoCaptureDevice* GetVideoCaptureDeviceBySessionId(int session_id); 217 // |serial_id|. In all cases, if not found, nullptr is returned.
217 218 DeviceEntry* GetDeviceEntryBySessionId(int session_id);
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.
221 DeviceEntry* GetDeviceEntryByTypeAndId(MediaStreamType type, 219 DeviceEntry* GetDeviceEntryByTypeAndId(MediaStreamType type,
222 const std::string& device_id) const; 220 const std::string& device_id) const;
223 DeviceEntry* GetDeviceEntryByController( 221 DeviceEntry* GetDeviceEntryByController(
224 const VideoCaptureController* controller) const; 222 const VideoCaptureController* controller) const;
225 DeviceEntry* GetDeviceEntryBySerialId(int serial_id) const; 223 DeviceEntry* GetDeviceEntryBySerialId(int serial_id) const;
226 224
227 // Finds the device info by |id| in |devices_info_cache_|, or nullptr. 225 // Finds the device info by |id| in |devices_info_cache_|, or nullptr.
228 DeviceInfo* GetDeviceInfoById(const std::string& id); 226 DeviceInfo* GetDeviceInfoById(const std::string& id);
229 227
230 // Finds a DeviceEntry entry for the indicated |capture_session_id|, creating 228 // Finds a DeviceEntry entry for the indicated |capture_session_id|, creating
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 std::unique_ptr<VideoCaptureDevice::Client> client); 266 std::unique_ptr<VideoCaptureDevice::Client> client);
269 267
270 // Stops and destroys the VideoCaptureDevice held in |device|. 268 // Stops and destroys the VideoCaptureDevice held in |device|.
271 void DoStopDeviceOnDeviceThread(std::unique_ptr<VideoCaptureDevice> device); 269 void DoStopDeviceOnDeviceThread(std::unique_ptr<VideoCaptureDevice> device);
272 270
273 void MaybePostDesktopCaptureWindowId(media::VideoCaptureSessionId session_id); 271 void MaybePostDesktopCaptureWindowId(media::VideoCaptureSessionId session_id);
274 void SetDesktopCaptureWindowIdOnDeviceThread( 272 void SetDesktopCaptureWindowIdOnDeviceThread(
275 media::VideoCaptureDevice* device, 273 media::VideoCaptureDevice* device,
276 gfx::NativeViewId window_id); 274 gfx::NativeViewId window_id);
277 275
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
278 #if defined(OS_MACOSX) 287 #if defined(OS_MACOSX)
279 // Called on the IO thread after the device layer has been initialized on Mac. 288 // Called on the IO thread after the device layer has been initialized on Mac.
280 // Sets |capture_device_api_initialized_| to true and then executes and_then. 289 // Sets |capture_device_api_initialized_| to true and then executes and_then.
281 void OnDeviceLayerInitialized(const base::Closure& and_then); 290 void OnDeviceLayerInitialized(const base::Closure& and_then);
282 291
283 // Returns true if the current operation needs to be preempted by a call to 292 // Returns true if the current operation needs to be preempted by a call to
284 // InitializeCaptureDeviceApiOnUIThread. 293 // InitializeCaptureDeviceApiOnUIThread.
285 // Called on the IO thread. 294 // Called on the IO thread.
286 bool NeedToInitializeCaptureDeviceApi(MediaStreamType stream_type); 295 bool NeedToInitializeCaptureDeviceApi(MediaStreamType stream_type);
287 296
(...skipping 29 matching lines...) Expand all
317 // only on the IO thread. 326 // only on the IO thread.
318 SessionMap sessions_; 327 SessionMap sessions_;
319 328
320 // Currently opened DeviceEntry instances (each owning a VideoCaptureDevice - 329 // Currently opened DeviceEntry instances (each owning a VideoCaptureDevice -
321 // VideoCaptureController pair). The device may or may not be started. This 330 // VideoCaptureController pair). The device may or may not be started. This
322 // member is only accessed on IO thread. 331 // member is only accessed on IO thread.
323 DeviceEntries devices_; 332 DeviceEntries devices_;
324 333
325 DeviceStartQueue device_start_queue_; 334 DeviceStartQueue device_start_queue_;
326 335
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
327 // Device creation factory injected on construction from MediaStreamManager or 341 // Device creation factory injected on construction from MediaStreamManager or
328 // from the test harness. 342 // from the test harness.
329 std::unique_ptr<media::VideoCaptureDeviceFactory> 343 std::unique_ptr<media::VideoCaptureDeviceFactory>
330 video_capture_device_factory_; 344 video_capture_device_factory_;
331 345
332 // Local cache of the enumerated video capture devices' names and capture 346 // Local cache of the enumerated video capture devices' names and capture
333 // supported formats. A snapshot of the current devices and their capabilities 347 // supported formats. A snapshot of the current devices and their capabilities
334 // is composed in VideoCaptureDeviceFactory::EnumerateDeviceNames() and 348 // is composed in VideoCaptureDeviceFactory::EnumerateDeviceNames() and
335 // ConsolidateDevicesInfoOnDeviceThread(), and this snapshot is used to update 349 // ConsolidateDevicesInfoOnDeviceThread(), and this snapshot is used to update
336 // this list in OnDevicesInfoEnumerated(). GetDeviceSupportedFormats() will 350 // this list in OnDevicesInfoEnumerated(). GetDeviceSupportedFormats() will
337 // use this list if the device is not started, otherwise it will retrieve the 351 // use this list if the device is not started, otherwise it will retrieve the
338 // active device capture format from the VideoCaptureController associated. 352 // active device capture format from the VideoCaptureController associated.
339 DeviceInfos devices_info_cache_; 353 DeviceInfos devices_info_cache_;
340 354
341 // Map used by DesktopCapture. 355 // Map used by DesktopCapture.
342 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> 356 std::map<media::VideoCaptureSessionId, gfx::NativeViewId>
343 notification_window_ids_; 357 notification_window_ids_;
344 358
345 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); 359 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager);
346 }; 360 };
347 361
348 } // namespace content 362 } // namespace content
349 363
350 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ 364 #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