2 * Copyright (C) 2012 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef HW_EMULATOR_CAMERA_EMULATED_BASE_CAMERA_H
18 #define HW_EMULATOR_CAMERA_EMULATED_BASE_CAMERA_H
20 #include <hardware/camera_common.h>
21 #include <utils/Errors.h>
26 * Contains declaration of a class EmulatedBaseCamera that encapsulates
27 * functionality common to all emulated camera device versions ("fake",
28 * "webcam", "video file", etc.). Instances of this class (for each emulated
29 * camera) are created during the construction of the EmulatedCameraFactory
30 * instance. This class serves as an entry point for all camera API calls that
31 * are common across all versions of the camera_device_t/camera_module_t
35 class EmulatedBaseCamera {
37 EmulatedBaseCamera(int cameraId,
38 uint32_t cameraVersion,
39 struct hw_device_t* device,
40 struct hw_module_t* module);
42 virtual ~EmulatedBaseCamera();
44 /****************************************************************************
46 ***************************************************************************/
49 /* Initializes EmulatedCamera instance.
51 * NO_ERROR on success, or an appropriate error status on failure.
53 virtual status_t Initialize() = 0;
55 /****************************************************************************
56 * Camera API implementation
57 ***************************************************************************/
60 /* Creates connection to the emulated camera device.
61 * This method is called in response to hw_module_methods_t::open callback.
62 * NOTE: When this method is called the object is locked.
63 * Note that failures in this method are reported as negative EXXX statuses.
65 virtual status_t connectCamera(hw_device_t** device) = 0;
68 /* Plug the connection for the emulated camera. Until it's plugged in
69 * calls to connectCamera should fail with -ENODEV.
71 virtual status_t plugCamera();
73 /* Unplug the connection from underneath the emulated camera.
74 * This is similar to closing the camera, except that
75 * all function calls into the camera device will return
76 * -EPIPE errors until the camera is reopened.
78 virtual status_t unplugCamera();
80 virtual camera_device_status_t getHotplugStatus();
82 /* Closes connection to the emulated camera.
83 * This method is called in response to camera_device::close callback.
84 * NOTE: When this method is called the object is locked.
85 * Note that failures in this method are reported as negative EXXX statuses.
87 virtual status_t closeCamera() = 0;
89 /* Gets camera information.
90 * This method is called in response to camera_module_t::get_camera_info
92 * NOTE: When this method is called the object is locked.
93 * Note that failures in this method are reported as negative EXXX statuses.
95 virtual status_t getCameraInfo(struct camera_info* info) = 0;
97 /****************************************************************************
99 ***************************************************************************/
102 /* Fixed camera information for camera2 devices. Must be valid to access if
103 * mCameraDeviceVersion is >= HARDWARE_DEVICE_API_VERSION(2,0) */
104 camera_metadata_t *mCameraInfo;
106 /* Zero-based ID assigned to this camera. */
111 /* Version of the camera device HAL implemented by this camera */
112 int mCameraDeviceVersion;
115 } /* namespace android */
117 #endif /* HW_EMULATOR_CAMERA_EMULATED_BASE_CAMERA_H */