Commit 47c136c6 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: mp4: extract iTunesInfo

parent b80e7034
......@@ -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 },
......
......@@ -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' )
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment