[vlc-commits] mux: extradata: parametrize extradata type

Francois Cartegnie git at videolan.org
Mon Dec 24 10:24:14 CET 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Dec 24 09:56:21 2018 +0100| [389be6fc27334c7762a8d9b1e2846bba822bcca9] | committer: Francois Cartegnie

mux: extradata: parametrize extradata type

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=389be6fc27334c7762a8d9b1e2846bba822bcca9
---

 modules/mux/extradata.c | 34 +++++++++++++++++++++-------------
 modules/mux/extradata.h |  7 ++++++-
 modules/mux/mp4/mp4.c   |  3 ++-
 3 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/modules/mux/extradata.c b/modules/mux/extradata.c
index c66565d1aa..e0c7365044 100644
--- a/modules/mux/extradata.c
+++ b/modules/mux/extradata.c
@@ -163,24 +163,32 @@ void mux_extradata_builder_Delete(mux_extradata_builder_t *m)
     free(m);
 }
 
-mux_extradata_builder_t * mux_extradata_builder_New(vlc_fourcc_t fcc)
+static const struct
 {
+    enum mux_extradata_type_e type;
+    vlc_fourcc_t fcc;
     const struct mux_extradata_builder_cb *cb;
-    switch(fcc)
+} mappings[] = {
+    { EXTRADATA_ISOBMFF, VLC_CODEC_AV1,  &av1_cb },
+    { EXTRADATA_ISOBMFF, VLC_CODEC_A52,  &ac3_cb },
+    { EXTRADATA_ISOBMFF, VLC_CODEC_EAC3, &eac3_cb },
+};
+
+mux_extradata_builder_t * mux_extradata_builder_New(vlc_fourcc_t fcc,
+                                                    enum mux_extradata_type_e type)
+{
+    const struct mux_extradata_builder_cb *cb = NULL;
+    for(size_t i=0; i<ARRAY_SIZE(mappings); i++)
     {
-        case VLC_CODEC_AV1:
-            cb = &av1_cb;
-            break;
-        case VLC_CODEC_A52:
-            cb = &ac3_cb;
-            break;
-        case VLC_CODEC_EAC3:
-            cb = &eac3_cb;
-            break;
-        default:
-            return NULL;
+        if(mappings[i].type != type || mappings[i].fcc != fcc)
+            continue;
+        cb = mappings[i].cb;
+        break;
     }
 
+    if(cb == NULL)
+        return NULL;
+
     mux_extradata_builder_t *m = calloc(1, sizeof(*m));
     if(m)
     {
diff --git a/modules/mux/extradata.h b/modules/mux/extradata.h
index 6754f84294..2b2cc55b6e 100644
--- a/modules/mux/extradata.h
+++ b/modules/mux/extradata.h
@@ -20,7 +20,12 @@
 
 typedef struct mux_extradata_builder_t mux_extradata_builder_t;
 
-mux_extradata_builder_t * mux_extradata_builder_New(vlc_fourcc_t);
+enum mux_extradata_type_e
+{
+    EXTRADATA_ISOBMFF,
+};
+
+mux_extradata_builder_t * mux_extradata_builder_New(vlc_fourcc_t, enum mux_extradata_type_e);
 void mux_extradata_builder_Delete(mux_extradata_builder_t *);
 void mux_extradata_builder_Feed(mux_extradata_builder_t *, const uint8_t *, size_t);
 size_t mux_extradata_builder_Get(mux_extradata_builder_t *, const uint8_t **);
diff --git a/modules/mux/mp4/mp4.c b/modules/mux/mp4/mp4.c
index 2c496a7c12..d85de415d1 100644
--- a/modules/mux/mp4/mp4.c
+++ b/modules/mux/mp4/mp4.c
@@ -526,7 +526,8 @@ static int AddStream(sout_mux_t *p_mux, sout_input_t *p_input)
         return VLC_ENOMEM;
     }
 
-    p_stream->extrabuilder = mux_extradata_builder_New(p_input->p_fmt->i_codec);
+    p_stream->extrabuilder = mux_extradata_builder_New(p_input->p_fmt->i_codec,
+                                                       EXTRADATA_ISOBMFF);
     p_stream->p_fmt = p_input->p_fmt;
 
     p_input->p_sys          = p_stream;



More information about the vlc-commits mailing list