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