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

Commit 0a4427bb authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: use MediaCodec::QueryCapabilities

This reverts commit cfb71f189ca620b7b2caf213572849bf59b50231
and still fixes b/27142863.

Bug: 27142863
Change-Id: I914bcc882d5f9049bc9eb8b31913b07ae572b441
parent 36e4e159
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -33,7 +33,6 @@ namespace android {


struct AMessage;
struct AMessage;
class Parcel;
class Parcel;
struct CodecCapabilities;


typedef KeyedVector<AString, AString> CodecSettings;
typedef KeyedVector<AString, AString> CodecSettings;


@@ -127,7 +126,8 @@ private:
    void addQuirk(const char *name);
    void addQuirk(const char *name);
    status_t addMime(const char *mime);
    status_t addMime(const char *mime);
    status_t updateMime(const char *mime);
    status_t updateMime(const char *mime);
    status_t initializeCapabilities(const CodecCapabilities &caps);

    status_t initializeCapabilities(const sp<Capabilities> &caps);
    void addDetail(const AString &key, const AString &value);
    void addDetail(const AString &key, const AString &value);
    void addFeature(const AString &key, int32_t value);
    void addFeature(const AString &key, int32_t value);
    void addFeature(const AString &key, const char *value);
    void addFeature(const AString &key, const char *value);
+8 −21
Original line number Original line Diff line number Diff line
@@ -26,8 +26,6 @@
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/foundation/AMessage.h>
#include <binder/Parcel.h>
#include <binder/Parcel.h>


#include <media/stagefright/OMXCodec.h>

namespace android {
namespace android {


void MediaCodecInfo::Capabilities::getSupportedProfileLevels(
void MediaCodecInfo::Capabilities::getSupportedProfileLevels(
@@ -240,26 +238,15 @@ void MediaCodecInfo::removeMime(const char *mime) {
    }
    }
}
}


status_t MediaCodecInfo::initializeCapabilities(const CodecCapabilities &caps) {
status_t MediaCodecInfo::initializeCapabilities(const sp<Capabilities> &caps) {
    mCurrentCaps->mProfileLevels.clear();
    // TRICKY: copy data to mCurrentCaps as it is a reference to
    // an element of the capabilites map.
    mCurrentCaps->mColorFormats.clear();
    mCurrentCaps->mColorFormats.clear();

    mCurrentCaps->mColorFormats.appendVector(caps->mColorFormats);
    for (size_t i = 0; i < caps.mProfileLevels.size(); ++i) {
    mCurrentCaps->mProfileLevels.clear();
        const CodecProfileLevel &src = caps.mProfileLevels.itemAt(i);
    mCurrentCaps->mProfileLevels.appendVector(caps->mProfileLevels);

    mCurrentCaps->mFlags = caps->mFlags;
        ProfileLevel profileLevel;
    mCurrentCaps->mDetails = caps->mDetails;
        profileLevel.mProfile = src.mProfile;
        profileLevel.mLevel = src.mLevel;
        mCurrentCaps->mProfileLevels.push_back(profileLevel);
    }

    for (size_t i = 0; i < caps.mColorFormats.size(); ++i) {
        mCurrentCaps->mColorFormats.push_back(caps.mColorFormats.itemAt(i));
    }

    mCurrentCaps->mFlags = caps.mFlags;
    mCurrentCaps->mDetails = new AMessage;

    return OK;
    return OK;
}
}


+9 −5
Original line number Original line Diff line number Diff line
@@ -31,10 +31,10 @@
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/ACodec.h>
#include <media/stagefright/ACodec.h>
#include <media/stagefright/MediaCodec.h>
#include <media/stagefright/MediaCodecList.h>
#include <media/stagefright/MediaCodecList.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/OMXClient.h>
#include <media/stagefright/OMXClient.h>
#include <media/stagefright/OMXCodec.h>


#include <sys/stat.h>
#include <sys/stat.h>
#include <utils/threads.h>
#include <utils/threads.h>
@@ -752,15 +752,19 @@ status_t MediaCodecList::initializeCapabilities(const char *type) {
    ALOGV("initializeCapabilities %s:%s",
    ALOGV("initializeCapabilities %s:%s",
            mCurrentInfo->mName.c_str(), type);
            mCurrentInfo->mName.c_str(), type);


    CodecCapabilities caps;
    sp<MediaCodecInfo::Capabilities> caps;
    status_t err = QueryCodec(
    status_t err = MediaCodec::QueryCapabilities(
            mOMX,
            mCurrentInfo->mName,
            mCurrentInfo->mName.c_str(),
            type,
            type,
            mCurrentInfo->mIsEncoder,
            mCurrentInfo->mIsEncoder,
            &caps);
            &caps);
    if (err != OK) {
    if (err != OK) {
        return err;
        return err;
    } else if (caps == NULL) {
        ALOGE("MediaCodec::QueryCapabilities returned OK but no capabilities for '%s':'%s':'%s'",
                mCurrentInfo->mName.c_str(), type,
                mCurrentInfo->mIsEncoder ? "encoder" : "decoder");
        return UNKNOWN_ERROR;
    }
    }


    return mCurrentInfo->initializeCapabilities(caps);
    return mCurrentInfo->initializeCapabilities(caps);