Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c37df00 authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

Reland "camera ndk: Add ACameraMetadata_getTagFromName to the ndk"



This reverts commit 45a66e86.

Bug: 327254006

Take2: build failures on branches with PLATFORM_VERSION < 15 shouldn't
       exist after aosp/2999516 is submitted

Test: build

Change-Id: Ib190b17d601ddcc7fb39943b230ce9569c274ea8
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 65e6c603
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -120,6 +120,18 @@ camera_status_t ACameraMetadata_getAllTags(
    return acm->getTags(numTags, tags);
}

EXPORT
camera_status_t ACameraMetadata_getTagFromName(
        const ACameraMetadata* acm, const char* name, uint32_t* tag) {
    ATRACE_CALL();
    if (acm == nullptr || name == nullptr || tag == nullptr) {
        ALOGE("%s: invalid argument! metadata %p, name %p, tag %p",
               __FUNCTION__, acm, name, tag);
        return ACAMERA_ERROR_INVALID_PARAMETER;
    }
    return acm->getTagFromName(name, tag);
}

EXPORT
ACameraMetadata* ACameraMetadata_copy(const ACameraMetadata* src) {
    ATRACE_CALL();
+22 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#define LOG_TAG "ACameraMetadata"

#include "ACameraMetadata.h"

#include <camera_metadata_hidden.h>
#include <utils/Vector.h>
#include <system/graphics.h>
#include <media/NdkImage.h>
@@ -85,6 +87,19 @@ ACameraMetadata::init() {
        filterDurations(ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STALL_DURATIONS);
    }
    // TODO: filter request/result keys
    const CameraMetadata& metadata = *mData;
    const camera_metadata_t *rawMetadata = metadata.getAndLock();
    metadata_vendor_id_t vendorTagId = get_camera_metadata_vendor_id(rawMetadata);
    metadata.unlock(rawMetadata);
    sp<VendorTagDescriptorCache> vtCache = VendorTagDescriptorCache::getGlobalVendorTagCache();
    if (vtCache == nullptr) {
        ALOGE("%s: error vendor tag descriptor cache is not initialized", __FUNCTION__);
        return;
    }
    vtCache->getVendorTagDescriptor(vendorTagId, &mVTags);
    if (mVTags == nullptr) {
        ALOGE("%s: error retrieving vendor tag descriptor", __FUNCTION__);
    }
}

bool
@@ -473,6 +488,13 @@ ACameraMetadata::getInternalData() const {
    return (*mData);
}

camera_status_t
ACameraMetadata::getTagFromName(const char *name, uint32_t *tag) const {
    Mutex::Autolock _l(mLock);
    status_t status = CameraMetadata::getTagFromName(name, mVTags.get(), tag);
    return status == OK ? ACAMERA_OK : ACAMERA_ERROR_METADATA_NOT_FOUND;
}

bool
ACameraMetadata::isLogicalMultiCamera(size_t* count, const char*const** physicalCameraIds) const {
    if (mType != ACM_CHARACTERISTICS) {
+11 −0
Original line number Diff line number Diff line
@@ -27,9 +27,17 @@

#ifdef __ANDROID_VNDK__
#include <CameraMetadata.h>
#include <aidl/android/frameworks/cameraservice/common/VendorTag.h>
#include <aidl/android/frameworks/cameraservice/common/VendorTagSection.h>
#include <aidl/android/frameworks/cameraservice/common/ProviderIdAndVendorTagSections.h>
#include <VendorTagDescriptor.h>
using CameraMetadata = android::hardware::camera::common::V1_0::helper::CameraMetadata;
using ::aidl::android::frameworks::cameraservice::common::ProviderIdAndVendorTagSections;
using ::android::hardware::camera::common::V1_0::helper::VendorTagDescriptor;
using ::android::hardware::camera::common::V1_0::helper::VendorTagDescriptorCache;
#else
#include <camera/CameraMetadata.h>
#include <camera/VendorTagDescriptor.h>
#endif

#include <camera/NdkCameraMetadata.h>
@@ -73,6 +81,8 @@ struct ACameraMetadata : public RefBase {

    camera_status_t getTags(/*out*/int32_t* numTags,
                            /*out*/const uint32_t** tags) const;
    camera_status_t
    getTagFromName(const char *name, uint32_t *tag) const;

    const CameraMetadata& getInternalData() const;
    bool isLogicalMultiCamera(size_t* count, const char* const** physicalCameraIds) const;
@@ -134,6 +144,7 @@ struct ACameraMetadata : public RefBase {

    std::vector<const char*> mStaticPhysicalCameraIds;
    std::vector<String8> mStaticPhysicalCameraIdValues;
    sp<VendorTagDescriptor> mVTags = nullptr;
};

#endif // _ACAMERA_METADATA_H
+18 −0
Original line number Diff line number Diff line
@@ -220,6 +220,24 @@ camera_status_t ACameraMetadata_getAllTags(
        const ACameraMetadata* metadata,
        /*out*/int32_t* numEntries, /*out*/const uint32_t** tags) __INTRODUCED_IN(24);

/**
 * Look up tag ID value for device-specific custom tags that are usable only
 * for the particular device, by name. The name and type of the tag need to be
 * discovered from some other source, such as the manufacturer. The ID value is
 * stable during the lifetime of an application, but should be queried again after
 * process restarts. This method can also be used to query tag values using the names
 * for public tags which exist in the Java API, however it is just simpler and faster to
 * use the values of the tags which exist in the ndk.
 * @param metadata The {@link ACameraMetadata} of to query the tag value from.
 * @param name The name of the tag being queried.
 * @param tag The output tag assigned by this method.
 *
 * @return ACAMERA_OK only if the function call was successful.
 */

camera_status_t
ACameraMetadata_getTagFromName(const ACameraMetadata* metadata, const char *name, uint32_t *tag)  __INTRODUCED_IN(35);

/**
 * Create a copy of input {@link ACameraMetadata}.
 *
+9 −9
Original line number Diff line number Diff line
@@ -2149,7 +2149,7 @@ typedef enum acamera_metadata_tag {
     * </ul>
     */
    ACAMERA_CONTROL_SETTINGS_OVERRIDE =                         // int32 (acamera_metadata_enum_android_control_settings_override_t)
            ACAMERA_CONTROL_START + 49,
            ACAMERA_CONTROL_START + 52,
    /**
     * <p>List of available settings overrides supported by the camera device that can
     * be used to speed up certain controls.</p>
@@ -2175,7 +2175,7 @@ typedef enum acamera_metadata_tag {
     * @see ACAMERA_CONTROL_SETTINGS_OVERRIDE
     */
    ACAMERA_CONTROL_AVAILABLE_SETTINGS_OVERRIDES =              // int32[n]
            ACAMERA_CONTROL_START + 50,
            ACAMERA_CONTROL_START + 53,
    /**
     * <p>Automatic crop, pan and zoom to keep objects in the center of the frame.</p>
     *
@@ -2202,7 +2202,7 @@ typedef enum acamera_metadata_tag {
     * @see ACAMERA_SCALER_CROP_REGION
     */
    ACAMERA_CONTROL_AUTOFRAMING =                               // byte (acamera_metadata_enum_android_control_autoframing_t)
            ACAMERA_CONTROL_START + 52,
            ACAMERA_CONTROL_START + 55,
    /**
     * <p>Whether the camera device supports ACAMERA_CONTROL_AUTOFRAMING.</p>
     *
@@ -2218,7 +2218,7 @@ typedef enum acamera_metadata_tag {
     * <p>Will be <code>false</code> if auto-framing is not available.</p>
     */
    ACAMERA_CONTROL_AUTOFRAMING_AVAILABLE =                     // byte (acamera_metadata_enum_android_control_autoframing_available_t)
            ACAMERA_CONTROL_START + 53,
            ACAMERA_CONTROL_START + 56,
    /**
     * <p>Current state of auto-framing.</p>
     *
@@ -2245,7 +2245,7 @@ typedef enum acamera_metadata_tag {
     * @see ACAMERA_CONTROL_AUTOFRAMING_AVAILABLE
     */
    ACAMERA_CONTROL_AUTOFRAMING_STATE =                         // byte (acamera_metadata_enum_android_control_autoframing_state_t)
            ACAMERA_CONTROL_START + 54,
            ACAMERA_CONTROL_START + 57,
    /**
     * <p>The operating luminance range of low light boost measured in lux (lx).</p>
     *
@@ -2258,7 +2258,7 @@ typedef enum acamera_metadata_tag {
     *
     */
    ACAMERA_CONTROL_LOW_LIGHT_BOOST_INFO_LUMINANCE_RANGE =      // float[2]
            ACAMERA_CONTROL_START + 55,
            ACAMERA_CONTROL_START + 58,
    /**
     * <p>Current state of the low light boost AE mode.</p>
     *
@@ -2278,7 +2278,7 @@ typedef enum acamera_metadata_tag {
     * 'ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY.</p>
     */
    ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE =                     // byte (acamera_metadata_enum_android_control_low_light_boost_state_t)
            ACAMERA_CONTROL_START + 56,
            ACAMERA_CONTROL_START + 59,
    ACAMERA_CONTROL_END,
    /**
@@ -4671,7 +4671,7 @@ typedef enum acamera_metadata_tag {
     * application should leave stream use cases within the session as DEFAULT.</p>
     */
    ACAMERA_SCALER_AVAILABLE_STREAM_USE_CASES =                 // int64[n] (acamera_metadata_enum_android_scaler_available_stream_use_cases_t)
            ACAMERA_SCALER_START + 25,
            ACAMERA_SCALER_START + 26,
    /**
     * <p>The region of the sensor that corresponds to the RAW read out for this
     * capture when the stream use case of a RAW stream is set to CROPPED_RAW.</p>
@@ -4727,7 +4727,7 @@ typedef enum acamera_metadata_tag {
     * @see ACAMERA_STATISTICS_HOT_PIXEL_MAP
     */
    ACAMERA_SCALER_RAW_CROP_REGION =                            // int32[4]
            ACAMERA_SCALER_START + 26,
            ACAMERA_SCALER_START + 27,
    ACAMERA_SCALER_END,
    /**
Loading