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

Commit f7863e09 authored by Ray Essick's avatar Ray Essick Committed by Automerger Merge Worker
Browse files

Cleaner fallback for findMatchingCodec() am: c7d3e049

parents bca41cc0 c7d3e049
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <media/stagefright/xmlparser/MediaCodecsXmlParser.h>
#include <media/stagefright/CCodec.h>
#include <media/stagefright/Codec2InfoBuilder.h>
#include <media/stagefright/MediaCodecConstants.h>
#include <media/stagefright/MediaCodecList.h>
#include <media/stagefright/MediaCodecListOverrides.h>
#include <media/stagefright/MediaErrors.h>
@@ -356,17 +357,6 @@ void MediaCodecList::findMatchingCodecs(
void MediaCodecList::findMatchingCodecs(
        const char *mime, bool encoder, uint32_t flags, const sp<AMessage> &format,
        Vector<AString> *matches) {
    findMatchingCodecs(mime, encoder, flags, format, matches, /* checkProfile= */ true);
    if (matches->empty()) {
        ALOGV("no matching codec found, retrying without profile check");
        findMatchingCodecs(mime, encoder, flags, format, matches, /* checkProfile= */ false);
    }
}

//static
void MediaCodecList::findMatchingCodecs(
        const char *mime, bool encoder, uint32_t flags, const sp<AMessage> &format,
        Vector<AString> *matches, bool checkProfile) {
    matches->clear();

    const sp<IMediaCodecList> list = getInstance();
@@ -390,7 +380,7 @@ void MediaCodecList::findMatchingCodecs(

        AString componentName = info->getCodecName();

        if (!codecHandlesFormat(mime, info, format, checkProfile)) {
        if (!codecHandlesFormat(mime, info, format)) {
            ALOGV("skipping codec '%s' which doesn't satisfy format %s",
                  componentName.c_str(), format->debugString(2).c_str());
            continue;
@@ -409,12 +399,23 @@ void MediaCodecList::findMatchingCodecs(
            property_get_bool("debug.stagefright.swcodec", false)) {
        matches->sort(compareSoftwareCodecsFirst);
    }

    // if we did NOT find anything maybe it's because of a profile mismatch.
    // let's recurse after trimming the profile from the format to see if that yields
    // a suitable codec.
    //
    int profile = -1;
    if (matches->empty() && format->findInt32(KEY_PROFILE, &profile)) {
        ALOGV("no matching codec found, retrying without profile");
        sp<AMessage> formatNoProfile = format->dup();
        formatNoProfile->removeEntryByName(KEY_PROFILE);
        findMatchingCodecs(mime, encoder, flags, formatNoProfile, matches);
    }
}

// static
bool MediaCodecList::codecHandlesFormat(
        const char *mime, const sp<MediaCodecInfo> &info, const sp<AMessage> &format,
        bool checkProfile) {
        const char *mime, const sp<MediaCodecInfo> &info, const sp<AMessage> &format) {

    if (format == nullptr) {
        ALOGD("codecHandlesFormat: no format, so no extra checks");
@@ -522,7 +523,7 @@ bool MediaCodecList::codecHandlesFormat(
        }

        int32_t profile = -1;
        if (checkProfile && format->findInt32("profile", &profile)) {
        if (format->findInt32(KEY_PROFILE, &profile)) {
            Vector<MediaCodecInfo::ProfileLevel> profileLevels;
            capabilities->getSupportedProfileLevels(&profileLevels);
            auto it = profileLevels.begin();
+1 −10
Original line number Diff line number Diff line
@@ -114,19 +114,10 @@ private:
    MediaCodecList(const MediaCodecList&) = delete;
    MediaCodecList& operator=(const MediaCodecList&) = delete;

    static void findMatchingCodecs(
            const char *mime,
            bool createEncoder,
            uint32_t flags,
            const sp<AMessage> &format,
            Vector<AString> *matchingCodecs,
            bool checkProfile);

    static bool codecHandlesFormat(
            const char *mime,
            const sp<MediaCodecInfo> &info,
            const sp<AMessage> &format,
            bool checkProfile);
            const sp<AMessage> &format);
};

}  // namespace android