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

Commit eafa0534 authored by Subhash Chandra Bose Naripeddy's avatar Subhash Chandra Bose Naripeddy Committed by Steve Kondik
Browse files

libstagefright: Add support for AC3/EC3 playback in tunnel mode

- Add support for AC3 and EC3 playback in tunnel mode

Change-Id: If5de26d3ff9e63737d6ed43b904c6094f93fbfc0
parent 5dcce8b1
Loading
Loading
Loading
Loading
+27 −2
Original line number Diff line number Diff line
@@ -531,6 +531,28 @@ bool ExtendedUtils::checkIsThumbNailMode(const uint32_t flags, char* componentNa
    return isInThumbnailMode;
}

void ExtendedUtils::helper_Mpeg4ExtractorCheckAC3EAC3(MediaBuffer *buffer,
                                                        sp<MetaData> &format,
                                                        size_t size) {
    bool mMakeBigEndian = false;
    const char *mime;

    if (format->findCString(kKeyMIMEType, &mime)
            && (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AC3) ||
            !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_EAC3))) {
        mMakeBigEndian = true;
    }
    if (mMakeBigEndian && *((uint8_t *)buffer->data())==0x0b &&
            *((uint8_t *)buffer->data()+1)==0x77 ) {
        size_t count = 0;
        for(count=0;count<size;count+=2) { // size is always even bytes in ac3/ec3 read
            uint8_t tmp = *((uint8_t *)buffer->data() + count);
            *((uint8_t *)buffer->data() + count) = *((uint8_t *)buffer->data()+count+1);
            *((uint8_t *)buffer->data() + count+1) = tmp;
        }
    }
}

void ExtendedUtils::prefetchSecurePool(const char *uri)
{
    if (!strncasecmp("widevine://", uri, 11)) {
@@ -614,8 +636,6 @@ void ExtendedUtils::drainSecurePool()
        close(fd);
    }
#endif
}

}
#else //ENABLE_AV_ENHANCEMENTS

@@ -707,6 +727,11 @@ bool ExtendedUtils::checkIsThumbNailMode(const uint32_t flags, char* componentNa
    return false;
}

void ExtendedUtils::helper_Mpeg4ExtractorCheckAC3EAC3(MediaBuffer *buffer,
                                                        sp<MetaData> &format,
                                                        size_t size) {
}

void ExtendedUtils::prefetchSecurePool(int fd) {}

void ExtendedUtils::prefetchSecurePool(const char *uri) {}
+4 −0
Original line number Diff line number Diff line
@@ -3289,6 +3289,10 @@ status_t MPEG4Source::read(

                return ERROR_IO;
            }
#ifdef ENABLE_AV_ENHANCEMENTS
            //for AC3/EAC3 detection
            ExtendedUtils::helper_Mpeg4ExtractorCheckAC3EAC3(mBuffer, mFormat, size);
#endif
            CHECK(mBuffer != NULL);
            mBuffer->set_range(0, size);
            mBuffer->meta_data()->clear();
+4 −0
Original line number Diff line number Diff line
@@ -141,6 +141,10 @@ struct ExtendedUtils {

    static bool checkIsThumbNailMode(const uint32_t flags, char* componentName);

    //helper function for MPEG4 Extractor to check for AC3/EAC3 contents
    static void helper_Mpeg4ExtractorCheckAC3EAC3(MediaBuffer *buffer, sp<MetaData> &format,
                                                   size_t size);

    static void prefetchSecurePool(int fd);

    static void prefetchSecurePool(const char *uri);