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

Commit 90afe080 authored by Jiwen Cai's avatar Jiwen Cai Committed by Android (Google) Code Review
Browse files

Merge "Refactor AImage/AImageReader"

parents f14c49bf 2f1a4737
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -646,7 +646,9 @@ media_status_t AImage_getNumberOfPlanes(const AImage* image, /*out*/int32_t* num
 *         <li>{@link AMEDIA_ERROR_UNSUPPORTED} if pixel stride is undefined for the format of input
 *                 image.</li>
 *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
 *                 image has been deleted.</li></ul>
 *                 image has been deleted.</li>
 *         <li>{@link AMEDIA_IMGREADER_CANNOT_LOCK_IMAGE} if the {@link AImage} cannot be locked
 *                 for CPU access.</li></ul>
 */
media_status_t AImage_getPlanePixelStride(
        const AImage* image, int planeIdx, /*out*/int32_t* pixelStride);
@@ -671,7 +673,9 @@ media_status_t AImage_getPlanePixelStride(
 *         <li>{@link AMEDIA_ERROR_UNSUPPORTED} if row stride is undefined for the format of input
 *                 image.</li>
 *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
 *                 image has been deleted.</li></ul>
 *                 image has been deleted.</li>
 *         <li>{@link AMEDIA_IMGREADER_CANNOT_LOCK_IMAGE} if the {@link AImage} cannot be locked
 *                 for CPU access.</li></ul>
 */
media_status_t AImage_getPlaneRowStride(
        const AImage* image, int planeIdx, /*out*/int32_t* rowStride);
@@ -693,7 +697,9 @@ media_status_t AImage_getPlaneRowStride(
 *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image, data or dataLength is NULL, or
 *                 planeIdx is out of the range of [0, numOfPlanes - 1].</li>
 *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
 *                 image has been deleted.</li></ul>
 *                 image has been deleted.</li>
 *         <li>{@link AMEDIA_IMGREADER_CANNOT_LOCK_IMAGE} if the {@link AImage} cannot be locked
 *                 for CPU access.</li></ul>
 */
media_status_t AImage_getPlaneData(
        const AImage* image, int planeIdx,
+3 −0
Original line number Diff line number Diff line
@@ -60,6 +60,9 @@ typedef enum {
    AMEDIA_IMGREADER_ERROR_BASE          = -30000,
    AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE = AMEDIA_IMGREADER_ERROR_BASE - 1,
    AMEDIA_IMGREADER_MAX_IMAGES_ACQUIRED = AMEDIA_IMGREADER_ERROR_BASE - 2,
    AMEDIA_IMGREADER_CANNOT_LOCK_IMAGE   = AMEDIA_IMGREADER_ERROR_BASE - 3,
    AMEDIA_IMGREADER_CANNOT_UNLOCK_IMAGE = AMEDIA_IMGREADER_ERROR_BASE - 4,
    AMEDIA_IMGREADER_IMAGE_NOT_LOCKED    = AMEDIA_IMGREADER_ERROR_BASE - 5,

} media_status_t;

+6 −1
Original line number Diff line number Diff line
@@ -34,9 +34,12 @@ LOCAL_MODULE:= libmediandk

LOCAL_C_INCLUDES := \
    bionic/libc/private \
    external/piex \
    frameworks/base/core/jni \
    frameworks/base/media/jni \
    frameworks/av/include/ndk \
    system/media/camera/include
    system/media/camera/include \
    $(call include-path-for, libhardware)/hardware \

LOCAL_CFLAGS += -fvisibility=hidden -D EXPORT='__attribute__ ((visibility ("default")))'

@@ -45,7 +48,9 @@ LOCAL_CFLAGS += -Werror -Wall
LOCAL_SHARED_LIBRARIES := \
    libbinder \
    libmedia \
    libmedia_jni \
    libmediadrm \
    libskia \
    libstagefright \
    libstagefright_foundation \
    liblog \
+201 −80

File changed.

Preview size limit exceeded, changes collapsed.

+10 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <utils/Log.h>
#include <utils/StrongPointer.h>

#include <gui/BufferItem.h>
#include <gui/CpuConsumer.h>

#include "NdkImageReaderPriv.h"
@@ -31,8 +32,8 @@ using namespace android;

// TODO: this only supports ImageReader
struct AImage {
    AImage(AImageReader* reader, int32_t format,
            CpuConsumer::LockedBuffer* buffer, int64_t timestamp,
    AImage(AImageReader* reader, int32_t format, uint64_t usage,
           BufferItem* buffer, int64_t timestamp,
           int32_t width, int32_t height, int32_t numPlanes);

    // free all resources while keeping object alive. Caller must obtain reader lock
@@ -54,6 +55,9 @@ struct AImage {
    media_status_t getNumPlanes(/*out*/int32_t* numPlanes) const;
    media_status_t getTimestamp(/*out*/int64_t* timestamp) const;

    media_status_t lockImage();
    media_status_t unlockImageIfLocked(/*out*/int* fenceFd);

    media_status_t getPlanePixelStride(int planeIdx, /*out*/int32_t* pixelStride) const;
    media_status_t getPlaneRowStride(int planeIdx, /*out*/int32_t* rowStride) const;
    media_status_t getPlaneData(int planeIdx,/*out*/uint8_t** data, /*out*/int* dataLength) const;
@@ -69,7 +73,9 @@ struct AImage {
    // When reader is close, AImage will only accept close API call
    wp<AImageReader>           mReader;
    const int32_t              mFormat;
    CpuConsumer::LockedBuffer* mBuffer;
    const uint64_t             mUsage;  // AHARDWAREBUFFER_USAGE0* flags.
    BufferItem*                mBuffer;
    std::unique_ptr<CpuConsumer::LockedBuffer> mLockedBuffer;
    const int64_t              mTimestamp;
    const int32_t              mWidth;
    const int32_t              mHeight;
Loading