Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 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> |
Chien-Yu Chen | 676b21b | 2015-02-24 10:28:19 -0800 | [diff] [blame] | 23 | #include <utils/KeyedVector.h> |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 24 | |
| 25 | namespace 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 | */ |
| 33 | class CameraModule { |
| 34 | public: |
Chih-Hung Hsieh | 8b0b971 | 2016-08-09 14:25:53 -0700 | [diff] [blame] | 35 | explicit CameraModule(camera_module_t *module); |
Chien-Yu Chen | 944f843 | 2015-07-01 17:08:03 -0700 | [diff] [blame] | 36 | virtual ~CameraModule(); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 37 | |
Eino-Ville Talvala | 1527f07 | 2015-04-07 15:55:31 -0700 | [diff] [blame] | 38 | // Must be called after construction |
| 39 | // Returns OK on success, NO_INIT on failure |
| 40 | int init(); |
| 41 | |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 42 | int getCameraInfo(int cameraId, struct camera_info *info); |
| 43 | int getNumberOfCameras(void); |
| 44 | int open(const char* id, struct hw_device_t** device); |
| 45 | int openLegacy(const char* id, uint32_t halVersion, struct hw_device_t** device); |
| 46 | int setCallbacks(const camera_module_callbacks_t *callbacks); |
| 47 | bool isVendorTagDefined(); |
| 48 | void getVendorTagOps(vendor_tag_ops_t* ops); |
| 49 | int setTorchMode(const char* camera_id, bool enable); |
Chien-Yu Chen | 676b21b | 2015-02-24 10:28:19 -0800 | [diff] [blame] | 50 | uint16_t getModuleApiVersion(); |
| 51 | const char* getModuleName(); |
| 52 | uint16_t getHalApiVersion(); |
| 53 | const char* getModuleAuthor(); |
| 54 | // Only used by CameraModuleFixture native test. Do NOT use elsewhere. |
| 55 | void *getDso(); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 56 | |
| 57 | private: |
| 58 | // Derive camera characteristics keys defined after HAL device version |
| 59 | static void deriveCameraCharacteristicsKeys(uint32_t deviceVersion, CameraMetadata &chars); |
Yin-Chia Yeh | 4c06099 | 2016-04-11 17:40:12 -0700 | [diff] [blame] | 60 | // Helper function to append available[request|result|chars]Keys |
| 61 | static void appendAvailableKeys(CameraMetadata &chars, |
| 62 | int32_t keyTag, const Vector<int32_t>& appendKeys); |
Chien-Yu Chen | d231fd6 | 2015-02-25 16:04:22 -0800 | [diff] [blame] | 63 | status_t filterOpenErrorCode(status_t err); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 64 | camera_module_t *mModule; |
Yin-Chia Yeh | 54298b3 | 2015-03-24 16:51:41 -0700 | [diff] [blame] | 65 | KeyedVector<int, camera_info> mCameraInfoMap; |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 66 | Mutex mCameraInfoLock; |
| 67 | }; |
| 68 | |
| 69 | } // namespace android |
| 70 | |
| 71 | #endif |