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

Commit 9ee755e3 authored by Toni Heidenreich's avatar Toni Heidenreich Committed by Android (Google) Code Review
Browse files

Merge "Retry codec matching without profile check if no matching codec was found."

parents 0f68b4a5 3a0ee396
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -354,8 +354,19 @@ void MediaCodecList::findMatchingCodecs(

//static
void MediaCodecList::findMatchingCodecs(
        const char *mime, bool encoder, uint32_t flags, sp<AMessage> format,
        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();
@@ -379,7 +390,7 @@ void MediaCodecList::findMatchingCodecs(

        AString componentName = info->getCodecName();

        if (!codecHandlesFormat(mime, info, format)) {
        if (!codecHandlesFormat(mime, info, format, checkProfile)) {
            ALOGV("skipping codec '%s' which doesn't satisfy format %s",
                  componentName.c_str(), format->debugString(2).c_str());
            continue;
@@ -400,9 +411,10 @@ void MediaCodecList::findMatchingCodecs(
    }
}

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

    if (format == nullptr) {
        ALOGD("codecHandlesFormat: no format, so no extra checks");
@@ -510,7 +522,7 @@ bool MediaCodecList::codecHandlesFormat(const char *mime, sp<MediaCodecInfo> inf
        }

        int32_t profile = -1;
        if (format->findInt32("profile", &profile)) {
        if (checkProfile && format->findInt32("profile", &profile)) {
            Vector<MediaCodecInfo::ProfileLevel> profileLevels;
            capabilities->getSupportedProfileLevels(&profileLevels);
            auto it = profileLevels.begin();
+15 −3
Original line number Diff line number Diff line
@@ -80,11 +80,9 @@ struct MediaCodecList : public BnMediaCodecList {
            const char *mime,
            bool createEncoder,
            uint32_t flags,
            sp<AMessage> format,
            const sp<AMessage> &format,
            Vector<AString> *matchingCodecs);

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

    static bool isSoftwareCodec(const AString &componentName);

private:
@@ -115,6 +113,20 @@ 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);
};

}  // namespace android