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

Side by Side Diff: services/video_capture/video_capture_service.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 unified diff | Download patch
« no previous file with comments | « services/video_capture/video_capture_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/video_capture/video_capture_service.h" 5 #include "services/video_capture/video_capture_service.h"
6 6
7 #include "services/video_capture/video_capture_device_factory_impl.h"
8
9 namespace {
10 static const char kFakeDeviceDisplayName[] = "Fake Video Capture Device";
11 static const char kFakeDeviceId[] = "FakeDeviceId";
12 static const char kFakeModelId[] = "FakeModelId";
13 }
14
7 namespace video_capture { 15 namespace video_capture {
8 16
9 VideoCaptureService::VideoCaptureService() = default; 17 VideoCaptureService::VideoCaptureService() = default;
10 18
11 VideoCaptureService::~VideoCaptureService() = default; 19 VideoCaptureService::~VideoCaptureService() = default;
12 20
13 bool VideoCaptureService::OnConnect(const shell::Identity& remote_identity, 21 bool VideoCaptureService::OnConnect(const shell::Identity& remote_identity,
14 shell::InterfaceRegistry* registry) { 22 shell::InterfaceRegistry* registry) {
15 registry->AddInterface<mojom::VideoCaptureDeviceFactory>(this); 23 registry->AddInterface<mojom::VideoCaptureService>(this);
16 return true; 24 return true;
17 } 25 }
18 26
19 void VideoCaptureService::Create( 27 void VideoCaptureService::Create(const shell::Identity& remote_identity,
20 const shell::Identity& remote_identity, 28 mojom::VideoCaptureServiceRequest request) {
29 bindings_.AddBinding(this, std::move(request));
30 }
31
32 void VideoCaptureService::ConnectToDeviceFactory(
21 mojom::VideoCaptureDeviceFactoryRequest request) { 33 mojom::VideoCaptureDeviceFactoryRequest request) {
22 bindings_.AddBinding(&device_factory_, std::move(request)); 34 LazyInitializeDeviceFactory();
35 factory_bindings_.AddBinding(device_factory_.get(), std::move(request));
36 }
37
38 void VideoCaptureService::ConnectToFakeDeviceFactory(
39 mojom::VideoCaptureDeviceFactoryRequest request) {
40 LazyInitializeFakeDeviceFactory();
41 fake_factory_bindings_.AddBinding(fake_device_factory_.get(),
42 std::move(request));
43 }
44
45 void VideoCaptureService::LazyInitializeDeviceFactory() {
46 if (device_factory_)
47 return;
48 device_factory_ = base::MakeUnique<VideoCaptureDeviceFactoryImpl>();
49 }
50
51 void VideoCaptureService::LazyInitializeFakeDeviceFactory() {
52 if (fake_device_factory_)
53 return;
54 fake_device_factory_ = base::MakeUnique<VideoCaptureDeviceFactoryImpl>();
55 auto fake_device_descriptor = mojom::VideoCaptureDeviceDescriptor::New();
56 fake_device_descriptor->display_name = kFakeDeviceDisplayName;
57 fake_device_descriptor->device_id = kFakeDeviceId;
58 fake_device_descriptor->model_id = kFakeModelId;
59 fake_device_descriptor->capture_api = mojom::VideoCaptureApi::UNKNOWN;
60 fake_device_descriptor->transport_type =
61 mojom::VideoCaptureTransportType::OTHER_TRANSPORT;
62 fake_device_factory_->AddDevice(std::move(fake_device_descriptor),
63 base::MakeUnique<VideoCaptureDeviceImpl>());
23 } 64 }
24 65
25 } // namespace video_capture 66 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/video_capture_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698