free( p_buff ); \
if( i_read < 0 ) \
{ \
- msg_Warn( p_stream->p_input, "Not enough data" ); \
+ msg_Warn( p_stream->s, "Not enough data" ); \
} \
return( i_code )
static MP4_Box_t *MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_father );
/*****************************************************************************
- * Some basic functions to manipulate MP4_Stream_t, an abstraction o p_input
+ * Some basic functions to manipulate MP4_Stream_t, an abstraction of stream_t
* in the way that you can read from a memory buffer or from an input
*
*****************************************************************************/
* MP4_InputStream create an stram with an input
*
****************************************************************************/
-MP4_Stream_t *MP4_InputStream( input_thread_t *p_input )
+MP4_Stream_t *MP4_InputStream( stream_t *s )
{
MP4_Stream_t *p_stream;
return( NULL );
}
p_stream->b_memory = 0;
- p_stream->p_input = p_input;
+ p_stream->s = s;
p_stream->i_start = 0;
p_stream->i_stop = 0;
p_stream->p_buffer = NULL;
* it uses p_buffer XXX you have to unallocate it yourself !
*
****************************************************************************/
-MP4_Stream_t *MP4_MemoryStream( input_thread_t *p_input,
+MP4_Stream_t *MP4_MemoryStream( stream_t *s,
int i_size, uint8_t *p_buffer )
{
MP4_Stream_t *p_stream;
return( NULL );
}
p_stream->b_memory = 1;
- p_stream->p_input = p_input;
+ p_stream->s = s;
p_stream->i_start = 0;
p_stream->i_stop = i_size;
if( !p_buffer )
}
else
{
- return( stream_Read( p_stream->p_input->s, p_buff, i_size ) < i_size ? VLC_EGENERIC : VLC_SUCCESS);
+ return( stream_Read( p_stream->s, p_buff, i_size ) < i_size ? VLC_EGENERIC : VLC_SUCCESS);
}
}
else
{
- if( p_stream->p_input->stream.p_selected_area->i_size > 0 )
+ if( stream_Size( p_stream->s ) > 0 )
{
- int64_t i_max =
- p_stream->p_input->stream.p_selected_area->i_size - stream_Tell( p_stream->p_input->s );
+ int64_t i_max = stream_Size( p_stream->s ) - stream_Tell( p_stream->s );
if( i_size > i_max )
{
i_size = i_max;
}
}
- return( stream_Peek( p_stream->p_input->s, pp_peek, i_size ) );
+ return( stream_Peek( p_stream->s, pp_peek, i_size ) );
}
}
}
else
{
- return( stream_Tell( p_stream->p_input->s ) );
+ return( stream_Tell( p_stream->s ) );
}
}
}
else
{
- return( stream_Seek( p_stream->p_input->s, (int64_t)i_pos ) );
+ return( stream_Seek( p_stream->s, (int64_t)i_pos ) );
}
}
#ifdef MP4_VERBOSE
if( p_box->i_size )
{
- msg_Dbg( p_stream->p_input, "found Box: %4.4s size "I64Fd,
+ msg_Dbg( p_stream->s, "found Box: %4.4s size "I64Fd,
(char*)&p_box->i_type,
p_box->i_size );
}
if( i_fcc == FOURCC_cmov || i_fcc == FOURCC_mvhd )
{
- msg_Warn( p_stream->p_input, "detected moov hidden in a free box ..." );
+ msg_Warn( p_stream->s, "detected moov hidden in a free box ..." );
p_box->i_type = FOURCC_foov;
return MP4_ReadBoxContainer( p_stream, p_box );
}
/* Nothing to do */
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "skip box: \"%4.4s\"",
+ msg_Dbg( p_stream->s, "skip box: \"%4.4s\"",
(char*)&p_box->i_type );
#endif
return( 1 );
{
s_duration[0] = 0;
}
- msg_Dbg( p_stream->p_input, "read box: \"mvhd\" creation %s modification %s time scale %d duration %s rate %f volume %f next track id %d",
+ msg_Dbg( p_stream->s, "read box: \"mvhd\" creation %s modification %s time scale %d duration %s rate %f volume %f next track id %d",
s_creation_time,
s_modification_time,
(uint32_t)p_box->data.p_mvhd->i_timescale,
MP4_ConvertDate2Str( s_modification_time, p_box->data.p_mvhd->i_modification_time );
MP4_ConvertDate2Str( s_duration, p_box->data.p_mvhd->i_duration );
- msg_Dbg( p_stream->p_input, "read box: \"tkhd\" creation %s modification %s duration %s track ID %d layer %d volume %f width %f height %f",
+ msg_Dbg( p_stream->s, "read box: \"tkhd\" creation %s modification %s duration %s track ID %d layer %d volume %f width %f height %f",
s_creation_time,
s_modification_time,
s_duration,
MP4_ConvertDate2Str( s_creation_time, p_box->data.p_mdhd->i_creation_time );
MP4_ConvertDate2Str( s_modification_time, p_box->data.p_mdhd->i_modification_time );
MP4_ConvertDate2Str( s_duration, p_box->data.p_mdhd->i_duration );
- msg_Dbg( p_stream->p_input, "read box: \"mdhd\" creation %s modification %s time scale %d duration %s language %c%c%c",
+ msg_Dbg( p_stream->s, "read box: \"mdhd\" creation %s modification %s time scale %d duration %s language %c%c%c",
s_creation_time,
s_modification_time,
(uint32_t)p_box->data.p_mdhd->i_timescale,
memcpy( p_box->data.p_hdlr->psz_name, p_peek, i_read );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"hdlr\" hanler type %4.4s name %s",
+ msg_Dbg( p_stream->s, "read box: \"hdlr\" hanler type %4.4s name %s",
(char*)&p_box->data.p_hdlr->i_handler_type,
p_box->data.p_hdlr->psz_name );
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"vmhd\" graphics-mode %d opcolor (%d, %d, %d)",
+ msg_Dbg( p_stream->s, "read box: \"vmhd\" graphics-mode %d opcolor (%d, %d, %d)",
p_box->data.p_vmhd->i_graphics_mode,
p_box->data.p_vmhd->i_opcolor[0],
p_box->data.p_vmhd->i_opcolor[1],
MP4_GET2BYTES( p_box->data.p_smhd->i_reserved );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"smhd\" balance %f",
+ msg_Dbg( p_stream->s, "read box: \"smhd\" balance %f",
(float)p_box->data.p_smhd->i_balance / 256 );
#endif
MP4_READBOX_EXIT( 1 );
MP4_GET4BYTES( p_box->data.p_hmhd->i_reserved );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"hmhd\" maxPDU-size %d avgPDU-size %d max-bitrate %d avg-bitrate %d",
+ msg_Dbg( p_stream->s, "read box: \"hmhd\" maxPDU-size %d avgPDU-size %d max-bitrate %d avg-bitrate %d",
p_box->data.p_hmhd->i_max_PDU_size,
p_box->data.p_hmhd->i_avg_PDU_size,
p_box->data.p_hmhd->i_max_bitrate,
MP4_GETSTRINGZ( p_box->data.p_url->psz_location );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"url\" url: %s",
+ msg_Dbg( p_stream->s, "read box: \"url\" url: %s",
p_box->data.p_url->psz_location );
#endif
MP4_GETSTRINGZ( p_box->data.p_urn->psz_location );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"urn\" name %s location %s",
+ msg_Dbg( p_stream->s, "read box: \"urn\" name %s location %s",
p_box->data.p_urn->psz_name,
p_box->data.p_urn->psz_location );
#endif
MP4_ReadBoxContainerRaw( p_stream, p_box );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"dref\" entry-count %d",
+ msg_Dbg( p_stream->s, "read box: \"dref\" entry-count %d",
p_box->data.p_dref->i_entry_count );
#endif
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"stts\" entry-count %d",
+ msg_Dbg( p_stream->s, "read box: \"stts\" entry-count %d",
p_box->data.p_stts->i_entry_count );
#endif
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"ctts\" entry-count %d",
+ msg_Dbg( p_stream->s, "read box: \"ctts\" entry-count %d",
p_box->data.p_ctts->i_entry_count );
#endif
i_len = MP4_ReadLengthDescriptor( &p_peek, &i_read );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "found esds MPEG4ESDescr (%dBytes)",
+ msg_Dbg( p_stream->s, "found esds MPEG4ESDescr (%dBytes)",
i_len );
#endif
i_len = MP4_ReadLengthDescriptor( &p_peek, &i_read );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "found esds MP4DecConfigDescr (%dBytes)",
+ msg_Dbg( p_stream->s, "found esds MP4DecConfigDescr (%dBytes)",
i_len );
#endif
i_len = MP4_ReadLengthDescriptor( &p_peek, &i_read );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "found esds MP4DecSpecificDescr (%dBytes)",
+ msg_Dbg( p_stream->s, "found esds MP4DecSpecificDescr (%dBytes)",
i_len );
#endif
MP4_GET4BYTES( p_box->data.p_sample_soun->i_bytes_per_sample );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input,
+ msg_Dbg( p_stream->s,
"read box: \"soun\" qt3+ sample/packet=%d bytes/packet=%d bytes/frame=%d bytes/sample=%d",
p_box->data.p_sample_soun->i_sample_per_packet, p_box->data.p_sample_soun->i_bytes_per_packet,
p_box->data.p_sample_soun->i_bytes_per_frame, p_box->data.p_sample_soun->i_bytes_per_sample );
p_box->data.p_sample_soun->i_bytes_per_frame = 0;
p_box->data.p_sample_soun->i_bytes_per_sample = 0;
- msg_Dbg( p_stream->p_input, "read box: \"soun\" mp4 or qt1/2 (rest="I64Fd")", i_read );
+ msg_Dbg( p_stream->s, "read box: \"soun\" mp4 or qt1/2 (rest="I64Fd")", i_read );
MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 28 );
}
if( p_box->i_type == FOURCC_drms )
{
p_box->data.p_sample_soun->p_drms =
- drms_alloc( p_stream->p_input->p_vlc->psz_homedir );
+ drms_alloc( p_stream->s->p_vlc->psz_homedir );
if( p_box->data.p_sample_soun->p_drms == NULL )
{
- msg_Err( p_stream->p_input, "drms_alloc() failed" );
+ msg_Err( p_stream->s, "drms_alloc() failed" );
}
}
MP4_ReadBoxContainerRaw( p_stream, p_box ); /* esds */
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"soun\" in stsd channel %d sample size %d sampl rate %f",
+ msg_Dbg( p_stream->s, "read box: \"soun\" in stsd channel %d sample size %d sampl rate %f",
p_box->data.p_sample_soun->i_channelcount,
p_box->data.p_sample_soun->i_samplesize,
(float)p_box->data.p_sample_soun->i_sampleratehi +
MP4_ReadBoxContainerRaw( p_stream, p_box );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"vide\" in stsd %dx%d depth %d",
+ msg_Dbg( p_stream->s, "read box: \"vide\" in stsd %dx%d depth %d",
p_box->data.p_sample_vide->i_width,
p_box->data.p_sample_vide->i_height,
p_box->data.p_sample_vide->i_depth );
MP4_ReadBoxContainerRaw( p_stream, p_box );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"stsd\" entry-count %d",
+ msg_Dbg( p_stream->s, "read box: \"stsd\" entry-count %d",
p_box->data.p_stsd->i_entry_count );
#endif
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"stsz\" sample-size %d sample-count %d",
+ msg_Dbg( p_stream->s, "read box: \"stsz\" sample-size %d sample-count %d",
p_box->data.p_stsz->i_sample_size,
p_box->data.p_stsz->i_sample_count );
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"stsc\" entry-count %d",
+ msg_Dbg( p_stream->s, "read box: \"stsc\" entry-count %d",
p_box->data.p_stsc->i_entry_count );
#endif
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"co64\" entry-count %d",
+ msg_Dbg( p_stream->s, "read box: \"co64\" entry-count %d",
p_box->data.p_co64->i_entry_count );
#endif
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"stss\" entry-count %d",
+ msg_Dbg( p_stream->s, "read box: \"stss\" entry-count %d",
p_box->data.p_stss->i_entry_count );
#endif
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"stsh\" entry-count %d",
+ msg_Dbg( p_stream->s, "read box: \"stsh\" entry-count %d",
p_box->data.p_stsh->i_entry_count );
#endif
MP4_READBOX_EXIT( 1 );
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"stdp\" entry-count "I64Fd,
+ msg_Dbg( p_stream->s, "read box: \"stdp\" entry-count "I64Fd,
i_read / 2 );
#endif
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"stdp\" entry-count "I64Fd,
+ msg_Dbg( p_stream->s, "read box: \"stdp\" entry-count "I64Fd,
i_read / 2 );
#endif
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"elst\" entry-count "I64Fd,
+ msg_Dbg( p_stream->s, "read box: \"elst\" entry-count "I64Fd,
i_read / 2 );
#endif
MP4_GETSTRINGZ( p_box->data.p_cprt->psz_notice );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"cprt\" language %c%c%c notice %s",
+ msg_Dbg( p_stream->s, "read box: \"cprt\" language %c%c%c notice %s",
p_box->data.p_cprt->i_language[0],
p_box->data.p_cprt->i_language[1],
p_box->data.p_cprt->i_language[2],
MP4_GETFOURCC( p_box->data.p_dcom->i_algorithm );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input,
+ msg_Dbg( p_stream->s,
"read box: \"dcom\" compression algorithm : %4.4s",
(char*)&p_box->data.p_dcom->i_algorithm );
#endif
if( !( p_box->data.p_cmvd->p_data = malloc( i_read ) ) )
{
- msg_Dbg( p_stream->p_input, "read box: \"cmvd\" not enough memory to load data" );
+ msg_Dbg( p_stream->s, "read box: \"cmvd\" not enough memory to load data" );
return( 1 );
}
p_box->data.p_cmvd->b_compressed = 1;
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input, "read box: \"cmvd\" compressed data size %d",
+ msg_Dbg( p_stream->s, "read box: \"cmvd\" compressed data size %d",
p_box->data.p_cmvd->i_compressed_size );
#endif
if( !( p_box->data.p_cmov = malloc( sizeof( MP4_Box_data_cmov_t ) ) ) )
{
- msg_Err( p_stream->p_input, "out of memory" );
+ msg_Err( p_stream->s, "out of memory" );
return( 0 );
}
memset( p_box->data.p_cmov, 0, sizeof( MP4_Box_data_cmov_t ) );
if( !p_box->p_father ||
( p_box->p_father->i_type != FOURCC_moov && p_box->p_father->i_type != FOURCC_foov) )
{
- msg_Warn( p_stream->p_input, "Read box: \"cmov\" box alone" );
+ msg_Warn( p_stream->s, "Read box: \"cmov\" box alone" );
return( 1 );
}
( p_cmvd = MP4_BoxGet( p_box, "cmvd" ) ) == NULL ||
p_cmvd->data.p_cmvd->p_data == NULL )
{
- msg_Warn( p_stream->p_input, "read box: \"cmov\" incomplete" );
+ msg_Warn( p_stream->s, "read box: \"cmov\" incomplete" );
return( 1 );
}
if( p_dcom->data.p_dcom->i_algorithm != FOURCC_zlib )
{
- msg_Dbg( p_stream->p_input, "read box: \"cmov\" compression algorithm : %4.4s not supported",
+ msg_Dbg( p_stream->s, "read box: \"cmov\" compression algorithm : %4.4s not supported",
(char*)&p_dcom->data.p_dcom->i_algorithm );
return( 1 );
}
#ifndef HAVE_ZLIB_H
- msg_Dbg( p_stream->p_input,
+ msg_Dbg( p_stream->s,
"read box: \"cmov\" zlib unsupported" );
return( 1 );
#else
/* allocate a new buffer */
if( !( p_data = malloc( p_cmvd->data.p_cmvd->i_uncompressed_size ) ) )
{
- msg_Err( p_stream->p_input,
+ msg_Err( p_stream->s,
"read box: \"cmov\" not enough memory to uncompress data" );
return( 1 );
}
/* init zlib */
if( ( i_result = inflateInit( &z_data ) ) != Z_OK )
{
- msg_Err( p_stream->p_input,
+ msg_Err( p_stream->s,
"read box: \"cmov\" error while uncompressing data" );
free( p_data );
return( 1 );
i_result = inflate( &z_data, Z_NO_FLUSH );
if( ( i_result != Z_OK )&&( i_result != Z_STREAM_END ) )
{
- msg_Err( p_stream->p_input,
+ msg_Err( p_stream->s,
"read box: \"cmov\" error while uncompressing data" );
free( p_data );
return( 1 );
if( p_cmvd->data.p_cmvd->i_uncompressed_size != z_data.total_out )
{
- msg_Warn( p_stream->p_input,
+ msg_Warn( p_stream->s,
"read box: \"cmov\" uncompressing data size mismatch" );
}
p_cmvd->data.p_cmvd->i_uncompressed_size = z_data.total_out;
i_result = inflateEnd( &z_data );
if( i_result != Z_OK )
{
- msg_Warn( p_stream->p_input,
+ msg_Warn( p_stream->s,
"read box: \"cmov\" error while uncompressing data (ignored)" );
}
p_cmvd->data.p_cmvd->p_data = p_data;
p_cmvd->data.p_cmvd->b_compressed = 0;
- msg_Dbg( p_stream->p_input,
+ msg_Dbg( p_stream->s,
"read box: \"cmov\" box succesfully uncompressed" );
/* now create a memory stream */
- p_stream_memory = MP4_MemoryStream( p_stream->p_input,
+ p_stream_memory = MP4_MemoryStream( p_stream->s,
p_cmvd->data.p_cmvd->i_uncompressed_size,
p_cmvd->data.p_cmvd->p_data );
free( p_stream_memory );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input,
+ msg_Dbg( p_stream->s,
"read box: \"cmov\" compressed movie header completed" );
#endif
return( p_box->data.p_cmov->p_moov ? 1 : 0 );
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input,
+ msg_Dbg( p_stream->s,
"read box: \"rdrf\" type:%4.4s ref %s",
(char*)&p_box->data.p_rdrf->i_ref_type,
p_box->data.p_rdrf->psz_ref );
MP4_GET4BYTES( p_box->data.p_rmdr->i_rate );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input,
+ msg_Dbg( p_stream->s,
"read box: \"rmdr\" rate:%d",
p_box->data.p_rmdr->i_rate );
#endif
MP4_GET4BYTES( p_box->data.p_rmqu->i_quality );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input,
+ msg_Dbg( p_stream->s,
"read box: \"rmqu\" quality:%d",
p_box->data.p_rmqu->i_quality );
#endif
MP4_GET2BYTES( p_box->data.p_rmvc->i_checkType );
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input,
+ msg_Dbg( p_stream->s,
"read box: \"rmvc\" gestaltType:%4.4s val1:0x%x val2:0x%x checkType:0x%x",
(char*)&p_box->data.p_rmvc->i_gestaltType,
p_box->data.p_rmvc->i_val1,p_box->data.p_rmvc->i_val2,
if( drms_init( p_drms_box->data.p_sample_soun->p_drms,
p_box->i_type, p_peek, i_read ) )
{
- msg_Err( p_stream->p_input, "drms_init( %4.4s ) failed",
+ msg_Err( p_stream->s, "drms_init( %4.4s ) failed",
(char *)&p_box->i_type );
drms_free( p_drms_box->data.p_sample_soun->p_drms );
p_box->data.p_0xa9xxx->psz_text[i_length] = '\0';
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream->p_input,
+ msg_Dbg( p_stream->s,
"read box: \"%4.4s\" text=`%s'",
(char*)&p_box->i_type,
p_box->data.p_0xa9xxx->psz_text );
if( !MP4_ReadBoxCommon( p_stream, p_box ) )
{
- msg_Warn( p_stream->p_input, "cannot read one box" );
+ msg_Warn( p_stream->s, "cannot read one box" );
free( p_box );
return NULL;
}
if( !p_box->i_size )
{
- msg_Dbg( p_stream->p_input, "found an empty box (null size)" );
+ msg_Dbg( p_stream->s, "found an empty box (null size)" );
free( p_box );
return NULL;
}
}
if( MP4_Box_Function[i_index].MP4_ReadBox_function == NULL )
{
- msg_Warn( p_stream->p_input,
+ msg_Warn( p_stream->s,
"unknown box type %4.4s (uncompletetly loaded)",
(char*)&p_box->i_type );
}
* MP4_FreeBox : free memory after read with MP4_ReadBox and all
* the children
*****************************************************************************/
-void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
+void MP4_BoxFree( stream_t *s, MP4_Box_t *p_box )
{
unsigned int i_index;
MP4_Box_t *p_child;
MP4_Box_t *p_next;
p_next = p_child->p_next;
- MP4_BoxFree( p_input, p_child );
+ MP4_BoxFree( s, p_child );
p_child = p_next;
}
if( MP4_Box_Function[i_index].MP4_FreeBox_function == NULL )
{
/* Should not happen */
- msg_Warn( p_input,
+ msg_Warn( s,
"cannot free box %4.4s, type unknown",
(char*)&p_box->i_type );
}
* The first box is a virtual box "root" and is the father for all first
* level boxes for the file, a sort of virtual contener
*****************************************************************************/
-MP4_Box_t *MP4_BoxGetRoot( input_thread_t *p_input )
+MP4_Box_t *MP4_BoxGetRoot( stream_t *s )
{
MP4_Box_t *p_root;
MP4_Stream_t *p_stream;
p_root->i_pos = 0;
p_root->i_type = VLC_FOURCC( 'r', 'o', 'o', 't' );
p_root->i_shortsize = 1;
- p_root->i_size = p_input->stream.p_selected_area->i_size;
+ p_root->i_size = stream_Size( s );
CreateUUID( &p_root->i_uuid, p_root->i_type );
p_root->data.p_data = NULL;
p_root->p_last = NULL;
p_root->p_next = NULL;
- p_stream = MP4_InputStream( p_input );
+ p_stream = MP4_InputStream( s );
i_result = MP4_ReadBoxContainerRaw( p_stream, p_root );
}
-static void __MP4_BoxDumpStructure( input_thread_t *p_input,
+static void __MP4_BoxDumpStructure( stream_t *s,
MP4_Box_t *p_box, unsigned int i_level )
{
MP4_Box_t *p_child;
if( !i_level )
{
- msg_Dbg( p_input, "dumping root Box \"%4.4s\"",
+ msg_Dbg( s, "dumping root Box \"%4.4s\"",
(char*)&p_box->i_type );
}
else
(char*)&p_box->i_type,
(uint32_t)p_box->i_size );
- msg_Dbg( p_input, "%s", str );
+ msg_Dbg( s, "%s", str );
}
p_child = p_box->p_first;
while( p_child )
{
- __MP4_BoxDumpStructure( p_input, p_child, i_level + 1 );
+ __MP4_BoxDumpStructure( s, p_child, i_level + 1 );
p_child = p_child->p_next;
}
}
-void MP4_BoxDumpStructure( input_thread_t *p_input, MP4_Box_t *p_box )
+void MP4_BoxDumpStructure( stream_t *s, MP4_Box_t *p_box )
{
- __MP4_BoxDumpStructure( p_input, p_box, 0 );
+ __MP4_BoxDumpStructure( s, p_box, 0 );
}
vlc_module_begin();
set_description( _("MP4 stream demuxer") );
- set_capability( "demux", 242 );
+ set_capability( "demux2", 242 );
set_callbacks( Open, Close );
vlc_module_end();
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int Demux ( input_thread_t * );
-static int DemuxRef( input_thread_t *p_input )
+static int Demux ( demux_t * );
+static int DemuxRef( demux_t *p_demux )
{
return 0;
}
-static int Seek ( input_thread_t *, mtime_t );
-static int Control ( input_thread_t *, int, va_list );
+static int Seek ( demux_t *, mtime_t );
+static int Control ( demux_t *, int, va_list );
/* Contain all information about a chunk */
typedef struct
/*****************************************************************************
* Declaration of local function
*****************************************************************************/
-static void MP4_TrackCreate ( input_thread_t *, mp4_track_t *, MP4_Box_t *);
-static void MP4_TrackDestroy( input_thread_t *, mp4_track_t * );
+static void MP4_TrackCreate ( demux_t *, mp4_track_t *, MP4_Box_t *);
+static void MP4_TrackDestroy( demux_t *, mp4_track_t * );
-static int MP4_TrackSelect ( input_thread_t *, mp4_track_t *, mtime_t );
-static void MP4_TrackUnselect(input_thread_t *, mp4_track_t * );
+static int MP4_TrackSelect ( demux_t *, mp4_track_t *, mtime_t );
+static void MP4_TrackUnselect(demux_t *, mp4_track_t * );
-static int MP4_TrackSeek ( input_thread_t *, mp4_track_t *, mtime_t );
+static int MP4_TrackSeek ( demux_t *, mp4_track_t *, mtime_t );
static uint64_t MP4_TrackGetPos ( mp4_track_t * );
static int MP4_TrackSampleSize( mp4_track_t * );
-static int MP4_TrackNextSample( input_thread_t *, mp4_track_t * );
-static void MP4_TrackSetELST( input_thread_t *, mp4_track_t *, int64_t );
+static int MP4_TrackNextSample( demux_t *, mp4_track_t * );
+static void MP4_TrackSetELST( demux_t *, mp4_track_t *, int64_t );
/* Return time in µs of a track */
-static inline int64_t MP4_TrackGetPTS( input_thread_t *p_input, mp4_track_t *p_track )
+static inline int64_t MP4_TrackGetPTS( demux_t *p_demux, mp4_track_t *p_track )
{
unsigned int i_sample;
unsigned int i_index;
/* now handle elst */
if( p_track->p_elst )
{
- demux_sys_t *p_sys = p_input->p_demux_data;
+ demux_sys_t *p_sys = p_demux->p_sys;
MP4_Box_data_elst_t *elst = p_track->p_elst->data.p_elst;
/* convert to offset */
*****************************************************************************/
static int Open( vlc_object_t * p_this )
{
- input_thread_t *p_input = (input_thread_t *)p_this;
+ demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys;
uint8_t *p_peek;
vlc_bool_t b_seekable;
/* a little test to see if it could be a mp4 */
- if( stream_Peek( p_input->s, &p_peek, 8 ) < 8 )
+ if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 )
{
- msg_Warn( p_input, "MP4 plugin discarded (cannot peek)" );
+ msg_Warn( p_demux, "MP4 plugin discarded (cannot peek)" );
return VLC_EGENERIC;
}
switch( VLC_FOURCC( p_peek[4], p_peek[5], p_peek[6], p_peek[7] ) )
case VLC_FOURCC( 'p', 'n', 'o', 't' ):
break;
default:
- msg_Warn( p_input, "MP4 plugin discarded (not a valid file)" );
+ msg_Warn( p_demux, "MP4 plugin discarded (not a valid file)" );
return VLC_EGENERIC;
}
/* I need to seek */
- stream_Control( p_input->s, STREAM_CAN_SEEK, &b_seekable );
+ stream_Control( p_demux->s, STREAM_CAN_SEEK, &b_seekable );
if( !b_seekable )
{
- msg_Warn( p_input, "MP4 plugin discarded (unseekable)" );
+ msg_Warn( p_demux, "MP4 plugin discarded (unseekable)" );
return VLC_EGENERIC;
}
/*Set exported functions */
- p_input->pf_demux = Demux;
- p_input->pf_demux_control = Control;
+ p_demux->pf_demux = Demux;
+ p_demux->pf_control = Control;
/* create our structure that will contains all data */
- p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
+ p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
memset( p_sys, 0, sizeof( demux_sys_t ) );
/* Now load all boxes ( except raw data ) */
- if( ( p_sys->p_root = MP4_BoxGetRoot( p_input ) ) == NULL )
+ if( ( p_sys->p_root = MP4_BoxGetRoot( p_demux->s ) ) == NULL )
{
- msg_Warn( p_input, "MP4 plugin discarded (not a valid file)" );
+ msg_Warn( p_demux, "MP4 plugin discarded (not a valid file)" );
goto error;
}
- MP4_BoxDumpStructure( p_input, p_sys->p_root );
+ MP4_BoxDumpStructure( p_demux->s, p_sys->p_root );
if( ( p_ftyp = MP4_BoxGet( p_sys->p_root, "/ftyp" ) ) )
{
switch( p_ftyp->data.p_ftyp->i_major_brand )
{
case( FOURCC_isom ):
- msg_Dbg( p_input,
+ msg_Dbg( p_demux,
"ISO Media file (isom) version %d.",
p_ftyp->data.p_ftyp->i_minor_version );
break;
default:
- msg_Dbg( p_input,
+ msg_Dbg( p_demux,
"unrecognized major file specification (%4.4s).",
(char*)&p_ftyp->data.p_ftyp->i_major_brand );
break;
}
else
{
- msg_Dbg( p_input, "file type box missing (assuming ISO Media file)" );
+ msg_Dbg( p_demux, "file type box missing (assuming ISO Media file)" );
}
/* the file need to have one moov box */
if( !p_foov )
{
- msg_Err( p_input, "MP4 plugin discarded (no moov box)" );
+ msg_Err( p_demux, "MP4 plugin discarded (no moov box)" );
goto error;
}
/* we have a free box as a moov, rename it */
int i_count = MP4_BoxCount( p_rmra, "rmda" );
int i;
- msg_Dbg( p_input, "detected playlist mov file (%d ref)", i_count );
+ msg_Dbg( p_demux, "detected playlist mov file (%d ref)", i_count );
p_playlist =
- (playlist_t *)vlc_object_find( p_input,
+ (playlist_t *)vlc_object_find( p_demux,
VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
}
i_ref_type = p_rdrf->data.p_rdrf->i_ref_type;
- msg_Dbg( p_input, "new ref=`%s' type=%4.4s",
+ msg_Dbg( p_demux, "new ref=`%s' type=%4.4s",
psz_ref, (char*)&i_ref_type );
if( i_ref_type == VLC_FOURCC( 'u', 'r', 'l', ' ' ) )
{
if( strstr( psz_ref, "qt5gateQT" ) )
{
- msg_Dbg( p_input, "ignoring pseudo ref =`%s'", psz_ref );
+ msg_Dbg( p_demux, "ignoring pseudo ref =`%s'", psz_ref );
continue;
}
if( !strncmp( psz_ref, "http://", 7 ) ||
!strncmp( psz_ref, "rtsp://", 7 ) )
{
- msg_Dbg( p_input, "adding ref = `%s'", psz_ref );
+ msg_Dbg( p_demux, "adding ref = `%s'", psz_ref );
playlist_Add( p_playlist, psz_ref, psz_ref,
PLAYLIST_APPEND, PLAYLIST_END );
}
else
{
/* msg dbg relative ? */
- char *psz_absolute = alloca( strlen( p_input->psz_source ) + strlen( psz_ref ) + 1);
- char *end = strrchr( p_input->psz_source, '/' );
+ char *psz_absolute = alloca( strlen( p_demux->psz_path ) + strlen( psz_ref ) + 1);
+ char *end = strrchr( p_demux->psz_path, '/' );
if( end )
{
- int i_len = end + 1 - p_input->psz_source;
+ int i_len = end + 1 - p_demux->psz_path;
- strncpy( psz_absolute, p_input->psz_source, i_len);
+ strncpy( psz_absolute, p_demux->psz_path, i_len);
psz_absolute[i_len] = '\0';
}
else
strcpy( psz_absolute, "" );
}
strcat( psz_absolute, psz_ref );
- msg_Dbg( p_input, "adding ref = `%s'", psz_absolute );
+ msg_Dbg( p_demux, "adding ref = `%s'", psz_absolute );
playlist_Add( p_playlist, psz_absolute, psz_absolute,
PLAYLIST_APPEND, PLAYLIST_END );
}
}
else
{
- msg_Err( p_input, "unknown ref type=%4.4s FIXME (send a bug report)",
+ msg_Err( p_demux, "unknown ref type=%4.4s FIXME (send a bug report)",
(char*)&p_rdrf->data.p_rdrf->i_ref_type );
}
}
}
else
{
- msg_Err( p_input, "can't find playlist" );
+ msg_Err( p_demux, "can't find playlist" );
}
}
{
if( !p_rmra )
{
- msg_Err( p_input, "cannot find /moov/mvhd" );
+ msg_Err( p_demux, "cannot find /moov/mvhd" );
goto error;
}
else
{
- msg_Warn( p_input, "cannot find /moov/mvhd (pure ref file)" );
- p_input->pf_demux = DemuxRef;
+ msg_Warn( p_demux, "cannot find /moov/mvhd (pure ref file)" );
+ p_demux->pf_demux = DemuxRef;
return VLC_SUCCESS;
}
}
if( !( p_sys->i_tracks = MP4_BoxCount( p_sys->p_root, "/moov/trak" ) ) )
{
- msg_Err( p_input, "cannot find any /moov/trak" );
+ msg_Err( p_demux, "cannot find any /moov/trak" );
goto error;
}
- msg_Dbg( p_input, "find %d track%c",
+ msg_Dbg( p_demux, "find %d track%c",
p_sys->i_tracks,
p_sys->i_tracks ? 's':' ' );
- /* create one program */
- vlc_mutex_lock( &p_input->stream.stream_lock );
- if( input_InitStream( p_input, 0 ) == -1)
- {
- vlc_mutex_unlock( &p_input->stream.stream_lock );
- msg_Err( p_input, "cannot init stream" );
- goto error;
- }
- if( p_sys->i_duration/p_sys->i_timescale > 0 )
- {
- p_input->stream.i_mux_rate =
- p_input->stream.p_selected_area->i_size / 50 /
- ( p_sys->i_duration / p_sys->i_timescale );
- }
- else
- {
- p_input->stream.i_mux_rate = 0;
- }
- vlc_mutex_unlock( &p_input->stream.stream_lock );
-
-
/* allocate memory */
p_sys->track = calloc( p_sys->i_tracks, sizeof( mp4_track_t ) );
memset( p_sys->track, 0, p_sys->i_tracks * sizeof( mp4_track_t ) );
for( i = 0; i < p_sys->i_tracks; i++ )
{
p_trak = MP4_BoxGet( p_sys->p_root, "/moov/trak[%d]", i );
- MP4_TrackCreate( p_input, &p_sys->track[i], p_trak );
+ MP4_TrackCreate( p_demux, &p_sys->track[i], p_trak );
if( p_sys->track[i].b_ok )
{
break;
}
- msg_Dbg( p_input, "adding track[Id 0x%x] %s (%s) language %s",
+ msg_Dbg( p_demux, "adding track[Id 0x%x] %s (%s) language %s",
p_sys->track[i].i_track_ID,
psz_cat,
p_sys->track[i].b_enable ? "enable":"disable",
}
else
{
- msg_Dbg( p_input, "ignoring track[Id 0x%x]", p_sys->track[i].i_track_ID );
+ msg_Dbg( p_demux, "ignoring track[Id 0x%x]", p_sys->track[i].i_track_ID );
}
}
error:
if( p_sys->p_root )
{
- MP4_BoxFree( p_input, p_sys->p_root );
+ MP4_BoxFree( p_demux->s, p_sys->p_root );
}
free( p_sys );
return VLC_EGENERIC;
*****************************************************************************
* TODO check for newly selected track (ie audio upt to now )
*****************************************************************************/
-static int Demux( input_thread_t *p_input )
+static int Demux( demux_t *p_demux )
{
- demux_sys_t *p_sys = p_input->p_demux_data;
+ demux_sys_t *p_sys = p_demux->p_sys;
unsigned int i_track;
unsigned int i_track_selected;
- vlc_bool_t b_play_audio;
/* check for newly selected/unselected track */
for( i_track = 0, i_track_selected = 0; i_track < p_sys->i_tracks; i_track++ )
if( tk->b_selected && tk->i_sample >= tk->i_sample_count )
{
- msg_Warn( p_input, "track[0x%x] will be disabled", tk->i_track_ID );
- MP4_TrackUnselect( p_input, tk);
+ msg_Warn( p_demux, "track[0x%x] will be disabled", tk->i_track_ID );
+ MP4_TrackUnselect( p_demux, tk);
}
else if( tk->b_ok )
{
vlc_bool_t b;
- es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, tk->p_es, &b );
+ es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE, tk->p_es, &b );
if( tk->b_selected && !b )
{
- MP4_TrackUnselect( p_input, tk );
+ MP4_TrackUnselect( p_demux, tk );
}
else if( !tk->b_selected && b)
{
- MP4_TrackSelect( p_input, tk, MP4_GetMoviePTS( p_sys ) );
+ MP4_TrackSelect( p_demux, tk, MP4_GetMoviePTS( p_sys ) );
}
if( tk->b_selected )
if( i_track_selected <= 0 )
{
- msg_Warn( p_input, "no track selected, exiting..." );
+ msg_Warn( p_demux, "no track selected, exiting..." );
return 0;
}
/* first wait for the good time to read a packet */
- es_out_Control( p_input->p_es_out, ES_OUT_SET_PCR, p_sys->i_pcr );
+ es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_pcr );
- /* update pcr XXX in mpeg scale so in 90000 unit/s */
p_sys->i_pcr = MP4_GetMoviePTS( p_sys );
/* we will read 100ms for each stream so ...*/
p_sys->i_time += __MAX( p_sys->i_timescale / 10 , 1 );
- /* Check if we need to send the audio data to decoder */
- b_play_audio = !p_input->stream.control.b_mute;
-
for( i_track = 0; i_track < p_sys->i_tracks; i_track++ )
{
mp4_track_t *tk = &p_sys->track[i_track];
continue;
}
- while( MP4_TrackGetPTS( p_input, tk ) < MP4_GetMoviePTS( p_sys ) )
+ while( MP4_TrackGetPTS( p_demux, tk ) < MP4_GetMoviePTS( p_sys ) )
{
#if 0
- msg_Dbg( p_input, "tk=%lld mv=%lld",
- MP4_TrackGetPTS( p_input, tk ),
+ msg_Dbg( p_demux, "tk=%lld mv=%lld",
+ MP4_TrackGetPTS( p_demux, tk ),
MP4_GetMoviePTS( p_sys ) );
#endif
- if( MP4_TrackSampleSize( tk ) > 0 &&
- ( b_play_audio || tk->fmt.i_cat != AUDIO_ES ) )
+ if( MP4_TrackSampleSize( tk ) > 0 )
{
block_t *p_block;
/* go,go go ! */
- if( stream_Seek( p_input->s, MP4_TrackGetPos( tk ) ) )
+ if( stream_Seek( p_demux->s, MP4_TrackGetPos( tk ) ) )
{
- msg_Warn( p_input, "track[0x%x] will be disabled (eof?)", tk->i_track_ID );
- MP4_TrackUnselect( p_input, tk );
+ msg_Warn( p_demux, "track[0x%x] will be disabled (eof?)", tk->i_track_ID );
+ MP4_TrackUnselect( p_demux, tk );
break;
}
/* now read pes */
- if( ( p_block = stream_Block( p_input->s,
+ if( ( p_block = stream_Block( p_demux->s,
MP4_TrackSampleSize( tk ) ) ) == NULL )
{
- msg_Warn( p_input, "track[0x%x] will be disabled (eof?)", tk->i_track_ID );
- MP4_TrackUnselect( p_input, tk );
+ msg_Warn( p_demux, "track[0x%x] will be disabled (eof?)", tk->i_track_ID );
+ MP4_TrackUnselect( p_demux, tk );
break;
}
(uint32_t*)p_block->p_buffer,
p_block->i_buffer );
}
- p_block->i_dts = MP4_TrackGetPTS( p_input, tk );
+ p_block->i_dts = MP4_TrackGetPTS( p_demux, tk );
p_block->i_pts = tk->fmt.i_cat == VIDEO_ES ? 0 : p_block->i_dts;
if( !tk->b_drms || ( tk->b_drms && tk->p_drms ) )
{
- es_out_Send( p_input->p_es_out, tk->p_es, p_block );
+ es_out_Send( p_demux->out, tk->p_es, p_block );
}
}
/* Next sample */
- if( MP4_TrackNextSample( p_input, tk ) )
+ if( MP4_TrackNextSample( p_demux, tk ) )
{
break;
}
/*****************************************************************************
* Seek: Got to i_date
******************************************************************************/
-static int Seek ( input_thread_t *p_input, mtime_t i_date )
+static int Seek ( demux_t *p_demux, mtime_t i_date )
{
- demux_sys_t *p_sys = p_input->p_demux_data;
+ demux_sys_t *p_sys = p_demux->p_sys;
unsigned int i_track;
/* First update update global time */
p_sys->i_time = i_date * p_sys->i_timescale / 1000000;
- p_sys->i_pcr = i_date* 9 / 100;
+ p_sys->i_pcr = i_date;
/* Now for each stream try to go to this time */
for( i_track = 0; i_track < p_sys->i_tracks; i_track++ )
if( tk->b_ok && tk->b_selected )
{
- MP4_TrackSeek( p_input, tk, i_date );
+ MP4_TrackSeek( p_demux, tk, i_date );
}
}
return( 1 );
/*****************************************************************************
* Control:
*****************************************************************************/
-static int Control( input_thread_t *p_input, int i_query, va_list args )
+static int Control( demux_t *p_demux, int i_query, va_list args )
{
- demux_sys_t *p_sys = p_input->p_demux_data;
+ demux_sys_t *p_sys = p_demux->p_sys;
double f, *pf;
int64_t i64, *pi64;
i64 = (int64_t)( f * (double)1000000 *
(double)p_sys->i_duration /
(double)p_sys->i_timescale );
- return Seek( p_input, i64 );
+ return Seek( p_demux, i64 );
}
else return VLC_SUCCESS;
case DEMUX_SET_TIME:
i64 = (int64_t)va_arg( args, int64_t );
- return Seek( p_input, i64 );
+ return Seek( p_demux, i64 );
case DEMUX_GET_LENGTH:
pi64 = (int64_t*)va_arg( args, int64_t * );
return VLC_SUCCESS;
case DEMUX_GET_FPS:
- msg_Warn( p_input, "DEMUX_GET_FPS unimplemented !!" );
+ msg_Warn( p_demux, "DEMUX_GET_FPS unimplemented !!" );
return VLC_EGENERIC;
case DEMUX_GET_META:
}
default:
- msg_Err( p_input, "control query unimplemented !!!" );
- return demux_vaControlDefault( p_input, i_query, args );
+ msg_Err( p_demux, "control query unimplemented !!!" );
+ return VLC_EGENERIC;
}
}
static void Close ( vlc_object_t * p_this )
{
unsigned int i_track;
- input_thread_t * p_input = (input_thread_t *)p_this;
- demux_sys_t *p_sys = p_input->p_demux_data;
+ demux_t * p_demux = (demux_t *)p_this;
+ demux_sys_t *p_sys = p_demux->p_sys;
- msg_Dbg( p_input, "freeing all memory" );
+ msg_Dbg( p_demux, "freeing all memory" );
- MP4_BoxFree( p_input, p_sys->p_root );
+ MP4_BoxFree( p_demux->s, p_sys->p_root );
for( i_track = 0; i_track < p_sys->i_tracks; i_track++ )
{
- MP4_TrackDestroy( p_input, &p_sys->track[i_track] );
+ MP4_TrackDestroy( p_demux, &p_sys->track[i_track] );
}
FREE( p_sys->track );
****************************************************************************/
/* now create basic chunk data, the rest will be filled by MP4_CreateSamplesIndex */
-static int TrackCreateChunksIndex( input_thread_t *p_input,
+static int TrackCreateChunksIndex( demux_t *p_demux,
mp4_track_t *p_demux_track )
{
MP4_Box_t *p_co64; /* give offset for each chunk, same for stco and co64 */
p_demux_track->i_chunk_count = p_co64->data.p_co64->i_entry_count;
if( !p_demux_track->i_chunk_count )
{
- msg_Warn( p_input, "no chunk defined" );
+ msg_Warn( p_demux, "no chunk defined" );
return( VLC_EGENERIC );
}
p_demux_track->chunk = calloc( p_demux_track->i_chunk_count,
i_index = p_stsc->data.p_stsc->i_entry_count;
if( !i_index )
{
- msg_Warn( p_input, "cannot read chunk table or table empty" );
+ msg_Warn( p_demux, "cannot read chunk table or table empty" );
return( VLC_EGENERIC );
}
p_demux_track->chunk[i_chunk-1].i_sample_count;
}
- msg_Dbg( p_input,
+ msg_Dbg( p_demux,
"track[Id 0x%x] read %d chunk",
p_demux_track->i_track_ID,
p_demux_track->i_chunk_count );
return( VLC_SUCCESS );
}
-static int TrackCreateSamplesIndex( input_thread_t *p_input,
+static int TrackCreateSamplesIndex( demux_t *p_demux,
mp4_track_t *p_demux_track )
{
MP4_Box_t *p_stts; /* makes mapping between sample and decoding time,
if( ( !p_stts )||( !p_stsz ) )
{
- msg_Warn( p_input, "cannot read sample table" );
+ msg_Warn( p_demux, "cannot read sample table" );
return( VLC_EGENERIC );
}
}
- msg_Dbg( p_input,
+ msg_Dbg( p_demux,
"track[Id 0x%x] read %d samples length:"I64Fd"s",
p_demux_track->i_track_ID,
p_demux_track->i_sample_count,
* TrackCreateES:
* Create ES and PES to init decoder if needed, for a track starting at i_chunk
*/
-static int TrackCreateES ( input_thread_t *p_input,
+static int TrackCreateES ( demux_t *p_demux,
mp4_track_t *p_track,
unsigned int i_chunk,
es_out_id_t **pp_es )
if( !p_track->chunk[i_chunk].i_sample_description_index )
{
- msg_Warn( p_input,
+ msg_Warn( p_demux,
"invalid SampleEntry index (track[Id 0x%x])",
p_track->i_track_ID );
return VLC_EGENERIC;
if( !p_sample || !p_sample->data.p_data )
{
- msg_Warn( p_input,
+ msg_Warn( p_demux,
"cannot find SampleEntry (track[Id 0x%x])",
p_track->i_track_ID );
return( VLC_EGENERIC );
break;
default:
/* Unknown entry, but don't touch i_fourcc */
- msg_Warn( p_input,
+ msg_Warn( p_demux,
"unknown objectTypeIndication(0x%x) (Track[ID 0x%x])",
p_decconfig->i_objectTypeIndication,
p_track->i_track_ID );
break;
}
- *pp_es = es_out_Add( p_input->p_es_out, &p_track->fmt );
+ *pp_es = es_out_Add( p_demux->out, &p_track->fmt );
return VLC_SUCCESS;
}
/* given a time it return sample/chunk
* it also update elst field of the track
*/
-static int TrackTimeToSampleChunk( input_thread_t *p_input,
+static int TrackTimeToSampleChunk( demux_t *p_demux,
mp4_track_t *p_track,
int64_t i_start,
uint32_t *pi_chunk,
uint32_t *pi_sample )
{
- demux_sys_t *p_sys = p_input->p_demux_data;
+ demux_sys_t *p_sys = p_demux->p_sys;
MP4_Box_t *p_stss;
uint64_t i_dts;
unsigned int i_sample;
}
/* handle elst (find the correct one) */
- MP4_TrackSetELST( p_input, p_track, i_start );
+ MP4_TrackSetELST( p_demux, p_track, i_start );
if( p_track->p_elst && p_track->p_elst->data.p_elst->i_entry_count > 0 )
{
MP4_Box_data_elst_t *elst = p_track->p_elst->data.p_elst;
i_start += elst->i_media_time[p_track->i_elst];
}
- msg_Dbg( p_input, "elst (%d) gives "I64Fd"ms (movie)-> "I64Fd"ms (track)",
+ msg_Dbg( p_demux, "elst (%d) gives "I64Fd"ms (movie)-> "I64Fd"ms (track)",
p_track->i_elst,
i_mvt * 1000 / p_sys->i_timescale,
i_start * 1000 / p_track->i_timescale );
if( i_sample >= p_track->i_sample_count )
{
- msg_Warn( p_input,
+ msg_Warn( p_demux,
"track[Id 0x%x] will be disabled (seeking too far) chunk=%d sample=%d",
p_track->i_track_ID, i_chunk, i_sample );
return( VLC_EGENERIC );
if( ( p_stss = MP4_BoxGet( p_track->p_stbl, "stss" ) ) )
{
unsigned int i_index;
- msg_Dbg( p_input,
+ msg_Dbg( p_demux,
"track[Id 0x%x] using Sync Sample Box (stss)",
p_track->i_track_ID );
for( i_index = 0; i_index < p_stss->data.p_stss->i_entry_count; i_index++ )
{
if( i_index > 0 )
{
- msg_Dbg( p_input, "stts gives %d --> %d (sample number)",
+ msg_Dbg( p_demux, "stts gives %d --> %d (sample number)",
i_sample,
p_stss->data.p_stss->i_sample_number[i_index-1] );
i_sample = p_stss->data.p_stss->i_sample_number[i_index-1];
}
else
{
- msg_Dbg( p_input, "stts gives %d --> %d (sample number)",
+ msg_Dbg( p_demux, "stts gives %d --> %d (sample number)",
i_sample,
p_stss->data.p_stss->i_sample_number[i_index] );
i_sample = p_stss->data.p_stss->i_sample_number[i_index];
}
else
{
- msg_Dbg( p_input,
+ msg_Dbg( p_demux,
"track[Id 0x%x] does not provide Sync Sample Box (stss)",
p_track->i_track_ID );
}
return VLC_SUCCESS;
}
-static int TrackGotoChunkSample( input_thread_t *p_input,
+static int TrackGotoChunkSample( demux_t *p_demux,
mp4_track_t *p_track,
unsigned int i_chunk,
unsigned int i_sample )
p_track->chunk[p_track->i_chunk].i_sample_description_index !=
p_track->chunk[i_chunk].i_sample_description_index )
{
- msg_Warn( p_input, "recreate ES" );
+ msg_Warn( p_demux, "recreate ES" );
- es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, p_track->p_es, &b_reselect );
+ es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE, p_track->p_es, &b_reselect );
- es_out_Del( p_input->p_es_out, p_track->p_es );
+ es_out_Del( p_demux->out, p_track->p_es );
p_track->p_es = NULL;
- if( TrackCreateES( p_input,
+ if( TrackCreateES( p_demux,
p_track, i_chunk,
&p_track->p_es ) )
{
- msg_Err( p_input, "cannot create es for track[Id 0x%x]",
+ msg_Err( p_demux, "cannot create es for track[Id 0x%x]",
p_track->i_track_ID );
p_track->b_ok = VLC_FALSE;
/* select again the new decoder */
if( b_reselect )
{
- es_out_Control( p_input->p_es_out, ES_OUT_SET_ES, p_track->p_es );
+ es_out_Control( p_demux->out, ES_OUT_SET_ES, p_track->p_es );
}
p_track->i_chunk = i_chunk;
* Parse track information and create all needed data to run a track
* If it succeed b_ok is set to 1 else to 0
****************************************************************************/
-static void MP4_TrackCreate( input_thread_t *p_input,
+static void MP4_TrackCreate( demux_t *p_demux,
mp4_track_t *p_track,
MP4_Box_t * p_box_trak )
{
- demux_sys_t *p_sys = p_input->p_demux_data;
+ demux_sys_t *p_sys = p_demux->p_sys;
MP4_Box_t *p_tkhd = MP4_BoxGet( p_box_trak, "tkhd" );
MP4_Box_t *p_tref = MP4_BoxGet( p_box_trak, "tref" );
if( p_tref )
{
-/* msg_Warn( p_input, "unhandled box: tref --> FIXME" ); */
+/* msg_Warn( p_demux, "unhandled box: tref --> FIXME" ); */
}
p_mdhd = MP4_BoxGet( p_box_trak, "mdia/mdhd" );
MP4_Box_data_elst_t *elst = p_elst->data.p_elst;
int i;
- msg_Warn( p_input, "elst box found" );
+ msg_Warn( p_demux, "elst box found" );
for( i = 0; i < elst->i_entry_count; i++ )
{
- msg_Dbg( p_input, " - [%d] duration="I64Fd"ms media time="I64Fd"ms) rate=%d.%d",
+ msg_Dbg( p_demux, " - [%d] duration="I64Fd"ms media time="I64Fd"ms) rate=%d.%d",
i,
elst->i_segment_duration[i] * 1000 / p_sys->i_timescale,
elst->i_media_time[i] >= 0 ?
if( p_soun->i_qt_version == 0 &&
p_track->i_timescale != p_soun->i_sampleratehi )
{
- msg_Warn( p_input,
+ msg_Warn( p_demux,
"i_timescale ("I64Fu") != i_sampleratehi (%u) with "
"qt_version == 0\n"
"Making both equal. (report any problem)",
}
/* Create chunk index table and sample index table */
- if( TrackCreateChunksIndex( p_input,p_track ) ||
- TrackCreateSamplesIndex( p_input, p_track ) )
+ if( TrackCreateChunksIndex( p_demux,p_track ) ||
+ TrackCreateSamplesIndex( p_demux, p_track ) )
{
return; /* cannot create chunks index */
}
p_track->i_sample = 0;
/* now create es */
- if( TrackCreateES( p_input,
+ if( TrackCreateES( p_demux,
p_track, p_track->i_chunk,
&p_track->p_es ) )
{
- msg_Err( p_input, "cannot create es for track[Id 0x%x]",
+ msg_Err( p_demux, "cannot create es for track[Id 0x%x]",
p_track->i_track_ID );
return;
}
****************************************************************************
* Destroy a track created by MP4_TrackCreate.
****************************************************************************/
-static void MP4_TrackDestroy( input_thread_t *p_input,
+static void MP4_TrackDestroy( demux_t *p_demux,
mp4_track_t *p_track )
{
unsigned int i_chunk;
}
}
-static int MP4_TrackSelect ( input_thread_t *p_input,
+static int MP4_TrackSelect ( demux_t *p_demux,
mp4_track_t *p_track,
mtime_t i_start )
{
if( p_track->b_selected )
{
- msg_Warn( p_input,
+ msg_Warn( p_demux,
"track[Id 0x%x] already selected",
p_track->i_track_ID );
return VLC_SUCCESS;
}
- return MP4_TrackSeek( p_input, p_track, i_start );
+ return MP4_TrackSeek( p_demux, p_track, i_start );
}
-static void MP4_TrackUnselect(input_thread_t *p_input,
+static void MP4_TrackUnselect(demux_t *p_demux,
mp4_track_t *p_track )
{
if( !p_track->b_ok )
if( !p_track->b_selected )
{
- msg_Warn( p_input,
+ msg_Warn( p_demux,
"track[Id 0x%x] already unselected",
p_track->i_track_ID );
return;
}
if( p_track->p_es )
{
- es_out_Control( p_input->p_es_out, ES_OUT_SET_ES_STATE, p_track->p_es, VLC_FALSE );
+ es_out_Control( p_demux->out, ES_OUT_SET_ES_STATE, p_track->p_es, VLC_FALSE );
}
p_track->b_selected = VLC_FALSE;
}
-static int MP4_TrackSeek ( input_thread_t *p_input,
+static int MP4_TrackSeek ( demux_t *p_demux,
mp4_track_t *p_track,
mtime_t i_start )
{
return( VLC_EGENERIC );
}
- if( TrackTimeToSampleChunk( p_input,
+ if( TrackTimeToSampleChunk( p_demux,
p_track, i_start,
&i_chunk, &i_sample ) )
{
- msg_Warn( p_input,
+ msg_Warn( p_demux,
"cannot select track[Id 0x%x]",
p_track->i_track_ID );
return( VLC_EGENERIC );
p_track->b_selected = VLC_TRUE;
- if( TrackGotoChunkSample( p_input, p_track, i_chunk, i_sample ) )
+ if( TrackGotoChunkSample( p_demux, p_track, i_chunk, i_sample ) )
{
p_track->b_selected = VLC_FALSE;
}
if( p_track->i_sample_size != 1 )
{
- //msg_Warn( p_input, "SampleSize != 1" );
+ //msg_Warn( p_demux, "SampleSize != 1" );
return( p_track->i_sample_size );
}
return( i_pos );
}
-static int MP4_TrackNextSample( input_thread_t *p_input,
+static int MP4_TrackNextSample( demux_t *p_demux,
mp4_track_t *p_track )
{
if( p_track->i_sample >= p_track->i_sample_count )
{
/* we have reach end of the track so free decoder stuff */
- msg_Warn( p_input, "track[0x%x] will be disabled", p_track->i_track_ID );
- MP4_TrackUnselect( p_input, p_track );
+ msg_Warn( p_demux, "track[0x%x] will be disabled", p_track->i_track_ID );
+ MP4_TrackUnselect( p_demux, p_track );
return VLC_EGENERIC;
}
p_track->chunk[p_track->i_chunk].i_sample_first +
p_track->chunk[p_track->i_chunk].i_sample_count )
{
- if( TrackGotoChunkSample( p_input,
+ if( TrackGotoChunkSample( p_demux,
p_track,
p_track->i_chunk + 1,
p_track->i_sample ) )
{
- msg_Warn( p_input, "track[0x%x] will be disabled (cannot restart decoder)", p_track->i_track_ID );
- MP4_TrackUnselect( p_input, p_track );
+ msg_Warn( p_demux, "track[0x%x] will be disabled (cannot restart decoder)", p_track->i_track_ID );
+ MP4_TrackUnselect( p_demux, p_track );
return VLC_EGENERIC;
}
}
/* Have we changed elst */
if( p_track->p_elst && p_track->p_elst->data.p_elst->i_entry_count > 0 )
{
- demux_sys_t *p_sys = p_input->p_demux_data;
+ demux_sys_t *p_sys = p_demux->p_sys;
MP4_Box_data_elst_t *elst = p_track->p_elst->data.p_elst;
- int64_t i_mvt = MP4_TrackGetPTS( p_input, p_track ) * p_sys->i_timescale / (int64_t)1000000;
+ int64_t i_mvt = MP4_TrackGetPTS( p_demux, p_track ) * p_sys->i_timescale / (int64_t)1000000;
if( p_track->i_elst < elst->i_entry_count &&
i_mvt >= p_track->i_elst_time + elst->i_segment_duration[p_track->i_elst] )
{
- MP4_TrackSetELST( p_input, p_track, MP4_TrackGetPTS( p_input, p_track ) );
+ MP4_TrackSetELST( p_demux, p_track, MP4_TrackGetPTS( p_demux, p_track ) );
}
}
return VLC_SUCCESS;
}
-static void MP4_TrackSetELST( input_thread_t *p_input, mp4_track_t *tk, int64_t i_time )
+static void MP4_TrackSetELST( demux_t *p_demux, mp4_track_t *tk, int64_t i_time )
{
- demux_sys_t *p_sys = p_input->p_demux_data;
+ demux_sys_t *p_sys = p_demux->p_sys;
int i_elst_last = tk->i_elst;
/* handle elst (find the correct one) */
if( tk->i_elst >= elst->i_entry_count )
{
- /* msg_Dbg( p_input, "invalid number of entry in elst" ); */
+ /* msg_Dbg( p_demux, "invalid number of entry in elst" ); */
tk->i_elst = elst->i_entry_count - 1;
tk->i_elst_time -= elst->i_segment_duration[tk->i_elst];
}
}
if( i_elst_last != tk->i_elst )
{
- msg_Warn( p_input, "elst old=%d new=%d", i_elst_last, tk->i_elst );
+ msg_Warn( p_demux, "elst old=%d new=%d", i_elst_last, tk->i_elst );
}
}