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

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

Issue 2802553002: Revert of [Mojo Video Capture] Introduce abstraction VideoCaptureSystem (Closed)
Patch Set: Created 3 years, 8 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 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 10e0c62aba40e82ccaab8b69684d0e47df9f2d77..a6fe9c4597bfc3ee56b6d82087b73551c0b6c34f 100644
--- a/content/browser/renderer_host/media/video_capture_manager.h
+++ b/content/browser/renderer_host/media/video_capture_manager.h
@@ -34,8 +34,6 @@
#include "media/base/video_facing.h"
#include "media/capture/video/video_capture_device.h"
#include "media/capture/video/video_capture_device_factory.h"
-#include "media/capture/video/video_capture_device_info.h"
-#include "media/capture/video/video_capture_system.h"
#include "media/capture/video_capture_types.h"
#if defined(OS_ANDROID)
@@ -58,7 +56,7 @@
base::Callback<void(const base::WeakPtr<VideoCaptureController>&)>;
VideoCaptureManager(
- std::unique_ptr<media::VideoCaptureSystem> capture_system,
+ std::unique_ptr<media::VideoCaptureDeviceFactory> factory,
scoped_refptr<base::SingleThreadTaskRunner> device_task_runner);
// AddVideoCaptureObserver() can be called only before any devices are opened.
@@ -165,7 +163,7 @@
// Gets a weak reference to the device factory, used for tests.
media::VideoCaptureDeviceFactory* video_capture_device_factory() const {
- return video_capture_system_->video_capture_device_factory();
+ return video_capture_device_factory_.get();
}
#if defined(OS_WIN)
@@ -199,12 +197,13 @@
using EnumerationCallback =
base::Callback<void(const media::VideoCaptureDeviceDescriptors&)>;
- // Asynchronously obtains descriptors for the available devices.
- // As a side-effect, updates |devices_info_cache_|.
void EnumerateDevices(const EnumerationCallback& client_callback);
// Implementation of BuildableVideoCaptureDevice::Callbacks:
- void OnDeviceStarted(VideoCaptureController* controller) override;
+ const media::VideoCaptureDeviceDescriptor* LookupDeviceDescriptor(
+ const std::string& id) override;
+ void WillStartDevice(media::VideoFacingMode facing_mode) override;
+ void DidStartDevice(VideoCaptureController* controller) override;
void OnDeviceStartFailed(VideoCaptureController* controller) override;
void OnDeviceStartAborted() override;
@@ -217,24 +216,32 @@
private:
class CaptureDeviceStartRequest;
+ struct DeviceInfo;
using SessionMap = std::map<media::VideoCaptureSessionId, MediaStreamDevice>;
+ using DeviceInfos = std::vector<DeviceInfo>;
using DeviceStartQueue = std::list<CaptureDeviceStartRequest>;
using VideoCaptureDeviceDescriptor = media::VideoCaptureDeviceDescriptor;
using VideoCaptureDeviceDescriptors = media::VideoCaptureDeviceDescriptors;
~VideoCaptureManager() override;
-
- void OnDeviceInfosReceived(
- base::ElapsedTimer* timer,
- const EnumerationCallback& client_callback,
- const std::vector<media::VideoCaptureDeviceInfo>& device_infos);
// Helpers to report an event to our Listener.
void OnOpened(MediaStreamType type,
media::VideoCaptureSessionId capture_session_id);
void OnClosed(MediaStreamType type,
media::VideoCaptureSessionId capture_session_id);
+ void OnDevicesInfoEnumerated(base::ElapsedTimer* timer,
+ const EnumerationCallback& client_callback,
+ const DeviceInfos& new_devices_info_cache);
+
+ // Consolidates the cached devices list with the list of currently connected
+ // devices in the system |names_snapshot|. Retrieves the supported formats of
+ // the new devices and sends the new cache to OnDevicesInfoEnumerated().
+ void ConsolidateDevicesInfoOnDeviceThread(
+ base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback,
+ const DeviceInfos& old_device_info_cache,
+ std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors_snapshot);
// Checks to see if |controller| has no clients left. If so, remove it from
// the list of controllers, and delete it asynchronously. |controller| may be
@@ -253,7 +260,7 @@
VideoCaptureController* controller) const;
// Finds the device info by |id| in |devices_info_cache_|, or nullptr.
- media::VideoCaptureDeviceInfo* GetDeviceInfoById(const std::string& id);
+ DeviceInfo* GetDeviceInfoById(const std::string& id);
// Finds a VideoCaptureController for the indicated |capture_session_id|,
// creating a fresh one if necessary. Returns nullptr if said
@@ -311,14 +318,19 @@
// Device creation factory injected on construction from MediaStreamManager or
// from the test harness.
- std::unique_ptr<media::VideoCaptureSystem> video_capture_system_;
+ std::unique_ptr<media::VideoCaptureDeviceFactory>
+ video_capture_device_factory_;
base::ObserverList<media::VideoCaptureObserver> capture_observers_;
- // Local cache of the enumerated DeviceInfos. GetDeviceSupportedFormats() will
+ // Local cache of the enumerated video capture devices' names and capture
+ // supported formats. A snapshot of the current devices and their capabilities
+ // is composed in VideoCaptureDeviceFactory::EnumerateDeviceNames() and
+ // ConsolidateDevicesInfoOnDeviceThread(), and this snapshot is used to update
+ // this list in OnDevicesInfoEnumerated(). GetDeviceSupportedFormats() will
// use this list if the device is not started, otherwise it will retrieve the
// active device capture format from the VideoCaptureController associated.
- std::vector<media::VideoCaptureDeviceInfo> devices_info_cache_;
+ DeviceInfos devices_info_cache_;
// Map used by DesktopCapture.
std::map<media::VideoCaptureSessionId, gfx::NativeViewId>

Powered by Google App Engine
This is Rietveld 408576698