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

Side by Side 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: perkj@s and magjed@s comments Created 4 years, 9 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_CAPTURE_SERVICE_VIDEO_CAPTURE_HANDLER_IMPL_H_
6 #define MEDIA_CAPTURE_SERVICE_VIDEO_CAPTURE_HANDLER_IMPL_H_
7
8 #include <map>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/system_monitor/system_monitor.h"
13 #include "base/threading/thread_checker.h"
14 #include "media/capture/interfaces/video_capture.mojom.h"
15 #include "media/capture/video/video_capture_device.h"
16
17 namespace media {
18 class VideoCaptureDeviceFactory;
19 }
20
21 namespace mojo {
22 class ApplicationImpl;
23 }
24
25 namespace media {
26
27 class StreamImpl;
28
29 // Implementation of the VideoCaptureHandler interface. This is the main top-
30 // level service exposed by the video_capture app, used to acquire handles to
31 // specific Stream objects. This class is single threaded throughout.
32 // We're a DevicesChangedObserver to reenumerate on device change.
33 class VideoCaptureHandlerImpl
34 : public mojom::VideoCaptureHandler,
35 public base::SystemMonitor::DevicesChangedObserver {
36 public:
37 explicit VideoCaptureHandlerImpl(mojo::ApplicationImpl* app);
38 ~VideoCaptureHandlerImpl() override;
39
40 private:
41 friend class VideoCaptureHandlerImplTest;
42 friend class VideoCaptureTest;
43
44 // mojom::VideoCaptureHandler:
45 void EnumerateDevices(const EnumerateDevicesCallback& callback) override;
46 void RequestVideoCaptureStream(
47 mojom::VideoCaptureOptionsPtr options,
48 const RequestVideoCaptureStreamCallback& callback) override;
49
50 // base::SystemMonitor::DevicesChangedObserver
51 void OnDevicesChanged(base::SystemMonitor::DeviceType device_type) override;
52
53 // Receives the results of devices enumeration and updates |device_names_|.
54 void OnVideoCaptureDevicesEnumerated(
55 scoped_ptr<media::VideoCaptureDevice::Names> device_names);
56
57 void OnStart(const std::string& id);
58 void OnStopOrError(const std::string& id);
59
60 mojo::ApplicationImpl* const app_;
61
62 const scoped_ptr<media::VideoCaptureDeviceFactory>
63 video_capture_device_factory_;
64 scoped_ptr<media::VideoCaptureDevice::Names> device_names_;
65
66 // Table mapping "public" device id to private device id.
67 std::map<std::string, std::string> public_to_private_id_map_;
68
69 // Table mapping (public/private) id and its implementation objects.
70 using DeviceAndStream =
71 std::pair<scoped_ptr<media::VideoCaptureDevice>, scoped_ptr<StreamImpl>>;
72 std::map<std::string, DeviceAndStream> device_and_streams_;
73
74 base::ThreadChecker thread_checker_;
75
76 base::WeakPtrFactory<VideoCaptureHandlerImpl> weak_factory_;
77
78 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHandlerImpl);
79 };
80
81 } // namespace media
82
83 #endif // MEDIA_CAPTURE_SERVICE_VIDEO_CAPTURE_HANDLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698