• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 //#define LOG_NDEBUG 0
18 #define LOG_TAG "ACameraMetadata"
19 
20 #include "ACameraMetadata.h"
21 #include <utils/Vector.h>
22 #include <system/graphics.h>
23 #include <media/NdkImage.h>
24 
25 using namespace android;
26 
27 // Formats not listed in the public API, but still available to AImageReader
28 // Enum value must match corresponding enum in ui/PublicFormat.h (which is not
29 // available to VNDK)
30 enum AIMAGE_PRIVATE_FORMATS {
31     /**
32      * Unprocessed implementation-dependent raw
33      * depth measurements, opaque with 16 bit
34      * samples.
35      *
36      */
37 
38     AIMAGE_FORMAT_RAW_DEPTH = 0x1002,
39 
40     /**
41      * Device specific 10 bits depth RAW image format.
42      *
43      * <p>Unprocessed implementation-dependent raw depth measurements, opaque with 10 bit samples
44      * and device specific bit layout.</p>
45      */
46     AIMAGE_FORMAT_RAW_DEPTH10 = 0x1003,
47 };
48 
49 /**
50  * ACameraMetadata Implementation
51  */
ACameraMetadata(camera_metadata_t * buffer,ACAMERA_METADATA_TYPE type)52 ACameraMetadata::ACameraMetadata(camera_metadata_t* buffer, ACAMERA_METADATA_TYPE type) :
53         mData(std::make_shared<CameraMetadata>(buffer)),
54         mType(type) {
55     init();
56 }
57 
ACameraMetadata(const std::shared_ptr<CameraMetadata> & cameraMetadata,ACAMERA_METADATA_TYPE type)58 ACameraMetadata::ACameraMetadata(const std::shared_ptr<CameraMetadata>& cameraMetadata,
59         ACAMERA_METADATA_TYPE type) :
60         mData(cameraMetadata),
61         mType(type) {
62     init();
63 }
64 
ACameraMetadata(const ACameraMetadata & other)65 ACameraMetadata::ACameraMetadata(const ACameraMetadata& other) :
66         mData(std::make_shared<CameraMetadata>(*(other.mData))),
67         mType(other.mType) {
68 }
69 
~ACameraMetadata()70 ACameraMetadata::~ACameraMetadata() {
71 }
72 
73 void
init()74 ACameraMetadata::init() {
75     if (mType == ACM_CHARACTERISTICS) {
76         filterUnsupportedFeatures();
77         filterStreamConfigurations();
78         filterDurations(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS);
79         filterDurations(ANDROID_SCALER_AVAILABLE_STALL_DURATIONS);
80         filterDurations(ANDROID_DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS);
81         filterDurations(ANDROID_DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS);
82         filterDurations(ANDROID_HEIC_AVAILABLE_HEIC_MIN_FRAME_DURATIONS);
83         filterDurations(ANDROID_HEIC_AVAILABLE_HEIC_STALL_DURATIONS);
84         filterDurations(ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_MIN_FRAME_DURATIONS);
85         filterDurations(ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STALL_DURATIONS);
86     }
87     // TODO: filter request/result keys
88 }
89 
90 bool
isNdkSupportedCapability(int32_t capability)91 ACameraMetadata::isNdkSupportedCapability(int32_t capability) {
92     switch (capability) {
93         case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING:
94         case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING:
95         case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO:
96             return false;
97         default:
98             // Assuming every capability passed to this function is actually a
99             // valid capability.
100             return true;
101     }
102 }
103 
104 void
filterUnsupportedFeatures()105 ACameraMetadata::filterUnsupportedFeatures() {
106     // Hide unsupported capabilities (reprocessing)
107     camera_metadata_entry entry = mData->find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
108     if (entry.count == 0 || entry.type != TYPE_BYTE) {
109         ALOGE("%s: malformed available capability key! count %zu, type %d",
110                 __FUNCTION__, entry.count, entry.type);
111         return;
112     }
113 
114     Vector<uint8_t> capabilities;
115     capabilities.setCapacity(entry.count);
116     for (size_t i = 0; i < entry.count; i++) {
117         uint8_t capability = entry.data.u8[i];
118         if (isNdkSupportedCapability(capability)) {
119             capabilities.push(capability);
120 
121             if (capability == ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA) {
122                 derivePhysicalCameraIds();
123             }
124         }
125     }
126     mData->update(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, capabilities);
127 }
128 
129 void
derivePhysicalCameraIds()130 ACameraMetadata::derivePhysicalCameraIds() {
131     ACameraMetadata_const_entry entry;
132     auto ret = getConstEntry(ACAMERA_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS, &entry);
133     if (ret != ACAMERA_OK) {
134         ALOGE("%s: Get ACAMERA_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS key failed. ret %d",
135                 __FUNCTION__, ret);
136         return;
137     }
138 
139     const uint8_t* ids = entry.data.u8;
140     size_t start = 0;
141     for (size_t i = 0; i < entry.count; ++i) {
142         if (ids[i] == '\0') {
143             if (start != i) {
144                 mStaticPhysicalCameraIdValues.push_back(String8((const char *)ids+start));
145                 mStaticPhysicalCameraIds.push_back(mStaticPhysicalCameraIdValues.back().string());
146             }
147             start = i+1;
148         }
149     }
150 
151     if (mStaticPhysicalCameraIds.size() < 2) {
152         ALOGW("%s: Logical multi-camera device only has %zu physical cameras",
153                 __FUNCTION__, mStaticPhysicalCameraIds.size());
154     }
155 }
156 
157 void
filterDurations(uint32_t tag)158 ACameraMetadata::filterDurations(uint32_t tag) {
159     const int STREAM_CONFIGURATION_SIZE = 4;
160     const int STREAM_FORMAT_OFFSET = 0;
161     const int STREAM_WIDTH_OFFSET = 1;
162     const int STREAM_HEIGHT_OFFSET = 2;
163     const int STREAM_DURATION_OFFSET = 3;
164 
165     camera_metadata_entry entry = mData->find(tag);
166 
167     if (entry.count == 0) {
168         // Duration keys can be missing when corresponding capture feature is not supported
169         return;
170     }
171 
172     if (entry.count % 4 || entry.type != TYPE_INT64) {
173         ALOGE("%s: malformed duration key %d! count %zu, type %d",
174                 __FUNCTION__, tag, entry.count, entry.type);
175         return;
176     }
177 
178     Vector<int64_t> filteredDurations;
179     filteredDurations.setCapacity(entry.count * 2);
180 
181     for (size_t i=0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) {
182         int64_t format = entry.data.i64[i + STREAM_FORMAT_OFFSET];
183         int64_t width = entry.data.i64[i + STREAM_WIDTH_OFFSET];
184         int64_t height = entry.data.i64[i + STREAM_HEIGHT_OFFSET];
185         int64_t duration = entry.data.i32[i + STREAM_DURATION_OFFSET];
186 
187         // Leave the unfiltered format in so apps depending on previous wrong
188         // filter behavior continue to work
189         filteredDurations.push_back(format);
190         filteredDurations.push_back(width);
191         filteredDurations.push_back(height);
192         filteredDurations.push_back(duration);
193 
194         // Translate HAL formats to NDK format
195         switch (tag) {
196             case ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS:
197             case ANDROID_SCALER_AVAILABLE_STALL_DURATIONS:
198                 if (format == HAL_PIXEL_FORMAT_BLOB) {
199                     format = AIMAGE_FORMAT_JPEG;
200                     filteredDurations.push_back(format);
201                     filteredDurations.push_back(width);
202                     filteredDurations.push_back(height);
203                     filteredDurations.push_back(duration);
204                 }
205                 break;
206             case ANDROID_DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS:
207             case ANDROID_DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS:
208                 if (format == HAL_PIXEL_FORMAT_BLOB) {
209                     format = AIMAGE_FORMAT_DEPTH_POINT_CLOUD;
210                     filteredDurations.push_back(format);
211                     filteredDurations.push_back(width);
212                     filteredDurations.push_back(height);
213                     filteredDurations.push_back(duration);
214                 } else if (format == HAL_PIXEL_FORMAT_Y16) {
215                     format = AIMAGE_FORMAT_DEPTH16;
216                     filteredDurations.push_back(format);
217                     filteredDurations.push_back(width);
218                     filteredDurations.push_back(height);
219                     filteredDurations.push_back(duration);
220                 }
221                 break;
222             case ANDROID_HEIC_AVAILABLE_HEIC_MIN_FRAME_DURATIONS:
223             case ANDROID_HEIC_AVAILABLE_HEIC_STALL_DURATIONS:
224                 if (format == HAL_PIXEL_FORMAT_BLOB) {
225                     format = AIMAGE_FORMAT_HEIC;
226                     filteredDurations.push_back(format);
227                     filteredDurations.push_back(width);
228                     filteredDurations.push_back(height);
229                     filteredDurations.push_back(duration);
230                 }
231                 break;
232             case ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_MIN_FRAME_DURATIONS:
233             case ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STALL_DURATIONS:
234                 if (format == HAL_PIXEL_FORMAT_BLOB) {
235                     format = AIMAGE_FORMAT_DEPTH_JPEG;
236                     filteredDurations.push_back(format);
237                     filteredDurations.push_back(width);
238                     filteredDurations.push_back(height);
239                     filteredDurations.push_back(duration);
240                 }
241                 break;
242             default:
243                 // Should not reach here
244                 ALOGE("%s: Unkown tag 0x%x", __FUNCTION__, tag);
245         }
246     }
247 
248     mData->update(tag, filteredDurations);
249 }
250 
251 void
filterStreamConfigurations()252 ACameraMetadata::filterStreamConfigurations() {
253     const int STREAM_CONFIGURATION_SIZE = 4;
254     const int STREAM_FORMAT_OFFSET = 0;
255     const int STREAM_WIDTH_OFFSET = 1;
256     const int STREAM_HEIGHT_OFFSET = 2;
257     const int STREAM_IS_INPUT_OFFSET = 3;
258     camera_metadata_entry entry = mData->find(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS);
259     if (entry.count > 0 && (entry.count % 4 || entry.type != TYPE_INT32)) {
260         ALOGE("%s: malformed available stream configuration key! count %zu, type %d",
261                 __FUNCTION__, entry.count, entry.type);
262         return;
263     }
264 
265     Vector<int32_t> filteredStreamConfigs;
266     filteredStreamConfigs.setCapacity(entry.count);
267 
268     for (size_t i=0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) {
269         int32_t format = entry.data.i32[i + STREAM_FORMAT_OFFSET];
270         int32_t width = entry.data.i32[i + STREAM_WIDTH_OFFSET];
271         int32_t height = entry.data.i32[i + STREAM_HEIGHT_OFFSET];
272         int32_t isInput = entry.data.i32[i + STREAM_IS_INPUT_OFFSET];
273         if (isInput == ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_INPUT) {
274             // Hide input streams
275             continue;
276         }
277         // Translate HAL formats to NDK format
278         if (format == HAL_PIXEL_FORMAT_BLOB) {
279             format = AIMAGE_FORMAT_JPEG;
280         }
281         filteredStreamConfigs.push_back(format);
282         filteredStreamConfigs.push_back(width);
283         filteredStreamConfigs.push_back(height);
284         filteredStreamConfigs.push_back(isInput);
285     }
286 
287     if (filteredStreamConfigs.size() > 0) {
288         mData->update(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, filteredStreamConfigs);
289     }
290 
291     entry = mData->find(ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS);
292     if (entry.count > 0 && (entry.count % 4 || entry.type != TYPE_INT32)) {
293         ALOGE("%s: malformed available depth stream configuration key! count %zu, type %d",
294                 __FUNCTION__, entry.count, entry.type);
295         return;
296     }
297 
298     Vector<int32_t> filteredDepthStreamConfigs;
299     filteredDepthStreamConfigs.setCapacity(entry.count);
300 
301     for (size_t i=0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) {
302         int32_t format = entry.data.i32[i + STREAM_FORMAT_OFFSET];
303         int32_t width = entry.data.i32[i + STREAM_WIDTH_OFFSET];
304         int32_t height = entry.data.i32[i + STREAM_HEIGHT_OFFSET];
305         int32_t isInput = entry.data.i32[i + STREAM_IS_INPUT_OFFSET];
306         if (isInput == ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_INPUT) {
307             // Hide input streams
308             continue;
309         }
310         // Translate HAL formats to NDK format
311         if (format == HAL_PIXEL_FORMAT_BLOB) {
312             format = AIMAGE_FORMAT_DEPTH_POINT_CLOUD;
313         } else if (format == HAL_PIXEL_FORMAT_Y16) {
314             format = AIMAGE_FORMAT_DEPTH16;
315         } else if (format == HAL_PIXEL_FORMAT_RAW16) {
316             format = static_cast<int32_t>(AIMAGE_FORMAT_RAW_DEPTH);
317         } else if (format == HAL_PIXEL_FORMAT_RAW10) {
318             format = static_cast<int32_t>(AIMAGE_FORMAT_RAW_DEPTH10);
319         }
320 
321         filteredDepthStreamConfigs.push_back(format);
322         filteredDepthStreamConfigs.push_back(width);
323         filteredDepthStreamConfigs.push_back(height);
324         filteredDepthStreamConfigs.push_back(isInput);
325     }
326 
327     if (filteredDepthStreamConfigs.size() > 0) {
328         mData->update(ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS,
329                 filteredDepthStreamConfigs);
330     }
331 
332     entry = mData->find(ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS);
333     Vector<int32_t> filteredHeicStreamConfigs;
334     filteredHeicStreamConfigs.setCapacity(entry.count);
335 
336     for (size_t i=0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) {
337         int32_t format = entry.data.i32[i + STREAM_FORMAT_OFFSET];
338         int32_t width = entry.data.i32[i + STREAM_WIDTH_OFFSET];
339         int32_t height = entry.data.i32[i + STREAM_HEIGHT_OFFSET];
340         int32_t isInput = entry.data.i32[i + STREAM_IS_INPUT_OFFSET];
341         if (isInput == ACAMERA_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS_INPUT) {
342             // Hide input streams
343             continue;
344         }
345         // Translate HAL formats to NDK format
346         if (format == HAL_PIXEL_FORMAT_BLOB) {
347             format = AIMAGE_FORMAT_HEIC;
348         }
349 
350         filteredHeicStreamConfigs.push_back(format);
351         filteredHeicStreamConfigs.push_back(width);
352         filteredHeicStreamConfigs.push_back(height);
353         filteredHeicStreamConfigs.push_back(isInput);
354     }
355     mData->update(ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS, filteredHeicStreamConfigs);
356 
357     entry = mData->find(ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS);
358     Vector<int32_t> filteredDynamicDepthStreamConfigs;
359     filteredDynamicDepthStreamConfigs.setCapacity(entry.count);
360 
361     for (size_t i = 0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) {
362         int32_t format = entry.data.i32[i + STREAM_FORMAT_OFFSET];
363         int32_t width = entry.data.i32[i + STREAM_WIDTH_OFFSET];
364         int32_t height = entry.data.i32[i + STREAM_HEIGHT_OFFSET];
365         int32_t isInput = entry.data.i32[i + STREAM_IS_INPUT_OFFSET];
366         if (isInput == ACAMERA_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS_INPUT) {
367             // Hide input streams
368             continue;
369         }
370         // Translate HAL formats to NDK format
371         if (format == HAL_PIXEL_FORMAT_BLOB) {
372             format = AIMAGE_FORMAT_DEPTH_JPEG;
373         }
374 
375         filteredDynamicDepthStreamConfigs.push_back(format);
376         filteredDynamicDepthStreamConfigs.push_back(width);
377         filteredDynamicDepthStreamConfigs.push_back(height);
378         filteredDynamicDepthStreamConfigs.push_back(isInput);
379     }
380     mData->update(ACAMERA_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS,
381             filteredDynamicDepthStreamConfigs);
382 }
383 
384 bool
isVendorTag(const uint32_t tag)385 ACameraMetadata::isVendorTag(const uint32_t tag) {
386     uint32_t tag_section = tag >> 16;
387     if (tag_section >= VENDOR_SECTION) {
388         return true;
389     }
390     return false;
391 }
392 
393 camera_status_t
getConstEntry(uint32_t tag,ACameraMetadata_const_entry * entry) const394 ACameraMetadata::getConstEntry(uint32_t tag, ACameraMetadata_const_entry* entry) const {
395     if (entry == nullptr) {
396         return ACAMERA_ERROR_INVALID_PARAMETER;
397     }
398 
399     Mutex::Autolock _l(mLock);
400 
401     camera_metadata_ro_entry rawEntry = static_cast<const CameraMetadata*>(mData.get())->find(tag);
402     if (rawEntry.count == 0) {
403         ALOGE("%s: cannot find metadata tag %d", __FUNCTION__, tag);
404         return ACAMERA_ERROR_METADATA_NOT_FOUND;
405     }
406     entry->tag = tag;
407     entry->type = rawEntry.type;
408     entry->count = rawEntry.count;
409     entry->data.u8 = rawEntry.data.u8;
410     return ACAMERA_OK;
411 }
412 
413 camera_status_t
update(uint32_t tag,uint32_t count,const uint8_t * data)414 ACameraMetadata::update(uint32_t tag, uint32_t count, const uint8_t* data) {
415     return updateImpl<uint8_t>(tag, count, data);
416 }
417 
418 camera_status_t
update(uint32_t tag,uint32_t count,const int32_t * data)419 ACameraMetadata::update(uint32_t tag, uint32_t count, const int32_t* data) {
420     return updateImpl<int32_t>(tag, count, data);
421 }
422 
423 camera_status_t
update(uint32_t tag,uint32_t count,const float * data)424 ACameraMetadata::update(uint32_t tag, uint32_t count, const float* data) {
425     return updateImpl<float>(tag, count, data);
426 }
427 
428 camera_status_t
update(uint32_t tag,uint32_t count,const double * data)429 ACameraMetadata::update(uint32_t tag, uint32_t count, const double* data) {
430     return updateImpl<double>(tag, count, data);
431 }
432 
433 camera_status_t
update(uint32_t tag,uint32_t count,const int64_t * data)434 ACameraMetadata::update(uint32_t tag, uint32_t count, const int64_t* data) {
435     return updateImpl<int64_t>(tag, count, data);
436 }
437 
438 camera_status_t
update(uint32_t tag,uint32_t count,const ACameraMetadata_rational * data)439 ACameraMetadata::update(uint32_t tag, uint32_t count, const ACameraMetadata_rational* data) {
440     return updateImpl<camera_metadata_rational_t>(tag, count, data);
441 }
442 
443 camera_status_t
getTags(int32_t * numTags,const uint32_t ** tags) const444 ACameraMetadata::getTags(/*out*/int32_t* numTags,
445                          /*out*/const uint32_t** tags) const {
446     Mutex::Autolock _l(mLock);
447     if (mTags.size() == 0) {
448         size_t entry_count = mData->entryCount();
449         mTags.setCapacity(entry_count);
450         const camera_metadata_t* rawMetadata = mData->getAndLock();
451         for (size_t i = 0; i < entry_count; i++) {
452             camera_metadata_ro_entry_t entry;
453             int ret = get_camera_metadata_ro_entry(rawMetadata, i, &entry);
454             if (ret != 0) {
455                 mData->unlock(rawMetadata);
456                 ALOGE("%s: error reading metadata index %zu", __FUNCTION__, i);
457                 return ACAMERA_ERROR_UNKNOWN;
458             }
459             // Hide system key from users
460             if (sSystemTags.count(entry.tag) == 0) {
461                 mTags.push_back(entry.tag);
462             }
463         }
464         mData->unlock(rawMetadata);
465     }
466 
467     *numTags = mTags.size();
468     *tags = mTags.array();
469     return ACAMERA_OK;
470 }
471 
472 const CameraMetadata&
getInternalData() const473 ACameraMetadata::getInternalData() const {
474     return (*mData);
475 }
476 
477 bool
isLogicalMultiCamera(size_t * count,const char * const ** physicalCameraIds) const478 ACameraMetadata::isLogicalMultiCamera(size_t* count, const char*const** physicalCameraIds) const {
479     if (mType != ACM_CHARACTERISTICS) {
480         ALOGE("%s must be called for a static metadata!", __FUNCTION__);
481         return false;
482     }
483     if (count == nullptr || physicalCameraIds == nullptr) {
484         ALOGE("%s: Invalid input count: %p, physicalCameraIds: %p", __FUNCTION__,
485                 count, physicalCameraIds);
486         return false;
487     }
488 
489     if (mStaticPhysicalCameraIds.size() >= 2) {
490         *count = mStaticPhysicalCameraIds.size();
491         *physicalCameraIds = mStaticPhysicalCameraIds.data();
492         return true;
493     }
494 
495     return false;
496 }
497 
498 // TODO: some of key below should be hidden from user
499 // ex: ACAMERA_REQUEST_ID and ACAMERA_REPROCESS_EFFECTIVE_EXPOSURE_FACTOR
500 /*@O~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
501  * The key entries below this point are generated from metadata
502  * definitions in /system/media/camera/docs. Do not modify by hand or
503  * modify the comment blocks at the start or end.
504  *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~*/
505 
506 bool
isCaptureRequestTag(const uint32_t tag)507 ACameraMetadata::isCaptureRequestTag(const uint32_t tag) {
508     // Skip check for vendor keys
509     if (isVendorTag(tag)) {
510         return true;
511     }
512 
513     switch (tag) {
514         case ACAMERA_COLOR_CORRECTION_MODE:
515         case ACAMERA_COLOR_CORRECTION_TRANSFORM:
516         case ACAMERA_COLOR_CORRECTION_GAINS:
517         case ACAMERA_COLOR_CORRECTION_ABERRATION_MODE:
518         case ACAMERA_CONTROL_AE_ANTIBANDING_MODE:
519         case ACAMERA_CONTROL_AE_EXPOSURE_COMPENSATION:
520         case ACAMERA_CONTROL_AE_LOCK:
521         case ACAMERA_CONTROL_AE_MODE:
522         case ACAMERA_CONTROL_AE_REGIONS:
523         case ACAMERA_CONTROL_AE_TARGET_FPS_RANGE:
524         case ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER:
525         case ACAMERA_CONTROL_AF_MODE:
526         case ACAMERA_CONTROL_AF_REGIONS:
527         case ACAMERA_CONTROL_AF_TRIGGER:
528         case ACAMERA_CONTROL_AWB_LOCK:
529         case ACAMERA_CONTROL_AWB_MODE:
530         case ACAMERA_CONTROL_AWB_REGIONS:
531         case ACAMERA_CONTROL_CAPTURE_INTENT:
532         case ACAMERA_CONTROL_EFFECT_MODE:
533         case ACAMERA_CONTROL_MODE:
534         case ACAMERA_CONTROL_SCENE_MODE:
535         case ACAMERA_CONTROL_VIDEO_STABILIZATION_MODE:
536         case ACAMERA_CONTROL_POST_RAW_SENSITIVITY_BOOST:
537         case ACAMERA_CONTROL_ENABLE_ZSL:
538         case ACAMERA_CONTROL_EXTENDED_SCENE_MODE:
539         case ACAMERA_CONTROL_ZOOM_RATIO:
540         case ACAMERA_EDGE_MODE:
541         case ACAMERA_FLASH_MODE:
542         case ACAMERA_HOT_PIXEL_MODE:
543         case ACAMERA_JPEG_GPS_COORDINATES:
544         case ACAMERA_JPEG_GPS_PROCESSING_METHOD:
545         case ACAMERA_JPEG_GPS_TIMESTAMP:
546         case ACAMERA_JPEG_ORIENTATION:
547         case ACAMERA_JPEG_QUALITY:
548         case ACAMERA_JPEG_THUMBNAIL_QUALITY:
549         case ACAMERA_JPEG_THUMBNAIL_SIZE:
550         case ACAMERA_LENS_APERTURE:
551         case ACAMERA_LENS_FILTER_DENSITY:
552         case ACAMERA_LENS_FOCAL_LENGTH:
553         case ACAMERA_LENS_FOCUS_DISTANCE:
554         case ACAMERA_LENS_OPTICAL_STABILIZATION_MODE:
555         case ACAMERA_NOISE_REDUCTION_MODE:
556         case ACAMERA_SCALER_CROP_REGION:
557         case ACAMERA_SCALER_ROTATE_AND_CROP:
558         case ACAMERA_SENSOR_EXPOSURE_TIME:
559         case ACAMERA_SENSOR_FRAME_DURATION:
560         case ACAMERA_SENSOR_SENSITIVITY:
561         case ACAMERA_SENSOR_TEST_PATTERN_DATA:
562         case ACAMERA_SENSOR_TEST_PATTERN_MODE:
563         case ACAMERA_SENSOR_PIXEL_MODE:
564         case ACAMERA_SHADING_MODE:
565         case ACAMERA_STATISTICS_FACE_DETECT_MODE:
566         case ACAMERA_STATISTICS_HOT_PIXEL_MAP_MODE:
567         case ACAMERA_STATISTICS_LENS_SHADING_MAP_MODE:
568         case ACAMERA_STATISTICS_OIS_DATA_MODE:
569         case ACAMERA_TONEMAP_CURVE_BLUE:
570         case ACAMERA_TONEMAP_CURVE_GREEN:
571         case ACAMERA_TONEMAP_CURVE_RED:
572         case ACAMERA_TONEMAP_MODE:
573         case ACAMERA_TONEMAP_GAMMA:
574         case ACAMERA_TONEMAP_PRESET_CURVE:
575         case ACAMERA_BLACK_LEVEL_LOCK:
576         case ACAMERA_DISTORTION_CORRECTION_MODE:
577             return true;
578         default:
579             return false;
580     }
581 }
582 
583 // System tags that should be hidden from users
584 std::unordered_set<uint32_t> ACameraMetadata::sSystemTags ({
585     ANDROID_CONTROL_SCENE_MODE_OVERRIDES,
586     ANDROID_CONTROL_AE_PRECAPTURE_ID,
587     ANDROID_CONTROL_AF_TRIGGER_ID,
588     ANDROID_DEMOSAIC_MODE,
589     ANDROID_EDGE_STRENGTH,
590     ANDROID_FLASH_FIRING_POWER,
591     ANDROID_FLASH_FIRING_TIME,
592     ANDROID_FLASH_COLOR_TEMPERATURE,
593     ANDROID_FLASH_MAX_ENERGY,
594     ANDROID_FLASH_INFO_CHARGE_DURATION,
595     ANDROID_JPEG_MAX_SIZE,
596     ANDROID_JPEG_SIZE,
597     ANDROID_NOISE_REDUCTION_STRENGTH,
598     ANDROID_QUIRKS_METERING_CROP_REGION,
599     ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO,
600     ANDROID_QUIRKS_USE_ZSL_FORMAT,
601     ANDROID_REQUEST_INPUT_STREAMS,
602     ANDROID_REQUEST_METADATA_MODE,
603     ANDROID_REQUEST_OUTPUT_STREAMS,
604     ANDROID_REQUEST_TYPE,
605     ANDROID_REQUEST_MAX_NUM_REPROCESS_STREAMS,
606     ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS,
607     ANDROID_SCALER_AVAILABLE_RAW_SIZES,
608     ANDROID_SENSOR_BASE_GAIN_FACTOR,
609     ANDROID_SENSOR_PROFILE_HUE_SAT_MAP_DIMENSIONS,
610     ANDROID_SENSOR_TEMPERATURE,
611     ANDROID_SENSOR_PROFILE_HUE_SAT_MAP,
612     ANDROID_SENSOR_PROFILE_TONE_CURVE,
613     ANDROID_SENSOR_OPAQUE_RAW_SIZE,
614     ANDROID_SENSOR_OPAQUE_RAW_SIZE_MAXIMUM_RESOLUTION,
615     ANDROID_SHADING_STRENGTH,
616     ANDROID_STATISTICS_HISTOGRAM_MODE,
617     ANDROID_STATISTICS_SHARPNESS_MAP_MODE,
618     ANDROID_STATISTICS_HISTOGRAM,
619     ANDROID_STATISTICS_SHARPNESS_MAP,
620     ANDROID_STATISTICS_INFO_HISTOGRAM_BUCKET_COUNT,
621     ANDROID_STATISTICS_INFO_MAX_HISTOGRAM_COUNT,
622     ANDROID_STATISTICS_INFO_MAX_SHARPNESS_MAP_VALUE,
623     ANDROID_STATISTICS_INFO_SHARPNESS_MAP_SIZE,
624     ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION,
625     ANDROID_DEPTH_MAX_DEPTH_SAMPLES,
626     ANDROID_HEIC_INFO_SUPPORTED,
627     ANDROID_HEIC_INFO_MAX_JPEG_APP_SEGMENTS_COUNT,
628 });
629 
630 /*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
631  * End generated code
632  *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/
633