OLD | NEW |
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 |
| 10 #include "mojo/public/cpp/bindings/binding_set.h" |
8 #include "services/video_capture/public/interfaces/video_capture_device_factory.
mojom.h" | 11 #include "services/video_capture/public/interfaces/video_capture_device_factory.
mojom.h" |
| 12 #include "services/video_capture/video_capture_device_access_impl.h" |
9 | 13 |
10 namespace video_capture { | 14 namespace video_capture { |
11 | 15 |
12 // Implementation of the VideoCaptureDeviceFactory Mojo interface. | |
13 class VideoCaptureDeviceFactoryImpl : public mojom::VideoCaptureDeviceFactory { | 16 class VideoCaptureDeviceFactoryImpl : public mojom::VideoCaptureDeviceFactory { |
14 public: | 17 public: |
| 18 VideoCaptureDeviceFactoryImpl(); |
| 19 ~VideoCaptureDeviceFactoryImpl() override; |
| 20 |
| 21 mojom::VideoCaptureDeviceDescriptorPtr AddFakeVideoCaptureDevice(); |
| 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 GetDeviceAccess(mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, |
22 mojom::VideoCaptureDeviceRequest device_request) override; | 30 mojom::VideoCaptureDeviceAccessRequest access_request, |
| 31 const GetDeviceAccessCallback& 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 support usage as keys |
| 37 // inside std::map. The performance penalty of not using a map should |
| 38 // be minimal assuming that the number of capture devices is typically small. |
| 39 class DeviceEntry { |
| 40 public: |
| 41 DeviceEntry(mojom::VideoCaptureDeviceDescriptorPtr descriptor, |
| 42 std::unique_ptr<VideoCaptureDeviceAccessImpl> bindable_target); |
| 43 ~DeviceEntry(); |
| 44 DeviceEntry(DeviceEntry&& other); |
| 45 DeviceEntry& operator=(DeviceEntry&& other); |
| 46 |
| 47 mojom::VideoCaptureDeviceDescriptorPtr MakeDescriptorCopy() const; |
| 48 |
| 49 private: |
| 50 mojom::VideoCaptureDeviceDescriptorPtr descriptor_; |
| 51 std::unique_ptr<VideoCaptureDeviceAccessImpl> device_access_; |
| 52 }; |
| 53 |
| 54 std::vector<DeviceEntry> devices_; |
| 55 int fake_device_count_; |
23 }; | 56 }; |
24 | 57 |
25 } // namespace video_capture | 58 } // namespace video_capture |
26 | 59 |
27 #endif // SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ | 60 #endif // SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ |
OLD | NEW |