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

Commit 9e6955a1 authored by Ronghua Wu's avatar Ronghua Wu
Browse files

media: handle overrides and measure max codec instance.

Bug: 19620911
Change-Id: I68d5919284700f37ccc6c6b9f96cd87ccdd40e6a
parent 5795cb16
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@
#include <binder/IInterface.h>
#include <binder/Parcel.h>

#include <media/stagefright/foundation/AMessage.h>

namespace android {

struct MediaCodecInfo;
@@ -33,6 +35,8 @@ public:
    virtual size_t countCodecs() const = 0;
    virtual sp<MediaCodecInfo> getCodecInfo(size_t index) const = 0;

    virtual const sp<AMessage> getGlobalSettings() const = 0;

    virtual ssize_t findCodecByType(
            const char *type, bool encoder, size_t startIndex = 0) const = 0;

+4 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ struct AMessage;
struct Parcel;
struct CodecCapabilities;

typedef KeyedVector<AString, AString> CodecSettings;

struct MediaCodecInfo : public RefBase {
    struct ProfileLevel {
        uint32_t mProfile;
@@ -104,6 +106,7 @@ private:
    MediaCodecInfo(AString name, bool encoder, const char *mime);
    void addQuirk(const char *name);
    status_t addMime(const char *mime);
    status_t updateMime(const char *mime);
    status_t initializeCapabilities(const CodecCapabilities &caps);
    void addDetail(const AString &key, const AString &value);
    void addFeature(const AString &key, int32_t value);
@@ -114,6 +117,7 @@ private:
    DISALLOW_EVIL_CONSTRUCTORS(MediaCodecInfo);

    friend class MediaCodecList;
    friend class MediaCodecListOverridesTest;
};

}  // namespace android
+12 −2
Original line number Diff line number Diff line
@@ -48,9 +48,14 @@ struct MediaCodecList : public BnMediaCodecList {
        return mCodecInfos.itemAt(index);
    }

    virtual const sp<AMessage> getGlobalSettings() const;

    // to be used by MediaPlayerService alone
    static sp<IMediaCodecList> getLocalInstance();

    // only to be used in getLocalInstance
    void updateDetailsForMultipleCodecs(const KeyedVector<AString, CodecSettings>& updates);

private:
    class BinderDeathObserver : public IBinder::DeathRecipient {
        void binderDied(const wp<IBinder> &the_late_who __unused);
@@ -75,11 +80,14 @@ private:

    status_t mInitCheck;
    Section mCurrentSection;
    bool mUpdate;
    Vector<Section> mPastSections;
    int32_t mDepth;
    AString mHrefBase;

    KeyedVector<AString, AString> mSettings;
    sp<AMessage> mGlobalSettings;
    KeyedVector<AString, CodecSettings> mOverrides;

    Vector<sp<MediaCodecInfo> > mCodecInfos;
    sp<MediaCodecInfo> mCurrentInfo;
    sp<IOMX> mOMX;
@@ -89,7 +97,7 @@ private:

    status_t initCheck() const;
    void parseXMLFile(const char *path);
    void parseTopLevelXMLFile(const char *path);
    void parseTopLevelXMLFile(const char *path, bool ignore_errors = false);

    static void StartElementHandlerWrapper(
            void *me, const char *name, const char **attrs);
@@ -104,6 +112,8 @@ private:
    status_t addMediaCodecFromAttributes(bool encoder, const char **attrs);
    void addMediaCodec(bool encoder, const char *name, const char *type = NULL);

    void setCurrentCodecInfo(bool encoder, const char *name, const char *type);

    status_t addQuirk(const char **attrs);
    status_t addTypeFromAttributes(const char **attrs);
    status_t addLimit(const char **attrs);
+28 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ enum {
    CREATE = IBinder::FIRST_CALL_TRANSACTION,
    COUNT_CODECS,
    GET_CODEC_INFO,
    GET_GLOBAL_SETTINGS,
    FIND_CODEC_BY_TYPE,
    FIND_CODEC_BY_NAME,
};
@@ -64,6 +65,19 @@ public:
        }
    }

    virtual const sp<AMessage> getGlobalSettings() const
    {
        Parcel data, reply;
        data.writeInterfaceToken(IMediaCodecList::getInterfaceDescriptor());
        remote()->transact(GET_GLOBAL_SETTINGS, data, &reply);
        status_t err = reply.readInt32();
        if (err == OK) {
            return AMessage::FromParcel(reply);
        } else {
            return NULL;
        }
    }

    virtual ssize_t findCodecByType(
            const char *type, bool encoder, size_t startIndex = 0) const
    {
@@ -125,6 +139,20 @@ status_t BnMediaCodecList::onTransact(
        }
        break;

        case GET_GLOBAL_SETTINGS:
        {
            CHECK_INTERFACE(IMediaCodecList, data, reply);
            const sp<AMessage> info = getGlobalSettings();
            if (info != NULL) {
                reply->writeInt32(OK);
                info->writeToParcel(reply);
            } else {
                reply->writeInt32(-ERANGE);
            }
            return NO_ERROR;
        }
        break;

        case FIND_CODEC_BY_TYPE:
        {
            CHECK_INTERFACE(IMediaCodecList, data, reply);
+11 −0
Original line number Diff line number Diff line
@@ -206,6 +206,17 @@ status_t MediaCodecInfo::addMime(const char *mime) {
    return OK;
}

status_t MediaCodecInfo::updateMime(const char *mime) {
    ssize_t ix = getCapabilityIndex(mime);
    if (ix < 0) {
        ALOGE("updateMime mime not found %s", mime);
        return -EINVAL;
    }

    mCurrentCaps = mCaps.valueAt(ix);
    return OK;
}

void MediaCodecInfo::removeMime(const char *mime) {
    ssize_t ix = getCapabilityIndex(mime);
    if (ix >= 0) {
Loading