1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 /*
18  * Contains implementation of a class EmulatedBaseCamera that encapsulates
19  * functionality common to all emulated camera device versions ("fake",
20  * "webcam", "video file", "cam2.0" etc.).  Instances of this class (for each
21  * emulated camera) are created during the construction of the
22  * EmulatedCameraFactory instance.  This class serves as an entry point for all
23  * camera API calls that are common across all versions of the
24  * camera_device_t/camera_module_t structures.
25  */
26 
27 #define LOG_NDEBUG 0
28 #define LOG_TAG "EmulatedCamera_BaseCamera"
29 #include <cutils/log.h>
30 
31 #include "EmulatedBaseCamera.h"
32 
33 namespace android {
34 
EmulatedBaseCamera(int cameraId,uint32_t cameraVersion,struct hw_device_t * device,struct hw_module_t * module)35 EmulatedBaseCamera::EmulatedBaseCamera(int cameraId,
36         uint32_t cameraVersion,
37         struct hw_device_t* device,
38         struct hw_module_t* module)
39         : mCameraInfo(NULL),
40           mCameraID(cameraId),
41           mCameraDeviceVersion(cameraVersion)
42 {
43     /*
44      * Initialize camera_device descriptor for this object.
45      */
46 
47     /* Common header */
48     device->tag = HARDWARE_DEVICE_TAG;
49     device->version = cameraVersion;
50     device->module = module;
51     device->close = NULL; // Must be filled in by child implementation
52 }
53 
~EmulatedBaseCamera()54 EmulatedBaseCamera::~EmulatedBaseCamera()
55 {
56 }
57 
getCameraInfo(struct camera_info * info)58 status_t EmulatedBaseCamera::getCameraInfo(struct camera_info* info)
59 {
60     ALOGV("%s", __FUNCTION__);
61 
62     info->device_version = mCameraDeviceVersion;
63     if (mCameraDeviceVersion >= HARDWARE_DEVICE_API_VERSION(2, 0)) {
64         info->static_camera_characteristics = mCameraInfo;
65     } else {
66         info->static_camera_characteristics = (camera_metadata_t*)0xcafef00d;
67     }
68 
69     return NO_ERROR;
70 }
71 
plugCamera()72 status_t EmulatedBaseCamera::plugCamera() {
73     ALOGE("%s: not supported", __FUNCTION__);
74     return INVALID_OPERATION;
75 }
76 
unplugCamera()77 status_t EmulatedBaseCamera::unplugCamera() {
78     ALOGE("%s: not supported", __FUNCTION__);
79     return INVALID_OPERATION;
80 }
81 
getHotplugStatus()82 camera_device_status_t EmulatedBaseCamera::getHotplugStatus() {
83     return CAMERA_DEVICE_STATUS_PRESENT;
84 }
85 
86 
87 
88 
89 } /* namespace android */
90