Index: services/video_capture/video_capture_device_factory_impl.h |
diff --git a/services/video_capture/video_capture_device_factory_impl.h b/services/video_capture/video_capture_device_factory_impl.h |
index 9775a57f92886087b2e2763e10d417fc0f45cb0c..883a581b6b0a3351ec52baaa67bcccefe3149082 100644 |
--- a/services/video_capture/video_capture_device_factory_impl.h |
+++ b/services/video_capture/video_capture_device_factory_impl.h |
@@ -5,21 +5,55 @@ |
#ifndef SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ |
#define SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ |
+#include <vector> |
+ |
+#include "mojo/public/cpp/bindings/binding_set.h" |
#include "services/video_capture/public/interfaces/video_capture_device_factory.mojom.h" |
+#include "services/video_capture/video_capture_device_proxy_impl.h" |
namespace video_capture { |
-// Implementation of the VideoCaptureDeviceFactory Mojo interface. |
class VideoCaptureDeviceFactoryImpl : public mojom::VideoCaptureDeviceFactory { |
public: |
+ VideoCaptureDeviceFactoryImpl(); |
+ ~VideoCaptureDeviceFactoryImpl() override; |
+ |
+ mojom::VideoCaptureDeviceDescriptorPtr AddFakeVideoCaptureDevice(); |
+ |
// mojom::VideoCaptureDeviceFactory: |
void EnumerateDeviceDescriptors( |
const EnumerateDeviceDescriptorsCallback& callback) override; |
void GetSupportedFormats( |
mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, |
const GetSupportedFormatsCallback& callback) override; |
- void CreateDevice(mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, |
- mojom::VideoCaptureDeviceRequest device_request) override; |
+ void CreateDeviceProxy( |
+ mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, |
+ mojom::VideoCaptureDeviceProxyRequest proxy_request, |
+ const CreateDeviceProxyCallback& callback) override; |
+ |
+ private: |
+ // We use a std::vector of structs with the |descriptor| field as a unique |
+ // keys. We do it this way instead of using a std::map because Mojo-generated |
+ // structs (here VideoCaptureDeviceDescriptor) do not support usage as keys |
+ // inside std::map. The performance penalty of not using a map should |
+ // be minimal assuming that the number of capture devices is typically small. |
+ class DeviceEntry { |
+ public: |
+ DeviceEntry(mojom::VideoCaptureDeviceDescriptorPtr descriptor, |
+ std::unique_ptr<VideoCaptureDeviceProxyImpl> bindable_target); |
+ ~DeviceEntry(); |
+ DeviceEntry(DeviceEntry&& other); |
+ DeviceEntry& operator=(DeviceEntry&& other); |
+ |
+ mojom::VideoCaptureDeviceDescriptorPtr MakeDescriptorCopy() const; |
+ |
+ private: |
+ mojom::VideoCaptureDeviceDescriptorPtr descriptor_; |
+ std::unique_ptr<VideoCaptureDeviceProxyImpl> device_proxy_; |
+ }; |
+ |
+ std::vector<DeviceEntry> devices_; |
+ int fake_device_count_; |
}; |
} // namespace video_capture |