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

Unified Diff: media/capture/video/video_capture_system.h

Issue 2769543002: [Mojo Video Capture] Introduce abstraction VideoCaptureSystem (Closed)
Patch Set: Incorporated suggestions from PatchSet 5 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
« no previous file with comments | « media/capture/video/video_capture_device_info.cc ('k') | media/capture/video/video_capture_system.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/capture/video/video_capture_system.h
diff --git a/media/capture/video/video_capture_system.h b/media/capture/video/video_capture_system.h
new file mode 100644
index 0000000000000000000000000000000000000000..f03e3a98236e5d9d47e2f2c91a0341a59da27c12
--- /dev/null
+++ b/media/capture/video/video_capture_system.h
@@ -0,0 +1,56 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_SYSTEM_H_
+#define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_SYSTEM_H_
+
+#include "media/capture/video/video_capture_device_factory.h"
+#include "media/capture/video/video_capture_device_info.h"
+
+namespace media {
+
+// Layer on top of VideoCaptureDeviceFactory that translates device descriptors
+// to string identifiers and consolidates and caches device descriptors and
+// supported formats into VideoCaptureDeviceInfos.
+class CAPTURE_EXPORT VideoCaptureSystem {
+ public:
+ using DeviceInfoCallback =
+ base::Callback<void(const std::vector<VideoCaptureDeviceInfo>&)>;
+
+ explicit VideoCaptureSystem(
+ std::unique_ptr<VideoCaptureDeviceFactory> factory);
+ ~VideoCaptureSystem();
+
+ // The passed-in |result_callback| must have ownership of the called
+ // VideoCaptureSystem instance to guarantee that it stays alive during the
+ // asynchronous operation.
+ void GetDeviceInfosAsync(const DeviceInfoCallback& result_callback);
+
+ // Creates a VideoCaptureDevice object. Returns nullptr if something goes
+ // wrong.
+ std::unique_ptr<VideoCaptureDevice> CreateDevice(
+ const std::string& device_id);
+
+ media::VideoCaptureDeviceFactory* video_capture_device_factory() const {
+ return factory_.get();
+ }
+
+ private:
+ void OnDescriptorsReceived(
+ const DeviceInfoCallback& result_callback,
+ std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors);
+
+ // Returns nullptr if no descriptor found.
+ const VideoCaptureDeviceInfo* LookupDeviceInfoFromId(
+ const std::string& device_id);
+
+ const std::unique_ptr<VideoCaptureDeviceFactory> factory_;
+ std::vector<VideoCaptureDeviceInfo> devices_info_cache_;
+
+ base::ThreadChecker thread_checker_;
+};
+
+} // namespace media
+
+#endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_FACTORY_H_
« no previous file with comments | « media/capture/video/video_capture_device_info.cc ('k') | media/capture/video/video_capture_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698