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

Side by Side 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: mcasas' comments 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 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> 5 #include <sstream>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "media/capture/video/fake_video_capture_device.h"
9 #include "services/video_capture/video_capture_device_factory_impl.h" 10 #include "services/video_capture/video_capture_device_factory_impl.h"
10 11
11 namespace video_capture { 12 namespace video_capture {
12 13
13 VideoCaptureDeviceFactoryImpl::DeviceEntry::DeviceEntry( 14 VideoCaptureDeviceFactoryImpl::DeviceEntry::DeviceEntry(
14 mojom::VideoCaptureDeviceDescriptorPtr descriptor, 15 mojom::VideoCaptureDeviceDescriptorPtr descriptor,
15 std::unique_ptr<VideoCaptureDeviceProxyImpl> bindable_target) 16 std::unique_ptr<VideoCaptureDeviceProxyImpl> bindable_target)
16 : descriptor_(std::move(descriptor)), 17 : descriptor_(std::move(descriptor)) {
17 device_proxy_(std::move(bindable_target)) {} 18 binding_ = base::MakeUnique<mojo::Binding<mojom::VideoCaptureDeviceProxy>>(
19 bindable_target.get());
20 device_proxy_ = std::move(bindable_target);
mcasas 2016/08/31 21:10:35 Move l.18-19 to the member initializer list.
chfremer 2016/08/31 21:49:43 Done.
21 }
18 22
19 VideoCaptureDeviceFactoryImpl::DeviceEntry::~DeviceEntry() = default; 23 VideoCaptureDeviceFactoryImpl::DeviceEntry::~DeviceEntry() = default;
20 24
21 VideoCaptureDeviceFactoryImpl::DeviceEntry::DeviceEntry( 25 VideoCaptureDeviceFactoryImpl::DeviceEntry::DeviceEntry(
22 VideoCaptureDeviceFactoryImpl::DeviceEntry&& other) = default; 26 VideoCaptureDeviceFactoryImpl::DeviceEntry&& other) = default;
23 27
24 VideoCaptureDeviceFactoryImpl::DeviceEntry& 28 VideoCaptureDeviceFactoryImpl::DeviceEntry&
25 VideoCaptureDeviceFactoryImpl::DeviceEntry::operator=( 29 VideoCaptureDeviceFactoryImpl::DeviceEntry::operator=(
26 VideoCaptureDeviceFactoryImpl::DeviceEntry&& other) = default; 30 VideoCaptureDeviceFactoryImpl::DeviceEntry&& other) = default;
27 31
28 mojom::VideoCaptureDeviceDescriptorPtr 32 mojom::VideoCaptureDeviceDescriptorPtr
29 VideoCaptureDeviceFactoryImpl::DeviceEntry::MakeDescriptorCopy() const { 33 VideoCaptureDeviceFactoryImpl::DeviceEntry::MakeDescriptorCopy() const {
30 return descriptor_.Clone(); 34 return descriptor_.Clone();
31 } 35 }
32 36
37 bool VideoCaptureDeviceFactoryImpl::DeviceEntry::DescriptorEquals(
38 const mojom::VideoCaptureDeviceDescriptorPtr& other) const {
39 return descriptor_.Equals(other);
40 }
41
42 bool VideoCaptureDeviceFactoryImpl::DeviceEntry::is_bound() const {
43 return binding_->is_bound();
44 }
45
46 void VideoCaptureDeviceFactoryImpl::DeviceEntry::Bind(
47 mojom::VideoCaptureDeviceProxyRequest request) {
48 binding_->Bind(std::move(request));
49 }
50
51 void VideoCaptureDeviceFactoryImpl::DeviceEntry::Unbind() {
52 binding_->Unbind();
53 }
54
33 VideoCaptureDeviceFactoryImpl::VideoCaptureDeviceFactoryImpl() = default; 55 VideoCaptureDeviceFactoryImpl::VideoCaptureDeviceFactoryImpl() = default;
34 56
35 VideoCaptureDeviceFactoryImpl::~VideoCaptureDeviceFactoryImpl() = default; 57 VideoCaptureDeviceFactoryImpl::~VideoCaptureDeviceFactoryImpl() = default;
36 58
37 void VideoCaptureDeviceFactoryImpl::AddDevice( 59 void VideoCaptureDeviceFactoryImpl::AddDevice(
38 mojom::VideoCaptureDeviceDescriptorPtr descriptor, 60 mojom::VideoCaptureDeviceDescriptorPtr descriptor,
39 std::unique_ptr<VideoCaptureDeviceProxyImpl> device) { 61 std::unique_ptr<VideoCaptureDeviceProxyImpl> device) {
40 devices_.emplace_back(std::move(descriptor), std::move(device)); 62 devices_.emplace_back(std::move(descriptor), std::move(device));
41 } 63 }
42 64
43 void VideoCaptureDeviceFactoryImpl::EnumerateDeviceDescriptors( 65 void VideoCaptureDeviceFactoryImpl::EnumerateDeviceDescriptors(
44 const EnumerateDeviceDescriptorsCallback& callback) { 66 const EnumerateDeviceDescriptorsCallback& callback) {
45 std::vector<mojom::VideoCaptureDeviceDescriptorPtr> descriptors; 67 std::vector<mojom::VideoCaptureDeviceDescriptorPtr> descriptors;
46 for (const auto& entry : devices_) 68 for (const auto& entry : devices_)
47 descriptors.push_back(entry.MakeDescriptorCopy()); 69 descriptors.push_back(entry.MakeDescriptorCopy());
48 callback.Run(std::move(descriptors)); 70 callback.Run(std::move(descriptors));
49 } 71 }
50 72
51 void VideoCaptureDeviceFactoryImpl::GetSupportedFormats( 73 void VideoCaptureDeviceFactoryImpl::GetSupportedFormats(
52 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, 74 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
53 const GetSupportedFormatsCallback& callback) { 75 const GetSupportedFormatsCallback& callback) {
54 NOTIMPLEMENTED(); 76 NOTIMPLEMENTED();
55 } 77 }
56 78
57 void VideoCaptureDeviceFactoryImpl::CreateDeviceProxy( 79 void VideoCaptureDeviceFactoryImpl::CreateDeviceProxy(
58 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, 80 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
59 mojom::VideoCaptureDeviceProxyRequest request, 81 mojom::VideoCaptureDeviceProxyRequest proxy_request,
60 const CreateDeviceProxyCallback& callback) { 82 const CreateDeviceProxyCallback& callback) {
61 callback.Run(mojom::DeviceAccessResultCode::SUCCESS); 83 for (auto& entry : devices_) {
84 if (entry.DescriptorEquals(device_descriptor)) {
85 if (entry.is_bound())
86 entry.Unbind();
mcasas 2016/08/31 21:10:35 Question: if there is a VCDeviceProxy correctly bo
chfremer 2016/08/31 21:49:43 I'll ping you to discuss about this.
chfremer 2016/08/31 22:30:52 I got clarification from yzshen. "Associated inter
87 entry.Bind(std::move(proxy_request));
88 callback.Run(mojom::DeviceAccessResultCode::SUCCESS);
89 return;
90 }
91 }
92 callback.Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND);
62 } 93 }
63 94
64 } // namespace video_capture 95 } // namespace video_capture
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698