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

Commit 17e172b4 authored by Dongwon Kang's avatar Dongwon Kang
Browse files

Remove String8 and AMessage from extractor plugin interface.

- mime(String8): is dropped from the interface since it was only used
for debug message. debug message is replaced with MediaExtractor::name.
- meta(AMessage): is replaced with an opaque pointer, void *, in addition
to an additional function pointer to free the object.
(In MPEG4Extractor case, AMessage with "meta-data-size", which was
introduced in Id2acdde89, is removed since the use case had been gone
with AwesomePlayer.)

Test: cts-tradefed run cts-dev --module CtsMediaTestCases --compatibility:module-arg
CtsMediaTestCases:include-annotation:android.platform.test.annotations.RequiresDevice
Bug: 67908556
Change-Id: I242944332bf0ff7dd4ad2106fe8f68e97264010b
parent d23ab3ae
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -333,13 +333,20 @@ status_t AACSource::read(

static MediaExtractor* CreateExtractor(
        DataSourceBase *source,
        const sp<AMessage>& meta) {
    return new AACExtractor(source, meta);
        void *meta) {
    sp<AMessage> metaData = static_cast<AMessage *>(meta);
    return new AACExtractor(source, metaData);
}

static void FreeMeta(void *meta) {
    if (meta != nullptr) {
        static_cast<AMessage *>(meta)->decStrong(nullptr);
    }
}

static MediaExtractor::CreatorFunc Sniff(
        DataSourceBase *source, String8 *mimeType, float *confidence,
        sp<AMessage> *meta) {
        DataSourceBase *source, float *confidence, void **meta,
        MediaExtractor::FreeMetaFunc *freeMeta) {
    off64_t pos = 0;

    for (;;) {
@@ -377,11 +384,14 @@ static MediaExtractor::CreatorFunc Sniff(

    // ADTS syncword
    if ((header[0] == 0xff) && ((header[1] & 0xf6) == 0xf0)) {
        *mimeType = MEDIA_MIMETYPE_AUDIO_AAC_ADTS;
        *confidence = 0.2;

        *meta = new AMessage;
        (*meta)->setInt64("offset", pos);
        AMessage *msg = new AMessage;
        msg->setInt64("offset", pos);
        *meta = msg;
        *freeMeta = &FreeMeta;
        // ref count will be decreased in FreeMeta.
        msg->incStrong(nullptr);

        return CreateExtractor;
    }
+12 −9
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ AMRExtractor::AMRExtractor(DataSourceBase *source)
      mOffsetTableLength(0) {
    String8 mimeType;
    float confidence;
    if (!SniffAMR(mDataSource, &mimeType, &confidence, NULL)) {
    if (!SniffAMR(mDataSource, &mimeType, &confidence)) {
        return;
    }

@@ -339,8 +339,7 @@ status_t AMRSource::read(
////////////////////////////////////////////////////////////////////////////////

bool SniffAMR(
        DataSourceBase *source, String8 *mimeType, float *confidence,
        sp<AMessage> *) {
        DataSourceBase *source, String8 *mimeType, float *confidence) {
    char header[9];

    if (source->readAt(0, header, sizeof(header)) != sizeof(header)) {
@@ -348,12 +347,16 @@ bool SniffAMR(
    }

    if (!memcmp(header, "#!AMR\n", 6)) {
        if (mimeType != nullptr) {
            *mimeType = MEDIA_MIMETYPE_AUDIO_AMR_NB;
        }
        *confidence = 0.5;

        return true;
    } else if (!memcmp(header, "#!AMR-WB\n", 9)) {
        if (mimeType != nullptr) {
            *mimeType = MEDIA_MIMETYPE_AUDIO_AMR_WB;
        }
        *confidence = 0.5;

        return true;
@@ -373,13 +376,13 @@ MediaExtractor::ExtractorDef GETEXTRACTORDEF() {
        "AMR Extractor",
        [](
                DataSourceBase *source,
                String8 *mimeType,
                float *confidence,
                sp<AMessage> *meta __unused) -> MediaExtractor::CreatorFunc {
            if (SniffAMR(source, mimeType, confidence, meta)) {
                void **,
                MediaExtractor::FreeMetaFunc *) -> MediaExtractor::CreatorFunc {
            if (SniffAMR(source, nullptr, confidence)) {
                return [](
                        DataSourceBase *source,
                        const sp<AMessage>& meta __unused) -> MediaExtractor* {
                        void *) -> MediaExtractor* {
                    return new AMRExtractor(source);};
            }
            return NULL;
+1 −2
Original line number Diff line number Diff line
@@ -55,8 +55,7 @@ private:
};

bool SniffAMR(
        DataSourceBase *source, String8 *mimeType, float *confidence,
        sp<AMessage> *);
        DataSourceBase *source, String8 *mimeType, float *confidence);

}  // namespace android

+5 −8
Original line number Diff line number Diff line
@@ -968,9 +968,7 @@ sp<MetaData> FLACExtractor::getMetaData()

// Sniffer

bool SniffFLAC(
        DataSourceBase *source, String8 *mimeType, float *confidence,
        sp<AMessage> *)
bool SniffFLAC(DataSourceBase *source, float *confidence)
{
    // first 4 is the signature word
    // second 4 is the sizeof STREAMINFO
@@ -983,7 +981,6 @@ bool SniffFLAC(
        return false;
    }

    *mimeType = MEDIA_MIMETYPE_AUDIO_FLAC;
    *confidence = 0.5;

    return true;
@@ -1001,13 +998,13 @@ MediaExtractor::ExtractorDef GETEXTRACTORDEF() {
            "FLAC Extractor",
            [](
                    DataSourceBase *source,
                    String8 *mimeType,
                    float *confidence,
                    sp<AMessage> *meta __unused) -> MediaExtractor::CreatorFunc {
                if (SniffFLAC(source, mimeType, confidence, meta)) {
                    void **,
                    MediaExtractor::FreeMetaFunc *) -> MediaExtractor::CreatorFunc {
                if (SniffFLAC(source, confidence)) {
                    return [](
                            DataSourceBase *source,
                            const sp<AMessage>& meta __unused) -> MediaExtractor* {
                            void *) -> MediaExtractor* {
                        return new FLACExtractor(source);};
                }
                return NULL;
+1 −2
Original line number Diff line number Diff line
@@ -56,8 +56,7 @@ private:

};

bool SniffFLAC(DataSourceBase *source, String8 *mimeType,
        float *confidence, sp<AMessage> *);
bool SniffFLAC(DataSourceBase *source, float *confidence);

}  // namespace android

Loading