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

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: Merge-in changes from upstream 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 b37cd1c76317b62655ea711ee5876a2aad2491f3..35276701faf9397dca0bd72b611fb8066243e908 100644
--- a/services/video_capture/video_capture_device_factory_impl.cc
+++ b/services/video_capture/video_capture_device_factory_impl.cc
@@ -2,14 +2,70 @@
// 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 "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<VideoCaptureDeviceAccessImpl> bindable_target)
+ : descriptor_(std::move(descriptor)) {
+ device_access_ = std::move(bindable_target);
+}
+
+VideoCaptureDeviceFactoryImpl::DeviceEntry::~DeviceEntry() = default;
mcasas 2016/08/12 23:38:37 empty lines after methods, here and in l.39
chfremer 2016/08/15 20:10:35 Done.
+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();
+ std::ostringstream display_name_oss;
+ display_name_oss << kFakeDeviceDisplayName << " (" << fake_device_count_
+ << ")";
+ fake_device_descriptor->display_name = display_name_oss.str();
+ std::ostringstream device_id_oss;
+ device_id_oss << kFakeDeviceId << "_" << fake_device_count_;
+ fake_device_descriptor->device_id = device_id_oss.str();
mcasas 2016/08/12 23:38:37 Use base::StringPrintf (which, also works magicall
chfremer 2016/08/15 20:10:35 Done.
+ 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::WrapUnique(new VideoCaptureDeviceAccessImpl()));
mcasas 2016/08/12 23:38:37 Per recent discussion in chromium-dev, prefer base
chfremer 2016/08/15 20:10:35 Done.
+
+ fake_device_count_ += 1;
mcasas 2016/08/12 23:38:37 fake_device_count_++;
chfremer 2016/08/15 20:10:35 Done.
+ return fake_device_descriptor;
+}
+
void VideoCaptureDeviceFactoryImpl::EnumerateDeviceDescriptors(
const EnumerateDeviceDescriptorsCallback& callback) {
std::vector<mojom::VideoCaptureDeviceDescriptorPtr> descriptors;
+ for (const auto& entry : devices_) {
+ descriptors.push_back(entry.MakeDescriptorCopy());
+ }
mcasas 2016/08/12 23:38:37 nit: no {} for one-line bodies.
chfremer 2016/08/15 20:10:34 Done.
callback.Run(std::move(descriptors));
}
@@ -19,9 +75,10 @@ void VideoCaptureDeviceFactoryImpl::GetSupportedFormats(
NOTIMPLEMENTED();
}
-void VideoCaptureDeviceFactoryImpl::CreateDevice(
+void VideoCaptureDeviceFactoryImpl::GetDeviceAccess(
mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
- mojom::VideoCaptureDeviceRequest device_request) {
+ mojom::VideoCaptureDeviceAccessRequest access_request,
+ const GetDeviceAccessCallback& callback) {
NOTIMPLEMENTED();
mcasas 2016/08/12 23:38:37 Don't we need to do some callback.Run(mojom::Devic
chfremer 2016/08/15 20:10:35 Done.
}

Powered by Google App Engine
This is Rietveld 408576698