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

Commit decc50ef authored by David Yeh's avatar David Yeh Committed by Robert Shih
Browse files

MetaData/MPEG4Writer: add language

Bug: 21761589
Bug: 24278318
Bug: 24615792
Change-Id: Iea039047c6c63551bcb0e65de9f4b089fd2fc85d
parent 781103a0
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -3259,7 +3259,12 @@ void MPEG4Writer::Track::writeMdhdBox(uint32_t now) {
    // Each character is packed as the difference between its ASCII value and 0x60.
    // For "English", these are 00101, 01110, 00111.
    // XXX: Where is the padding bit located: 0x15C7?
    mOwner->writeInt16(0);             // language code
    const char *lang = NULL;
    int16_t langCode = 0;
    if (mMeta->findCString(kKeyMediaLanguage, &lang) && lang && strnlen(lang, 3) > 2) {
        langCode = ((lang[0] & 0x1f) << 10) | ((lang[1] & 0x1f) << 5) | (lang[2] & 0x1f);
    }
    mOwner->writeInt16(langCode);      // language code
    mOwner->writeInt16(0);             // predefined
    mOwner->endBox();
}
+10 −0
Original line number Diff line number Diff line
@@ -637,6 +637,11 @@ status_t convertMetaDataToMessage(
        msg->setInt32("track-id", trackID);
    }

    const char *lang;
    if (meta->findCString(kKeyMediaLanguage, &lang)) {
        msg->setString("language", lang);
    }

    if (!strncasecmp("video/", mime, 6)) {
        int32_t width, height;
        if (!meta->findInt32(kKeyWidth, &width)
@@ -1273,6 +1278,11 @@ void convertMessageToMetaData(const sp<AMessage> &msg, sp<MetaData> &meta) {
        meta->setInt32(kKeyMaxBitRate, maxBitrate);
    }

    AString lang;
    if (msg->findString("language", &lang)) {
        meta->setCString(kKeyMediaLanguage, lang.c_str());
    }

    if (mime.startsWith("video/")) {
        int32_t width;
        int32_t height;