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

Side by Side Diff: media/capture/video/chromeos/video_capture_device_factory_chromeos.cc

Issue 2837273004: media: add video capture device for ARC++ camera HAL v3 (Closed)
Patch Set: address wuchengli@'s comments Created 3 years, 7 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/capture/video/chromeos/video_capture_device_factory_chromeos.h"
6
7 #include "base/files/file_util.h"
8 #include "media/capture/video/linux/video_capture_device_factory_linux.h"
9
10 namespace media {
11
12 VideoCaptureDeviceFactoryChromeOS::VideoCaptureDeviceFactoryChromeOS(
13 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
14 : ui_task_runner_(ui_task_runner), module_thread_("CameraModuleThread") {}
15
16 VideoCaptureDeviceFactoryChromeOS::~VideoCaptureDeviceFactoryChromeOS() {}
17
18 bool VideoCaptureDeviceFactoryChromeOS::Init() {
19 if (!module_thread_.Start()) {
20 LOG(ERROR) << "Module thread failed to start";
21 return false;
22 }
23 camera_hal_delegate_ = new CameraHalDelegate(module_thread_.task_runner());
24 return camera_hal_delegate_->StartCameraModuleIpc();
25 }
26
27 std::unique_ptr<VideoCaptureDevice>
28 VideoCaptureDeviceFactoryChromeOS::CreateDevice(
29 const VideoCaptureDeviceDescriptor& device_descriptor) {
30 DCHECK(thread_checker_.CalledOnValidThread());
chfremer 2017/05/24 23:36:43 Not an issue introduced by this CL, but it feels w
jcliang 2017/05/25 14:23:48 I agree it's a bit weird. Can we do the clean up i
chfremer 2017/05/25 17:13:07 Agreed.
31 return camera_hal_delegate_->CreateDevice(ui_task_runner_, device_descriptor);
chfremer 2017/05/24 23:36:43 Nit: Should we DCHECK that Init() has been called
jcliang 2017/05/25 14:23:48 Done.
32 }
33
34 void VideoCaptureDeviceFactoryChromeOS::GetSupportedFormats(
35 const VideoCaptureDeviceDescriptor& device_descriptor,
36 VideoCaptureFormats* supported_formats) {
37 DCHECK(thread_checker_.CalledOnValidThread());
38 camera_hal_delegate_->GetSupportedFormats(device_descriptor,
39 supported_formats);
40 }
41
42 void VideoCaptureDeviceFactoryChromeOS::GetDeviceDescriptors(
43 VideoCaptureDeviceDescriptors* device_descriptors) {
44 DCHECK(thread_checker_.CalledOnValidThread());
45 camera_hal_delegate_->GetDeviceDescriptors(device_descriptors);
46 }
47
48 #if defined(OS_CHROMEOS)
49 const base::FilePath kArcCamera3Service("/usr/bin/arc_camera3_service");
50
51 // static
52 VideoCaptureDeviceFactory*
53 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory(
54 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
55 if (base::PathExists(kArcCamera3Service)) {
56 std::unique_ptr<VideoCaptureDeviceFactoryChromeOS> factory(
chfremer 2017/05/24 23:36:43 Please use base::MakeUnique<> here
jcliang 2017/05/25 14:23:48 Done.
57 new VideoCaptureDeviceFactoryChromeOS(ui_task_runner));
58 if (!factory->Init()) {
59 return nullptr;
60 }
61 return factory.release();
62 } else {
63 return new VideoCaptureDeviceFactoryLinux(ui_task_runner);
64 }
65 }
66 #endif
67
68 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698