X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fmux%2Favi.c;h=b801b918ecf013e5ce008a15831c011af3c47667;hb=a7e2dcfe29e2767bfa13d4b3451d2543fe8ae2bd;hp=bdc33168ccb51e3f1cee6f4a8550562b7c2dcdda;hpb=085985d56d23695e137dbb04228fddde7a74c072;p=vlc diff --git a/modules/mux/avi.c b/modules/mux/avi.c index bdc33168cc..b801b918ec 100644 --- a/modules/mux/avi.c +++ b/modules/mux/avi.c @@ -1,7 +1,7 @@ /***************************************************************************** * avi.c ***************************************************************************** - * Copyright (C) 2001, 2002 VideoLAN + * Copyright (C) 2001, 2002 the VideoLAN team * $Id$ * * Authors: Laurent Aimar @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** @@ -26,13 +26,15 @@ *****************************************************************************/ /* TODO: add OpenDML write support */ -#include -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif -#include "codecs.h" +#include +#include +#include +#include /***************************************************************************** * Module descriptor @@ -42,6 +44,8 @@ static void Close ( vlc_object_t * ); vlc_module_begin(); set_description( _("AVI muxer") ); + set_category( CAT_SOUT ); + set_subcategory( SUBCAT_SOUT_MUX ); set_capability( "sout mux", 5 ); add_shortcut( "avi" ); set_callbacks( Open, Close ); @@ -51,10 +55,10 @@ vlc_module_end(); /***************************************************************************** * Local prototypes *****************************************************************************/ -static int Capability(sout_mux_t *, int , void *, void * ); -static int AddStream( sout_mux_t *, sout_input_t * ); -static int DelStream( sout_mux_t *, sout_input_t * ); -static int Mux ( sout_mux_t * ); +static int Control( sout_mux_t *, int, va_list ); +static int AddStream( sout_mux_t *, sout_input_t * ); +static int DelStream( sout_mux_t *, sout_input_t * ); +static int Mux ( sout_mux_t * ); typedef struct avi_stream_s { @@ -62,7 +66,7 @@ typedef struct avi_stream_s char fcc[4]; - mtime_t i_duration; // in µs + mtime_t i_duration; // in µs int i_frames; // total frame count int64_t i_totalsize; // total stream size @@ -149,7 +153,7 @@ static int Open( vlc_object_t *p_this ) p_sys->b_write_header = VLC_TRUE; - p_mux->pf_capacity = Capability; + p_mux->pf_control = Control; p_mux->pf_addstream = AddStream; p_mux->pf_delstream = DelStream; p_mux->pf_mux = Mux; @@ -212,16 +216,31 @@ static void Close( vlc_object_t * p_this ) sout_AccessOutWrite( p_mux->p_access, p_hdr ); } -static int Capability( sout_mux_t *p_mux, int i_query, - void *p_args, void *p_answer ) +static int Control( sout_mux_t *p_mux, int i_query, va_list args ) { + VLC_UNUSED(p_mux); + vlc_bool_t *pb_bool; + char **ppsz; + switch( i_query ) { - case SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME: - *(vlc_bool_t*)p_answer = VLC_FALSE; - return( SOUT_MUX_CAP_ERR_OK ); + case MUX_CAN_ADD_STREAM_WHILE_MUXING: + pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * ); + *pb_bool = VLC_FALSE; + return VLC_SUCCESS; + + case MUX_GET_ADD_STREAM_WAIT: + pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * ); + *pb_bool = VLC_TRUE; + return VLC_SUCCESS; + + case MUX_GET_MIME: + ppsz = (char**)va_arg( args, char ** ); + *ppsz = strdup( "video/avi" ); + return VLC_SUCCESS; + default: - return( SOUT_MUX_CAP_ERR_UNIMPLEMENTED ); + return VLC_EGENERIC; } } @@ -280,11 +299,15 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) case VLC_FOURCC( 'w', 'm', 'a', '1' ): p_wf->wFormatTag = WAVE_FORMAT_WMA1; break; + case VLC_FOURCC( 'w', 'm', 'a', ' ' ): case VLC_FOURCC( 'w', 'm', 'a', '2' ): p_wf->wFormatTag = WAVE_FORMAT_WMA2; break; - case VLC_FOURCC( 'w', 'm', 'a', '3' ): - p_wf->wFormatTag = WAVE_FORMAT_WMA3; + case VLC_FOURCC( 'w', 'm', 'a', 'p' ): + p_wf->wFormatTag = WAVE_FORMAT_WMAP; + break; + case VLC_FOURCC( 'w', 'm', 'a', 'l' ): + p_wf->wFormatTag = WAVE_FORMAT_WMAL; break; /* raw codec */ case VLC_FOURCC( 'u', '8', ' ', ' ' ): @@ -382,8 +405,7 @@ static int Mux ( sout_mux_t *p_mux ) { sout_mux_sys_t *p_sys = p_mux->p_sys; avi_stream_t *p_stream; - int i_stream; - int i; + int i_stream, i; if( p_sys->b_write_header ) { @@ -406,14 +428,14 @@ static int Mux ( sout_mux_t *p_mux ) p_stream = &p_sys->stream[i_stream]; p_fifo = p_mux->pp_inputs[i]->p_fifo; - i_count = p_fifo->i_depth; - while( i_count > 0 ) + i_count = block_FifoCount( p_fifo ); + while( i_count > 1 ) { avi_idx1_entry_t *p_idx; block_t *p_data; p_data = block_FifoGet( p_fifo ); - if( p_fifo->i_depth > 0 ) + if( block_FifoCount( p_fifo ) > 0 ) { block_t *p_next = block_FifoShow( p_fifo ); p_data->i_length = p_next->i_dts - p_data->i_dts; @@ -444,7 +466,7 @@ static int Mux ( sout_mux_t *p_mux ) p_sys->idx1.i_entry_max * sizeof( avi_idx1_entry_t ) ); } - p_data = block_Realloc( p_data, 8, 0 ); + p_data = block_Realloc( p_data, 8, p_data->i_buffer ); if( p_data ) { SetFCC( p_data->p_buffer, p_stream->fcc ); @@ -453,6 +475,7 @@ static int Mux ( sout_mux_t *p_mux ) if( p_data->i_buffer & 0x01 ) { p_data = block_Realloc( p_data, 0, p_data->i_buffer + 1 ); + p_data->p_buffer[ p_data->i_buffer - 1 ] = '\0'; } p_sys->i_movi_size += p_data->i_buffer; @@ -526,7 +549,7 @@ static void bo_AddLWordBE( buffer_out_t *p_bo, uint64_t i ) } #endif -static void bo_AddFCC( buffer_out_t *p_bo, char *fcc ) +static void bo_AddFCC( buffer_out_t *p_bo, const char *fcc ) { bo_AddByte( p_bo, fcc[0] ); bo_AddByte( p_bo, fcc[1] ); @@ -605,8 +628,8 @@ static int avi_HeaderAdd_avih( sout_mux_t *p_mux, if( p_sys->stream[i_stream].i_duration > 0 ) { i_maxbytespersec += - p_sys->stream[p_sys->i_stream_video].i_totalsize / - p_sys->stream[p_sys->i_stream_video].i_duration; + p_sys->stream[i_stream].i_totalsize / + p_sys->stream[i_stream].i_duration; } } @@ -637,9 +660,7 @@ static int avi_HeaderAdd_avih( sout_mux_t *p_mux, AVI_BOX_EXIT( 0 ); } -static int avi_HeaderAdd_strh( sout_mux_t *p_mux, - buffer_out_t *p_bo, - avi_stream_t *p_stream ) +static int avi_HeaderAdd_strh( buffer_out_t *p_bo, avi_stream_t *p_stream ) { AVI_BOX_ENTER( "strh" ); @@ -706,9 +727,7 @@ static int avi_HeaderAdd_strh( sout_mux_t *p_mux, AVI_BOX_EXIT( 0 ); } -static int avi_HeaderAdd_strf( sout_mux_t *p_mux, - buffer_out_t *p_bo, - avi_stream_t *p_stream ) +static int avi_HeaderAdd_strf( buffer_out_t *p_bo, avi_stream_t *p_stream ) { AVI_BOX_ENTER( "strf" ); @@ -752,14 +771,12 @@ static int avi_HeaderAdd_strf( sout_mux_t *p_mux, AVI_BOX_EXIT( 0 ); } -static int avi_HeaderAdd_strl( sout_mux_t *p_mux, - buffer_out_t *p_bo, - avi_stream_t *p_stream ) +static int avi_HeaderAdd_strl( buffer_out_t *p_bo, avi_stream_t *p_stream ) { AVI_BOX_ENTER_LIST( "strl" ); - avi_HeaderAdd_strh( p_mux, p_bo, p_stream ); - avi_HeaderAdd_strf( p_mux, p_bo, p_stream ); + avi_HeaderAdd_strh( p_bo, p_stream ); + avi_HeaderAdd_strf( p_bo, p_stream ); AVI_BOX_EXIT( 0 ); } @@ -789,7 +806,7 @@ static block_t *avi_HeaderCreateRIFF( sout_mux_t *p_mux ) avi_HeaderAdd_avih( p_mux, &bo ); for( i_stream = 0,i_maxbytespersec = 0; i_stream < p_sys->i_streams; i_stream++ ) { - avi_HeaderAdd_strl( p_mux, &bo, &p_sys->stream[i_stream] ); + avi_HeaderAdd_strl( &bo, &p_sys->stream[i_stream] ); } i_junk = HDR_SIZE - bo.i_buffer - 8 - 12;