OLD | NEW |
---|---|
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" |
6 #include "services/video_capture/video_capture_device_factory_impl.h" | 8 #include "services/video_capture/video_capture_device_factory_impl.h" |
7 | 9 |
10 namespace { | |
11 static const char kFakeDeviceDisplayName[] = "Fake Video Capture Device"; | |
12 static const char kFakeDeviceId[] = "FakeDeviceId"; | |
13 static const char kFakeModelId[] = "FakeModelId"; | |
14 } | |
15 | |
8 namespace video_capture { | 16 namespace video_capture { |
9 | 17 |
18 VideoCaptureDeviceFactoryImpl::DeviceEntry::DeviceEntry( | |
19 mojom::VideoCaptureDeviceDescriptorPtr descriptor, | |
20 std::unique_ptr<VideoCaptureDeviceAccessImpl> bindable_target) | |
21 : descriptor_(std::move(descriptor)) { | |
22 device_access_ = std::move(bindable_target); | |
23 } | |
24 | |
25 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.
| |
26 VideoCaptureDeviceFactoryImpl::DeviceEntry::DeviceEntry( | |
27 VideoCaptureDeviceFactoryImpl::DeviceEntry&& other) = default; | |
28 | |
29 VideoCaptureDeviceFactoryImpl::DeviceEntry& | |
30 VideoCaptureDeviceFactoryImpl::DeviceEntry::operator=( | |
31 VideoCaptureDeviceFactoryImpl::DeviceEntry&& other) = default; | |
32 | |
33 mojom::VideoCaptureDeviceDescriptorPtr | |
34 VideoCaptureDeviceFactoryImpl::DeviceEntry::MakeDescriptorCopy() const { | |
35 return descriptor_.Clone(); | |
36 } | |
37 | |
38 VideoCaptureDeviceFactoryImpl::VideoCaptureDeviceFactoryImpl() | |
39 : fake_device_count_(0) {} | |
40 VideoCaptureDeviceFactoryImpl::~VideoCaptureDeviceFactoryImpl() = default; | |
41 | |
42 mojom::VideoCaptureDeviceDescriptorPtr | |
43 VideoCaptureDeviceFactoryImpl::AddFakeVideoCaptureDevice() { | |
44 auto fake_device_descriptor = mojom::VideoCaptureDeviceDescriptor::New(); | |
45 std::ostringstream display_name_oss; | |
46 display_name_oss << kFakeDeviceDisplayName << " (" << fake_device_count_ | |
47 << ")"; | |
48 fake_device_descriptor->display_name = display_name_oss.str(); | |
49 std::ostringstream device_id_oss; | |
50 device_id_oss << kFakeDeviceId << "_" << fake_device_count_; | |
51 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.
| |
52 fake_device_descriptor->model_id = kFakeModelId; | |
53 fake_device_descriptor->capture_api = mojom::VideoCaptureApi::UNKNOWN; | |
54 fake_device_descriptor->transport_type = | |
55 mojom::VideoCaptureTransportType::OTHER_TRANSPORT; | |
56 devices_.emplace_back(fake_device_descriptor->Clone(), | |
57 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.
| |
58 | |
59 fake_device_count_ += 1; | |
mcasas
2016/08/12 23:38:37
fake_device_count_++;
chfremer
2016/08/15 20:10:35
Done.
| |
60 return fake_device_descriptor; | |
61 } | |
62 | |
10 void VideoCaptureDeviceFactoryImpl::EnumerateDeviceDescriptors( | 63 void VideoCaptureDeviceFactoryImpl::EnumerateDeviceDescriptors( |
11 const EnumerateDeviceDescriptorsCallback& callback) { | 64 const EnumerateDeviceDescriptorsCallback& callback) { |
12 std::vector<mojom::VideoCaptureDeviceDescriptorPtr> descriptors; | 65 std::vector<mojom::VideoCaptureDeviceDescriptorPtr> descriptors; |
66 for (const auto& entry : devices_) { | |
67 descriptors.push_back(entry.MakeDescriptorCopy()); | |
68 } | |
mcasas
2016/08/12 23:38:37
nit: no {} for one-line bodies.
chfremer
2016/08/15 20:10:34
Done.
| |
13 callback.Run(std::move(descriptors)); | 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::GetDeviceAccess( |
23 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, | 79 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, |
24 mojom::VideoCaptureDeviceRequest device_request) { | 80 mojom::VideoCaptureDeviceAccessRequest access_request, |
81 const GetDeviceAccessCallback& callback) { | |
25 NOTIMPLEMENTED(); | 82 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.
| |
26 } | 83 } |
27 | 84 |
28 } // namespace video_capture | 85 } // namespace video_capture |
OLD | NEW |