Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -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 | //#define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "NdkCameraMetadata" |
| 19 | #define ATRACE_TAG ATRACE_TAG_CAMERA |
| 20 | |
| 21 | #include <utils/Log.h> |
| 22 | #include <utils/Trace.h> |
| 23 | |
Colin Cross | 7e8d4ba | 2017-05-04 16:17:42 -0700 | [diff] [blame] | 24 | #include <camera/NdkCameraMetadata.h> |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 25 | #include "impl/ACameraMetadata.h" |
| 26 | |
| 27 | using namespace android; |
| 28 | |
| 29 | EXPORT |
| 30 | camera_status_t ACameraMetadata_getConstEntry( |
| 31 | const ACameraMetadata* acm, uint32_t tag, ACameraMetadata_const_entry* entry) { |
| 32 | ATRACE_CALL(); |
| 33 | if (acm == nullptr || entry == nullptr) { |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 34 | ALOGE("%s: invalid argument! metadata %p, tag 0x%x, entry %p", |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 35 | __FUNCTION__, acm, tag, entry); |
| 36 | return ACAMERA_ERROR_INVALID_PARAMETER; |
| 37 | } |
| 38 | return acm->getConstEntry(tag, entry); |
| 39 | } |
| 40 | |
| 41 | EXPORT |
Yin-Chia Yeh | 8aac03f | 2016-03-03 15:45:23 -0800 | [diff] [blame] | 42 | camera_status_t ACameraMetadata_getAllTags( |
| 43 | const ACameraMetadata* acm, /*out*/int32_t* numTags, /*out*/const uint32_t** tags) { |
| 44 | ATRACE_CALL(); |
| 45 | if (acm == nullptr || numTags == nullptr || tags == nullptr) { |
| 46 | ALOGE("%s: invalid argument! metadata %p, numTags %p, tags %p", |
| 47 | __FUNCTION__, acm, numTags, tags); |
| 48 | return ACAMERA_ERROR_INVALID_PARAMETER; |
| 49 | } |
| 50 | return acm->getTags(numTags, tags); |
| 51 | } |
| 52 | |
| 53 | EXPORT |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 54 | ACameraMetadata* ACameraMetadata_copy(const ACameraMetadata* src) { |
| 55 | ATRACE_CALL(); |
| 56 | if (src == nullptr) { |
| 57 | ALOGE("%s: src is null!", __FUNCTION__); |
| 58 | return nullptr; |
| 59 | } |
Yin-Chia Yeh | dd045bf | 2018-08-20 12:39:19 -0700 | [diff] [blame] | 60 | ACameraMetadata* copy = new ACameraMetadata(*src); |
| 61 | copy->incStrong((void*) ACameraMetadata_copy); |
| 62 | return copy; |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | EXPORT |
| 66 | void ACameraMetadata_free(ACameraMetadata* metadata) { |
| 67 | ATRACE_CALL(); |
| 68 | if (metadata != nullptr) { |
Yin-Chia Yeh | dd045bf | 2018-08-20 12:39:19 -0700 | [diff] [blame] | 69 | metadata->decStrong((void*) ACameraMetadata_free); |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 70 | } |
| 71 | } |
Shuzhen Wang | 0ff9ae3 | 2018-12-05 18:06:12 -0800 | [diff] [blame] | 72 | |
| 73 | EXPORT |
| 74 | bool ACameraMetadata_isLogicalMultiCamera(const ACameraMetadata* staticMetadata, |
| 75 | /*out*/size_t* numPhysicalCameras, /*out*/const char*const** physicalCameraIds) { |
| 76 | ATRACE_CALL(); |
| 77 | if (numPhysicalCameras == nullptr || physicalCameraIds == nullptr) { |
| 78 | ALOGE("%s: Invalid input: numPhysicalCameras %p, physicalCameraIds %p", |
| 79 | __FUNCTION__, numPhysicalCameras, physicalCameraIds); |
| 80 | return false; |
| 81 | } |
| 82 | if (staticMetadata == nullptr) { |
| 83 | ALOGE("%s: Invalid input: staticMetadata is null.", __FUNCTION__); |
| 84 | return false; |
| 85 | } |
| 86 | |
| 87 | return staticMetadata->isLogicalMultiCamera(numPhysicalCameras, physicalCameraIds); |
| 88 | } |