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

Side by Side Diff: services/video_capture/video_capture_device_factory_impl.h

Issue 2244763002: Video Capture Mojo (1.4a.a): Add service configurator interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@MakeService
Patch Set: mcasas' comments Created 4 years, 4 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ 5 #ifndef SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_
6 #define SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ 6 #define SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_
7 7
8 #include <vector>
9
8 #include "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h" 10 #include "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h"
11 #include "services/video_capture/video_capture_device_impl.h"
9 12
10 namespace video_capture { 13 namespace video_capture {
11 14
12 // Implementation of the VideoCaptureDeviceFactory Mojo interface.
13 class VideoCaptureDeviceFactoryImpl : public mojom::VideoCaptureDeviceFactory { 15 class VideoCaptureDeviceFactoryImpl : public mojom::VideoCaptureDeviceFactory {
14 public: 16 public:
17 VideoCaptureDeviceFactoryImpl();
18 ~VideoCaptureDeviceFactoryImpl() override;
19
20 void AddDevice(mojom::VideoCaptureDeviceDescriptorPtr descriptor,
21 std::unique_ptr<VideoCaptureDeviceImpl> device);
22
15 // mojom::VideoCaptureDeviceFactory: 23 // mojom::VideoCaptureDeviceFactory:
16 void EnumerateDeviceDescriptors( 24 void EnumerateDeviceDescriptors(
17 const EnumerateDeviceDescriptorsCallback& callback) override; 25 const EnumerateDeviceDescriptorsCallback& callback) override;
18 void GetSupportedFormats( 26 void GetSupportedFormats(
19 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, 27 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
20 const GetSupportedFormatsCallback& callback) override; 28 const GetSupportedFormatsCallback& callback) override;
21 void CreateDevice(mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, 29 void CreateDevice(mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
22 mojom::VideoCaptureDeviceRequest device_request) override; 30 mojom::VideoCaptureDeviceRequest device_request,
31 const CreateDeviceCallback& callback) override;
32
33 private:
34 // We use a std::vector of structs with the |descriptor| field as a unique
35 // keys. We do it this way instead of using a std::map because Mojo-generated
36 // structs (here VideoCaptureDeviceDescriptor) do not (yet) generate a
37 // comparison operator, and we do not want to provide a custom one. The
38 // performance penalty of linear-time lookup should be minimal assuming that
39 // the number of capture devices is typically small.
40 class DeviceEntry {
41 public:
42 DeviceEntry(mojom::VideoCaptureDeviceDescriptorPtr descriptor,
43 std::unique_ptr<VideoCaptureDeviceImpl> bindable_target);
44 ~DeviceEntry();
45 DeviceEntry(DeviceEntry&& other);
46 DeviceEntry& operator=(DeviceEntry&& other);
47
48 mojom::VideoCaptureDeviceDescriptorPtr MakeDescriptorCopy() const;
49
50 private:
51 mojom::VideoCaptureDeviceDescriptorPtr descriptor_;
52 std::unique_ptr<VideoCaptureDeviceImpl> device_;
53
54 DISALLOW_COPY_AND_ASSIGN(DeviceEntry);
55 };
56
57 std::vector<DeviceEntry> devices_;
23 }; 58 };
24 59
25 } // namespace video_capture 60 } // namespace video_capture
26 61
27 #endif // SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ 62 #endif // SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698