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

Commit 732c6d95 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright/media: add support for codec features with text value

Bug: 11990470
Change-Id: I7600d999c5f4b6821d825d25fa7e8a2bb5a80c46
parent 26156231
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ private:
    status_t initializeCapabilities(const CodecCapabilities &caps);
    void addDetail(const AString &key, const AString &value);
    void addFeature(const AString &key, int32_t value);
    void addFeature(const AString &key, const char *value);
    void removeMime(const char *mime);
    void complete();

+6 −0
Original line number Diff line number Diff line
@@ -257,4 +257,10 @@ void MediaCodecInfo::addFeature(const AString &key, int32_t value) {
    mCurrentCaps->mDetails->setInt32(tag.c_str(), value);
}

void MediaCodecInfo::addFeature(const AString &key, const char *value) {
    AString tag = "feature-";
    tag.append(key);
    mCurrentCaps->mDetails->setString(tag.c_str(), value);
}

}  // namespace android
+14 −1
Original line number Diff line number Diff line
@@ -783,6 +783,7 @@ status_t MediaCodecList::addFeature(const char **attrs) {
    const char *name = NULL;
    int32_t optional = -1;
    int32_t required = -1;
    const char *value = NULL;

    while (attrs[i] != NULL) {
        if (attrs[i + 1] == NULL) {
@@ -801,6 +802,9 @@ status_t MediaCodecList::addFeature(const char **attrs) {
                required = value;
            }
            ++i;
        } else if (!strcmp(attrs[i], "value")) {
            value = attrs[i + 1];
            ++i;
        } else {
            return -EINVAL;
        }
@@ -816,7 +820,16 @@ status_t MediaCodecList::addFeature(const char **attrs) {
        return -EINVAL;
    }

    if ((optional != -1 || required != -1) && (value != NULL)) {
        ALOGE("feature '%s' has both a value and optional/required attribute", name);
        return -EINVAL;
    }

    if (value != NULL) {
        mCurrentInfo->addFeature(name, value);
    } else {
        mCurrentInfo->addFeature(name, (required == 1) || (optional == 0));
    }
    return OK;
}