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

Commit 1512c75c authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: MediaCodecsXmlParser: add support for parsing rank

Rank is supplied in a limit:

<Limit name="rank" value="4" />

This overrides the rank provided by the component stores (C2Store,
or default values for OMX).

Bug: 119631295
Change-Id: I01cfcaf1dcdb60f8bd6f907ebec0ed3f4e3b117b
parent 2df13053
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -502,6 +502,7 @@ status_t MediaCodecsXmlParser::addMediaCodecFromAttributes(
    const char *name = nullptr;
    const char *type = nullptr;
    const char *update = nullptr;
    const char *rank = nullptr;

    size_t i = 0;
    while (attrs[i] != nullptr) {
@@ -523,6 +524,12 @@ status_t MediaCodecsXmlParser::addMediaCodecFromAttributes(
                return BAD_VALUE;
            }
            update = attrs[i];
        } else if (strEq(attrs[i], "rank")) {
            if (attrs[++i] == nullptr) {
                ALOGE("addMediaCodecFromAttributes: rank is null");
                return BAD_VALUE;
            }
            rank = attrs[i];
        } else {
            ALOGE("addMediaCodecFromAttributes: unrecognized attribute: %s", attrs[i]);
            return BAD_VALUE;
@@ -579,6 +586,15 @@ status_t MediaCodecsXmlParser::addMediaCodecFromAttributes(
        }
    }

    if (rank != nullptr) {
        if (!mCurrentCodec->second.rank.empty() && mCurrentCodec->second.rank != rank) {
            ALOGE("addMediaCodecFromAttributes: code \"%s\" rank changed from \"%s\" to \"%s\"",
                    name, mCurrentCodec->second.rank.c_str(), rank);
            return BAD_VALUE;
        }
        mCurrentCodec->second.rank = rank;
    }

    return OK;
}

@@ -1035,6 +1051,7 @@ void MediaCodecsXmlParser::generateRoleMap() const {
        const auto& codecName = codec.first;
        bool isEncoder = codec.second.isEncoder;
        size_t order = codec.second.order;
        std::string rank = codec.second.rank;
        const auto& typeMap = codec.second.typeMap;
        for (const auto& type : typeMap) {
            const auto& typeName = type.first;
@@ -1090,6 +1107,9 @@ void MediaCodecsXmlParser::generateRoleMap() const {
                    nodeInfo.attributeList.push_back(Attribute{quirk, "present"});
                }
            }
            if (!rank.empty()) {
                nodeInfo.attributeList.push_back(Attribute{"rank", rank});
            }
            nodeList->insert(std::make_pair(
                    std::move(order), std::move(nodeInfo)));
        }
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ public:
        QuirkSet quirkSet; ///< Set of quirks requested by this codec
        TypeMap typeMap;   ///< Map of types supported by this codec
        std::vector<std::string> aliases; ///< Name aliases for this codec
        std::string rank;  ///< Rank of this codec. This is a numeric string.
    };

    typedef std::pair<std::string, CodecProperties> Codec;