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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: media/capture/video/chromeos/video_capture_device_factory_chromeos.cc
diff --git a/media/capture/video/chromeos/video_capture_device_factory_chromeos.cc b/media/capture/video/chromeos/video_capture_device_factory_chromeos.cc
new file mode 100644
index 0000000000000000000000000000000000000000..982d4d4a8f79b5418896f8a99df41f43caf9df26
--- /dev/null
+++ b/media/capture/video/chromeos/video_capture_device_factory_chromeos.cc
@@ -0,0 +1,68 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/capture/video/chromeos/video_capture_device_factory_chromeos.h"
+
+#include "base/files/file_util.h"
+#include "media/capture/video/linux/video_capture_device_factory_linux.h"
+
+namespace media {
+
+VideoCaptureDeviceFactoryChromeOS::VideoCaptureDeviceFactoryChromeOS(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
+ : ui_task_runner_(ui_task_runner), module_thread_("CameraModuleThread") {}
+
+VideoCaptureDeviceFactoryChromeOS::~VideoCaptureDeviceFactoryChromeOS() {}
+
+bool VideoCaptureDeviceFactoryChromeOS::Init() {
+ if (!module_thread_.Start()) {
+ LOG(ERROR) << "Module thread failed to start";
+ return false;
+ }
+ camera_hal_delegate_ = new CameraHalDelegate(module_thread_.task_runner());
+ return camera_hal_delegate_->StartCameraModuleIpc();
+}
+
+std::unique_ptr<VideoCaptureDevice>
+VideoCaptureDeviceFactoryChromeOS::CreateDevice(
+ const VideoCaptureDeviceDescriptor& device_descriptor) {
+ 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.
+ 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.
+}
+
+void VideoCaptureDeviceFactoryChromeOS::GetSupportedFormats(
+ const VideoCaptureDeviceDescriptor& device_descriptor,
+ VideoCaptureFormats* supported_formats) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ camera_hal_delegate_->GetSupportedFormats(device_descriptor,
+ supported_formats);
+}
+
+void VideoCaptureDeviceFactoryChromeOS::GetDeviceDescriptors(
+ VideoCaptureDeviceDescriptors* device_descriptors) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ camera_hal_delegate_->GetDeviceDescriptors(device_descriptors);
+}
+
+#if defined(OS_CHROMEOS)
+const base::FilePath kArcCamera3Service("/usr/bin/arc_camera3_service");
+
+// static
+VideoCaptureDeviceFactory*
+VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
+ if (base::PathExists(kArcCamera3Service)) {
+ 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.
+ new VideoCaptureDeviceFactoryChromeOS(ui_task_runner));
+ if (!factory->Init()) {
+ return nullptr;
+ }
+ return factory.release();
+ } else {
+ return new VideoCaptureDeviceFactoryLinux(ui_task_runner);
+ }
+}
+#endif
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698