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

Commit aadfdb27 authored by Pawin Vongmasa's avatar Pawin Vongmasa Committed by Android (Google) Code Review
Browse files

Merge "Add conversion functions."

parents ae2026ec 517b0e09
Loading
Loading
Loading
Loading
+35 −4
Original line number Diff line number Diff line
@@ -24,12 +24,27 @@

namespace android {

class OMXBuffer;

// This is needed temporarily for the OMX HIDL transition.
namespace hardware { namespace media { namespace omx {
namespace V1_0 {
    struct CodecBuffer;
namespace implementation {
    inline bool wrapAs(::android::hardware::media::omx::V1_0::CodecBuffer* t,
            ::android::OMXBuffer const& l);
    inline bool convertTo(::android::OMXBuffer* l,
            ::android::hardware::media::omx::V1_0::CodecBuffer const& t);
}}}}}

class GraphicBuffer;
class IMemory;
class MediaCodecBuffer;
class NativeHandle;
class OMXNodeInstance;
struct OMXNodeInstance;

// TODO: After complete HIDL transition, this class would be replaced by
// CodecBuffer.
class OMXBuffer {
public:
    // sPreset is used in places where we are referring to a pre-registered
@@ -43,6 +58,10 @@ public:
    // |codecBuffer|'s size (or 0 if |codecBuffer| is NULL).
    OMXBuffer(const sp<MediaCodecBuffer> &codecBuffer);

    // Constructs a buffer of type kBufferTypePreset with a specified
    // mRangeLength.
    explicit OMXBuffer(OMX_U32 rangeLength);

    // Constructs a buffer of type kBufferTypeSharedMem.
    OMXBuffer(const sp<IMemory> &mem);

@@ -59,7 +78,15 @@ public:
    ~OMXBuffer();

private:
    friend class OMXNodeInstance;
    friend struct OMXNodeInstance;

    // This is needed temporarily for OMX HIDL transition.
    friend inline bool (::android::hardware::media::omx::V1_0::implementation::
            wrapAs)(::android::hardware::media::omx::V1_0::CodecBuffer* t,
            OMXBuffer const& l);
    friend inline bool (::android::hardware::media::omx::V1_0::implementation::
            convertTo)(OMXBuffer* l,
            ::android::hardware::media::omx::V1_0::CodecBuffer const& t);

    enum BufferType {
        kBufferTypeInvalid = 0,
@@ -85,8 +112,12 @@ private:
    // kBufferTypeNativeHandle
    sp<NativeHandle> mNativeHandle;

    OMXBuffer(const OMXBuffer &);
    OMXBuffer &operator=(const OMXBuffer &);
    // Move assignment
    OMXBuffer &operator=(OMXBuffer&&);

    // Deleted copy constructor and assignment.
    OMXBuffer(const OMXBuffer&) = delete;
    OMXBuffer& operator=(const OMXBuffer&) = delete;
};

}  // namespace android
+20 −0
Original line number Diff line number Diff line
@@ -21,6 +21,18 @@

namespace android {

struct OMXFenceParcelable;

// This is needed temporarily for the OMX HIDL transition.
namespace hardware {
    struct hidl_handle;
namespace media { namespace omx { namespace V1_0 { namespace implementation {
    void wrapAs(::android::OMXFenceParcelable* l,
            ::android::hardware::hidl_handle const& t);
    bool convertTo(::android::OMXFenceParcelable* l,
            ::android::hardware::hidl_handle const& t);
}}}}}

struct OMXFenceParcelable : public Parcelable {
    OMXFenceParcelable() : mFenceFd(-1) {}
    OMXFenceParcelable(int fenceFd) : mFenceFd(fenceFd) {}
@@ -36,6 +48,14 @@ private:
    OMXFenceParcelable &operator=(const OMXFenceParcelable &);

    int mFenceFd;

    // This is needed temporarily for OMX HIDL transition.
    friend void (::android::hardware::media::omx::V1_0::implementation::
            wrapAs)(OMXFenceParcelable* l,
            ::android::hardware::hidl_handle const& t);
    friend bool (::android::hardware::media::omx::V1_0::implementation::
            convertTo)(OMXFenceParcelable* l,
            ::android::hardware::hidl_handle const& t);
};

inline status_t OMXFenceParcelable::readFromParcel(const Parcel* parcel) {
+14 −0
Original line number Diff line number Diff line
@@ -38,6 +38,11 @@ OMXBuffer::OMXBuffer(const sp<MediaCodecBuffer>& codecBuffer)
      mRangeLength(codecBuffer != NULL ? codecBuffer->size() : 0) {
}

OMXBuffer::OMXBuffer(OMX_U32 rangeLength)
    : mBufferType(kBufferTypePreset),
      mRangeLength(rangeLength) {
}

OMXBuffer::OMXBuffer(const sp<IMemory> &mem)
    : mBufferType(kBufferTypeSharedMem),
      mMem(mem) {
@@ -133,6 +138,15 @@ status_t OMXBuffer::readFromParcel(const Parcel *parcel) {
    return OK;
}

OMXBuffer& OMXBuffer::operator=(OMXBuffer&& source) {
    mBufferType = std::move(source.mBufferType);
    mRangeLength = std::move(source.mRangeLength);
    mMem = std::move(source.mMem);
    mGraphicBuffer = std::move(source.mGraphicBuffer);
    mNativeHandle = std::move(source.mNativeHandle);
    return *this;
}

} // namespace android


+19 −3
Original line number Diff line number Diff line
@@ -4,19 +4,35 @@ include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.media.omx@1.0-impl
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_SRC_FILES := \
    GraphicBufferSource.cpp \
    WGraphicBufferSource.cpp \
    WOmx.cpp \
    WOmxBufferSource.cpp \
    WOmxNode.cpp \
    WOmxObserver.cpp \
    Omx.cpp \
    OmxBufferSource.cpp \
    OmxNode.cpp \
    OmxObserver.cpp \

LOCAL_SHARED_LIBRARIES := \
    libmedia \
    libstagefright_foundation \
    libstagefright_omx \
    libui \
    libhidlbase \
    libhidltransport \
    libhwbinder \
    libutils \
    libcutils \
    libbinder \
    android.hardware.media.omx@1.0 \
    android.hardware.graphics.common@1.0 \
    android.hardware.media@1.0 \
    android.hidl.base@1.0 \

LOCAL_C_INCLUDES += \
        $(TOP) \
        $(TOP)/frameworks/av/include/media \
        $(TOP)/frameworks/av/media/libstagefright/include \
        $(TOP)/frameworks/native/include/media/hardware \
        $(TOP)/frameworks/native/include/media/openmax

include $(BUILD_SHARED_LIBRARY)
+820 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading