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

Unified Diff: content/browser/renderer_host/media/video_capture_manager.h

Issue 801363002: Queue commands to the Os to start a video device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/video_capture_manager.h
diff --git a/content/browser/renderer_host/media/video_capture_manager.h b/content/browser/renderer_host/media/video_capture_manager.h
index 58ed04b6be5e8040f65fca8f6a3ca006a32ff19a..7ada66b27dc63218132ffe9019ec3a4d03db906a 100644
--- a/content/browser/renderer_host/media/video_capture_manager.h
+++ b/content/browser/renderer_host/media/video_capture_manager.h
@@ -12,6 +12,7 @@
#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_
#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_
+#include <list>
#include <map>
#include <set>
#include <string>
@@ -182,6 +183,19 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
const media::VideoCaptureDeviceInfos& old_device_info_cache,
scoped_ptr<media::VideoCaptureDevice::Names> names_snapshot);
+ // On the OS level, starting a capture device can take 1-2 seconds.
+ // To avoid multiple unnecessary start/stop commands to the OS, each start
+ // request is queued in |device_start_queue_|.
+ // QueueStartDevice creates a new entry in |device_start_queue_| and posts a
+ // request to start |entry| on the device thread unless there is another
+ // request pending start.
+ void QueueStartDevice(media::VideoCaptureSessionId session_id,
+ DeviceEntry* entry,
tommi (sloooow) - chröme 2014/12/15 16:25:05 can you document the ownership/lifetime of |entry|
+ const media::VideoCaptureParams& params);
+ void OnDeviceStarted();
+ void DoStopDevice(DeviceEntry* entry, bool delete_entry);
+ void HandleQueuedStartRequest();
+
// Creates and Starts a new VideoCaptureDevice, storing the result in
// |entry->video_capture_device|. Ownership of |client| passes to
// the device.
@@ -245,8 +259,24 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
scoped_ptr<media::VideoCaptureDevice> video_capture_device;
};
typedef std::set<DeviceEntry*> DeviceEntries;
+ // Currently opened devices. The device may or may not be started.
DeviceEntries devices_;
+ // On the OS level, starting a capture device can take 1-2 seconds.
+ // To avoid multiple unnecessary start/stop commands to the OS, each start
+ // request is queued in a CaptureDeviceStartRequest.
+ struct CaptureDeviceStartRequest {
+ CaptureDeviceStartRequest(DeviceEntry* device_entry,
+ media::VideoCaptureSessionId session_id,
+ const media::VideoCaptureParams& params);
+
+ DeviceEntry* device_entry;
tommi (sloooow) - chröme 2014/12/15 16:25:05 ownership/scope?
+ media::VideoCaptureSessionId session_id;
+ media::VideoCaptureParams params;
+ };
+ typedef std::list<CaptureDeviceStartRequest> DeviceStartQueue;
+ DeviceStartQueue device_start_queue_;
+
// Device creation factory injected on construction from MediaStreamManager or
// from the test harness.
scoped_ptr<media::VideoCaptureDeviceFactory> video_capture_device_factory_;

Powered by Google App Engine
This is Rietveld 408576698