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

Commit 813ab342 authored by Chong Zhang's avatar Chong Zhang Committed by android-build-merger
Browse files

Merge "stagefright: MetadataRetriever API to specify mime and color format" into oc-mr1-dev

am: e88fd530

Change-Id: I64109800186f687ebfca5eb3c5aed6885d30f08a
parents d6b5b067 e88fd530
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -870,7 +870,9 @@ int main(int argc, char **argv) {


            sp<IMemory> mem =
            sp<IMemory> mem =
                    retriever->getFrameAtTime(-1,
                    retriever->getFrameAtTime(-1,
                                    MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
                            MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC,
                            HAL_PIXEL_FORMAT_RGB_565,
                            false /*metaOnly*/);


            if (mem != NULL) {
            if (mem != NULL) {
                failed = false;
                failed = false;
+24 −6
Original line number Original line Diff line number Diff line
@@ -127,22 +127,32 @@ public:
        return reply.readInt32();
        return reply.readInt32();
    }
    }


    status_t setDataSource(const sp<IDataSource>& source)
    status_t setDataSource(const sp<IDataSource>& source, const char *mime)
    {
    {
        Parcel data, reply;
        Parcel data, reply;
        data.writeInterfaceToken(IMediaMetadataRetriever::getInterfaceDescriptor());
        data.writeInterfaceToken(IMediaMetadataRetriever::getInterfaceDescriptor());
        data.writeStrongBinder(IInterface::asBinder(source));
        data.writeStrongBinder(IInterface::asBinder(source));

        if (mime != NULL) {
            data.writeInt32(1);
            data.writeCString(mime);
        } else {
            data.writeInt32(0);
        }
        remote()->transact(SET_DATA_SOURCE_CALLBACK, data, &reply);
        remote()->transact(SET_DATA_SOURCE_CALLBACK, data, &reply);
        return reply.readInt32();
        return reply.readInt32();
    }
    }


    sp<IMemory> getFrameAtTime(int64_t timeUs, int option)
    sp<IMemory> getFrameAtTime(int64_t timeUs, int option, int colorFormat, bool metaOnly)
    {
    {
        ALOGV("getTimeAtTime: time(%" PRId64 " us) and option(%d)", timeUs, option);
        ALOGV("getTimeAtTime: time(%" PRId64 " us), option(%d), colorFormat(%d) metaOnly(%d)",
                timeUs, option, colorFormat, metaOnly);
        Parcel data, reply;
        Parcel data, reply;
        data.writeInterfaceToken(IMediaMetadataRetriever::getInterfaceDescriptor());
        data.writeInterfaceToken(IMediaMetadataRetriever::getInterfaceDescriptor());
        data.writeInt64(timeUs);
        data.writeInt64(timeUs);
        data.writeInt32(option);
        data.writeInt32(option);
        data.writeInt32(colorFormat);
        data.writeInt32(metaOnly);
#ifndef DISABLE_GROUP_SCHEDULE_HACK
#ifndef DISABLE_GROUP_SCHEDULE_HACK
        sendSchedPolicy(data);
        sendSchedPolicy(data);
#endif
#endif
@@ -258,7 +268,12 @@ status_t BnMediaMetadataRetriever::onTransact(
            if (source == NULL) {
            if (source == NULL) {
                reply->writeInt32(BAD_VALUE);
                reply->writeInt32(BAD_VALUE);
            } else {
            } else {
                reply->writeInt32(setDataSource(source));
                int32_t hasMime = data.readInt32();
                const char *mime = NULL;
                if (hasMime) {
                    mime = data.readCString();
                }
                reply->writeInt32(setDataSource(source, mime));
            }
            }
            return NO_ERROR;
            return NO_ERROR;
        } break;
        } break;
@@ -266,11 +281,14 @@ status_t BnMediaMetadataRetriever::onTransact(
            CHECK_INTERFACE(IMediaMetadataRetriever, data, reply);
            CHECK_INTERFACE(IMediaMetadataRetriever, data, reply);
            int64_t timeUs = data.readInt64();
            int64_t timeUs = data.readInt64();
            int option = data.readInt32();
            int option = data.readInt32();
            ALOGV("getTimeAtTime: time(%" PRId64 " us) and option(%d)", timeUs, option);
            int colorFormat = data.readInt32();
            bool metaOnly = (data.readInt32() != 0);
            ALOGV("getTimeAtTime: time(%" PRId64 " us), option(%d), colorFormat(%d), metaOnly(%d)",
                    timeUs, option, colorFormat, metaOnly);
#ifndef DISABLE_GROUP_SCHEDULE_HACK
#ifndef DISABLE_GROUP_SCHEDULE_HACK
            setSchedPolicy(data);
            setSchedPolicy(data);
#endif
#endif
            sp<IMemory> bitmap = getFrameAtTime(timeUs, option);
            sp<IMemory> bitmap = getFrameAtTime(timeUs, option, colorFormat, metaOnly);
            if (bitmap != 0) {  // Don't send NULL across the binder interface
            if (bitmap != 0) {  // Don't send NULL across the binder interface
                reply->writeInt32(NO_ERROR);
                reply->writeInt32(NO_ERROR);
                reply->writeStrongBinder(IInterface::asBinder(bitmap));
                reply->writeStrongBinder(IInterface::asBinder(bitmap));
+5 −4
Original line number Original line Diff line number Diff line
@@ -19,13 +19,12 @@
#define ANDROID_IMEDIAMETADATARETRIEVER_H
#define ANDROID_IMEDIAMETADATARETRIEVER_H


#include <binder/IInterface.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
#include <binder/IMemory.h>
#include <binder/IMemory.h>
#include <utils/KeyedVector.h>
#include <utils/KeyedVector.h>
#include <utils/RefBase.h>
#include <utils/RefBase.h>


namespace android {
namespace android {

class Parcel;
class IDataSource;
class IDataSource;
struct IMediaHTTPService;
struct IMediaHTTPService;


@@ -41,8 +40,10 @@ public:
            const KeyedVector<String8, String8> *headers = NULL) = 0;
            const KeyedVector<String8, String8> *headers = NULL) = 0;


    virtual status_t        setDataSource(int fd, int64_t offset, int64_t length) = 0;
    virtual status_t        setDataSource(int fd, int64_t offset, int64_t length) = 0;
    virtual status_t        setDataSource(const sp<IDataSource>& dataSource) = 0;
    virtual status_t        setDataSource(
    virtual sp<IMemory>     getFrameAtTime(int64_t timeUs, int option) = 0;
            const sp<IDataSource>& dataSource, const char *mime) = 0;
    virtual sp<IMemory>     getFrameAtTime(
            int64_t timeUs, int option, int colorFormat, bool metaOnly) = 0;
    virtual sp<IMemory>     extractAlbumArt() = 0;
    virtual sp<IMemory>     extractAlbumArt() = 0;
    virtual const char*     extractMetadata(int keyCode) = 0;
    virtual const char*     extractMetadata(int keyCode) = 0;
};
};
+6 −3
Original line number Original line Diff line number Diff line
@@ -41,8 +41,9 @@ public:
            const KeyedVector<String8, String8> *headers = NULL) = 0;
            const KeyedVector<String8, String8> *headers = NULL) = 0;


    virtual status_t    setDataSource(int fd, int64_t offset, int64_t length) = 0;
    virtual status_t    setDataSource(int fd, int64_t offset, int64_t length) = 0;
    virtual status_t setDataSource(const sp<DataSource>& source) = 0;
    virtual status_t setDataSource(const sp<DataSource>& source, const char *mime) = 0;
    virtual VideoFrame* getFrameAtTime(int64_t timeUs, int option) = 0;
    virtual VideoFrame* getFrameAtTime(
            int64_t timeUs, int option, int colorFormat, bool metaOnly) = 0;
    virtual MediaAlbumArt* extractAlbumArt() = 0;
    virtual MediaAlbumArt* extractAlbumArt() = 0;
    virtual const char* extractMetadata(int keyCode) = 0;
    virtual const char* extractMetadata(int keyCode) = 0;
};
};
@@ -54,7 +55,9 @@ public:
    MediaMetadataRetrieverInterface() {}
    MediaMetadataRetrieverInterface() {}


    virtual             ~MediaMetadataRetrieverInterface() {}
    virtual             ~MediaMetadataRetrieverInterface() {}
    virtual VideoFrame* getFrameAtTime(int64_t /*timeUs*/, int /*option*/) { return NULL; }
    virtual VideoFrame* getFrameAtTime(
            int64_t /*timeUs*/, int /*option*/, int /*colorFormat*/, bool /*metaOnly*/)
    { return NULL; }
    virtual MediaAlbumArt* extractAlbumArt() { return NULL; }
    virtual MediaAlbumArt* extractAlbumArt() { return NULL; }
    virtual const char* extractMetadata(int /*keyCode*/) { return NULL; }
    virtual const char* extractMetadata(int /*keyCode*/) { return NULL; }
};
};
+4 −2
Original line number Original line Diff line number Diff line
@@ -76,8 +76,10 @@ public:
            const KeyedVector<String8, String8> *headers = NULL);
            const KeyedVector<String8, String8> *headers = NULL);


    status_t setDataSource(int fd, int64_t offset, int64_t length);
    status_t setDataSource(int fd, int64_t offset, int64_t length);
    status_t setDataSource(const sp<IDataSource>& dataSource);
    status_t setDataSource(
    sp<IMemory> getFrameAtTime(int64_t timeUs, int option);
            const sp<IDataSource>& dataSource, const char *mime = NULL);
    sp<IMemory> getFrameAtTime(int64_t timeUs, int option,
            int colorFormat = 0, bool metaOnly = false);
    sp<IMemory> extractAlbumArt();
    sp<IMemory> extractAlbumArt();
    const char* extractMetadata(int keyCode);
    const char* extractMetadata(int keyCode);


Loading