Commit d4f8c820 authored by Laurent Aimar's avatar Laurent Aimar

* libmp4.c: MMhh .mp4 is 99.99% the same thing than .mov but not 100% :(((

 * mp4.c: hdlr atom in the .mp4 and .mov way.
parent 24aecbe0
......@@ -729,15 +729,39 @@ static int MP4_ReadBox_mdhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
static int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
int32_t i_reserved;
MP4_READBOX_ENTER( MP4_Box_data_hdlr_t );
MP4_GETVERSIONFLAGS( p_box->data.p_hdlr );
MP4_GET4BYTES( p_box->data.p_hdlr->i_predefined );
MP4_GETFOURCC( p_box->data.p_hdlr->i_predefined );
MP4_GETFOURCC( p_box->data.p_hdlr->i_handler_type );
MP4_GET4BYTES( i_reserved );
MP4_GET4BYTES( i_reserved );
MP4_GET4BYTES( i_reserved );
p_box->data.p_hdlr->psz_name = calloc( sizeof( char ), i_read + 1 );
memcpy( p_box->data.p_hdlr->psz_name, p_peek, i_read );
/* Yes, I love .mp4 :( */
if( p_box->data.p_hdlr->i_predefined == VLC_FOURCC( 'm', 'h', 'l', 'r' ) )
{
uint8_t i_len;
int i_copy;
MP4_GET1BYTE( i_len );
i_copy = __MIN( i_read, i_len );
memcpy( p_box->data.p_hdlr->psz_name, p_peek, i_copy );
p_box->data.p_hdlr->psz_name[i_copy] = '\0';
}
else
{
memcpy( p_box->data.p_hdlr->psz_name, p_peek, i_read );
p_box->data.p_hdlr->psz_name[i_read] = '\0';
}
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->s, "read box: \"hdlr\" hanler type %4.4s name %s",
......
......@@ -1697,25 +1697,25 @@ static bo_t *GetMoovBox( sout_mux_t *p_mux )
/* handler reference */
hdlr = box_full_new( "hdlr", 0, 0 );
bo_add_fourcc( hdlr, "mhlr" ); // media handler
if( p_sys->b_mov )
bo_add_fourcc( hdlr, "mhlr" ); // media handler
else
bo_add_32be( hdlr, 0 );
if( p_stream->fmt.i_cat == AUDIO_ES )
{
bo_add_fourcc( hdlr, "soun" );
}
else if( p_stream->fmt.i_cat == VIDEO_ES )
{
bo_add_fourcc( hdlr, "vide" );
}
else if( p_stream->fmt.i_cat == SPU_ES )
{
bo_add_fourcc( hdlr, "text" );
}
bo_add_32be( hdlr, 0 ); // reserved
bo_add_32be( hdlr, 0 ); // reserved
bo_add_32be( hdlr, 0 ); // reserved
bo_add_8( hdlr, 12 );
if( p_sys->b_mov )
bo_add_8( hdlr, 12 ); /* Pascal string for .mov */
if( p_stream->fmt.i_cat == AUDIO_ES )
bo_add_mem( hdlr, 12, "SoundHandler" );
else if( p_stream->fmt.i_cat == VIDEO_ES )
......@@ -1723,6 +1723,9 @@ static bo_t *GetMoovBox( sout_mux_t *p_mux )
else
bo_add_mem( hdlr, 12, "Text Handler" );
if( !p_sys->b_mov )
bo_add_8( hdlr, 0 ); /* asciiz string for .mp4, yes that's BRAIN DAMAGED F**K MP4 */
box_fix( hdlr );
box_gather( mdia, hdlr );
......
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