| 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..2e3bfbe1619ff5ed117b5e9e9be27ad6c80465c5 100644
|
| --- a/services/video_capture/video_capture_device_factory_impl.h
|
| +++ b/services/video_capture/video_capture_device_factory_impl.h
|
| @@ -5,13 +5,21 @@
|
| #ifndef SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_
|
| #define SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_
|
|
|
| +#include <vector>
|
| +
|
| #include "services/video_capture/public/interfaces/video_capture_device_factory.mojom.h"
|
| +#include "services/video_capture/video_capture_device_impl.h"
|
|
|
| namespace video_capture {
|
|
|
| -// Implementation of the VideoCaptureDeviceFactory Mojo interface.
|
| class VideoCaptureDeviceFactoryImpl : public mojom::VideoCaptureDeviceFactory {
|
| public:
|
| + VideoCaptureDeviceFactoryImpl();
|
| + ~VideoCaptureDeviceFactoryImpl() override;
|
| +
|
| + void AddDevice(mojom::VideoCaptureDeviceDescriptorPtr descriptor,
|
| + std::unique_ptr<VideoCaptureDeviceImpl> device);
|
| +
|
| // mojom::VideoCaptureDeviceFactory:
|
| void EnumerateDeviceDescriptors(
|
| const EnumerateDeviceDescriptorsCallback& callback) override;
|
| @@ -19,7 +27,34 @@ class VideoCaptureDeviceFactoryImpl : public mojom::VideoCaptureDeviceFactory {
|
| mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
|
| const GetSupportedFormatsCallback& callback) override;
|
| void CreateDevice(mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
|
| - mojom::VideoCaptureDeviceRequest device_request) override;
|
| + mojom::VideoCaptureDeviceRequest device_request,
|
| + const CreateDeviceCallback& 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 (yet) generate a
|
| + // comparison operator, and we do not want to provide a custom one. The
|
| + // performance penalty of linear-time lookup should be minimal assuming that
|
| + // the number of capture devices is typically small.
|
| + class DeviceEntry {
|
| + public:
|
| + DeviceEntry(mojom::VideoCaptureDeviceDescriptorPtr descriptor,
|
| + std::unique_ptr<VideoCaptureDeviceImpl> bindable_target);
|
| + ~DeviceEntry();
|
| + DeviceEntry(DeviceEntry&& other);
|
| + DeviceEntry& operator=(DeviceEntry&& other);
|
| +
|
| + mojom::VideoCaptureDeviceDescriptorPtr MakeDescriptorCopy() const;
|
| +
|
| + private:
|
| + mojom::VideoCaptureDeviceDescriptorPtr descriptor_;
|
| + std::unique_ptr<VideoCaptureDeviceImpl> device_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(DeviceEntry);
|
| + };
|
| +
|
| + std::vector<DeviceEntry> devices_;
|
| };
|
|
|
| } // namespace video_capture
|
|
|