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

Side by Side Diff: media/capture/video/chromeos/camera_hal_delegate.h

Issue 2878233002: media: add ArcCamera3Service Mojo service (Closed)
Patch Set: rebase on latest patch set of issue 2837273004 Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 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 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 #ifndef MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_HAL_DELEGATE_H_ 5 #ifndef MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_HAL_DELEGATE_H_
6 #define MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_HAL_DELEGATE_H_ 6 #define MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_HAL_DELEGATE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/sequence_checker.h" 13 #include "base/sequence_checker.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "media/capture/video/chromeos/arc_camera3_service.h"
16 #include "media/capture/video/chromeos/mojo/arc_camera3.mojom.h" 17 #include "media/capture/video/chromeos/mojo/arc_camera3.mojom.h"
17 #include "media/capture/video/video_capture_device_factory.h" 18 #include "media/capture/video/video_capture_device_factory.h"
18 #include "media/capture/video_capture_types.h" 19 #include "media/capture/video_capture_types.h"
19 #include "mojo/public/cpp/bindings/binding.h" 20 #include "mojo/public/cpp/bindings/binding.h"
20 21
21 namespace media { 22 namespace media {
22 23
23 // CameraHalDelegate is the component which does Mojo IPCs to the camera HAL 24 // CameraHalDelegate is the component which does Mojo IPCs to the camera HAL
24 // process on Chrome OS to access the module-level camera functionalities such 25 // process on Chrome OS to access the module-level camera functionalities such
25 // as camera device info look-up and opening camera devices. 26 // as camera device info look-up and opening camera devices.
26 // 27 //
27 // CameraHalDelegate is refcounted because VideoCaptureDeviceFactoryChromeOS and 28 // CameraHalDelegate is refcounted because VideoCaptureDeviceFactoryChromeOS and
28 // CameraDeviceDelegate both need to reference CameraHalDelegate, and 29 // CameraDeviceDelegate both need to reference CameraHalDelegate, and
29 // VideoCaptureDeviceFactoryChromeOS may be destroyed while CameraDeviceDelegate 30 // VideoCaptureDeviceFactoryChromeOS may be destroyed while CameraDeviceDelegate
30 // is still alive. 31 // is still alive.
31 class CAPTURE_EXPORT CameraHalDelegate final 32 class CAPTURE_EXPORT CameraHalDelegate final
32 : public base::RefCountedThreadSafe<CameraHalDelegate>, 33 : public base::RefCountedThreadSafe<CameraHalDelegate>,
33 public arc::mojom::CameraModuleCallbacks { 34 public arc::mojom::CameraModuleCallbacks {
34 public: 35 public:
35 // All the Mojo IPC operations happen on |ipc_task_runner|. 36 // All the Mojo IPC operations happen on |ipc_task_runner|.
36 explicit CameraHalDelegate( 37 explicit CameraHalDelegate(
37 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner); 38 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner);
38 39
39 // Establishes the Mojo IPC channel to the camera HAL adapter. This method 40 // Registers the camera client observer to the ArcCamera3Service Mojo service.
40 // should be called before any other methods of CameraHalDelegate is called. 41 void RegisterCameraClient();
41 bool StartCameraModuleIpc();
42 42
43 // Resets |camera_module_| and |camera_module_callbacks_|. 43 // Resets |camera_module_| and |camera_module_callbacks_|.
44 void Reset(); 44 void Reset();
45 45
46 // Delegation methods for the VideoCaptureDeviceFactory interface. These 46 // Delegation methods for the VideoCaptureDeviceFactory interface. These
47 // methods are called by VideoCaptureDeviceFactoryChromeOS directly. They 47 // methods are called by VideoCaptureDeviceFactoryChromeOS directly. They
48 // operate on the same thread that the VideoCaptureDeviceFactoryChromeOS runs 48 // operate on the same thread that the VideoCaptureDeviceFactoryChromeOS runs
49 // on. 49 // on.
50 std::unique_ptr<VideoCaptureDevice> CreateDevice( 50 std::unique_ptr<VideoCaptureDevice> CreateDevice(
51 scoped_refptr<base::SingleThreadTaskRunner> 51 scoped_refptr<base::SingleThreadTaskRunner>
(...skipping 18 matching lines...) Expand all
70 arc::mojom::Camera3DeviceOpsRequest device_ops_request, 70 arc::mojom::Camera3DeviceOpsRequest device_ops_request,
71 const OpenDeviceCallback& callback); 71 const OpenDeviceCallback& callback);
72 72
73 private: 73 private:
74 friend class base::RefCountedThreadSafe<CameraHalDelegate>; 74 friend class base::RefCountedThreadSafe<CameraHalDelegate>;
75 75
76 ~CameraHalDelegate(); 76 ~CameraHalDelegate();
77 77
78 friend class CameraHalDelegateTest; 78 friend class CameraHalDelegateTest;
79 friend class CameraDeviceDelegateTest; 79 friend class CameraDeviceDelegateTest;
80 void StartForTesting(arc::mojom::CameraModulePtrInfo info); 80
81 class LocalCameraClient : public ArcCamera3Service::CameraClientObserver {
82 public:
83 LocalCameraClient(scoped_refptr<CameraHalDelegate> camera_hal_delegate);
84
85 void NotifyCameraHalRegistered(arc::mojom::CameraModulePtr camera_module);
86
87 private:
88 scoped_refptr<CameraHalDelegate> camera_hal_delegate_;
89 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalCameraClient);
90 };
91
92 void SetCameraModule(arc::mojom::CameraModulePtrInfo camera_module_ptr_info);
93 base::WaitableEvent camera_module_set_;
94
95 // Mojo connection error handler. On Mojo connection error, the handler will
96 // try to re-establish the Mojo connection to the camera HAL.
97 void SetConnectionErrorHandlerOnModuleThread();
98 void HandleMojoConnectionErrorOnModuleThread();
81 99
82 // Resets the Mojo interface and bindings. 100 // Resets the Mojo interface and bindings.
83 void ResetMojoInterfaceOnModuleThread(); 101 void ResetMojoInterfaceOnModuleThread();
84 102
85 // Internal method to update the camera info for all built-in cameras. Runs on 103 // Internal method to update the camera info for all built-in cameras. Runs on
86 // the same thread as CreateDevice, GetSupportedFormats, and 104 // the same thread as CreateDevice, GetSupportedFormats, and
87 // GetDeviceDescriptors. 105 // GetDeviceDescriptors.
88 bool UpdateBuiltInCameraInfo(); 106 bool UpdateBuiltInCameraInfo();
89 void UpdateBuiltInCameraInfoOnModuleThread(); 107 void UpdateBuiltInCameraInfoOnModuleThread();
90 // Callback for GetNumberOfCameras Mojo IPC function. GetNumberOfCameras 108 // Callback for GetNumberOfCameras Mojo IPC function. GetNumberOfCameras
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // The Mojo binding serving the camera module callbacks. Bound to 156 // The Mojo binding serving the camera module callbacks. Bound to
139 // |ipc_task_runner_|. 157 // |ipc_task_runner_|.
140 mojo::Binding<arc::mojom::CameraModuleCallbacks> camera_module_callbacks_; 158 mojo::Binding<arc::mojom::CameraModuleCallbacks> camera_module_callbacks_;
141 159
142 DISALLOW_COPY_AND_ASSIGN(CameraHalDelegate); 160 DISALLOW_COPY_AND_ASSIGN(CameraHalDelegate);
143 }; 161 };
144 162
145 } // namespace media 163 } // namespace media
146 164
147 #endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_HAL_DELEGATE_H_ 165 #endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_HAL_DELEGATE_H_
OLDNEW
« no previous file with comments | « media/capture/video/chromeos/camera_device_delegate_unittest.cc ('k') | media/capture/video/chromeos/camera_hal_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698