]> git.sesse.net Git - vlc/commitdiff
* mp4*: demux -> demux2.
authorLaurent Aimar <fenrir@videolan.org>
Sat, 3 Apr 2004 01:36:04 +0000 (01:36 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 3 Apr 2004 01:36:04 +0000 (01:36 +0000)
modules/demux/mp4/libmp4.c
modules/demux/mp4/libmp4.h
modules/demux/mp4/mp4.c

index 3b1a82b724609873fa6541c6ef70169ba7c553ce..bbd7c1ffe6c8b77899f34e5137c98d34e8dbb56f 100644 (file)
     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 )
 
@@ -161,7 +161,7 @@ static void MP4_ConvertDate2Str( char *psz, uint64_t i_date )
 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
  *
  *****************************************************************************/
@@ -172,7 +172,7 @@ static MP4_Box_t *MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_father );
  * 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;
 
@@ -181,7 +181,7 @@ MP4_Stream_t *MP4_InputStream( input_thread_t *p_input )
         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;
@@ -195,7 +195,7 @@ MP4_Stream_t *MP4_InputStream( input_thread_t *p_input )
  *     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;
@@ -205,7 +205,7 @@ MP4_Stream_t *MP4_MemoryStream( input_thread_t *p_input,
         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 )
@@ -243,7 +243,7 @@ int MP4_ReadStream( MP4_Stream_t *p_stream, uint8_t *p_buff, int i_size )
     }
     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);
     }
 }
 
@@ -262,16 +262,15 @@ int MP4_PeekStream( MP4_Stream_t *p_stream, uint8_t **pp_peek, int i_size )
     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 ) );
     }
 }
 
@@ -287,7 +286,7 @@ off_t MP4_TellStream( MP4_Stream_t *p_stream )
     }
     else
     {
-        return( stream_Tell( p_stream->p_input->s ) );
+        return( stream_Tell( p_stream->s ) );
     }
 }
 
@@ -311,7 +310,7 @@ int MP4_SeekStream( MP4_Stream_t *p_stream, off_t i_pos)
     }
     else
     {
-        return( stream_Seek( p_stream->p_input->s, (int64_t)i_pos ) );
+        return( stream_Seek( p_stream->s, (int64_t)i_pos ) );
     }
 }
 
@@ -371,7 +370,7 @@ static int MP4_ReadBoxCommon( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 #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 );
     }
@@ -492,7 +491,7 @@ static int MP4_ReadBoxSkip( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
             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 );
@@ -501,7 +500,7 @@ static int MP4_ReadBoxSkip( MP4_Stream_t *p_stream, MP4_Box_t *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 );
@@ -599,7 +598,7 @@ static int MP4_ReadBox_mvhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     {
         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,
@@ -661,7 +660,7 @@ static int MP4_ReadBox_tkhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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,
@@ -715,7 +714,7 @@ static int MP4_ReadBox_mdhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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,
@@ -741,7 +740,7 @@ static int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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 );
 
@@ -769,7 +768,7 @@ static int MP4_ReadBox_vmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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],
@@ -791,7 +790,7 @@ static int MP4_ReadBox_smhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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 );
@@ -813,7 +812,7 @@ static int MP4_ReadBox_hmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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,
@@ -830,7 +829,7 @@ static int MP4_ReadBox_url( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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
@@ -853,7 +852,7 @@ static int MP4_ReadBox_urn( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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
@@ -878,7 +877,7 @@ static int MP4_ReadBox_dref( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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
@@ -906,7 +905,7 @@ static int MP4_ReadBox_stts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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
@@ -940,7 +939,7 @@ static int MP4_ReadBox_ctts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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
@@ -986,7 +985,7 @@ static int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         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
 
@@ -1032,7 +1031,7 @@ static int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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
 
@@ -1057,7 +1056,7 @@ static int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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
 
@@ -1138,7 +1137,7 @@ static int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         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 );
@@ -1152,25 +1151,25 @@ static int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         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 +
@@ -1250,7 +1249,7 @@ static int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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 );
@@ -1280,7 +1279,7 @@ static int MP4_ReadBox_stsd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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
@@ -1312,7 +1311,7 @@ static int MP4_ReadBox_stsz( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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 );
 
@@ -1350,7 +1349,7 @@ static int MP4_ReadBox_stsc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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
@@ -1398,7 +1397,7 @@ static int MP4_ReadBox_stco_co64( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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
@@ -1432,7 +1431,7 @@ static int MP4_ReadBox_stss( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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
@@ -1470,7 +1469,7 @@ static int MP4_ReadBox_stsh( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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 );
@@ -1501,7 +1500,7 @@ static int MP4_ReadBox_stdp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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
@@ -1545,7 +1544,7 @@ static int MP4_ReadBox_padb( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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
@@ -1604,7 +1603,7 @@ static int MP4_ReadBox_elst( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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
@@ -1638,7 +1637,7 @@ static int MP4_ReadBox_cprt( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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],
@@ -1660,7 +1659,7 @@ static int MP4_ReadBox_dcom( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
     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
@@ -1677,7 +1676,7 @@ static int MP4_ReadBox_cmvd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
     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 );
     }
 
@@ -1689,7 +1688,7 @@ static int MP4_ReadBox_cmvd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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
 
@@ -1716,7 +1715,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
     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 ) );
@@ -1724,7 +1723,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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 );
     }
 
@@ -1737,19 +1736,19 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         ( 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
@@ -1757,7 +1756,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     /* 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 );
     }
@@ -1773,7 +1772,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     /* 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 );
@@ -1783,7 +1782,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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 );
@@ -1791,7 +1790,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
     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;
@@ -1800,7 +1799,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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)" );
     }
 
@@ -1809,11 +1808,11 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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 );
 
@@ -1823,7 +1822,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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 );
@@ -1854,7 +1853,7 @@ static int MP4_ReadBox_rdrf( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
 #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 );
@@ -1878,7 +1877,7 @@ static int MP4_ReadBox_rmdr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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
@@ -1892,7 +1891,7 @@ static int MP4_ReadBox_rmqu( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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
@@ -1910,7 +1909,7 @@ static int MP4_ReadBox_rmvc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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,
@@ -1936,7 +1935,7 @@ static int MP4_ReadBox_drms( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         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 );
@@ -1969,7 +1968,7 @@ static int MP4_ReadBox_0xa9xxx( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         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 );
@@ -2162,13 +2161,13 @@ static MP4_Box_t *MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_father )
 
     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;
     }
@@ -2185,7 +2184,7 @@ static MP4_Box_t *MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_father )
     }
     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 );
     }
@@ -2202,7 +2201,7 @@ static MP4_Box_t *MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_father )
  * 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;
@@ -2217,7 +2216,7 @@ void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
         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;
     }
 
@@ -2235,7 +2234,7 @@ void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
         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 );
         }
@@ -2256,7 +2255,7 @@ void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
  *  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;
@@ -2266,7 +2265,7 @@ MP4_Box_t *MP4_BoxGetRoot( input_thread_t *p_input )
     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;
@@ -2275,7 +2274,7 @@ MP4_Box_t *MP4_BoxGetRoot( input_thread_t *p_input )
     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 );
 
@@ -2314,14 +2313,14 @@ MP4_Box_t *MP4_BoxGetRoot( input_thread_t *p_input )
 }
 
 
-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
@@ -2337,19 +2336,19 @@ static void __MP4_BoxDumpStructure( input_thread_t *p_input,
                       (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 );
 }
 
 
index e83fdca6566215ffd2bab557d3dc270214392ed1..a89a1009ebddaf5689fb50a705652bf2874be796 100644 (file)
@@ -189,7 +189,7 @@ typedef struct MP4_Stream_s
 {
     int     b_memory;   /* do we uses a memory buffer */
 
-    input_thread_t *p_input;
+    stream_t *s;
 
     off_t   i_start; /* in the buffer position for memory stream */
     off_t   i_stop;
@@ -821,7 +821,7 @@ typedef struct MP4_Box_s
  *  The first box is a virtual box "root" and is the father for all first
  *  level boxes
  *****************************************************************************/
-MP4_Box_t *MP4_BoxGetRoot( input_thread_t *p_input );
+MP4_Box_t *MP4_BoxGetRoot( stream_t * );
 
 /*****************************************************************************
  * MP4_FreeBox : free memory allocated after read with MP4_ReadBox
@@ -829,14 +829,14 @@ MP4_Box_t *MP4_BoxGetRoot( input_thread_t *p_input );
  * XXX : all children have to be allocated by a malloc !! and
  *         p_box is freed
  *****************************************************************************/
-void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box );
+void MP4_BoxFree( stream_t *, MP4_Box_t *p_box );
 
 /*****************************************************************************
  * MP4_DumpBoxStructure: print the structure of the p_box
  *****************************************************************************
  * Usefull while debugging
  *****************************************************************************/
-void MP4_BoxDumpStructure( input_thread_t *p_input, MP4_Box_t *p_box );
+void MP4_BoxDumpStructure( stream_t *p_input, MP4_Box_t *p_box );
 
 
 /*****************************************************************************
index 3d6c6830ccd7d22890d5f918f7c4882ef7f9ea49..8500c83105f7aefb3e6e04691a55550bdf992447 100644 (file)
@@ -42,20 +42,20 @@ static void Close( vlc_object_t * );
 
 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
@@ -147,21 +147,21 @@ struct demux_sys_t
 /*****************************************************************************
  * 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;
@@ -191,7 +191,7 @@ static inline int64_t MP4_TrackGetPTS( input_thread_t *p_input, mp4_track_t *p_t
     /* 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 */
@@ -222,7 +222,7 @@ static inline int64_t MP4_GetMoviePTS(demux_sys_t *p_sys )
  *****************************************************************************/
 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;
@@ -236,9 +236,9 @@ static int Open( vlc_object_t * p_this )
     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] ) )
@@ -255,46 +255,46 @@ static int Open( vlc_object_t * p_this )
         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;
@@ -302,7 +302,7 @@ static int Open( vlc_object_t * p_this )
     }
     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 */
@@ -312,7 +312,7 @@ static int Open( vlc_object_t * p_this )
 
         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 */
@@ -325,10 +325,10 @@ static int Open( vlc_object_t * p_this )
         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 )
@@ -346,34 +346,34 @@ static int Open( vlc_object_t * p_this )
                 }
                 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
@@ -381,14 +381,14 @@ static int Open( vlc_object_t * p_this )
                             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 );
                 }
             }
@@ -396,7 +396,7 @@ static int Open( vlc_object_t * p_this )
         }
         else
         {
-            msg_Err( p_input, "can't find playlist" );
+            msg_Err( p_demux, "can't find playlist" );
         }
     }
 
@@ -404,13 +404,13 @@ static int Open( vlc_object_t * p_this )
     {
         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;
         }
     }
@@ -422,34 +422,13 @@ static int Open( vlc_object_t * p_this )
 
     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 ) );
@@ -458,7 +437,7 @@ static int Open( vlc_object_t * p_this )
     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 )
         {
@@ -476,7 +455,7 @@ static int Open( vlc_object_t * p_this )
                     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",
@@ -484,7 +463,7 @@ static int Open( vlc_object_t * p_this )
         }
         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 );
         }
 
     }
@@ -493,7 +472,7 @@ static int Open( vlc_object_t * p_this )
 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;
@@ -504,14 +483,13 @@ error:
  *****************************************************************************
  * 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++ )
@@ -520,21 +498,21 @@ static int Demux( input_thread_t *p_input )
 
         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 )
@@ -546,22 +524,18 @@ static int Demux( input_thread_t *p_input )
 
     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];
@@ -571,33 +545,32 @@ static int Demux( input_thread_t *p_input )
             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;
                 }
 
@@ -607,18 +580,18 @@ static int Demux( input_thread_t *p_input )
                                   (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;
             }
@@ -630,14 +603,14 @@ static int Demux( input_thread_t *p_input )
 /*****************************************************************************
  * 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++ )
@@ -646,7 +619,7 @@ static int   Seek     ( input_thread_t *p_input, mtime_t i_date )
 
         if( tk->b_ok && tk->b_selected )
         {
-            MP4_TrackSeek( p_input, tk, i_date );
+            MP4_TrackSeek( p_demux, tk, i_date );
         }
     }
     return( 1 );
@@ -655,9 +628,9 @@ static int   Seek     ( input_thread_t *p_input, mtime_t i_date )
 /*****************************************************************************
  * 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;
@@ -683,7 +656,7 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
                 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;
 
@@ -700,7 +673,7 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
 
         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 * );
@@ -714,7 +687,7 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
             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:
@@ -778,8 +751,8 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
         }
 
         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;
     }
 }
 
@@ -789,15 +762,15 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
 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 );
 
@@ -811,7 +784,7 @@ static void Close ( vlc_object_t * p_this )
  ****************************************************************************/
 
 /* 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 */
@@ -830,7 +803,7 @@ static int TrackCreateChunksIndex( input_thread_t *p_input,
     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,
@@ -850,7 +823,7 @@ static int TrackCreateChunksIndex( input_thread_t *p_input,
     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 );
     }
 
@@ -876,14 +849,14 @@ static int TrackCreateChunksIndex( input_thread_t *p_input,
                 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,
@@ -907,7 +880,7 @@ static int TrackCreateSamplesIndex( input_thread_t *p_input,
 
     if( ( !p_stts )||( !p_stsz ) )
     {
-        msg_Warn( p_input, "cannot read sample table" );
+        msg_Warn( p_demux, "cannot read sample table" );
         return( VLC_EGENERIC );
     }
 
@@ -1007,7 +980,7 @@ static int TrackCreateSamplesIndex( input_thread_t *p_input,
 
     }
 
-    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,
@@ -1020,7 +993,7 @@ static int TrackCreateSamplesIndex( input_thread_t *p_input,
  * 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 )
@@ -1032,7 +1005,7 @@ static int  TrackCreateES   ( input_thread_t   *p_input,
 
     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;
@@ -1043,7 +1016,7 @@ static int  TrackCreateES   ( input_thread_t   *p_input,
 
     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 );
@@ -1158,7 +1131,7 @@ static int  TrackCreateES   ( input_thread_t   *p_input,
                 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 );
@@ -1251,7 +1224,7 @@ static int  TrackCreateES   ( input_thread_t   *p_input,
         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;
 }
@@ -1259,13 +1232,13 @@ static int  TrackCreateES   ( input_thread_t   *p_input,
 /* 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;
@@ -1279,7 +1252,7 @@ static int  TrackTimeToSampleChunk( input_thread_t *p_input,
     }
 
     /* 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;
@@ -1305,7 +1278,7 @@ static int  TrackTimeToSampleChunk( input_thread_t *p_input,
             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 );
@@ -1364,7 +1337,7 @@ static int  TrackTimeToSampleChunk( input_thread_t *p_input,
 
     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 );
@@ -1375,7 +1348,7 @@ static int  TrackTimeToSampleChunk( input_thread_t *p_input,
     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++ )
@@ -1384,7 +1357,7 @@ static int  TrackTimeToSampleChunk( input_thread_t *p_input,
             {
                 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];
@@ -1397,7 +1370,7 @@ static int  TrackTimeToSampleChunk( input_thread_t *p_input,
                 }
                 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];
@@ -1415,7 +1388,7 @@ static int  TrackTimeToSampleChunk( input_thread_t *p_input,
     }
     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 );
     }
@@ -1426,7 +1399,7 @@ static int  TrackTimeToSampleChunk( input_thread_t *p_input,
     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 )
@@ -1439,19 +1412,19 @@ static int  TrackGotoChunkSample( input_thread_t   *p_input,
         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;
@@ -1463,7 +1436,7 @@ static int  TrackGotoChunkSample( input_thread_t   *p_input,
     /* 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;
@@ -1478,11 +1451,11 @@ static int  TrackGotoChunkSample( input_thread_t   *p_input,
  * 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" );
@@ -1523,7 +1496,7 @@ static void MP4_TrackCreate( input_thread_t *p_input,
 
     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" );
@@ -1571,10 +1544,10 @@ static void MP4_TrackCreate( input_thread_t *p_input,
         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 ?
@@ -1618,7 +1591,7 @@ static void MP4_TrackCreate( input_thread_t *p_input,
             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)",
@@ -1633,8 +1606,8 @@ static void MP4_TrackCreate( input_thread_t *p_input,
     }
 
     /* 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 */
     }
@@ -1643,11 +1616,11 @@ static void MP4_TrackCreate( input_thread_t *p_input,
     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;
     }
@@ -1670,7 +1643,7 @@ static void MP4_TrackCreate( input_thread_t *p_input,
  ****************************************************************************
  * 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;
@@ -1697,7 +1670,7 @@ static void MP4_TrackDestroy( input_thread_t *p_input,
     }
 }
 
-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 )
 {
@@ -1708,16 +1681,16 @@ static int  MP4_TrackSelect ( input_thread_t    *p_input,
 
     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 )
@@ -1727,20 +1700,20 @@ static void MP4_TrackUnselect(input_thread_t    *p_input,
 
     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 )
 {
@@ -1752,11 +1725,11 @@ static int  MP4_TrackSeek   ( input_thread_t    *p_input,
         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 );
@@ -1764,7 +1737,7 @@ static int  MP4_TrackSeek   ( input_thread_t    *p_input,
 
     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;
     }
@@ -1794,7 +1767,7 @@ static int  MP4_TrackSampleSize( mp4_track_t   *p_track )
 
     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 );
     }
 
@@ -1856,7 +1829,7 @@ static uint64_t MP4_TrackGetPos( mp4_track_t *p_track )
     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 )
 {
 
@@ -1894,8 +1867,8 @@ static int  MP4_TrackNextSample( input_thread_t     *p_input,
     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;
     }
 
@@ -1904,13 +1877,13 @@ static int  MP4_TrackNextSample( input_thread_t     *p_input,
             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;
         }
     }
@@ -1918,23 +1891,23 @@ static int  MP4_TrackNextSample( input_thread_t     *p_input,
     /* 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) */
@@ -1958,7 +1931,7 @@ static void MP4_TrackSetELST( input_thread_t *p_input, mp4_track_t *tk, int64_t
 
         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];
         }
@@ -1971,7 +1944,7 @@ static void MP4_TrackSetELST( input_thread_t *p_input, mp4_track_t *tk, int64_t
     }
     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 );
     }
 }