Yuriy Romanenko | 33d5f66 | 2018-01-23 13:00:17 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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_HARDWARE_INTERFACES_CAMERA_COMMON_1_0_EXIF_H |
| 18 | #define ANDROID_HARDWARE_INTERFACES_CAMERA_COMMON_1_0_EXIF_H |
| 19 | |
| 20 | #include "CameraMetadata.h" |
| 21 | |
| 22 | namespace android { |
| 23 | namespace hardware { |
| 24 | namespace camera { |
| 25 | namespace common { |
Yuriy Romanenko | 33d5f66 | 2018-01-23 13:00:17 -0800 | [diff] [blame] | 26 | namespace helper { |
| 27 | |
Yuriy Romanenko | 33d5f66 | 2018-01-23 13:00:17 -0800 | [diff] [blame] | 28 | // This is based on the original ChromeOS ARC implementation of a V4L2 HAL |
| 29 | |
| 30 | // ExifUtils can generate APP1 segment with tags which caller set. ExifUtils can |
| 31 | // also add a thumbnail in the APP1 segment if thumbnail size is specified. |
| 32 | // ExifUtils can be reused with different images by calling initialize(). |
| 33 | // |
| 34 | // Example of using this class : |
| 35 | // std::unique_ptr<ExifUtils> utils(ExifUtils::Create()); |
| 36 | // utils->initialize(); |
| 37 | // ... |
| 38 | // // Call ExifUtils functions to set Exif tags. |
| 39 | // ... |
| 40 | // utils->GenerateApp1(thumbnail_buffer, thumbnail_size); |
| 41 | // unsigned int app1Length = utils->GetApp1Length(); |
| 42 | // uint8_t* app1Buffer = new uint8_t[app1Length]; |
| 43 | // memcpy(app1Buffer, utils->GetApp1Buffer(), app1Length); |
| 44 | class ExifUtils { |
Avichal Rakesh | 0d2d8a4 | 2022-06-14 17:23:40 -0700 | [diff] [blame] | 45 | public: |
Yuriy Romanenko | 33d5f66 | 2018-01-23 13:00:17 -0800 | [diff] [blame] | 46 | virtual ~ExifUtils(); |
| 47 | |
| 48 | static ExifUtils* create(); |
| 49 | |
| 50 | // Initialize() can be called multiple times. The setting of Exif tags will be |
| 51 | // cleared. |
| 52 | virtual bool initialize() = 0; |
| 53 | |
| 54 | // Set all known fields from a metadata structure |
Avichal Rakesh | 0d2d8a4 | 2022-06-14 17:23:40 -0700 | [diff] [blame] | 55 | virtual bool setFromMetadata(const CameraMetadata& metadata, const size_t imageWidth, |
Yuriy Romanenko | 33d5f66 | 2018-01-23 13:00:17 -0800 | [diff] [blame] | 56 | const size_t imageHeight) = 0; |
| 57 | |
| 58 | // Sets the len aperture. |
| 59 | // Returns false if memory allocation fails. |
| 60 | virtual bool setAperture(uint32_t numerator, uint32_t denominator) = 0; |
| 61 | |
| 62 | // Sets the value of brightness. |
| 63 | // Returns false if memory allocation fails. |
| 64 | virtual bool setBrightness(int32_t numerator, int32_t denominator) = 0; |
| 65 | |
| 66 | // Sets the color space. |
| 67 | // Returns false if memory allocation fails. |
| 68 | virtual bool setColorSpace(uint16_t color_space) = 0; |
| 69 | |
| 70 | // Sets the information to compressed data. |
| 71 | // Returns false if memory allocation fails. |
| 72 | virtual bool setComponentsConfiguration(const std::string& components_configuration) = 0; |
| 73 | |
| 74 | // Sets the compression scheme used for the image data. |
| 75 | // Returns false if memory allocation fails. |
| 76 | virtual bool setCompression(uint16_t compression) = 0; |
| 77 | |
| 78 | // Sets image contrast. |
| 79 | // Returns false if memory allocation fails. |
| 80 | virtual bool setContrast(uint16_t contrast) = 0; |
| 81 | |
| 82 | // Sets the date and time of image last modified. It takes local time. The |
| 83 | // name of the tag is DateTime in IFD0. |
| 84 | // Returns false if memory allocation fails. |
| 85 | virtual bool setDateTime(const struct tm& t) = 0; |
| 86 | |
| 87 | // Sets the image description. |
| 88 | // Returns false if memory allocation fails. |
| 89 | virtual bool setDescription(const std::string& description) = 0; |
| 90 | |
| 91 | // Sets the digital zoom ratio. If the numerator is 0, it means digital zoom |
| 92 | // was not used. |
| 93 | // Returns false if memory allocation fails. |
| 94 | virtual bool setDigitalZoomRatio(uint32_t numerator, uint32_t denominator) = 0; |
| 95 | |
| 96 | // Sets the exposure bias. |
| 97 | // Returns false if memory allocation fails. |
| 98 | virtual bool setExposureBias(int32_t numerator, int32_t denominator) = 0; |
| 99 | |
| 100 | // Sets the exposure mode set when the image was shot. |
| 101 | // Returns false if memory allocation fails. |
| 102 | virtual bool setExposureMode(uint16_t exposure_mode) = 0; |
| 103 | |
| 104 | // Sets the program used by the camera to set exposure when the picture is |
| 105 | // taken. |
| 106 | // Returns false if memory allocation fails. |
| 107 | virtual bool setExposureProgram(uint16_t exposure_program) = 0; |
| 108 | |
| 109 | // Sets the exposure time, given in seconds. |
| 110 | // Returns false if memory allocation fails. |
| 111 | virtual bool setExposureTime(uint32_t numerator, uint32_t denominator) = 0; |
| 112 | |
| 113 | // Sets the status of flash. |
| 114 | // Returns false if memory allocation fails. |
| 115 | virtual bool setFlash(uint16_t flash) = 0; |
| 116 | |
| 117 | // Sets the F number. |
| 118 | // Returns false if memory allocation fails. |
| 119 | virtual bool setFNumber(uint32_t numerator, uint32_t denominator) = 0; |
| 120 | |
| 121 | // Sets the focal length of lens used to take the image in millimeters. |
| 122 | // Returns false if memory allocation fails. |
| 123 | virtual bool setFocalLength(uint32_t numerator, uint32_t denominator) = 0; |
| 124 | |
| 125 | // Sets the degree of overall image gain adjustment. |
| 126 | // Returns false if memory allocation fails. |
| 127 | virtual bool setGainControl(uint16_t gain_control) = 0; |
| 128 | |
| 129 | // Sets the altitude in meters. |
| 130 | // Returns false if memory allocation fails. |
| 131 | virtual bool setGpsAltitude(double altitude) = 0; |
| 132 | |
| 133 | // Sets the latitude with degrees minutes seconds format. |
| 134 | // Returns false if memory allocation fails. |
| 135 | virtual bool setGpsLatitude(double latitude) = 0; |
| 136 | |
| 137 | // Sets the longitude with degrees minutes seconds format. |
| 138 | // Returns false if memory allocation fails. |
| 139 | virtual bool setGpsLongitude(double longitude) = 0; |
| 140 | |
| 141 | // Sets GPS processing method. |
| 142 | // Returns false if memory allocation fails. |
| 143 | virtual bool setGpsProcessingMethod(const std::string& method) = 0; |
| 144 | |
| 145 | // Sets GPS date stamp and time stamp (atomic clock). It takes UTC time. |
| 146 | // Returns false if memory allocation fails. |
| 147 | virtual bool setGpsTimestamp(const struct tm& t) = 0; |
| 148 | |
| 149 | // Sets the height (number of rows) of main image. |
| 150 | // Returns false if memory allocation fails. |
| 151 | virtual bool setImageHeight(uint32_t length) = 0; |
| 152 | |
| 153 | // Sets the width (number of columns) of main image. |
| 154 | // Returns false if memory allocation fails. |
| 155 | virtual bool setImageWidth(uint32_t width) = 0; |
| 156 | |
| 157 | // Sets the ISO speed. |
| 158 | // Returns false if memory allocation fails. |
| 159 | virtual bool setIsoSpeedRating(uint16_t iso_speed_ratings) = 0; |
| 160 | |
| 161 | // Sets the kind of light source. |
| 162 | // Returns false if memory allocation fails. |
| 163 | virtual bool setLightSource(uint16_t light_source) = 0; |
| 164 | |
| 165 | // Sets the smallest F number of the lens. |
| 166 | // Returns false if memory allocation fails. |
| 167 | virtual bool setMaxAperture(uint32_t numerator, uint32_t denominator) = 0; |
| 168 | |
| 169 | // Sets the metering mode. |
| 170 | // Returns false if memory allocation fails. |
| 171 | virtual bool setMeteringMode(uint16_t metering_mode) = 0; |
| 172 | |
| 173 | // Sets image orientation. |
| 174 | // Returns false if memory allocation fails. |
| 175 | virtual bool setOrientation(uint16_t orientation) = 0; |
| 176 | |
| 177 | // Sets the unit for measuring XResolution and YResolution. |
| 178 | // Returns false if memory allocation fails. |
| 179 | virtual bool setResolutionUnit(uint16_t resolution_unit) = 0; |
| 180 | |
| 181 | // Sets image saturation. |
| 182 | // Returns false if memory allocation fails. |
| 183 | virtual bool setSaturation(uint16_t saturation) = 0; |
| 184 | |
| 185 | // Sets the type of scene that was shot. |
| 186 | // Returns false if memory allocation fails. |
| 187 | virtual bool setSceneCaptureType(uint16_t type) = 0; |
| 188 | |
| 189 | // Sets image sharpness. |
| 190 | // Returns false if memory allocation fails. |
| 191 | virtual bool setSharpness(uint16_t sharpness) = 0; |
| 192 | |
| 193 | // Sets the shutter speed. |
| 194 | // Returns false if memory allocation fails. |
| 195 | virtual bool setShutterSpeed(int32_t numerator, int32_t denominator) = 0; |
| 196 | |
| 197 | // Sets the distance to the subject, given in meters. |
| 198 | // Returns false if memory allocation fails. |
| 199 | virtual bool setSubjectDistance(uint32_t numerator, uint32_t denominator) = 0; |
| 200 | |
| 201 | // Sets the fractions of seconds for the <DateTime> tag. |
| 202 | // Returns false if memory allocation fails. |
| 203 | virtual bool setSubsecTime(const std::string& subsec_time) = 0; |
| 204 | |
| 205 | // Sets the white balance mode set when the image was shot. |
| 206 | // Returns false if memory allocation fails. |
| 207 | virtual bool setWhiteBalance(uint16_t white_balance) = 0; |
| 208 | |
| 209 | // Sets the number of pixels per resolution unit in the image width. |
| 210 | // Returns false if memory allocation fails. |
| 211 | virtual bool setXResolution(uint32_t numerator, uint32_t denominator) = 0; |
| 212 | |
| 213 | // Sets the position of chrominance components in relation to the luminance |
| 214 | // component. |
| 215 | // Returns false if memory allocation fails. |
| 216 | virtual bool setYCbCrPositioning(uint16_t ycbcr_positioning) = 0; |
| 217 | |
| 218 | // Sets the number of pixels per resolution unit in the image length. |
| 219 | // Returns false if memory allocation fails. |
| 220 | virtual bool setYResolution(uint32_t numerator, uint32_t denominator) = 0; |
| 221 | |
| 222 | // Sets the manufacturer of camera. |
| 223 | // Returns false if memory allocation fails. |
| 224 | virtual bool setMake(const std::string& make) = 0; |
| 225 | |
| 226 | // Sets the model number of camera. |
| 227 | // Returns false if memory allocation fails. |
| 228 | virtual bool setModel(const std::string& model) = 0; |
| 229 | |
| 230 | // Generates APP1 segment. |
| 231 | // Returns false if generating APP1 segment fails. |
| 232 | virtual bool generateApp1(const void* thumbnail_buffer, uint32_t size) = 0; |
| 233 | |
| 234 | // Gets buffer of APP1 segment. This method must be called only after calling |
| 235 | // GenerateAPP1(). |
| 236 | virtual const uint8_t* getApp1Buffer() = 0; |
| 237 | |
| 238 | // Gets length of APP1 segment. This method must be called only after calling |
| 239 | // GenerateAPP1(). |
| 240 | virtual unsigned int getApp1Length() = 0; |
| 241 | }; |
| 242 | |
Avichal Rakesh | 0d2d8a4 | 2022-06-14 17:23:40 -0700 | [diff] [blame] | 243 | } // namespace helper |
Yuriy Romanenko | 33d5f66 | 2018-01-23 13:00:17 -0800 | [diff] [blame] | 244 | |
Avichal Rakesh | 0d2d8a4 | 2022-06-14 17:23:40 -0700 | [diff] [blame] | 245 | // NOTE: Deprecated namespace. This namespace should no longer be used for the following symbols |
| 246 | namespace V1_0::helper { |
| 247 | // Export symbols to the old namespace to preserve compatibility |
| 248 | typedef android::hardware::camera::common::helper::ExifUtils ExifUtils; |
| 249 | } // namespace V1_0::helper |
Yuriy Romanenko | 33d5f66 | 2018-01-23 13:00:17 -0800 | [diff] [blame] | 250 | |
Avichal Rakesh | 0d2d8a4 | 2022-06-14 17:23:40 -0700 | [diff] [blame] | 251 | } // namespace common |
| 252 | } // namespace camera |
| 253 | } // namespace hardware |
| 254 | } // namespace android |
Yuriy Romanenko | 33d5f66 | 2018-01-23 13:00:17 -0800 | [diff] [blame] | 255 | |
| 256 | #endif // ANDROID_HARDWARE_INTERFACES_CAMERA_COMMON_1_0_EXIF_H |