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..35e20c68f29e7e9cffc2b1ba57a4b1b773b4aee4 100644 |
--- a/services/video_capture/video_capture_device_factory_impl.h |
+++ b/services/video_capture/video_capture_device_factory_impl.h |
@@ -5,21 +5,54 @@ |
#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_access_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 GetDeviceAccess(mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, |
+ mojom::VideoCaptureDeviceAccessRequest access_request, |
+ const GetDeviceAccessCallback& 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<VideoCaptureDeviceAccessImpl> bindable_target); |
+ ~DeviceEntry(); |
+ DeviceEntry(DeviceEntry&& other); |
+ DeviceEntry& operator=(DeviceEntry&& other); |
+ |
+ mojom::VideoCaptureDeviceDescriptorPtr MakeDescriptorCopy() const; |
+ |
+ private: |
+ mojom::VideoCaptureDeviceDescriptorPtr descriptor_; |
+ std::unique_ptr<VideoCaptureDeviceAccessImpl> device_access_; |
+ }; |
+ |
+ std::vector<DeviceEntry> devices_; |
+ int fake_device_count_; |
}; |
} // namespace video_capture |