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> | 8 #include <vector> |
9 | 9 |
10 #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" | 11 #include "services/video_capture/video_capture_device_proxy_impl.h" |
12 | 12 |
13 namespace video_capture { | 13 namespace video_capture { |
14 | 14 |
15 class VideoCaptureDeviceFactoryImpl : public mojom::VideoCaptureDeviceFactory { | 15 class VideoCaptureDeviceFactoryImpl : public mojom::VideoCaptureDeviceFactory { |
16 public: | 16 public: |
17 VideoCaptureDeviceFactoryImpl(); | 17 VideoCaptureDeviceFactoryImpl(); |
18 ~VideoCaptureDeviceFactoryImpl() override; | 18 ~VideoCaptureDeviceFactoryImpl() override; |
19 | 19 |
20 void AddDevice(mojom::VideoCaptureDeviceDescriptorPtr descriptor, | 20 void AddDevice(mojom::VideoCaptureDeviceDescriptorPtr descriptor, |
21 std::unique_ptr<VideoCaptureDeviceImpl> device); | 21 std::unique_ptr<VideoCaptureDeviceProxyImpl> device); |
22 | 22 |
23 // mojom::VideoCaptureDeviceFactory: | 23 // mojom::VideoCaptureDeviceFactory: |
24 void EnumerateDeviceDescriptors( | 24 void EnumerateDeviceDescriptors( |
25 const EnumerateDeviceDescriptorsCallback& callback) override; | 25 const EnumerateDeviceDescriptorsCallback& callback) override; |
26 void GetSupportedFormats( | 26 void GetSupportedFormats( |
27 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, | 27 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, |
28 const GetSupportedFormatsCallback& callback) override; | 28 const GetSupportedFormatsCallback& callback) override; |
29 void CreateDevice(mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, | 29 void CreateDeviceProxy( |
30 mojom::VideoCaptureDeviceRequest device_request, | 30 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, |
31 const CreateDeviceCallback& callback) override; | 31 mojom::VideoCaptureDeviceProxyRequest proxy_request, |
| 32 const CreateDeviceProxyCallback& callback) override; |
32 | 33 |
33 private: | 34 private: |
34 // We use a std::vector of structs with the |descriptor| field as a unique | 35 // 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 // 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 // structs (here VideoCaptureDeviceDescriptor) do not (yet) generate a |
37 // comparison operator, and we do not want to provide a custom one. The | 38 // 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 // performance penalty of linear-time lookup should be minimal assuming that |
39 // the number of capture devices is typically small. | 40 // the number of capture devices is typically small. |
40 class DeviceEntry { | 41 class DeviceEntry { |
41 public: | 42 public: |
42 DeviceEntry(mojom::VideoCaptureDeviceDescriptorPtr descriptor, | 43 DeviceEntry(mojom::VideoCaptureDeviceDescriptorPtr descriptor, |
43 std::unique_ptr<VideoCaptureDeviceImpl> bindable_target); | 44 std::unique_ptr<VideoCaptureDeviceProxyImpl> bindable_target); |
44 ~DeviceEntry(); | 45 ~DeviceEntry(); |
45 DeviceEntry(DeviceEntry&& other); | 46 DeviceEntry(DeviceEntry&& other); |
46 DeviceEntry& operator=(DeviceEntry&& other); | 47 DeviceEntry& operator=(DeviceEntry&& other); |
47 | 48 |
48 mojom::VideoCaptureDeviceDescriptorPtr MakeDescriptorCopy() const; | 49 mojom::VideoCaptureDeviceDescriptorPtr MakeDescriptorCopy() const; |
49 | 50 |
50 private: | 51 private: |
51 mojom::VideoCaptureDeviceDescriptorPtr descriptor_; | 52 mojom::VideoCaptureDeviceDescriptorPtr descriptor_; |
52 std::unique_ptr<VideoCaptureDeviceImpl> device_; | 53 std::unique_ptr<VideoCaptureDeviceProxyImpl> device_proxy_; |
53 | 54 |
54 DISALLOW_COPY_AND_ASSIGN(DeviceEntry); | 55 DISALLOW_COPY_AND_ASSIGN(DeviceEntry); |
55 }; | 56 }; |
56 | 57 |
57 std::vector<DeviceEntry> devices_; | 58 std::vector<DeviceEntry> devices_; |
58 }; | 59 }; |
59 | 60 |
60 } // namespace video_capture | 61 } // namespace video_capture |
61 | 62 |
62 #endif // SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ | 63 #endif // SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ |
OLD | NEW |