Chromium Code Reviews| 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..2387be729cd14ab59648e0a13c852c5e5d0f8495 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 { |
| @@ -13,8 +14,11 @@ namespace video_capture { |
| VideoCaptureDeviceFactoryImpl::DeviceEntry::DeviceEntry( |
| mojom::VideoCaptureDeviceDescriptorPtr descriptor, |
| std::unique_ptr<VideoCaptureDeviceProxyImpl> bindable_target) |
| - : descriptor_(std::move(descriptor)), |
| - device_proxy_(std::move(bindable_target)) {} |
| + : descriptor_(std::move(descriptor)) { |
| + 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( |
|
mcasas
2016/08/30 01:20:26
Why not adding a friend bool operator== ?
chfremer
2016/08/30 18:22:54
Not sure I understand. Do you mean adding DeviceEn
mcasas
2016/08/31 21:10:35
I meant a VideoCaptureDeviceDescriptor's
operator
|
| + 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,19 @@ 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)); |
|
mcasas
2016/08/30 01:20:27
nit: no {} for one-line bodies.
chfremer
2016/08/30 18:22:54
Done.
|
| + callback.Run(mojom::DeviceAccessResultCode::SUCCESS); |
| + return; |
| + } |
| + } |
| + callback.Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND); |
| } |
| } // namespace video_capture |