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

Side by Side 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: Split out rename to separate CL 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sstream>
6
5 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h"
6 #include "services/video_capture/video_capture_device_factory_impl.h" 9 #include "services/video_capture/video_capture_device_factory_impl.h"
7 10
11 namespace {
12 static const char kFakeDeviceDisplayName[] = "Fake Video Capture Device";
13 static const char kFakeDeviceId[] = "FakeDeviceId";
14 static const char kFakeModelId[] = "FakeModelId";
15 }
16
8 namespace video_capture { 17 namespace video_capture {
9 18
19 VideoCaptureDeviceFactoryImpl::DeviceEntry::DeviceEntry(
20 mojom::VideoCaptureDeviceDescriptorPtr descriptor,
21 std::unique_ptr<VideoCaptureDeviceImpl> bindable_target)
22 : descriptor_(std::move(descriptor)) {
23 device_ = std::move(bindable_target);
yzshen1 2016/08/16 17:55:08 do it in the initialization list?
chfremer 2016/08/16 18:34:40 Done.
24 }
25
26 VideoCaptureDeviceFactoryImpl::DeviceEntry::~DeviceEntry() = default;
27
28 VideoCaptureDeviceFactoryImpl::DeviceEntry::DeviceEntry(
29 VideoCaptureDeviceFactoryImpl::DeviceEntry&& other) = default;
30
31 VideoCaptureDeviceFactoryImpl::DeviceEntry&
32 VideoCaptureDeviceFactoryImpl::DeviceEntry::operator=(
33 VideoCaptureDeviceFactoryImpl::DeviceEntry&& other) = default;
34
35 mojom::VideoCaptureDeviceDescriptorPtr
36 VideoCaptureDeviceFactoryImpl::DeviceEntry::MakeDescriptorCopy() const {
37 return descriptor_.Clone();
38 }
39
40 VideoCaptureDeviceFactoryImpl::VideoCaptureDeviceFactoryImpl()
41 : fake_device_count_(0) {}
42
43 VideoCaptureDeviceFactoryImpl::~VideoCaptureDeviceFactoryImpl() = default;
44
45 mojom::VideoCaptureDeviceDescriptorPtr
46 VideoCaptureDeviceFactoryImpl::AddFakeVideoCaptureDevice() {
47 auto fake_device_descriptor = mojom::VideoCaptureDeviceDescriptor::New();
48 fake_device_descriptor->display_name =
49 base::StringPrintf("%s (%d)", kFakeDeviceDisplayName, fake_device_count_);
50 std::ostringstream display_name_oss;
51 fake_device_descriptor->device_id =
52 base::StringPrintf("%s_%d", kFakeDeviceId, fake_device_count_);
53 fake_device_descriptor->model_id = kFakeModelId;
54 fake_device_descriptor->capture_api = mojom::VideoCaptureApi::UNKNOWN;
55 fake_device_descriptor->transport_type =
56 mojom::VideoCaptureTransportType::OTHER_TRANSPORT;
57 devices_.emplace_back(fake_device_descriptor->Clone(),
58 base::MakeUnique<VideoCaptureDeviceImpl>());
59
60 fake_device_count_++;
61 return fake_device_descriptor;
62 }
63
10 void VideoCaptureDeviceFactoryImpl::EnumerateDeviceDescriptors( 64 void VideoCaptureDeviceFactoryImpl::EnumerateDeviceDescriptors(
11 const EnumerateDeviceDescriptorsCallback& callback) { 65 const EnumerateDeviceDescriptorsCallback& callback) {
12 std::vector<mojom::VideoCaptureDeviceDescriptorPtr> empty_descriptors; 66 std::vector<mojom::VideoCaptureDeviceDescriptorPtr> descriptors;
13 callback.Run(std::move(empty_descriptors)); 67 for (const auto& entry : devices_)
68 descriptors.push_back(entry.MakeDescriptorCopy());
69 callback.Run(std::move(descriptors));
14 } 70 }
15 71
16 void VideoCaptureDeviceFactoryImpl::GetSupportedFormats( 72 void VideoCaptureDeviceFactoryImpl::GetSupportedFormats(
17 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, 73 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
18 const GetSupportedFormatsCallback& callback) { 74 const GetSupportedFormatsCallback& callback) {
19 NOTIMPLEMENTED(); 75 NOTIMPLEMENTED();
20 } 76 }
21 77
22 void VideoCaptureDeviceFactoryImpl::CreateDevice( 78 void VideoCaptureDeviceFactoryImpl::CreateDevice(
23 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, 79 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
24 mojom::VideoCaptureDeviceRequest device_request) { 80 mojom::VideoCaptureDeviceRequest request,
25 NOTIMPLEMENTED(); 81 const CreateDeviceCallback& callback) {
82 callback.Run(mojom::DeviceAccessResultCode::SUCCESS);
26 } 83 }
27 84
28 } // namespace video_capture 85 } // namespace video_capture
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698