Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Unified Diff: services/video_capture/video_capture_device_factory_impl.cc

Issue 2238083004: Video Capture Mojo (1.4b): Implement ability to use fake device instance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@FillServicePart1
Patch Set: Fix control reached end of non-void function. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « services/video_capture/video_capture_device_factory_impl.h ('k') | services/video_capture/video_capture_device_proxy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698