CameraModule.h revision 54298b338cf9f782f2ac681a15e6cbbb99649350
1/* 2 * Copyright (C) 2015 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#ifndef ANDROID_SERVERS_CAMERA_CAMERAMODULE_H 18#define ANDROID_SERVERS_CAMERA_CAMERAMODULE_H 19 20#include <hardware/camera.h> 21#include <camera/CameraMetadata.h> 22#include <utils/Mutex.h> 23#include <utils/KeyedVector.h> 24 25namespace android { 26/** 27 * A wrapper class for HAL camera module. 28 * 29 * This class wraps camera_module_t returned from HAL to provide a wrapped 30 * get_camera_info implementation which CameraService generates some 31 * camera characteristics keys defined in newer HAL version on an older HAL. 32 */ 33class CameraModule { 34public: 35 CameraModule(camera_module_t *module); 36 37 int getCameraInfo(int cameraId, struct camera_info *info); 38 int getNumberOfCameras(void); 39 int open(const char* id, struct hw_device_t** device); 40 int openLegacy(const char* id, uint32_t halVersion, struct hw_device_t** device); 41 int setCallbacks(const camera_module_callbacks_t *callbacks); 42 bool isVendorTagDefined(); 43 void getVendorTagOps(vendor_tag_ops_t* ops); 44 int setTorchMode(const char* camera_id, bool enable); 45 uint16_t getModuleApiVersion(); 46 const char* getModuleName(); 47 uint16_t getHalApiVersion(); 48 const char* getModuleAuthor(); 49 // Only used by CameraModuleFixture native test. Do NOT use elsewhere. 50 void *getDso(); 51 52private: 53 // Derive camera characteristics keys defined after HAL device version 54 static void deriveCameraCharacteristicsKeys(uint32_t deviceVersion, CameraMetadata &chars); 55 status_t filterOpenErrorCode(status_t err); 56 57 camera_module_t *mModule; 58 KeyedVector<int, camera_info> mCameraInfoMap; 59 KeyedVector<int, CameraMetadata> mCameraCharacteristicsMap; 60 Mutex mCameraInfoLock; 61}; 62 63} // namespace android 64 65#endif 66 67