| Index: services/video_capture/video_capture_device_factory_impl.cc
|
| diff --git a/services/video_capture/video_capture_device_factory_impl.cc b/services/video_capture/video_capture_device_factory_impl.cc
|
| index f3ca7dd5b2c5d184a8fe3e66104637d626daae6f..ea3309fa18192d4b926dd079b4a152151b5d19de 100644
|
| --- a/services/video_capture/video_capture_device_factory_impl.cc
|
| +++ b/services/video_capture/video_capture_device_factory_impl.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/logging.h"
|
| #include "base/strings/stringprintf.h"
|
| +#include "media/capture/video/fake_video_capture_device.h"
|
| #include "services/video_capture/video_capture_device_factory_impl.h"
|
|
|
| namespace video_capture {
|
| @@ -14,7 +15,10 @@ VideoCaptureDeviceFactoryImpl::DeviceEntry::DeviceEntry(
|
| mojom::VideoCaptureDeviceDescriptorPtr descriptor,
|
| std::unique_ptr<VideoCaptureDeviceProxyImpl> bindable_target)
|
| : descriptor_(std::move(descriptor)),
|
| - device_proxy_(std::move(bindable_target)) {}
|
| + binding_(base::MakeUnique<mojo::Binding<mojom::VideoCaptureDeviceProxy>>(
|
| + bindable_target.get())) {
|
| + device_proxy_ = std::move(bindable_target);
|
| +}
|
|
|
| VideoCaptureDeviceFactoryImpl::DeviceEntry::~DeviceEntry() = default;
|
|
|
| @@ -30,6 +34,24 @@ VideoCaptureDeviceFactoryImpl::DeviceEntry::MakeDescriptorCopy() const {
|
| return descriptor_.Clone();
|
| }
|
|
|
| +bool VideoCaptureDeviceFactoryImpl::DeviceEntry::DescriptorEquals(
|
| + const mojom::VideoCaptureDeviceDescriptorPtr& other) const {
|
| + return descriptor_.Equals(other);
|
| +}
|
| +
|
| +bool VideoCaptureDeviceFactoryImpl::DeviceEntry::is_bound() const {
|
| + return binding_->is_bound();
|
| +}
|
| +
|
| +void VideoCaptureDeviceFactoryImpl::DeviceEntry::Bind(
|
| + mojom::VideoCaptureDeviceProxyRequest request) {
|
| + binding_->Bind(std::move(request));
|
| +}
|
| +
|
| +void VideoCaptureDeviceFactoryImpl::DeviceEntry::Unbind() {
|
| + binding_->Unbind();
|
| +}
|
| +
|
| VideoCaptureDeviceFactoryImpl::VideoCaptureDeviceFactoryImpl() = default;
|
|
|
| VideoCaptureDeviceFactoryImpl::~VideoCaptureDeviceFactoryImpl() = default;
|
| @@ -56,9 +78,18 @@ void VideoCaptureDeviceFactoryImpl::GetSupportedFormats(
|
|
|
| void VideoCaptureDeviceFactoryImpl::CreateDeviceProxy(
|
| mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
|
| - mojom::VideoCaptureDeviceProxyRequest request,
|
| + mojom::VideoCaptureDeviceProxyRequest proxy_request,
|
| const CreateDeviceProxyCallback& callback) {
|
| - callback.Run(mojom::DeviceAccessResultCode::SUCCESS);
|
| + for (auto& entry : devices_) {
|
| + if (entry.DescriptorEquals(device_descriptor)) {
|
| + if (entry.is_bound())
|
| + entry.Unbind();
|
| + entry.Bind(std::move(proxy_request));
|
| + callback.Run(mojom::DeviceAccessResultCode::SUCCESS);
|
| + return;
|
| + }
|
| + }
|
| + callback.Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND);
|
| }
|
|
|
| } // namespace video_capture
|
|
|