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

Unified Diff: services/video_capture/video_capture_device_factory_impl.cc

Issue 2244763002: Video Capture Mojo (1.4a.a): Add service configurator interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@MakeService
Patch Set: mcasas' comments Created 4 years, 4 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 045441537a9d483f907dcf02bf269efddd06a3df..17eb345537d21bd7832c20b035c48a93f36fce9e 100644
--- a/services/video_capture/video_capture_device_factory_impl.cc
+++ b/services/video_capture/video_capture_device_factory_impl.cc
@@ -2,15 +2,71 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <sstream>
+
#include "base/logging.h"
+#include "base/strings/stringprintf.h"
#include "services/video_capture/video_capture_device_factory_impl.h"
+namespace {
+static const char kFakeDeviceDisplayName[] = "Fake Video Capture Device";
+static const char kFakeDeviceId[] = "FakeDeviceId";
+static const char kFakeModelId[] = "FakeModelId";
+}
+
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);
+}
+
+VideoCaptureDeviceFactoryImpl::DeviceEntry::~DeviceEntry() = default;
+
+VideoCaptureDeviceFactoryImpl::DeviceEntry::DeviceEntry(
+ VideoCaptureDeviceFactoryImpl::DeviceEntry&& other) = default;
+
+VideoCaptureDeviceFactoryImpl::DeviceEntry&
+VideoCaptureDeviceFactoryImpl::DeviceEntry::operator=(
+ VideoCaptureDeviceFactoryImpl::DeviceEntry&& other) = default;
+
+mojom::VideoCaptureDeviceDescriptorPtr
+VideoCaptureDeviceFactoryImpl::DeviceEntry::MakeDescriptorCopy() const {
+ return descriptor_.Clone();
+}
+
+VideoCaptureDeviceFactoryImpl::VideoCaptureDeviceFactoryImpl()
+ : fake_device_count_(0) {}
+
+VideoCaptureDeviceFactoryImpl::~VideoCaptureDeviceFactoryImpl() = default;
+
+mojom::VideoCaptureDeviceDescriptorPtr
+VideoCaptureDeviceFactoryImpl::AddFakeVideoCaptureDevice() {
+ auto fake_device_descriptor = mojom::VideoCaptureDeviceDescriptor::New();
+ fake_device_descriptor->display_name =
+ base::StringPrintf("%s (%d)", kFakeDeviceDisplayName, fake_device_count_);
+ std::ostringstream display_name_oss;
+ fake_device_descriptor->device_id =
+ base::StringPrintf("%s_%d", kFakeDeviceId, fake_device_count_);
+ fake_device_descriptor->model_id = kFakeModelId;
+ fake_device_descriptor->capture_api = mojom::VideoCaptureApi::UNKNOWN;
+ fake_device_descriptor->transport_type =
+ mojom::VideoCaptureTransportType::OTHER_TRANSPORT;
+ devices_.emplace_back(fake_device_descriptor->Clone(),
+ base::MakeUnique<VideoCaptureDeviceProxyImpl>());
+
+ fake_device_count_++;
+ return fake_device_descriptor;
+}
+
void VideoCaptureDeviceFactoryImpl::EnumerateDeviceDescriptors(
const EnumerateDeviceDescriptorsCallback& callback) {
- std::vector<mojom::VideoCaptureDeviceDescriptorPtr> empty_descriptors;
- callback.Run(std::move(empty_descriptors));
+ std::vector<mojom::VideoCaptureDeviceDescriptorPtr> descriptors;
+ for (const auto& entry : devices_)
+ descriptors.push_back(entry.MakeDescriptorCopy());
+ callback.Run(std::move(descriptors));
}
void VideoCaptureDeviceFactoryImpl::GetSupportedFormats(
@@ -19,10 +75,11 @@ void VideoCaptureDeviceFactoryImpl::GetSupportedFormats(
NOTIMPLEMENTED();
}
-void VideoCaptureDeviceFactoryImpl::CreateDevice(
+void VideoCaptureDeviceFactoryImpl::CreateDeviceProxy(
mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
- mojom::VideoCaptureDeviceRequest device_request) {
- NOTIMPLEMENTED();
+ mojom::VideoCaptureDeviceProxyRequest proxy_request,
+ const CreateDeviceProxyCallback& callback) {
+ callback.Run(mojom::DeviceAccessResultCode::SUCCESS);
}
} // namespace video_capture

Powered by Google App Engine
This is Rietveld 408576698