From 091aff73545a19bdb1c1706acecfc86e326e2734 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sun, 7 Sep 2003 22:48:29 +0000 Subject: [PATCH] * all : demuxers *have to* set pf_demux_control. (demux_vaControlDefault is a generic handler) * avi, mp4 : begin to implement a specific pf_demux_control. --- modules/demux/a52sys.c | 5 +- modules/demux/aac.c | 5 +- modules/demux/asf/asf.c | 6 +- modules/demux/asf/libasf.c | 3 +- modules/demux/au.c | 4 +- modules/demux/avi/avi.c | 102 ++++++++++++++-- modules/demux/avi/libavi.c | 3 +- modules/demux/demuxdump.c | 3 +- modules/demux/flac.c | 3 +- modules/demux/mkv.cpp | 4 +- modules/demux/mp4/libmp4.c | 119 +++++++++--------- modules/demux/mp4/mp4.c | 242 +++++++++++++++++++------------------ modules/demux/mpeg/es.c | 3 +- modules/demux/mpeg/m4v.c | 3 +- modules/demux/mpeg/mpga.c | 5 +- modules/demux/mpeg/ps.c | 3 +- modules/demux/mpeg/ts.c | 3 +- modules/demux/ogg.c | 3 +- modules/demux/rawdv.c | 3 +- modules/demux/wav.c | 4 +- 20 files changed, 312 insertions(+), 214 deletions(-) diff --git a/modules/demux/a52sys.c b/modules/demux/a52sys.c index 8b60ee59a3..7c848e6581 100644 --- a/modules/demux/a52sys.c +++ b/modules/demux/a52sys.c @@ -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 * @@ -29,8 +29,6 @@ #include #include -#include - /***************************************************************************** * 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; diff --git a/modules/demux/aac.c b/modules/demux/aac.c index add4547139..1b21f11ae1 100644 --- a/modules/demux/aac.c +++ b/modules/demux/aac.c @@ -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 * @@ -29,8 +29,6 @@ #include #include -#include - /***************************************************************************** * 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; diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c index 6118a23a97..a0ff6830a4 100644 --- a/modules/demux/asf/asf.c +++ b/modules/demux/asf/asf.c @@ -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 * @@ -28,7 +28,6 @@ #include #include -#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; diff --git a/modules/demux/asf/libasf.c b/modules/demux/asf/libasf.c index 41bbb4a4b3..f76781f589 100644 --- a/modules/demux/asf/libasf.c +++ b/modules/demux/asf/libasf.c @@ -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 * * This program is free software; you can redistribute it and/or modify @@ -24,7 +24,6 @@ #include #include -#include "ninput.h" #include "codecs.h" /* BITMAPINFOHEADER, WAVEFORMATEX */ #include "libasf.h" diff --git a/modules/demux/au.c b/modules/demux/au.c index 7b751214e6..e769ddfd3b 100644 --- a/modules/demux/au.c +++ b/modules/demux/au.c @@ -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 * @@ -30,7 +30,6 @@ #include #include -#include /***************************************************************************** * 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 */ diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c index e3608b5c0b..e61513f37e 100644 --- a/modules/demux/avi/avi.c +++ b/modules/demux/avi/avi.c @@ -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 * * This program is free software; you can redistribute it and/or modify @@ -27,7 +27,6 @@ #include #include -#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 diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c index 51c9c224c6..1590ecec2a 100644 --- a/modules/demux/avi/libavi.c +++ b/modules/demux/avi/libavi.c @@ -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 * * This program is free software; you can redistribute it and/or modify @@ -24,7 +24,6 @@ #include #include -#include "ninput.h" #include "codecs.h" /* BITMAPINFOHEADER */ #include "libavi.h" diff --git a/modules/demux/demuxdump.c b/modules/demux/demuxdump.c index e9ba85c2ca..c759a8698a 100644 --- a/modules/demux/demuxdump.c +++ b/modules/demux/demuxdump.c @@ -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 * @@ -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 ) diff --git a/modules/demux/flac.c b/modules/demux/flac.c index 4f61cae15e..2674122a76 100644 --- a/modules/demux/flac.c +++ b/modules/demux/flac.c @@ -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 * @@ -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. */ diff --git a/modules/demux/mkv.cpp b/modules/demux/mkv.cpp index ef82c491dd..18c686132a 100644 --- a/modules/demux/mkv.cpp +++ b/modules/demux/mkv.cpp @@ -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 * @@ -36,7 +36,6 @@ #include /* BITMAPINFOHEADER, WAVEFORMATEX */ #include "iso_lang.h" -#include "ninput.h" #include #include @@ -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 ) diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c index ef27fc289d..99167fb0d9 100644 --- a/modules/demux/mp4/libmp4.c +++ b/modules/demux/mp4/libmp4.c @@ -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 * * 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 ); diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c index bcf370368d..1d86bd37f0 100644 --- a/modules/demux/mp4/mp4.c +++ b/modules/demux/mp4/mp4.c @@ -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 * * This program is free software; you can redistribute it and/or modify @@ -24,9 +24,6 @@ * Preamble *****************************************************************************/ #include /* malloc(), free() */ -#include /* strdup() */ -#include -#include #include #include @@ -35,56 +32,45 @@ #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 ****************************************************************************/ diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c index 80c1991991..b7dd1eecc1 100644 --- a/modules/demux/mpeg/es.c +++ b/modules/demux/mpeg/es.c @@ -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 * @@ -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 ) diff --git a/modules/demux/mpeg/m4v.c b/modules/demux/mpeg/m4v.c index 007db52a24..d52394ab19 100644 --- a/modules/demux/mpeg/m4v.c +++ b/modules/demux/mpeg/m4v.c @@ -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 * @@ -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 ) diff --git a/modules/demux/mpeg/mpga.c b/modules/demux/mpeg/mpga.c index a0f1577def..dc93627793 100644 --- a/modules/demux/mpeg/mpga.c +++ b/modules/demux/mpeg/mpga.c @@ -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 * @@ -29,8 +29,6 @@ #include #include -#include - /***************************************************************************** * 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; diff --git a/modules/demux/mpeg/ps.c b/modules/demux/mpeg/ps.c index dd5dd8c658..7510f81065 100644 --- a/modules/demux/mpeg/ps.c +++ b/modules/demux/mpeg/ps.c @@ -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 * @@ -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 ) diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c index 8bb5d27b82..a7052cb5d6 100644 --- a/modules/demux/mpeg/ts.c +++ b/modules/demux/mpeg/ts.c @@ -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 * Johan Bilien @@ -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 */ diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c index 17aa3cbbe8..fa6e612340 100644 --- a/modules/demux/ogg.c +++ b/modules/demux/ogg.c @@ -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 * @@ -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 ) diff --git a/modules/demux/rawdv.c b/modules/demux/rawdv.c index b4e122e9c8..1386ddcb10 100644 --- a/modules/demux/rawdv.c +++ b/modules/demux/rawdv.c @@ -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 * @@ -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 ) diff --git a/modules/demux/wav.c b/modules/demux/wav.c index da8f38039d..026c274203 100644 --- a/modules/demux/wav.c +++ b/modules/demux/wav.c @@ -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 * @@ -30,7 +30,6 @@ #include #include -#include /***************************************************************************** * 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; -- 2.39.5