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

Commit 70b22a02 authored by Vignesh Venkatasubramanian's avatar Vignesh Venkatasubramanian
Browse files

libstagefright/webm: Add support for VP9 in webm muxer

WebM muxer cannot write out VP9 files. This CL adds support for
that. It will be useful when VP9 hardware encoders come out and
also when we add the software encoder for VP9.

Change-Id: Ie24d0f928a7421d8e6a53073b4cae45fba01d45b
parent 81becaec
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -338,6 +338,7 @@ sp<WebmElement> WebmElement::AudioTrackEntry(
}

sp<WebmElement> WebmElement::VideoTrackEntry(
        const char *codec,
        uint64_t width,
        uint64_t height,
        uint64_t uid,
@@ -353,7 +354,7 @@ sp<WebmElement> WebmElement::VideoTrackEntry(
            uid,
            lacing,
            lang,
            "V_VP8",
            codec,
            kVideoType,
            trackEntryFields);

+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ struct WebmElement : public LightRefBase<WebmElement> {
            const char *lang = "und");

    static sp<WebmElement> VideoTrackEntry(
            const char *codec,
            uint64_t width,
            uint64_t height,
            uint64_t uid = 0,
+22 −3
Original line number Diff line number Diff line
@@ -83,9 +83,25 @@ WebmWriter::WebmWriter(int fd)
// static
sp<WebmElement> WebmWriter::videoTrack(const sp<MetaData>& md) {
    int32_t width, height;
    const char *mimeType;
    CHECK(md->findInt32(kKeyWidth, &width));
    CHECK(md->findInt32(kKeyHeight, &height));
    return WebmElement::VideoTrackEntry(width, height);
    CHECK(md->findCString(kKeyMIMEType, &mimeType));
    const char *codec;
    if (!strncasecmp(
            mimeType,
            MEDIA_MIMETYPE_VIDEO_VP8,
            strlen(MEDIA_MIMETYPE_VIDEO_VP8))) {
        codec = "V_VP8";
    } else if (!strncasecmp(
            mimeType,
            MEDIA_MIMETYPE_VIDEO_VP9,
            strlen(MEDIA_MIMETYPE_VIDEO_VP9))) {
        codec = "V_VP9";
    } else {
        CHECK(!"Unsupported codec");
    }
    return WebmElement::VideoTrackEntry(codec, width, height);
}

// static
@@ -348,15 +364,18 @@ status_t WebmWriter::addSource(const sp<IMediaSource> &source) {
    const char *mime;
    source->getFormat()->findCString(kKeyMIMEType, &mime);
    const char *vp8 = MEDIA_MIMETYPE_VIDEO_VP8;
    const char *vp9 = MEDIA_MIMETYPE_VIDEO_VP9;
    const char *vorbis = MEDIA_MIMETYPE_AUDIO_VORBIS;

    size_t streamIndex;
    if (!strncasecmp(mime, vp8, strlen(vp8))) {
    if (!strncasecmp(mime, vp8, strlen(vp8)) ||
        !strncasecmp(mime, vp9, strlen(vp9))) {
        streamIndex = kVideoIndex;
    } else if (!strncasecmp(mime, vorbis, strlen(vorbis))) {
        streamIndex = kAudioIndex;
    } else {
        ALOGE("Track (%s) other than %s or %s is not supported", mime, vp8, vorbis);
        ALOGE("Track (%s) other than %s, %s or %s is not supported",
              mime, vp8, vp9, vorbis);
        return ERROR_UNSUPPORTED;
    }