[vlc-commits] demux: mp4: extract iTunesInfo
Francois Cartegnie
git at videolan.org
Mon May 29 17:14:25 CEST 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon May 29 15:42:40 2017 +0200| [47c136c6638e073946c93dc8a069b7b74f39a8fa] | committer: Francois Cartegnie
demux: mp4: extract iTunesInfo
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=47c136c6638e073946c93dc8a069b7b74f39a8fa
---
modules/demux/mp4/libmp4.c | 5 ++++-
modules/demux/mp4/libmp4.h | 2 ++
modules/demux/mp4/meta.c | 28 ++++++++++++++++++++++++++++
3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index f61d4c4496..b410e41c2e 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -4438,6 +4438,7 @@ static const struct
{ ATOM_gssd, MP4_ReadBox_Metadata, ATOM_ilst },
{ ATOM_gsst, MP4_ReadBox_Metadata, ATOM_ilst },
{ ATOM_gstd, MP4_ReadBox_Metadata, ATOM_ilst },
+ { ATOM_ITUN, MP4_ReadBox_Metadata, ATOM_ilst }, /* iTunesInfo */
/* udta */
{ ATOM_0x40PRM, MP4_ReadBox_Binary, ATOM_udta },
@@ -4503,7 +4504,9 @@ static const struct
/* iTunes/Quicktime meta info */
{ ATOM_meta, MP4_ReadBox_meta, 0 },
- { ATOM_data, MP4_ReadBox_data, 0 },
+ { 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 },
/* found in smoothstreaming */
{ ATOM_traf, MP4_ReadBoxContainer, ATOM_moof },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index ad2c373132..0836c14ffb 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -275,6 +275,7 @@ typedef int64_t stime_t;
#define ATOM_user VLC_FOURCC( 'u', 's', 'e', 'r' )
#define ATOM_key VLC_FOURCC( 'k', 'e', 'y', ' ' )
#define ATOM_iviv VLC_FOURCC( 'i', 'v', 'i', 'v' )
+#define ATOM_mean VLC_FOURCC( 'm', 'e', 'a', 'n' )
#define ATOM_name VLC_FOURCC( 'n', 'a', 'm', 'e' )
#define ATOM_priv VLC_FOURCC( 'p', 'r', 'i', 'v' )
#define ATOM_drmi VLC_FOURCC( 'd', 'r', 'm', 'i' )
@@ -354,6 +355,7 @@ typedef int64_t stime_t;
#define ATOM_HMMT VLC_FOURCC( 'H', 'M', 'M', 'T' )
#define ATOM_disk VLC_FOURCC( 'd', 'i', 's', 'k' )
#define ATOM_WLOC VLC_FOURCC( 'W', 'L', 'O', 'C' )
+#define ATOM_ITUN VLC_FOURCC( '-', '-', '-', '-' )
#define ATOM_meta VLC_FOURCC( 'm', 'e', 't', 'a' )
#define ATOM_atID VLC_FOURCC( 'a', 't', 'I', 'D' )
diff --git a/modules/demux/mp4/meta.c b/modules/demux/mp4/meta.c
index 2510c167e4..180a11e913 100644
--- a/modules/demux/mp4/meta.c
+++ b/modules/demux/mp4/meta.c
@@ -319,6 +319,31 @@ static int ExtractIntlStrings( vlc_meta_t *p_meta, MP4_Box_t *p_box )
return i_read == 0;
}
+static void ExtractItunesInfoTriplets( vlc_meta_t *p_meta, MP4_Box_t *p_box )
+{
+ if( p_box->i_type != ATOM_ITUN )
+ return;
+ MP4_Box_t *p_mean = MP4_BoxGet( p_box, "mean" );
+ MP4_Box_t *p_name = MP4_BoxGet( p_box, "name" );
+ MP4_Box_t *p_data = MP4_BoxGet( p_box, "data" );
+ if( !p_mean || p_mean->data.p_binary->i_blob < 4 + 16 ||
+ !p_name || p_name->data.p_binary->i_blob < 5 ||
+ !p_data || !BOXDATA(p_data) )
+ return;
+
+ if( !strncmp( &((char*)p_mean->data.p_binary->p_blob)[4], "com.apple.iTunes",
+ p_mean->data.p_binary->i_blob - 4 ) )
+ {
+ char *psz_name = strndup( &((char*)p_name->data.p_binary->p_blob)[4],
+ p_name->data.p_binary->i_blob - 4 );
+ char *psz_value = ExtractString( p_data );
+ if( psz_name && psz_value )
+ vlc_meta_AddExtra( p_meta, psz_name, psz_value );
+ free( psz_name );
+ free( psz_value );
+ }
+}
+
static void SetupmdirMeta( vlc_meta_t *p_meta, MP4_Box_t *p_box )
{
const MP4_Box_t *p_data = MP4_BoxGet( p_box, "data" );
@@ -421,6 +446,9 @@ static void SetupmdirMeta( vlc_meta_t *p_meta, MP4_Box_t *p_box )
}
break;
}
+ case ATOM_ITUN:
+ ExtractItunesInfoTriplets( p_meta, p_box );
+ break;
default:
SetMeta( p_meta, p_box->i_type, NULL, p_box );
break;
More information about the vlc-commits
mailing list