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

Unified Diff: media/capture/service/video_capture_handler_impl.h

Issue 1699553002: Mojo Video Capture service in media/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added missing BUILD deps Created 4 years, 10 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: media/capture/service/video_capture_handler_impl.h
diff --git a/media/capture/service/video_capture_handler_impl.h b/media/capture/service/video_capture_handler_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..187cd3246f5e8ac12f5fdf853317608623d1d941
--- /dev/null
+++ b/media/capture/service/video_capture_handler_impl.h
@@ -0,0 +1,85 @@
+// Copyright 2016 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_SERVICE_VIDEO_CAPTURE_HANDLER_IMPL_H_
+#define MEDIA_CAPTURE_SERVICE_VIDEO_CAPTURE_HANDLER_IMPL_H_
+
+#include <map>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/system_monitor/system_monitor.h"
+#include "base/threading/thread_checker.h"
+#include "media/capture/interfaces/video_capture.mojom.h"
+#include "media/capture/video/video_capture_device.h"
+
+namespace media {
+class VideoCaptureDeviceFactory;
+}
+
+namespace mojo {
+class ApplicationImpl;
+}
+
+namespace media {
+
+class StreamImpl;
+
+// Implementation of the VideoCaptureHandler interface. This is the main top-
+// level service exposed by the video_capture app, used to acquire handles to
+// specific Stream objects. This class is single threaded throughout.
+// We're a DevicesChangedObserver to reenumerate on device change.
+class VideoCaptureHandlerImpl
+ : public video_capture::VideoCaptureHandler,
+ public base::SystemMonitor::DevicesChangedObserver {
+ public:
+ explicit VideoCaptureHandlerImpl(mojo::ApplicationImpl* app);
+ ~VideoCaptureHandlerImpl() override;
+
+ private:
+ friend class VideoCaptureHandlerImplTest;
+ friend class VideoCaptureTest;
+
+ // video_capture::VideoCaptureHandler:
+ void RequestMediaDevices(
+ video_capture::MediaDevicesInfoRequestPtr request,
+ const RequestMediaDevicesCallback& callback) override;
+ void RequestStream(video_capture::StreamOptionsPtr options,
+ const mojo::String& security_origin,
+ const RequestStreamCallback& callback) override;
+
+ // base::SystemMonitor::DevicesChangedObserver
+ void OnDevicesChanged(base::SystemMonitor::DeviceType device_type) override;
+
+ // Receives the results of devices enumeration and updates |device_names_|.
+ void OnVideoCaptureDevicesEnumerated(
+ scoped_ptr<media::VideoCaptureDevice::Names> device_names);
+
+ void OnStart(const std::string& id);
+ void OnStopOrError(const std::string& id);
+
+ mojo::ApplicationImpl* const app_;
+
+ const scoped_ptr<media::VideoCaptureDeviceFactory>
+ video_capture_device_factory_;
+ scoped_ptr<media::VideoCaptureDevice::Names> device_names_;
+
+ // Table mapping "public" device id to private device id.
+ std::map<std::string, std::string> public_to_private_id_map_;
+
+ // Table mapping (public/private) id and its implementation objects.
+ using DeviceAndStream =
+ std::pair<scoped_ptr<media::VideoCaptureDevice>, scoped_ptr<StreamImpl>>;
+ std::map<std::string, DeviceAndStream> device_and_streams_;
+
+ base::ThreadChecker thread_checker_;
+
+ base::WeakPtrFactory<VideoCaptureHandlerImpl> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(VideoCaptureHandlerImpl);
+};
+
+} // namespace media
+
+#endif // MEDIA_CAPTURE_SERVICE_VIDEO_CAPTURE_HANDLER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698