10dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh/* 20dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Copyright (C) 2015 The Android Open Source Project 30dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * 40dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Licensed under the Apache License, Version 2.0 (the "License"); 50dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * you may not use this file except in compliance with the License. 60dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * You may obtain a copy of the License at 70dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * 80dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * http://www.apache.org/licenses/LICENSE-2.0 90dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * 100dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Unless required by applicable law or agreed to in writing, software 110dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * distributed under the License is distributed on an "AS IS" BASIS, 120dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * See the License for the specific language governing permissions and 140dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * limitations under the License. 150dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh */ 160dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 170dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh//#define LOG_NDEBUG 0 180dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh#define LOG_TAG "NdkCameraMetadata" 190dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh#define ATRACE_TAG ATRACE_TAG_CAMERA 200dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 210dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh#include <utils/Log.h> 220dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh#include <utils/Trace.h> 230dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 240dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh#include "NdkCameraMetadata.h" 250dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh#include "impl/ACameraMetadata.h" 260dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 270dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yehusing namespace android; 280dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 290dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia YehEXPORT 300dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yehcamera_status_t ACameraMetadata_getConstEntry( 310dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh const ACameraMetadata* acm, uint32_t tag, ACameraMetadata_const_entry* entry) { 320dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh ATRACE_CALL(); 330dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh if (acm == nullptr || entry == nullptr) { 34ead9146f844ee194a4f4244ba8ae1a3aece12b63Yin-Chia Yeh ALOGE("%s: invalid argument! metadata %p, tag 0x%x, entry %p", 350dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh __FUNCTION__, acm, tag, entry); 360dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh return ACAMERA_ERROR_INVALID_PARAMETER; 370dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh } 380dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh return acm->getConstEntry(tag, entry); 390dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh} 400dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 410dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia YehEXPORT 428aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia Yehcamera_status_t ACameraMetadata_getAllTags( 438aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia Yeh const ACameraMetadata* acm, /*out*/int32_t* numTags, /*out*/const uint32_t** tags) { 448aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia Yeh ATRACE_CALL(); 458aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia Yeh if (acm == nullptr || numTags == nullptr || tags == nullptr) { 468aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia Yeh ALOGE("%s: invalid argument! metadata %p, numTags %p, tags %p", 478aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia Yeh __FUNCTION__, acm, numTags, tags); 488aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia Yeh return ACAMERA_ERROR_INVALID_PARAMETER; 498aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia Yeh } 508aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia Yeh return acm->getTags(numTags, tags); 518aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia Yeh} 528aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia Yeh 538aac03f4d6c66749803d5708086ba5f509aa88c6Yin-Chia YehEXPORT 540dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia YehACameraMetadata* ACameraMetadata_copy(const ACameraMetadata* src) { 550dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh ATRACE_CALL(); 560dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh if (src == nullptr) { 570dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh ALOGE("%s: src is null!", __FUNCTION__); 580dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh return nullptr; 590dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh } 600dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh return new ACameraMetadata(*src); 610dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh} 620dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 630dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia YehEXPORT 640dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yehvoid ACameraMetadata_free(ACameraMetadata* metadata) { 650dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh ATRACE_CALL(); 660dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh if (metadata != nullptr) { 670dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh delete metadata; 680dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh } 690dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh} 70