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

Commit 57822099 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Export support types from extractors

Make each extractor  plugin export a list of file types it supports,
so we no longer need to hardcode such a list in the framework.

Test: manual
Change-Id: I1e41a5d477ea56960ad3e4bc35f5183c03c3fe3a
parent 435ba2e2
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -135,8 +135,16 @@ struct ExtractorDef {
    const char *extractor_name;

    union {
        SnifferFunc v2;
    } sniff;
        struct {
            SnifferFunc sniff;
        } v2;
        struct {
            SnifferFunc sniff;
            // a NULL terminated list of container mime types and/or file extensions
            // that this extractor supports
            const char **supported_types;
        } v3;
    } u;
};

// the C++ based API which first shipped in P and is no longer supported
@@ -145,7 +153,10 @@ const uint32_t EXTRACTORDEF_VERSION_LEGACY = 1;
// the first C/NDK based API
const uint32_t EXTRACTORDEF_VERSION_NDK_V1 = 2;

const uint32_t EXTRACTORDEF_VERSION = EXTRACTORDEF_VERSION_NDK_V1;
// the second C/NDK based API
const uint32_t EXTRACTORDEF_VERSION_NDK_V2 = 3;

const uint32_t EXTRACTORDEF_VERSION = EXTRACTORDEF_VERSION_NDK_V2;

// each plugin library exports one function of this type
typedef ExtractorDef (*GetExtractorDef)();
+5 −1
Original line number Diff line number Diff line
@@ -377,6 +377,10 @@ static CreatorFunc Sniff(
    return NULL;
}

static const char *extensions[] = {
    "aac",
    NULL
};

extern "C" {
// This is the only symbol that needs to be exported
@@ -387,7 +391,7 @@ ExtractorDef GETEXTRACTORDEF() {
        UUID("4fd80eae-03d2-4d72-9eb9-48fa6bb54613"),
        1, // version
        "AAC Extractor",
        { .v2 = Sniff }
        { .v3 = {Sniff, extensions} },
    };
}

+25 −16
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ media_status_t AMRExtractor::getMetaData(AMediaFormat *meta) {

    if (mInitCheck == OK) {
        AMediaFormat_setString(meta,
                AMEDIAFORMAT_KEY_MIME, mIsWide ? "audio/amr-wb" : "audio/amr");
                AMEDIAFORMAT_KEY_MIME, mIsWide ? MEDIA_MIMETYPE_AUDIO_AMR_WB : "audio/amr");
    }

    return AMEDIA_OK;
@@ -358,6 +358,12 @@ media_status_t AMRSource::read(

////////////////////////////////////////////////////////////////////////////////

static const char *extensions[] = {
    "amr",
    "awb",
    NULL
};

extern "C" {
// This is the only symbol that needs to be exported
__attribute__ ((visibility ("default")))
@@ -368,7 +374,8 @@ ExtractorDef GETEXTRACTORDEF() {
        1,
        "AMR Extractor",
        {
           .v2 = [](
           .v3 = {
               [](
                   CDataSource *source,
                   float *confidence,
                   void **,
@@ -381,8 +388,10 @@ ExtractorDef GETEXTRACTORDEF() {
                           return wrap(new AMRExtractor(new DataSourceHelper(source)));};
                   }
                   return NULL;
            }
        }
               },
               extensions
           },
        },
    };
}

+18 −10
Original line number Diff line number Diff line
@@ -822,6 +822,11 @@ bool SniffFLAC(DataSourceHelper *source, float *confidence)
    return true;
}

static const char *extensions[] = {
    "flac",
    "fl",
    NULL
};

extern "C" {
// This is the only symbol that needs to be exported
@@ -833,7 +838,8 @@ ExtractorDef GETEXTRACTORDEF() {
            1,
            "FLAC Extractor",
            {
                .v2 = [](
                .v3 = {
                    [](
                        CDataSource *source,
                        float *confidence,
                        void **,
@@ -846,8 +852,10 @@ ExtractorDef GETEXTRACTORDEF() {
                                return wrap(new FLACExtractor(new DataSourceHelper(source)));};
                        }
                        return NULL;
                    },
                    extensions
                }
            }
            },
     };
}

+24 −9
Original line number Diff line number Diff line
@@ -326,6 +326,18 @@ bool SniffMidi(CDataSource *source, float *confidence)

}

static const char *extensions[] = {
    "imy",
    "mid",
    "midi",
    "mxmf",
    "ota",
    "rtttl",
    "rtx",
    "smf",
    "xmf",
    NULL
};

extern "C" {
// This is the only symbol that needs to be exported
@@ -337,7 +349,8 @@ ExtractorDef GETEXTRACTORDEF() {
        1,
        "MIDI Extractor",
        {
            .v2 = [](
            .v3 = {
                [](
                CDataSource *source,
                float *confidence,
                void **,
@@ -349,8 +362,10 @@ ExtractorDef GETEXTRACTORDEF() {
                            return wrap(new MidiExtractor(source));};
                    }
                    return NULL;
                },
                extensions
            }
        }
        },
    };
}

Loading