blob: 28b40631a897a26a3a60641ddeadc0d95bad55fb
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 | |
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 | |
54 | EmulatedBaseCamera::~EmulatedBaseCamera() |
55 | { |
56 | } |
57 | |
58 | void EmulatedBaseCamera::setCameraStatus(camera_status_t status) |
59 | { |
60 | ALOGE("%s: do nothing", __FUNCTION__); |
61 | } |
62 | |
63 | camera_status_t EmulatedBaseCamera::getCameraStatus() |
64 | { |
65 | ALOGE("%s: do nothing", __FUNCTION__); |
66 | return CAMERA_READY_REMOVE; |
67 | } |
68 | |
69 | status_t EmulatedBaseCamera::getCameraInfo(struct camera_info* info) |
70 | { |
71 | ALOGV("%s", __FUNCTION__); |
72 | |
73 | info->device_version = mCameraDeviceVersion; |
74 | if (mCameraDeviceVersion >= HARDWARE_DEVICE_API_VERSION(2, 0)) { |
75 | info->static_camera_characteristics = mCameraInfo; |
76 | } else { |
77 | info->static_camera_characteristics = (camera_metadata_t*)0xcafef00d; |
78 | } |
79 | |
80 | return NO_ERROR; |
81 | } |
82 | |
83 | status_t EmulatedBaseCamera::plugCamera() { |
84 | ALOGE("%s: not supported", __FUNCTION__); |
85 | return INVALID_OPERATION; |
86 | } |
87 | |
88 | status_t EmulatedBaseCamera::unplugCamera() { |
89 | ALOGE("%s: not supported", __FUNCTION__); |
90 | return INVALID_OPERATION; |
91 | } |
92 | |
93 | camera_device_status_t EmulatedBaseCamera::getHotplugStatus() { |
94 | return CAMERA_DEVICE_STATUS_PRESENT; |
95 | } |
96 | |
97 | |
98 | |
99 | |
100 | } /* namespace android */ |
101 |