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

Commit 92573a2d authored by Sungtak Lee's avatar Sungtak Lee
Browse files

Support AIDL BufferPool from BlockPool

Support AIDL based BufferPool from C2PooledBlockPool
Bug: 251850069

Change-Id: I7dc60172038cda691a5322266b1ee860733101a9
parent 37420762
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ cc_library {
        "libbase",
        "libdmabufheap",
        "android.hardware.media.bufferpool@2.0",
        "android.hardware.media.bufferpool2-V1-ndk",
    ],

    local_include_dirs: [
@@ -94,8 +95,12 @@ cc_library {
    shared_libs: [
        "android.hardware.graphics.bufferqueue@2.0",
        "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.bufferpool2-V1-ndk",
        "libbase",
        "libbinder_ndk",
        "libcutils",
        "libdl",
        "libdmabufheap",
@@ -107,6 +112,7 @@ cc_library {
        "libnativewindow",
        "libstagefright_foundation",
        "libstagefright_bufferpool@2.0.1",
        "libstagefright_aidl_bufferpool2",
        "libui",
        "libutils",
    ],
@@ -135,6 +141,7 @@ cc_defaults {
        "libnativewindow",
        "libcodec2_soft_common",
        "libsfplugin_ccodec_utils",
        "libstagefright_aidl_bufferpool2",
        "libstagefright_foundation",
        "libstagefright_bufferpool@2.0.1",
        "libgralloctypes",
@@ -144,9 +151,13 @@ cc_defaults {
        "android.hardware.graphics.allocator@2.0",
        "android.hardware.graphics.allocator@3.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: [
        "libbinder_ndk",
        "libui",
        "libdl",
        "libvndksupport",
+452 −36

File changed.

Preview size limit exceeded, changes collapsed.

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

class C2PooledBlockPool : public C2BlockPool {
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;

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

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

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

#include <C2Buffer.h>

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

// BuffePool Data for HIDL-BufferPool
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.
@@ -40,6 +45,7 @@ struct C2_HIDE _C2BlockPoolData {
    enum type_t : int {
        TYPE_BUFFERPOOL = 0,
        TYPE_BUFFERQUEUE,
        TYPE_BUFFERPOOL2, // AIDL-BufferPool
    };

    virtual type_t getType() const = 0;
@@ -136,6 +142,48 @@ struct _C2BlockFactory {
    std::shared_ptr<C2GraphicBlock> CreateGraphicBlock(
            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.
     *
@@ -147,7 +195,7 @@ struct _C2BlockFactory {
    static
    std::shared_ptr<C2LinearBlock> CreateLinearBlock(
            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.
@@ -160,7 +208,7 @@ struct _C2BlockFactory {
    static
    std::shared_ptr<C2GraphicBlock> CreateGraphicBlock(
            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.
@@ -174,7 +222,7 @@ struct _C2BlockFactory {
    static
    bool GetBufferPoolData(
            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