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

Commit e3ec3183 authored by Robert Shih's avatar Robert Shih Committed by Android (Google) Code Review
Browse files

Merge "BufferChannelBase: IMemory to drm hal buffer helper"

parents 1666b947 206949d6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -66,12 +66,14 @@ cc_library_shared {

    shared_libs: [
        "libgui",
        "libhidlallocatorutils",
        "liblog",
        "libmedia_codeclist",
        "libstagefright_foundation",
        "libui",
        "libutils",
        "android.hardware.cas.native@1.0",
        "android.hardware.drm@1.0",
    ],

    sanitize: {
+16 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#define LOG_TAG "CodecBase"

#include <android/hardware/cas/native/1.0/IDescrambler.h>
#include <android/hardware/drm/1.0/types.h>
#include <hidlmemory/FrameworkUtils.h>
#include <mediadrm/ICrypto.h>
#include <media/stagefright/CodecBase.h>
#include <utils/Log.h>
@@ -32,4 +34,18 @@ void BufferChannelBase::setDescrambler(const sp<IDescrambler> &descrambler) {
    mDescrambler = descrambler;
}

void BufferChannelBase::IMemoryToSharedBuffer(
        const sp<IMemory> &memory,
        int32_t heapSeqNum,
        hardware::drm::V1_0::SharedBuffer *buf) {
    ssize_t offset;
    size_t size;

    sp<hardware::HidlMemory> hidlMemory;
    hidlMemory = hardware::fromHeap(memory->getMemory(&offset, &size));
    buf->bufferId = static_cast<uint32_t>(heapSeqNum);
    buf->offset = offset >= 0 ? offset : 0;
    buf->size = size;
}

} // namespace android
+21 −1
Original line number Diff line number Diff line
@@ -42,12 +42,20 @@ struct PersistentSurface;
struct RenderedFrameInfo;
class Surface;
struct ICrypto;
class IMemory;

namespace hardware {
namespace cas {
namespace native {
namespace V1_0 {
struct IDescrambler;
}}}}
}}}
namespace drm {
namespace V1_0 {
struct SharedBuffer;
}}
}

using hardware::cas::native::V1_0::IDescrambler;

struct CodecBase : public AHandler, /* static */ ColorUtils {
@@ -314,6 +322,18 @@ public:
     */
    virtual void getOutputBufferArray(Vector<sp<MediaCodecBuffer>> *array) = 0;

    /**
     * Convert binder IMemory to drm SharedBuffer
     *
     * \param   memory      IMemory object to store encrypted content.
     * \param   heapSeqNum  Heap sequence number from ICrypto; -1 if N/A
     * \param   buf         SharedBuffer structure to fill.
     */
    static void IMemoryToSharedBuffer(
            const sp<IMemory> &memory,
            int32_t heapSeqNum,
            hardware::drm::V1_0::SharedBuffer *buf);

protected:
    std::unique_ptr<CodecBase::BufferCallback> mCallback;
    sp<ICrypto> mCrypto;