summaryrefslogtreecommitdiffstats
path: root/camera/EmulatedBaseCamera.cpp
blob: 0b85dcfcee6bab20b6e98bb25eadf0ca949ef886 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Contains implementation of a class EmulatedBaseCamera that encapsulates
 * functionality common to all emulated camera device versions ("fake",
 * "webcam", "video file", "cam2.0" etc.).  Instances of this class (for each
 * emulated camera) are created during the construction of the
 * EmulatedCameraFactory instance.  This class serves as an entry point for all
 * camera API calls that are common across all versions of the
 * camera_device_t/camera_module_t structures.
 */

#define LOG_NDEBUG 0
#define LOG_TAG "EmulatedCamera_BaseCamera"
#include <log/log.h>

#include "EmulatedBaseCamera.h"

namespace android {

EmulatedBaseCamera::EmulatedBaseCamera(int cameraId,
        uint32_t cameraVersion,
        struct hw_device_t* device,
        struct hw_module_t* module)
        : mCameraInfo(NULL),
          mCameraID(cameraId),
          mCameraDeviceVersion(cameraVersion)
{
    /*
     * Initialize camera_device descriptor for this object.
     */

    /* Common header */
    device->tag = HARDWARE_DEVICE_TAG;
    device->version = cameraVersion;
    device->module = module;
    device->close = NULL; // Must be filled in by child implementation
}

EmulatedBaseCamera::~EmulatedBaseCamera()
{
}

status_t EmulatedBaseCamera::getCameraInfo(struct camera_info* info)
{
    ALOGV("%s", __FUNCTION__);

    info->device_version = mCameraDeviceVersion;
    if (mCameraDeviceVersion >= HARDWARE_DEVICE_API_VERSION(2, 0)) {
        info->static_camera_characteristics = mCameraInfo;
    } else {
        info->static_camera_characteristics = (camera_metadata_t*)0xcafef00d;
    }

    return NO_ERROR;
}

status_t EmulatedBaseCamera::plugCamera() {
    ALOGE("%s: not supported", __FUNCTION__);
    return INVALID_OPERATION;
}

status_t EmulatedBaseCamera::unplugCamera() {
    ALOGE("%s: not supported", __FUNCTION__);
    return INVALID_OPERATION;
}

camera_device_status_t EmulatedBaseCamera::getHotplugStatus() {
    return CAMERA_DEVICE_STATUS_PRESENT;
}




} /* namespace android */