[vlc-commits] demux: mp4: parse 3GPP ID3

Francois Cartegnie git at videolan.org
Mon May 29 20:33:51 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon May 29 20:01:42 2017 +0200| [d7c9404fbee95fb527ef9449122fcee4f8ede12d] | committer: Francois Cartegnie

demux: mp4: parse 3GPP ID3

Untested

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

 modules/demux/mp4/libmp4.c |  1 +
 modules/demux/mp4/libmp4.h |  2 ++
 modules/demux/mp4/meta.c   | 28 ++++++++++++++++++++++++++++
 3 files changed, 31 insertions(+)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index b410e41c2e..f67f965b6a 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -4504,6 +4504,7 @@ static const struct
 
     /* iTunes/Quicktime meta info */
     { ATOM_meta,    MP4_ReadBox_meta,    0 },
+    { ATOM_ID32,    MP4_ReadBox_Binary,  ATOM_meta }, /* ID3v2 in 3GPP / ETSI TS 126 244 8.3 */
     { ATOM_data,    MP4_ReadBox_data,    0 }, /* ilst/@too and others, ITUN/data */
     { ATOM_mean,    MP4_ReadBox_Binary,  ATOM_ITUN },
     { ATOM_name,    MP4_ReadBox_Binary,  ATOM_ITUN },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 0836c14ffb..646ffb018a 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -354,6 +354,7 @@ typedef int64_t stime_t;
 #define ATOM_chpl VLC_FOURCC( 'c', 'h', 'p', 'l' )
 #define ATOM_HMMT VLC_FOURCC( 'H', 'M', 'M', 'T' )
 #define ATOM_disk VLC_FOURCC( 'd', 'i', 's', 'k' )
+#define ATOM_ID32 VLC_FOURCC( 'I', 'D', '3', '2' )
 #define ATOM_WLOC VLC_FOURCC( 'W', 'L', 'O', 'C' )
 #define ATOM_ITUN VLC_FOURCC( '-', '-', '-', '-' )
 
@@ -383,6 +384,7 @@ typedef int64_t stime_t;
 
 #define HANDLER_mdta VLC_FOURCC('m', 'd', 't', 'a')
 #define HANDLER_mdir VLC_FOURCC('m', 'd', 'i', 'r')
+#define HANDLER_ID32 ATOM_ID32
 
 #define SAMPLEGROUP_rap  VLC_FOURCC('r', 'a', 'p', ' ')
 
diff --git a/modules/demux/mp4/meta.c b/modules/demux/mp4/meta.c
index 3421e847d6..6a8942ec44 100644
--- a/modules/demux/mp4/meta.c
+++ b/modules/demux/mp4/meta.c
@@ -28,6 +28,9 @@
 #include <vlc_meta.h>
 #include <vlc_charset.h>
 
+#include "../meta_engine/ID3Tag.h"
+#include "../meta_engine/ID3Meta.h"
+
 #include <assert.h>
 
 static const struct
@@ -487,6 +490,27 @@ static void SetupmdtaMeta( vlc_meta_t *p_meta, MP4_Box_t *p_box, MP4_Box_t *p_ke
     }
 }
 
+static int ID3TAG_Parse_Handler( uint32_t i_tag, const uint8_t *p_payload,
+                                 size_t i_payload, void *p_priv )
+{
+    vlc_meta_t *p_meta = (vlc_meta_t *) p_priv;
+
+    (void) ID3HandleTag( p_payload, i_payload, i_tag, p_meta, NULL );
+
+    return VLC_SUCCESS;
+}
+
+static void SetupID3v2Meta( vlc_meta_t *p_meta, MP4_Box_t *p_box )
+{
+    const MP4_Box_t *p_binary = MP4_BoxGet( p_box, "ID32" );
+    if( p_binary == NULL || !BOXDATA(p_binary) || BOXDATA(p_binary)->i_blob < 6 + 20 + 1 )
+        return;
+
+    /* ID3v2 in 3GPP / ETSI TS 126 244 8.3, Header size 4 + 2 */
+    ID3TAG_Parse( &((uint8_t *)BOXDATA(p_binary)->p_blob)[6], BOXDATA(p_binary)->i_blob - 6,
+                  ID3TAG_Parse_Handler, p_meta );
+}
+
 void SetupMeta( vlc_meta_t *p_meta, MP4_Box_t *p_udta )
 {
     uint32_t i_handler = 0;
@@ -504,6 +528,10 @@ void SetupMeta( vlc_meta_t *p_meta, MP4_Box_t *p_udta )
                 break;
             }
 
+            case HANDLER_ID32:
+                SetupID3v2Meta( p_meta, p_box );
+                break;
+
             case HANDLER_mdir:
             default:
                 SetupmdirMeta( p_meta, p_box );



More information about the vlc-commits mailing list