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.
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.
28 #define LOG_TAG "EmulatedCamera_BaseCamera"
29 #include <cutils/log.h>
31 #include "EmulatedBaseCamera.h"
35 EmulatedBaseCamera::EmulatedBaseCamera(int cameraId,
36 uint32_t cameraVersion,
37 struct hw_device_t* device,
38 struct hw_module_t* module)
41 mCameraDeviceVersion(cameraVersion)
44 * Initialize camera_device descriptor for this object.
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
54 EmulatedBaseCamera::~EmulatedBaseCamera()
58 status_t EmulatedBaseCamera::getCameraInfo(struct camera_info* info)
60 ALOGV("%s", __FUNCTION__);
62 info->device_version = mCameraDeviceVersion;
63 if (mCameraDeviceVersion >= HARDWARE_DEVICE_API_VERSION(2, 0)) {
64 info->static_camera_characteristics = mCameraInfo;
66 info->static_camera_characteristics = (camera_metadata_t*)0xcafef00d;
72 status_t EmulatedBaseCamera::plugCamera() {
73 ALOGE("%s: not supported", __FUNCTION__);
74 return INVALID_OPERATION;
77 status_t EmulatedBaseCamera::unplugCamera() {
78 ALOGE("%s: not supported", __FUNCTION__);
79 return INVALID_OPERATION;
82 camera_device_status_t EmulatedBaseCamera::getHotplugStatus() {
83 return CAMERA_DEVICE_STATUS_PRESENT;
89 } /* namespace android */