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

Commit 675253c4 authored by Gopalakrishnan Nallasamy's avatar Gopalakrishnan Nallasamy
Browse files

WebmWriter:read kKeyBitsPerSample from input

kKeyBitsPerSample information from input was not passed to
audioTrackEntry while remuxing. Hence, the metadata of input file and
muxed file didn't match.  Now kKeyBitsPerSample is passed as it is in
the input to muxed file.

Bug: 131842669

Test: cts-tradefed run cts-dev -m CtsMediaTestCases --compatibility:module-arg
      CtsMediaTestCases:include-annotation:android.platform.test.annotations.RequiresDevice

Change-Id: I04ab296c39596d02c3f2cd9e219d8d80fe2f9185
parent 91c82546
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -124,6 +124,11 @@ sp<WebmElement> WebmWriter::audioTrack(const sp<MetaData>& md) {
        return NULL;
    }

    int32_t bitsPerSample = 0;
    if (!md->findInt32(kKeyBitsPerSample, &bitsPerSample)) {
        ALOGV("kKeyBitsPerSample not available");
    }

    if (!strncasecmp(mimeType, MEDIA_MIMETYPE_AUDIO_OPUS, strlen(MEDIA_MIMETYPE_AUDIO_OPUS))) {
        // Opus in WebM is a well-known, yet under-documented, format. The codec private data
        // of the track is an Opus Ogg header (https://tools.ietf.org/html/rfc7845#section-5.1)
@@ -164,8 +169,8 @@ sp<WebmElement> WebmWriter::audioTrack(const sp<MetaData>& md) {
        uint8_t* codecPrivateData = codecPrivateBuf->data();

        memcpy(codecPrivateData + off, (uint8_t*)header_data, headerSize);
        sp<WebmElement> entry =
                WebmElement::AudioTrackEntry("A_OPUS", nChannels, samplerate, codecPrivateBuf);
        sp<WebmElement> entry = WebmElement::AudioTrackEntry("A_OPUS", nChannels, samplerate,
                                                             codecPrivateBuf, bitsPerSample);
        return entry;
    } else if (!strncasecmp(mimeType,
                            MEDIA_MIMETYPE_AUDIO_VORBIS,
@@ -203,8 +208,8 @@ sp<WebmElement> WebmWriter::audioTrack(const sp<MetaData>& md) {
        off += headerSize2;
        memcpy(codecPrivateData + off, headerData3, headerSize3);

        sp<WebmElement> entry =
                WebmElement::AudioTrackEntry("A_VORBIS", nChannels, samplerate, codecPrivateBuf);
        sp<WebmElement> entry = WebmElement::AudioTrackEntry("A_VORBIS", nChannels, samplerate,
                                                             codecPrivateBuf, bitsPerSample);
        return entry;
    } else {
        ALOGE("Track (%s) is not a supported audio format", mimeType);