]> git.sesse.net Git - vlc/commitdiff
* all : demuxers *have to* set pf_demux_control. (demux_vaControlDefault
authorLaurent Aimar <fenrir@videolan.org>
Sun, 7 Sep 2003 22:48:29 +0000 (22:48 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 7 Sep 2003 22:48:29 +0000 (22:48 +0000)
 is a generic handler)
 * avi, mp4 : begin to implement a specific pf_demux_control.

20 files changed:
modules/demux/a52sys.c
modules/demux/aac.c
modules/demux/asf/asf.c
modules/demux/asf/libasf.c
modules/demux/au.c
modules/demux/avi/avi.c
modules/demux/avi/libavi.c
modules/demux/demuxdump.c
modules/demux/flac.c
modules/demux/mkv.cpp
modules/demux/mp4/libmp4.c
modules/demux/mp4/mp4.c
modules/demux/mpeg/es.c
modules/demux/mpeg/m4v.c
modules/demux/mpeg/mpga.c
modules/demux/mpeg/ps.c
modules/demux/mpeg/ts.c
modules/demux/ogg.c
modules/demux/rawdv.c
modules/demux/wav.c

index 8b60ee59a36a9d98a11dd21b09a1975152eed780..7c848e6581b4fe3bcb2cd4f26baf9c4eff4fc75c 100644 (file)
@@ -2,7 +2,7 @@
  * a52.c : Raw a52 Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: a52sys.c,v 1.4 2003/08/01 00:04:28 fenrir Exp $
+ * $Id: a52sys.c,v 1.5 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -29,8 +29,6 @@
 #include <vlc/vlc.h>
 #include <vlc/input.h>
 
-#include <ninput.h>
-
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -129,6 +127,7 @@ static int Open( vlc_object_t * p_this )
     }
 
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
     p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
     p_sys->i_time = 0;
index add45471399133028ac55d6455e71765172d4683..1b21f11ae1cc1a5c7794dfc59447994cde10f116 100644 (file)
@@ -2,7 +2,7 @@
  * aac.c : Raw aac Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: aac.c,v 1.2 2003/08/01 00:40:05 fenrir Exp $
+ * $Id: aac.c,v 1.3 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -29,8 +29,6 @@
 #include <vlc/vlc.h>
 #include <vlc/input.h>
 
-#include <ninput.h>
-
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -136,6 +134,7 @@ static int Open( vlc_object_t * p_this )
     }
 
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
     p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
     p_sys->i_time = 0;
index 6118a23a97e542e3a5fde15b2b5a6a1a6b79fbfb..a0ff6830a40e7c4cdbd70c3e2ab5e8db09342b1b 100644 (file)
@@ -2,7 +2,7 @@
  * asf.c : ASFv01 file input module for vlc
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: asf.c,v 1.36 2003/08/25 23:36:16 fenrir Exp $
+ * $Id: asf.c,v 1.37 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -28,7 +28,6 @@
 
 #include <vlc/vlc.h>
 #include <vlc/input.h>
-#include "ninput.h"
 
 #include "codecs.h"                        /* BITMAPINFOHEADER, WAVEFORMATEX */
 #include "libasf.h"
@@ -117,7 +116,8 @@ static int Open( vlc_object_t * p_this )
     }
 
     /* Set p_input field */
-    p_input->pf_demux = Demux;
+    p_input->pf_demux         = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
     p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
     memset( p_sys, 0, sizeof( demux_sys_t ) );
     p_sys->i_time = -1;
index 41bbb4a4b3936adef9f2d6518daaf7c6c6613b3b..f76781f5894f7b07d6a1149fc27533af8fdc2f07 100644 (file)
@@ -2,7 +2,7 @@
  * libasf.c :
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: libasf.c,v 1.17 2003/08/24 15:05:27 fenrir Exp $
+ * $Id: libasf.c,v 1.18 2003/09/07 22:48:29 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -24,7 +24,6 @@
 
 #include <vlc/vlc.h>
 #include <vlc/input.h>
-#include "ninput.h"
 
 #include "codecs.h"                        /* BITMAPINFOHEADER, WAVEFORMATEX */
 #include "libasf.h"
index 7b751214e68478664c0d3bd2c85e75ae125d2150..e769ddfd3b0bf6b0d1c4442bad2c1c105334f28c 100644 (file)
@@ -2,7 +2,7 @@
  * au.c : au file input module for vlc
  *****************************************************************************
  * Copyright (C) 2001-2003 VideoLAN
- * $Id: au.c,v 1.5 2003/08/22 20:32:27 fenrir Exp $
+ * $Id: au.c,v 1.6 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -30,7 +30,6 @@
 #include <vlc/input.h>
 
 #include <codecs.h>
-#include <ninput.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -320,6 +319,7 @@ static int Open( vlc_object_t * p_this )
                                 (mtime_t)p_sys->wf.nSamplesPerSec;
 
         p_input->pf_demux = DemuxPCM;
+        p_input->pf_demux_control = demux_vaControlDefault;
     }
 
     /*  create one program */
index e3608b5c0bf33f9f27ddf0e84a22f571a5416e1a..e61513f37e984f461223d469f0f9726e6695cf3f 100644 (file)
@@ -2,7 +2,7 @@
  * avi.c : AVI file Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: avi.c,v 1.59 2003/08/23 11:46:06 fenrir Exp $
+ * $Id: avi.c,v 1.60 2003/09/07 22:48:29 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -27,7 +27,6 @@
 
 #include <vlc/vlc.h>
 #include <vlc/input.h>
-#include "ninput.h"
 #include "codecs.h"
 
 #include "../util/sub.h"
@@ -58,6 +57,7 @@ vlc_module_end();
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
+static int    Control         ( input_thread_t *, int, va_list );
 static int    Seek            ( input_thread_t *, mtime_t, int );
 static int    Demux_Seekable  ( input_thread_t * );
 static int    Demux_UnSeekable( input_thread_t *p_input );
@@ -159,6 +159,7 @@ static int Open( vlc_object_t * p_this )
     }
     stream_Control( p_avi->s, STREAM_CAN_FASTSEEK, &p_avi->b_seekable );
 
+    p_input->pf_demux_control = Control;
     p_input->pf_demux = Demux_Seekable;
     /* For unseekable stream, automaticaly use Demux_UnSeekable */
     if( !p_avi->b_seekable || config_GetInt( p_input, "avi-interleaved" ) )
@@ -460,7 +461,6 @@ static int Open( vlc_object_t * p_this )
     {
         msg_Warn( p_input, "broken or missing index, 'seek' will be axproximative or will have strange behavour" );
     }
-
     /* fix some BeOS MediaKit generated file */
     for( i = 0 ; i < p_avi->i_streams; i++ )
     {
@@ -656,7 +656,7 @@ static int Demux_Seekable( input_thread_t *p_input )
         msg_Warn( p_input, "no track selected, exiting..." );
         return( 0 );
     }
-
+#if 0
     if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
     {
         mtime_t i_date;
@@ -678,7 +678,7 @@ static int Demux_Seekable( input_thread_t *p_input )
             subtitle_Seek( p_avi->p_sub, p_avi->i_time );
         }
     }
-
+#endif
 
     /* wait for the good time */
 
@@ -1131,8 +1131,7 @@ static int Demux_UnSeekable( input_thread_t *p_input )
  *****************************************************************************
  * Returns -1 in case of error, 0 in case of EOF, 1 otherwise
  *****************************************************************************/
-static int    Seek   ( input_thread_t *p_input,
-                          mtime_t i_date, int i_percent )
+static int Seek( input_thread_t *p_input, mtime_t i_date, int i_percent )
 {
 
     demux_sys_t *p_avi = p_input->p_demux_data;
@@ -1184,7 +1183,7 @@ static int    Seek   ( input_thread_t *p_input,
                 return( -1 );
             }
 
-            /* be sure that the index exit */
+            /* be sure that the index exist */
             if( AVI_StreamChunkSet( p_input,
                                     i_stream,
                                     0 ) )
@@ -1253,6 +1252,93 @@ static int    Seek   ( input_thread_t *p_input,
     }
 }
 
+/*****************************************************************************
+ * Control:
+ *****************************************************************************
+ *
+ *****************************************************************************/
+static int    Control( input_thread_t *p_input, int i_query, va_list args )
+{
+    demux_sys_t *p_sys = p_input->p_demux_data;
+    double   f, *pf;
+    int64_t i64, *pi64;
+
+    switch( i_query )
+    {
+        case DEMUX_GET_POSITION:
+            pf = (double*)va_arg( args, double * );
+            if( p_sys->i_length > 0 )
+            {
+                *pf = (double)p_sys->i_time / (double)( p_sys->i_length * (mtime_t)1000000 );
+                return VLC_SUCCESS;
+            }
+            else if( stream_Size( p_sys->s ) > 0 )
+            {
+                unsigned int i;
+                int64_t i_tmp;
+
+                i64 = 0;
+                /* search the more advanced selected es */
+                for( i = 0; i < p_sys->i_streams; i++ )
+                {
+#define tk  p_sys->pp_info[i]
+                    if( tk->b_activated && tk->i_idxposc < tk->i_idxnb )
+                    {
+                        i_tmp = tk->p_index[tk->i_idxposc].i_pos +
+                                tk->p_index[tk->i_idxposc].i_length + 8;
+                        if( i_tmp > i64 )
+                        {
+                            i64 = i_tmp;
+                        }
+                    }
+#undef tk
+                }
+                *pf = (double)i64 / (double)stream_Size( p_sys->s );
+                return VLC_SUCCESS;
+            }
+            else
+            {
+                *pf = 0.0;
+                return VLC_SUCCESS;
+            }
+        case DEMUX_SET_POSITION:
+            if( p_sys->b_seekable )
+            {
+                int i_ret;
+
+                f = (double)va_arg( args, double );
+                i64 = (mtime_t)(1000000.0 * p_sys->i_length * f );
+                i_ret = Seek( p_input, i64, (int)(f * 100) );
+                if( p_sys->p_sub )
+                {
+                    subtitle_Seek( p_sys->p_sub, p_sys->i_time );
+                }
+                return i_ret;
+            }
+            else
+            {
+                return demux_vaControlDefault( p_input, i_query, args );
+            }
+        case DEMUX_GET_TIME:
+            pi64 = (int64_t*)va_arg( args, int64_t * );
+            *pi64 = p_sys->i_time;
+            return VLC_SUCCESS;
+
+        case DEMUX_SET_TIME:
+            msg_Err( p_input, "FIXME DEMUX_SET_TIME to be implemented" );
+            return VLC_EGENERIC;
+            /* return demux_vaControlDefault( p_input, i_query, args ); */
+
+        case DEMUX_GET_LENGTH:
+            pi64 = (int64_t*)va_arg( args, int64_t * );
+            *pi64 = p_sys->i_length * (mtime_t)1000000;
+            return VLC_SUCCESS;
+
+        default:
+            return demux_vaControlDefault( p_input, i_query, args );
+    }
+    return VLC_EGENERIC;
+}
 
 /*****************************************************************************
  * Function to convert pts to chunk or byte
index 51c9c224c686050e0db9e9be159040cc04367d9b..1590ecec2aa77e978b6bfeeac79ae17228b0ac1a 100644 (file)
@@ -2,7 +2,7 @@
  * libavi.c :
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: libavi.c,v 1.25 2003/08/30 02:03:44 fenrir Exp $
+ * $Id: libavi.c,v 1.26 2003/09/07 22:48:29 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -24,7 +24,6 @@
 
 #include <vlc/vlc.h>
 #include <vlc/input.h>
-#include "ninput.h"
 #include "codecs.h"                                      /* BITMAPINFOHEADER */
 
 #include "libavi.h"
index e9ba85c2ca6045cf073a8b8e92786b9f51b0aea2..c759a8698a71f9050b1359a91d92417a320d550d 100644 (file)
@@ -2,7 +2,7 @@
  * demuxdump.c : Pseudo demux module for vlc (dump raw stream)
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: demuxdump.c,v 1.9 2003/05/15 22:27:37 massiot Exp $
+ * $Id: demuxdump.c,v 1.10 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -84,6 +84,7 @@ static int Activate( vlc_object_t * p_this )
 
     /* Set the demux function */
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
     /* Initialize access plug-in structures. */
     if( p_input->i_mtu == 0 )
index 4f61cae15e65c6a89cde1da2804c060e241c29c7..2674122a76c93f3da2a84353012af306e2ae1110 100644 (file)
@@ -2,7 +2,7 @@
  * flac.c : FLAC demuc module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: flac.c,v 1.4 2003/08/17 13:56:26 gbazin Exp $
+ * $Id: flac.c,v 1.5 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
@@ -72,6 +72,7 @@ static int Init( vlc_object_t * p_this )
     }
 
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
     p_input->pf_rewind = NULL;
 
     /* Have a peep at the show. */
index ef82c491dd127db5ec1c3d3124587bdb1b2712a3..18c686132a8dc50eb6b72ae1dbba584179d244db 100644 (file)
@@ -2,7 +2,7 @@
  * mkv.cpp : matroska demuxer
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: mkv.cpp,v 1.25 2003/08/26 19:43:51 hartman Exp $
+ * $Id: mkv.cpp,v 1.26 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -36,7 +36,6 @@
 
 #include <codecs.h>                        /* BITMAPINFOHEADER, WAVEFORMATEX */
 #include "iso_lang.h"
-#include "ninput.h"
 
 #include <iostream>
 #include <cassert>
@@ -300,6 +299,7 @@ static int Open( vlc_object_t * p_this )
 
     /* Set the demux function */
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
     /* peek the begining */
     if( input_Peek( p_input, &p_peek, 4 ) < 4 )
index ef27fc289de6305273955d5e8c67d696edb3f7b2..99167fb0d91b2f6a39832866bdd41088fddeb0b2 100644 (file)
@@ -2,7 +2,7 @@
  * libmp4.c : LibMP4 library for mp4 module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: libmp4.c,v 1.31 2003/08/17 23:02:52 fenrir Exp $
+ * $Id: libmp4.c,v 1.32 2003/09/07 22:48:29 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -519,7 +519,7 @@ int MP4_ReadBoxCommon( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
 
 /*****************************************************************************
- * MP4_MP4_NextBox : Go to the next box
+ * MP4_NextBox : Go to the next box
  *****************************************************************************
  * if p_box == NULL, go to the next box in witch we are( at the begining ).
  *****************************************************************************/
@@ -566,7 +566,7 @@ int MP4_GotoBox( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
  *       after called one of theses functions, file position is unknown
  *       you need to call MP4_GotoBox to go where you want
  *****************************************************************************/
-int MP4_ReadBoxContainerRaw( MP4_Stream_t *p_stream, MP4_Box_t *p_container )
+static int MP4_ReadBoxContainerRaw( MP4_Stream_t *p_stream, MP4_Box_t *p_container )
 {
     MP4_Box_t *p_box;
 
@@ -607,7 +607,7 @@ int MP4_ReadBoxContainerRaw( MP4_Stream_t *p_stream, MP4_Box_t *p_container )
 }
 
 
-int MP4_ReadBoxContainer( MP4_Stream_t *p_stream, MP4_Box_t *p_container )
+static int MP4_ReadBoxContainer( MP4_Stream_t *p_stream, MP4_Box_t *p_container )
 {
     if( p_container->i_size <= (size_t)MP4_BOX_HEADERSIZE(p_container ) + 8 )
     {
@@ -621,12 +621,12 @@ int MP4_ReadBoxContainer( MP4_Stream_t *p_stream, MP4_Box_t *p_container )
     return( MP4_ReadBoxContainerRaw( p_stream, p_container ) );
 }
 
-void MP4_FreeBox_Common( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_Common( MP4_Box_t *p_box )
 {
     /* Up to now do nothing */
 }
 
-int MP4_ReadBoxSkip( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBoxSkip( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     /* XXX sometime moov is hiden in a free box */
     if( p_box->p_father && p_box->p_father->i_type == VLC_FOURCC( 'r', 'o', 'o', 't' )&&
@@ -662,7 +662,7 @@ int MP4_ReadBoxSkip( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     return( 1 );
 }
 
-int MP4_ReadBox_ftyp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_ftyp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_ftyp_t );
 
@@ -688,13 +688,13 @@ int MP4_ReadBox_ftyp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_ftyp( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_ftyp( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_ftyp->i_compatible_brands );
 }
 
 
-int MP4_ReadBox_mvhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_mvhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 #ifdef MP4_VERBOSE
@@ -766,7 +766,7 @@ int MP4_ReadBox_mvhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-int MP4_ReadBox_tkhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_tkhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 #ifdef MP4_VERBOSE
@@ -830,7 +830,7 @@ int MP4_ReadBox_tkhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 }
 
 
-int MP4_ReadBox_mdhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_mdhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
     uint16_t i_language;
@@ -883,7 +883,7 @@ int MP4_ReadBox_mdhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 }
 
 
-int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_hdlr_t );
 
@@ -904,12 +904,12 @@ int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_hdlr( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_hdlr( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_hdlr->psz_name );
 }
 
-int MP4_ReadBox_vmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_vmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 
@@ -933,7 +933,7 @@ int MP4_ReadBox_vmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-int MP4_ReadBox_smhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_smhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_smhd_t );
 
@@ -953,7 +953,7 @@ int MP4_ReadBox_smhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 }
 
 
-int MP4_ReadBox_hmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_hmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_hmhd_t );
 
@@ -977,7 +977,7 @@ int MP4_ReadBox_hmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-int MP4_ReadBox_url( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_url( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_url_t );
 
@@ -993,12 +993,12 @@ int MP4_ReadBox_url( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 }
 
 
-void MP4_FreeBox_url( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_url( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_url->psz_location )
 }
 
-int MP4_ReadBox_urn( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_urn( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_urn_t );
 
@@ -1014,14 +1014,14 @@ int MP4_ReadBox_urn( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 #endif
     MP4_READBOX_EXIT( 1 );
 }
-void MP4_FreeBox_urn( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_urn( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_urn->psz_name );
     FREE( p_box->data.p_urn->psz_location );
 }
 
 
-int MP4_ReadBox_dref( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_dref( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_dref_t );
 
@@ -1041,7 +1041,7 @@ int MP4_ReadBox_dref( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 }
 
 
-int MP4_ReadBox_stts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_stts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
     MP4_READBOX_ENTER( MP4_Box_data_stts_t );
@@ -1068,13 +1068,13 @@ int MP4_ReadBox_stts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_stts( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_stts( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_stts->i_sample_count );
     FREE( p_box->data.p_stts->i_sample_delta );
 }
 
-int MP4_ReadBox_ctts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_ctts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
     MP4_READBOX_ENTER( MP4_Box_data_ctts_t );
@@ -1102,7 +1102,7 @@ int MP4_ReadBox_ctts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_ctts( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_ctts( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_ctts->i_sample_count );
     FREE( p_box->data.p_ctts->i_sample_offset );
@@ -1123,7 +1123,7 @@ static int MP4_ReadLengthDescriptor( uint8_t **pp_peek, int64_t  *i_read )
     return( i_len );
 }
 
-int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
 #define es_descriptor p_box->data.p_esds->es_descriptor
     unsigned int i_len;
@@ -1209,7 +1209,7 @@ int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 #undef es_descriptor
 }
 
-void MP4_FreeBox_esds( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_esds( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_esds->es_descriptor.psz_URL );
     if( p_box->data.p_esds->es_descriptor.p_decConfigDescr )
@@ -1219,7 +1219,7 @@ void MP4_FreeBox_esds( input_thread_t *p_input, MP4_Box_t *p_box )
     FREE( p_box->data.p_esds->es_descriptor.p_decConfigDescr );
 }
 
-int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 
@@ -1301,7 +1301,7 @@ int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 }
 
 
-int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 
@@ -1367,7 +1367,7 @@ int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 }
 
 
-int MP4_ReadBox_stsd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_stsd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
 
     MP4_READBOX_ENTER( MP4_Box_data_stsd_t );
@@ -1389,7 +1389,7 @@ int MP4_ReadBox_stsd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 }
 
 
-int MP4_ReadBox_stsz( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_stsz( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 
@@ -1421,12 +1421,12 @@ int MP4_ReadBox_stsz( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_stsz( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_stsz( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_stsz->i_entry_size );
 }
 
-int MP4_ReadBox_stsc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_stsc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 
@@ -1458,14 +1458,14 @@ int MP4_ReadBox_stsc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_stsc( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_stsc( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_stsc->i_first_chunk );
     FREE( p_box->data.p_stsc->i_samples_per_chunk );
     FREE( p_box->data.p_stsc->i_sample_description_index );
 }
 
-int MP4_ReadBox_stco_co64( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_stco_co64( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 
@@ -1506,12 +1506,12 @@ int MP4_ReadBox_stco_co64( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_stco_co64( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_stco_co64( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_co64->i_chunk_offset );
 }
 
-int MP4_ReadBox_stss( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_stss( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 
@@ -1540,12 +1540,12 @@ int MP4_ReadBox_stss( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_stss( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_stss( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_stss->i_sample_number )
 }
 
-int MP4_ReadBox_stsh( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_stsh( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 
@@ -1577,14 +1577,14 @@ int MP4_ReadBox_stsh( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_stsh( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_stsh( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_stsh->i_shadowed_sample_number )
     FREE( p_box->data.p_stsh->i_sync_sample_number )
 }
 
 
-int MP4_ReadBox_stdp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_stdp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 
@@ -1609,12 +1609,12 @@ int MP4_ReadBox_stdp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_stdp( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_stdp( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_stdp->i_priority )
 }
 
-int MP4_ReadBox_padb( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_padb( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 
@@ -1653,7 +1653,7 @@ int MP4_ReadBox_padb( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_padb( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_padb( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_padb->i_reserved1 );
     FREE( p_box->data.p_padb->i_pad2 );
@@ -1661,7 +1661,7 @@ void MP4_FreeBox_padb( input_thread_t *p_input, MP4_Box_t *p_box )
     FREE( p_box->data.p_padb->i_pad1 );
 }
 
-int MP4_ReadBox_elst( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_elst( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
 
@@ -1711,7 +1711,7 @@ int MP4_ReadBox_elst( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_elst( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_elst( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_elst->i_segment_duration );
     FREE( p_box->data.p_elst->i_media_time );
@@ -1719,7 +1719,7 @@ void MP4_FreeBox_elst( input_thread_t *p_input, MP4_Box_t *p_box )
     FREE( p_box->data.p_elst->i_media_rate_fraction );
 }
 
-int MP4_ReadBox_cprt( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_cprt( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i_language;
     unsigned int i;
@@ -1748,13 +1748,13 @@ int MP4_ReadBox_cprt( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-void MP4_FreeBox_cprt( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_cprt( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_cprt->psz_notice );
 }
 
 
-int MP4_ReadBox_dcom( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_dcom( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_dcom_t );
 
@@ -1767,7 +1767,7 @@ int MP4_ReadBox_dcom( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-int MP4_ReadBox_cmvd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_cmvd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_cmvd_t );
 
@@ -1795,13 +1795,13 @@ int MP4_ReadBox_cmvd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
     MP4_READBOX_EXIT( 1 );
 }
-void MP4_FreeBox_cmvd( input_thread_t *p_input, MP4_Box_t *p_box )
+static void MP4_FreeBox_cmvd( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_cmvd->p_data );
 }
 
 
-int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_Stream_t *p_stream_memory;
     MP4_Box_t *p_umov;
@@ -1937,7 +1937,7 @@ int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 #endif /* HAVE_ZLIB_H */
 }
 
-int MP4_ReadBox_rdrf( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_rdrf( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     uint32_t i_len;
     MP4_READBOX_ENTER( MP4_Box_data_rdrf_t );
@@ -1969,13 +1969,14 @@ int MP4_ReadBox_rdrf( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 #endif
     MP4_READBOX_EXIT( 1 );
 }
-void MP4_FreeBox_rdrf( input_thread_t *p_input, MP4_Box_t *p_box )
+
+static void MP4_FreeBox_rdrf( MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_rdrf->psz_ref )
 }
 
 
-int MP4_ReadBox_rmdr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_rmdr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_rmdr_t );
 
@@ -1991,7 +1992,7 @@ int MP4_ReadBox_rmdr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-int MP4_ReadBox_rmqu( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_rmqu( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_rmqu_t );
 
@@ -2005,7 +2006,7 @@ int MP4_ReadBox_rmqu( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-int MP4_ReadBox_rmvc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
+static int MP4_ReadBox_rmvc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_rmvc_t );
     MP4_GETVERSIONFLAGS( p_box->data.p_rmvc );
@@ -2034,7 +2035,7 @@ static struct
 {
     uint32_t i_type;
     int  (*MP4_ReadBox_function )( MP4_Stream_t *p_stream, MP4_Box_t *p_box );
-    void (*MP4_FreeBox_function )( input_thread_t *p_input, MP4_Box_t *p_box );
+    void (*MP4_FreeBox_function )( MP4_Box_t *p_box );
 } MP4_Box_Function [] =
 {
     /* Containers */
@@ -2364,7 +2365,7 @@ void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
         }
         else
         {
-            MP4_Box_Function[i_index].MP4_FreeBox_function( p_input, p_box );
+            MP4_Box_Function[i_index].MP4_FreeBox_function( p_box );
         }
 
         free( p_box->data.p_data );
index bcf370368d957933347be4f672a8914002e5754f..1d86bd37f05759c92b70237dcc611d8a90a25f6a 100644 (file)
@@ -2,7 +2,7 @@
  * mp4.c : MP4 file input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: mp4.c,v 1.34 2003/07/23 01:13:47 gbazin Exp $
+ * $Id: mp4.c,v 1.35 2003/09/07 22:48:29 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -24,9 +24,6 @@
  * Preamble
  *****************************************************************************/
 #include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>                                              /* strdup() */
-#include <errno.h>
-#include <sys/types.h>
 
 #include <vlc/vlc.h>
 #include <vlc/input.h>
 #include "libmp4.h"
 #include "mp4.h"
 
-/*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-static int    MP4Init    ( vlc_object_t * );
-static void __MP4End     ( vlc_object_t * );
-static int    MP4Demux   ( input_thread_t * );
-
-static int    MP4DemuxRef( input_thread_t *p_input )
-{
-    return 0;
-}
-
-/* New input could have something like that... */
-static int   MP4Seek     ( input_thread_t *, mtime_t );
-
-#define MP4End(a) __MP4End(VLC_OBJECT(a))
-
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
+static int  Open    ( vlc_object_t * );
+static void Close     ( vlc_object_t * );
+
 vlc_module_begin();
     set_description( _("MP4 demuxer") );
     set_capability( "demux", 242 );
-    set_callbacks( MP4Init, __MP4End );
+    set_callbacks( Open, Close );
 vlc_module_end();
 
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static int    Demux   ( input_thread_t * );
+static int    DemuxRef( input_thread_t *p_input )
+{
+    return 0;
+}
+static int   Seek     ( input_thread_t *, mtime_t );
+static int   Control  ( input_thread_t *, int, va_list );
+
 /*****************************************************************************
  * Declaration of local function
  *****************************************************************************/
 
-static void MP4_TrackCreate ( input_thread_t *,
-                              track_data_mp4_t *,
-                              MP4_Box_t  * );
-static void MP4_TrackDestroy( input_thread_t *,
-                              track_data_mp4_t * );
+static void MP4_TrackCreate ( input_thread_t *, track_data_mp4_t *, MP4_Box_t  *);
+static void MP4_TrackDestroy( input_thread_t *, track_data_mp4_t * );
 
-static int  MP4_TrackSelect ( input_thread_t *,
-                              track_data_mp4_t *,
-                              mtime_t );
-static void MP4_TrackUnselect(input_thread_t *,
-                              track_data_mp4_t * );
+static int  MP4_TrackSelect ( input_thread_t *, track_data_mp4_t *, mtime_t );
+static void MP4_TrackUnselect(input_thread_t *, track_data_mp4_t * );
 
-static int  MP4_TrackSeek   ( input_thread_t *,
-                              track_data_mp4_t *,
-                              mtime_t );
+static int  MP4_TrackSeek   ( input_thread_t *, track_data_mp4_t *, mtime_t );
 
-static uint64_t MP4_GetTrackPos( track_data_mp4_t * );
-static int  MP4_TrackSampleSize( track_data_mp4_t * );
-static int  MP4_TrackNextSample( input_thread_t *,
-                                 track_data_mp4_t * );
+static uint64_t MP4_GetTrackPos    ( track_data_mp4_t * );
+static int      MP4_TrackSampleSize( track_data_mp4_t * );
+static int      MP4_TrackNextSample( input_thread_t *, track_data_mp4_t * );
 
 #define MP4_Set4BytesLE( p, dw ) \
     *((uint8_t*)p)   = ( (dw)&0xff ); \
@@ -100,9 +86,9 @@ static int  MP4_TrackNextSample( input_thread_t *,
     if( p ) { free( p ); (p) = NULL;}
 
 /*****************************************************************************
- * MP4Init: check file and initializes MP4 structures
+ * Open: check file and initializes MP4 structures
  *****************************************************************************/
-static int MP4Init( vlc_object_t * p_this )
+static int Open( vlc_object_t * p_this )
 {
     input_thread_t  *p_input = (input_thread_t *)p_this;
     uint8_t         *p_peek;
@@ -119,63 +105,49 @@ static int MP4Init( vlc_object_t * p_this )
     unsigned int    i;
     vlc_bool_t      b_audio;
 
-    /* I need to seek */
-    if( !p_input->stream.b_seekable )
-    {
-        msg_Warn( p_input, "MP4 plugin discarded (unseekable)" );
-        return( VLC_EGENERIC );
-
-    }
-    /* Initialize access plug-in structures. */
-    if( p_input->i_mtu == 0 )
-    {
-        /* Improve speed. */
-        p_input->i_bufsize = INPUT_DEFAULT_BUFSIZE ;
-    }
-
-    p_input->pf_demux = MP4Demux;
-
     /* a little test to see if it could be a mp4 */
     if( input_Peek( p_input, &p_peek, 8 ) < 8 )
     {
         msg_Warn( p_input, "MP4 plugin discarded (cannot peek)" );
-        return( VLC_EGENERIC );
+        return VLC_EGENERIC;
     }
-
-
     switch( VLC_FOURCC( p_peek[4], p_peek[5], p_peek[6], p_peek[7] ) )
     {
-        case( FOURCC_ftyp ):
-        case( FOURCC_moov ):
-        case( FOURCC_foov ):
-        case( FOURCC_moof ):
-        case( FOURCC_mdat ):
-        case( FOURCC_udta ):
-        case( FOURCC_free ):
-        case( FOURCC_skip ):
-        case( FOURCC_wide ):
+        case FOURCC_ftyp:
+        case FOURCC_moov:
+        case FOURCC_foov:
+        case FOURCC_moof:
+        case FOURCC_mdat:
+        case FOURCC_udta:
+        case FOURCC_free:
+        case FOURCC_skip:
+        case FOURCC_wide:
             break;
          default:
             msg_Warn( p_input, "MP4 plugin discarded (not a valid file)" );
-            return( VLC_EGENERIC );
+            return VLC_EGENERIC;
     }
-
-    /* create our structure that will contains all data */
-    if( !( p_input->p_demux_data =
-                p_demux = malloc( sizeof( demux_sys_t ) ) ) )
+    /* I need to seek */
+    if( !p_input->stream.b_seekable )
     {
-        msg_Err( p_input, "out of memory" );
-        return( VLC_EGENERIC );
+        msg_Warn( p_input, "MP4 plugin discarded (unseekable)" );
+        return VLC_EGENERIC;
     }
-    memset( p_demux, 0, sizeof( demux_sys_t ) );
-    p_input->p_demux_data = p_demux;
 
+    /*Set exported functions */
+    p_input->pf_demux = Demux;
+    p_input->pf_demux_control = Control;
+
+
+    /* create our structure that will contains all data */
+    p_input->p_demux_data = p_demux = malloc( sizeof( demux_sys_t ) );
+    memset( p_demux, 0, sizeof( demux_sys_t ) );
 
     /* Now load all boxes ( except raw data ) */
     if( !MP4_BoxGetRoot( p_input, &p_demux->box_root ) )
     {
         msg_Warn( p_input, "MP4 plugin discarded (not a valid file)" );
-        return( VLC_EGENERIC );
+        return VLC_EGENERIC;
     }
 
     MP4_BoxDumpStructure( p_input, &p_demux->box_root );
@@ -209,8 +181,7 @@ static int MP4Init( vlc_object_t * p_this )
         if( !p_foov )
         {
             msg_Err( p_input, "MP4 plugin discarded (no moov box)" );
-            MP4End( p_input );
-            return( VLC_EGENERIC );
+            goto error;
         }
         /* we have a free box as a moov, rename it */
         p_foov->i_type = FOURCC_moov;
@@ -301,13 +272,12 @@ static int MP4Init( vlc_object_t * p_this )
         if( !p_rmra )
         {
             msg_Err( p_input, "cannot find /moov/mvhd" );
-            MP4End( p_input );
-            return VLC_EGENERIC;
+            goto error;
         }
         else
         {
             msg_Warn( p_input, "cannot find /moov/mvhd (pure ref file)" );
-            p_input->pf_demux = MP4DemuxRef;
+            p_input->pf_demux = DemuxRef;
             return VLC_SUCCESS;
         }
     }
@@ -321,8 +291,7 @@ static int MP4Init( vlc_object_t * p_this )
                 MP4_BoxCount( &p_demux->box_root, "/moov/trak" ) ) )
     {
         msg_Err( p_input, "cannot find any /moov/trak" );
-        MP4End( p_input );
-        return( VLC_EGENERIC );
+        goto error;
     }
     msg_Dbg( p_input, "find %d track%c",
                         p_demux->i_tracks,
@@ -334,19 +303,16 @@ static int MP4Init( vlc_object_t * p_this )
     {
         vlc_mutex_unlock( &p_input->stream.stream_lock );
         msg_Err( p_input, "cannot init stream" );
-        MP4End( p_input );
-        return( VLC_EGENERIC );
+        goto error;
     }
     /* Needed to create program _before_ MP4_TrackCreate */
     if( input_AddProgram( p_input, 0, 0) == NULL )
     {
         vlc_mutex_unlock( &p_input->stream.stream_lock );
         msg_Err( p_input, "cannot add program" );
-        MP4End( p_input );
-        return( VLC_EGENERIC );
+        goto error;
     }
     p_input->stream.p_selected_program = p_input->stream.pp_programs[0];
-    /* XXX beurk and beurk, see MP4Demux and MP4Seek */
     if( p_demux->i_duration/p_demux->i_timescale > 0 )
     {
         p_input->stream.i_mux_rate =
@@ -422,15 +388,19 @@ static int MP4Init( vlc_object_t * p_this )
     p_input->stream.p_selected_program->b_is_ok = 1;
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 
-    return( VLC_SUCCESS );
+    return VLC_SUCCESS;
+
+error:
+    Close( VLC_OBJECT( p_input ) );
+    return VLC_EGENERIC;
 }
 
 /*****************************************************************************
- * MP4Demux: read packet and send them to decoders
+ * Demux: read packet and send them to decoders
  *****************************************************************************
  * TODO check for newly selected track (ie audio upt to now )
  *****************************************************************************/
-static int MP4Demux( input_thread_t *p_input )
+static int Demux( input_thread_t *p_input )
 {
     demux_sys_t *p_demux = p_input->p_demux_data;
     unsigned int i_track;
@@ -480,25 +450,6 @@ static int MP4Demux( input_thread_t *p_input )
         return( 0 );
     }
 
-
-    /* XXX beurk, beuRK and BEURK,
-       but only way I've found to detect seek from interface */
-    if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
-    {
-        mtime_t i_date;
-
-        /* first wait for empty buffer, arbitrary time FIXME */
-        msleep( DEFAULT_PTS_DELAY );
-        /* *** calculate new date *** */
-
-        i_date = (mtime_t)1000000 *
-                 (mtime_t)p_demux->i_duration /
-                 (mtime_t)p_demux->i_timescale *
-                 (mtime_t)MP4_TellAbsolute( p_input ) /
-                 (mtime_t)p_input->stream.p_selected_area->i_size;
-        MP4Seek( p_input, i_date );
-    }
-
     /* first wait for the good time to read a packet */
     input_ClockManageRef( p_input,
                           p_input->stream.p_selected_program,
@@ -617,9 +568,9 @@ static int MP4Demux( input_thread_t *p_input )
     return( 1 );
 }
 /*****************************************************************************
- * MP4Seek: Got to i_date
+ * Seek: Got to i_date
  ******************************************************************************/
-static int   MP4Seek     ( input_thread_t *p_input, mtime_t i_date )
+static int   Seek     ( input_thread_t *p_input, mtime_t i_date )
 {
     demux_sys_t *p_demux = p_input->p_demux_data;
     unsigned int i_track;
@@ -641,9 +592,65 @@ static int   MP4Seek     ( input_thread_t *p_input, mtime_t i_date )
 }
 
 /*****************************************************************************
- * MP4End: frees unused data
+ * Control:
  *****************************************************************************/
-static void __MP4End ( vlc_object_t * p_this )
+static int   Control  ( input_thread_t *p_input, int i_query, va_list args )
+{
+    demux_sys_t *p_sys = p_input->p_demux_data;
+
+    double   f, *pf;
+    int64_t i64, *pi64;
+
+    switch( i_query )
+    {
+        case DEMUX_GET_POSITION:
+            pf = (double*)va_arg( args, double * );
+            if( p_sys->i_duration > 0 )
+            {
+                *pf = (double)p_sys->i_time / (double)p_sys->i_duration;
+            }
+            else
+            {
+                *pf = 0.0;
+            }
+            return VLC_SUCCESS;
+
+        case DEMUX_SET_POSITION:
+            f = (double)va_arg( args, double );
+            i64 = (int64_t)( f *
+                             (double)1000000 *
+                             (double)p_sys->i_duration /
+                             (double)p_sys->i_timescale );
+            return Seek( p_input, i64 );
+
+        case DEMUX_GET_TIME:
+            pi64 = (int64_t*)va_arg( args, int64_t * );
+            *pi64 = (mtime_t)1000000 *
+                    (mtime_t)p_sys->i_time /
+                    (mtime_t)p_sys->i_timescale;
+            return VLC_SUCCESS;
+
+        case DEMUX_SET_TIME:
+            i64 = (int64_t)va_arg( args, int64_t );
+            return Seek( p_input, i64 );
+
+        case DEMUX_GET_LENGTH:
+            pi64 = (int64_t*)va_arg( args, int64_t * );
+            *pi64 = (mtime_t)1000000 *
+                    (mtime_t)p_sys->i_duration /
+                    (mtime_t)p_sys->i_timescale;
+            return VLC_SUCCESS;
+
+        default:
+            msg_Err( p_input, "control query unimplemented !!!" );
+            return demux_vaControlDefault( p_input, i_query, args );
+    }
+}
+
+/*****************************************************************************
+ * Close: frees unused data
+ *****************************************************************************/
+static void Close ( vlc_object_t * p_this )
 {
     unsigned int i_track;
     input_thread_t *  p_input = (input_thread_t *)p_this;
@@ -661,6 +668,7 @@ static void __MP4End ( vlc_object_t * p_this )
 }
 
 
+
 /****************************************************************************
  * Local functions, specific to vlc
  ****************************************************************************/
index 80c1991991d622a904b93ed953588ddff2f86cf6..b7dd1eecc1d6c8dd891f51a81bde1f779c1a9884 100644 (file)
@@ -2,7 +2,7 @@
  * mpeg_es.c : Elementary Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: es.c,v 1.3 2003/05/05 22:23:36 gbazin Exp $
+ * $Id: es.c,v 1.4 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -67,6 +67,7 @@ static int Activate( vlc_object_t * p_this )
 
     /* Set the demux function */
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
     /* Initialize access plug-in structures. */
     if( p_input->i_mtu == 0 )
index 007db52a240fd10a7800b90dd88ecc1c6d46b6e4..d52394ab19141e5f6d0a49c052c656075a006c0d 100644 (file)
@@ -2,7 +2,7 @@
  * m4v.c : MPEG-4 video Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: m4v.c,v 1.6 2003/08/01 00:05:07 gbazin Exp $
+ * $Id: m4v.c,v 1.7 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -71,6 +71,7 @@ static int Activate( vlc_object_t * p_this )
 
     /* Set the demux function */
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
     /* Initialize access plug-in structures. */
     if( p_input->i_mtu == 0 )
index a0f1577defcbb3641261cf70f9f40d710da4f74f..dc93627793d0e62abead52c16344ea5adb97587d 100644 (file)
@@ -2,7 +2,7 @@
  * mpga.c : MPEG-I/II Audio input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: mpga.c,v 1.2 2003/08/17 23:02:52 fenrir Exp $
+ * $Id: mpga.c,v 1.3 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -29,8 +29,6 @@
 #include <vlc/vlc.h>
 #include <vlc/input.h>
 
-#include <ninput.h>
-
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -237,6 +235,7 @@ static int Open( vlc_object_t * p_this )
     }
 
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
     p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
     p_sys->i_time = 0;
index dd5dd8c6582a0cce24a2ed80766a9b90a48c43b3..7510f8106569e2d6c4434f4b9a9486077203b61c 100644 (file)
@@ -2,7 +2,7 @@
  * ps.c : Program Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: ps.c,v 1.9 2003/03/09 23:39:05 jlj Exp $
+ * $Id: ps.c,v 1.10 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -74,6 +74,7 @@ static int Activate( vlc_object_t * p_this )
 
     /* Set the demux function */
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
     /* Initialize access plug-in structures. */
     if( p_input->i_mtu == 0 )
index 8bb5d27b82247def1e5e3ec45c80990164553c2b..a7052cb5d668ac86ffbe027bf8198a4a19d08e24 100644 (file)
@@ -2,7 +2,7 @@
  * mpeg_ts.c : Transport Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: ts.c,v 1.34 2003/08/14 23:32:51 fenrir Exp $
+ * $Id: ts.c,v 1.35 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Henri Fallon <henri@via.ecp.fr>
  *          Johan Bilien <jobi@via.ecp.fr>
@@ -136,6 +136,7 @@ static int Activate( vlc_object_t * p_this )
 
     /* Set the demux function */
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
 #if 0
     /* XXX Unused already done by src/input.c */
index 17aa3cbbe8e27273f31b01a86052d1316cebdfb0..fa6e612340bd1a532ed8f74022c386afd2d0cadc 100644 (file)
@@ -2,7 +2,7 @@
  * ogg.c : ogg stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: ogg.c,v 1.32 2003/09/02 20:19:26 gbazin Exp $
+ * $Id: ogg.c,v 1.33 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  * 
@@ -1092,6 +1092,7 @@ static int Activate( vlc_object_t * p_this )
 
     /* Set the demux function */
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
     /* Initialize access plug-in structures. */
     if( p_input->i_mtu == 0 )
index b4e122e9c8fbfffd7bbb1bb8a955272b802428f3..1386ddcb10f76a7551c6c2a53a3596e3b0786186 100644 (file)
@@ -2,7 +2,7 @@
  * rawdv.c : raw dv input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: rawdv.c,v 1.9 2003/08/17 23:02:52 fenrir Exp $
+ * $Id: rawdv.c,v 1.10 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -139,6 +139,7 @@ static int Activate( vlc_object_t * p_this )
     }
 
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
     /* Have a peep at the show. */
     if( input_Peek(p_input, &p_peek, DV_PAL_FRAME_SIZE) < DV_NTSC_FRAME_SIZE )
index da8f38039da84835f2e384df6687705460b7ab25..026c274203d40cc58a07cf5baebfd0d9cf230491 100644 (file)
@@ -2,7 +2,7 @@
  * wav.c : wav file input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: wav.c,v 1.5 2003/08/22 20:32:27 fenrir Exp $
+ * $Id: wav.c,v 1.6 2003/09/07 22:48:29 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -30,7 +30,6 @@
 #include <vlc/input.h>
 
 #include <codecs.h>
-#include <ninput.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -104,6 +103,7 @@ static int Open( vlc_object_t * p_this )
     }
 
     p_input->pf_demux     = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
     p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
     p_sys->p_wf           = NULL;
     p_sys->p_es           = NULL;