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

Commit 098db221 authored by Wonsik Kim's avatar Wonsik Kim Committed by Gerrit Code Review
Browse files

Merge "Support AIDL BufferPool from BlockPool" into main

parents 75e12fc9 be2fbc2d
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -80,6 +80,7 @@ cc_library {
        "libbase",
        "libbase",
        "libdmabufheap",
        "libdmabufheap",
        "android.hardware.media.bufferpool@2.0",
        "android.hardware.media.bufferpool@2.0",
        "android.hardware.media.bufferpool2-V1-ndk",
    ],
    ],


    local_include_dirs: [
    local_include_dirs: [
@@ -94,8 +95,12 @@ cc_library {
    shared_libs: [
    shared_libs: [
        "android.hardware.graphics.bufferqueue@2.0",
        "android.hardware.graphics.bufferqueue@2.0",
        "android.hardware.graphics.common@1.2",
        "android.hardware.graphics.common@1.2",
        "android.hardware.common-V2-ndk",
        "android.hardware.common.fmq-V1-ndk",
        "android.hardware.media.bufferpool@2.0",
        "android.hardware.media.bufferpool@2.0",
        "android.hardware.media.bufferpool2-V1-ndk",
        "libbase",
        "libbase",
        "libbinder_ndk",
        "libcutils",
        "libcutils",
        "libdl",
        "libdl",
        "libdmabufheap",
        "libdmabufheap",
@@ -107,6 +112,7 @@ cc_library {
        "libnativewindow",
        "libnativewindow",
        "libstagefright_foundation",
        "libstagefright_foundation",
        "libstagefright_bufferpool@2.0.1",
        "libstagefright_bufferpool@2.0.1",
        "libstagefright_aidl_bufferpool2",
        "libui",
        "libui",
        "libutils",
        "libutils",
    ],
    ],
@@ -135,6 +141,7 @@ cc_defaults {
        "libnativewindow",
        "libnativewindow",
        "libcodec2_soft_common",
        "libcodec2_soft_common",
        "libsfplugin_ccodec_utils",
        "libsfplugin_ccodec_utils",
        "libstagefright_aidl_bufferpool2",
        "libstagefright_foundation",
        "libstagefright_foundation",
        "libstagefright_bufferpool@2.0.1",
        "libstagefright_bufferpool@2.0.1",
        "libgralloctypes",
        "libgralloctypes",
@@ -144,9 +151,13 @@ cc_defaults {
        "android.hardware.graphics.allocator@2.0",
        "android.hardware.graphics.allocator@2.0",
        "android.hardware.graphics.allocator@3.0",
        "android.hardware.graphics.allocator@3.0",
        "android.hardware.graphics.bufferqueue@2.0",
        "android.hardware.graphics.bufferqueue@2.0",
        "android.hardware.common-V2-ndk",
        "android.hardware.common.fmq-V1-ndk",
        "android.hardware.media.bufferpool2-V1-ndk",
    ],
    ],


    shared_libs: [
    shared_libs: [
        "libbinder_ndk",
        "libui",
        "libui",
        "libdl",
        "libdl",
        "libvndksupport",
        "libvndksupport",
+452 −36

File changed.

Preview size limit exceeded, changes collapsed.

+12 −2
Original line number Original line Diff line number Diff line
@@ -74,7 +74,14 @@ private:


class C2PooledBlockPool : public C2BlockPool {
class C2PooledBlockPool : public C2BlockPool {
public:
public:
    C2PooledBlockPool(const std::shared_ptr<C2Allocator> &allocator, const local_id_t localId);
    enum BufferPoolVer : int {
        VER_HIDL = 0,
        VER_AIDL2
    };
    C2PooledBlockPool(
            const std::shared_ptr<C2Allocator> &allocator,
            const local_id_t localId,
            BufferPoolVer ver = VER_HIDL);


    virtual ~C2PooledBlockPool() override;
    virtual ~C2PooledBlockPool() override;


@@ -117,9 +124,12 @@ public:
private:
private:
    const std::shared_ptr<C2Allocator> mAllocator;
    const std::shared_ptr<C2Allocator> mAllocator;
    const local_id_t mLocalId;
    const local_id_t mLocalId;
    const BufferPoolVer mBufferPoolVer;


    class Impl;
    class Impl; // HIDL BufferPool VER_HIDL
    std::unique_ptr<Impl> mImpl;
    std::unique_ptr<Impl> mImpl;
    class Impl2; // AIDL BufferPool(bufferpool2) VER_AIDL2
    std::unique_ptr<Impl2> mImpl2;
};
};


#endif // STAGEFRIGHT_CODEC2_BUFFER_PRIV_H_
#endif // STAGEFRIGHT_CODEC2_BUFFER_PRIV_H_
+57 −9
Original line number Original line Diff line number Diff line
@@ -21,17 +21,22 @@


#include <C2Buffer.h>
#include <C2Buffer.h>


namespace android {
// Note: HIDL-BufferPool and AIDL-BufferPool are not compatible
namespace hardware {
namespace android::hardware::media::bufferpool {
namespace media {
namespace bufferpool {


// BuffePool Data for HIDL-BufferPool
struct BufferPoolData;
struct BufferPoolData;


}
}
namespace aidl::android::hardware::media::bufferpool2 {

// BuffePool Data for AIDL-BufferPool
struct BufferPoolData;

}
}
}

}
using bufferpool_BufferPoolData = android::hardware::media::bufferpool::BufferPoolData;
using bufferpool2_BufferPoolData = aidl::android::hardware::media::bufferpool2::BufferPoolData;


/**
/**
 * Stores informations from C2BlockPool implementations which are required by C2Block.
 * Stores informations from C2BlockPool implementations which are required by C2Block.
@@ -40,6 +45,7 @@ struct C2_HIDE _C2BlockPoolData {
    enum type_t : int {
    enum type_t : int {
        TYPE_BUFFERPOOL = 0,
        TYPE_BUFFERPOOL = 0,
        TYPE_BUFFERQUEUE,
        TYPE_BUFFERQUEUE,
        TYPE_BUFFERPOOL2, // AIDL-BufferPool
    };
    };


    virtual type_t getType() const = 0;
    virtual type_t getType() const = 0;
@@ -136,6 +142,48 @@ struct _C2BlockFactory {
    std::shared_ptr<C2GraphicBlock> CreateGraphicBlock(
    std::shared_ptr<C2GraphicBlock> CreateGraphicBlock(
            const C2Handle *handle);
            const C2Handle *handle);


    // HIDL-BufferPool
    /**
     * Create a linear block from the received bufferpool data.
     *
     * \param data  bufferpool data to a linear block
     *
     * \return shared pointer to the linear block. nullptr if there was not enough memory to
     *         create this block.
     */
    static
    std::shared_ptr<C2LinearBlock> CreateLinearBlock(
            const C2Handle *handle,
            const std::shared_ptr<bufferpool_BufferPoolData> &data);

    /**
     * Create a graphic block from the received bufferpool data.
     *
     * \param data  bufferpool data to a graphic block
     *
     * \return shared pointer to the graphic block. nullptr if there was not enough memory to
     *         create this block.
     */
    static
    std::shared_ptr<C2GraphicBlock> CreateGraphicBlock(
            const C2Handle *handle,
            const std::shared_ptr<bufferpool_BufferPoolData> &data);

    /**
     * Get bufferpool data from the blockpool data.
     *
     * \param poolData          blockpool data
     * \param bufferPoolData    pointer to bufferpool data where the bufferpool
     *                          data is stored.
     *
     * \return {\code true} when there is valid bufferpool data, {\code false} otherwise.
     */
    static
    bool GetBufferPoolData(
            const std::shared_ptr<const _C2BlockPoolData> &poolData,
            std::shared_ptr<bufferpool_BufferPoolData> *bufferPoolData);

    // AIDL-BufferPool
    /**
    /**
     * Create a linear block from the received bufferpool data.
     * Create a linear block from the received bufferpool data.
     *
     *
@@ -147,7 +195,7 @@ struct _C2BlockFactory {
    static
    static
    std::shared_ptr<C2LinearBlock> CreateLinearBlock(
    std::shared_ptr<C2LinearBlock> CreateLinearBlock(
            const C2Handle *handle,
            const C2Handle *handle,
            const std::shared_ptr<android::hardware::media::bufferpool::BufferPoolData> &data);
            const std::shared_ptr<bufferpool2_BufferPoolData> &data);


    /**
    /**
     * Create a graphic block from the received bufferpool data.
     * Create a graphic block from the received bufferpool data.
@@ -160,7 +208,7 @@ struct _C2BlockFactory {
    static
    static
    std::shared_ptr<C2GraphicBlock> CreateGraphicBlock(
    std::shared_ptr<C2GraphicBlock> CreateGraphicBlock(
            const C2Handle *handle,
            const C2Handle *handle,
            const std::shared_ptr<android::hardware::media::bufferpool::BufferPoolData> &data);
            const std::shared_ptr<bufferpool2_BufferPoolData> &data);


    /**
    /**
     * Get bufferpool data from the blockpool data.
     * Get bufferpool data from the blockpool data.
@@ -174,7 +222,7 @@ struct _C2BlockFactory {
    static
    static
    bool GetBufferPoolData(
    bool GetBufferPoolData(
            const std::shared_ptr<const _C2BlockPoolData> &poolData,
            const std::shared_ptr<const _C2BlockPoolData> &poolData,
            std::shared_ptr<android::hardware::media::bufferpool::BufferPoolData> *bufferPoolData);
            std::shared_ptr<bufferpool2_BufferPoolData> *bufferPoolData);


    /*
    /*
     * Life Cycle Management of BufferQueue-Based Blocks
     * Life Cycle Management of BufferQueue-Based Blocks