From 05ca109431cf7084040b099a4132b6012f706091 Mon Sep 17 00:00:00 2001 From: Laurent Aimar <fenrir@videolan.org> Date: Fri, 12 Sep 2003 16:26:40 +0000 Subject: [PATCH] * include/input_ext-intf.h : added stream_t member to input_thread_t. * modules/demux/* : use the stream_t from input_thread_t. * include/ninput.h : begin to add new way to register es. (unused for now). (in the long term I want to split input_thread_t and intoduce demux_t and access_t and perhaps something like access_demux_t) --- include/input_ext-intf.h | 5 +- include/ninput.h | 129 +++++++++++++++++++++++++++++++++++++- modules/demux/a52sys.c | 27 ++------ modules/demux/aac.c | 27 ++------ modules/demux/asf/asf.c | 43 +++++-------- modules/demux/au.c | 29 +++------ modules/demux/avi/avi.c | 95 +++++++++------------------- modules/demux/avi/avi.h | 4 +- modules/demux/mkv.cpp | 34 ++++------ modules/demux/mp4/mp4.c | 15 +---- modules/demux/mp4/mp4.h | 4 +- modules/demux/mpeg/mpga.c | 28 +++------ modules/demux/sdp.c | 17 +---- modules/demux/wav.c | 39 ++++-------- src/input/input.c | 24 ++++++- 15 files changed, 259 insertions(+), 261 deletions(-) diff --git a/include/input_ext-intf.h b/include/input_ext-intf.h index 578dc300be74..dc38611cb1dc 100644 --- a/include/input_ext-intf.h +++ b/include/input_ext-intf.h @@ -4,7 +4,7 @@ * control the pace of reading. ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: input_ext-intf.h,v 1.93 2003/08/02 15:22:07 fenrir Exp $ + * $Id: input_ext-intf.h,v 1.94 2003/09/12 16:26:40 fenrir Exp $ * * Authors: Christophe Massiot <massiot@via.ecp.fr> * @@ -313,6 +313,9 @@ struct input_thread_t size_t i_mtu; int i_pts_delay; /* internal caching */ + /* Stream */ + stream_t *s; + /* Demux module */ module_t * p_demux; int (* pf_demux ) ( input_thread_t * ); diff --git a/include/ninput.h b/include/ninput.h index b19d9e05170f..4876a72f006c 100644 --- a/include/ninput.h +++ b/include/ninput.h @@ -2,7 +2,7 @@ * ninput.h ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: ninput.h,v 1.8 2003/09/07 22:45:16 fenrir Exp $ + * $Id: ninput.h,v 1.9 2003/09/12 16:26:40 fenrir Exp $ * * Authors: Laurent Aimar <fenrir@via.ecp.fr> * @@ -24,6 +24,132 @@ #ifndef _NINPUT_H #define _NINPUT_H 1 +#if 0 +enum es_extra_type_e +{ + ES_EXTRA_TYPE_UNKNOWN, + ES_EXTRA_TYPE_WAVEFORMATEX, + ES_EXTRA_TYPE_BITMAPINFOHEADER +}; + +typedef struct +{ + int i_cat; + vlc_fourcc_t i_codec; + + int i_group; /* eg -1. if >= 0 then a "group" (program) is + created for each value */ + + int i_priority; /* -2 : mean not selectable by the users + -1 : mean not selected by default even + when no other stream + >=0: priority */ + char *psz_language; + char *psz_description; + + struct + { + int i_samplerate; + int i_channels; + int i_bitrate; + int i_blockalign; + int i_bitspersample; + } audio; + + struct + { + int i_width; + int i_height; + int i_display_width; + int i_display_height; + } video; + + struct + { + char *psz_encoding; + } subs; + + int i_extra_type; + int i_extra; + void *p_extra; +} es_format_t; + +static inline void es_format_Init( es_format_t *fmt, + int i_cat, vlc_fourcc_t i_codec ) +{ + fmt->i_cat = i_cat; + fmt->i_codec = i_codec; + fmt->i_group = -1; + fmt->i_priority = 0; + fmt->psz_language = NULL; + fmt->psz_description = NULL; + + fmt->audio.i_samplerate = 0; + fmt->audio.i_channels = 0; + fmt->audio.i_bitrate = 0; + fmt->audio.i_blockalign = 0; + fmt->audio.i_bitspersample = 0; + + fmt->video.i_width = 0; + fmt->video.i_height = 0; + fmt->video.i_display_width = 0; + fmt->video.i_display_height = 0; + + fmt->subs.psz_encoding = NULL; + + fmt->i_extra_type = ES_EXTRA_TYPE_UNKNOWN; + fmt->i_extra = 0; + fmt->p_extra = NULL; +} + +enum es_out_query_e +{ + ES_OUT_SET_SELECT, /* arg1= es_out_id_t* arg2=vlc_bool_t */ + ES_OUT_GET_SELECT /* arg1= es_out_id_t* arg2=vlc_bool_t* */ +}; + +typedef struct es_out_t es_out_t; +typedef struct es_out_id_t es_out_id_t; +typedef struct es_out_sys_t es_out_sys_t; + +struct es_out_t +{ + es_out_id_t (*pf_add) ( es_out_t *, es_format_t * ); + int (*pf_send) ( es_out_t *, es_out_id_t *, pes_packet_t * ); + void (*pf_del) ( es_out_t *, es_out_id_t * ); + int (*pf_control)( es_out_t *, int i_query, va_list ); + + es_out_sys_t *p_sys; +}; + +static inline es_out_id_t * es_out_Add( es_out_t *out, es_format_t *fmt ) +{ + return out->pf_add( out, fmt ); +} +static inline void es_out_Del( es_out_t *out, es_out_id_t *id ) +{ + out->pf_del( out, id ); +} +static inline int es_out_Send( es_out_t *out, es_out_id_t *id, pes_packet_t *p_pes ) +{ + return out->pf_send( out, id, p_pes ); +} +static inline int es_out_vaControl( es_out_t *out, int i_query, va_list args ) +{ + return out->pf_control( out, i_query, args ); +} +static inline int es_out_Control( es_out_t *out, int i_query, ... ) +{ + va_list args; + int i_result; + + va_start( args, i_query ); + i_result = es_out_vaControl( out, i_query, args ); + va_end( args ); + return i_result; +} +#endif + /** * \defgroup stream Stream * @@ -83,7 +209,6 @@ static int inline stream_Seek( stream_t *s, int64_t i_pos ) /** * \defgroup demux Demux - * XXX: don't look at it yet. * @{ */ enum demux_query_e diff --git a/modules/demux/a52sys.c b/modules/demux/a52sys.c index 7c848e6581b4..7afced905421 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.5 2003/09/07 22:48:29 fenrir Exp $ + * $Id: a52sys.c,v 1.6 2003/09/12 16:26:40 fenrir Exp $ * * Authors: Laurent Aimar <fenrir@via.ecp.fr> * @@ -53,7 +53,6 @@ static int Demux ( input_thread_t * ); struct demux_sys_t { - stream_t *s; mtime_t i_time; es_descriptor_t *p_es; @@ -132,13 +131,7 @@ static int Open( vlc_object_t * p_this ) p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) ); p_sys->i_time = 0; - if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL ) - { - msg_Err( p_input, "cannot create stream" ); - goto error; - } - - if( stream_Peek( p_sys->s, &p_peek, 6 ) < 6 ) + if( stream_Peek( p_input->s, &p_peek, 6 ) < 6 ) { msg_Err( p_input, "cannot peek" ); goto error; @@ -198,10 +191,6 @@ static int Open( vlc_object_t * p_this ) return VLC_SUCCESS; error: - if( p_sys->s ) - { - stream_Release( p_sys->s ); - } free( p_sys ); return VLC_EGENERIC; } @@ -221,7 +210,7 @@ static int Demux( input_thread_t * p_input ) uint8_t *p_peek; - if( stream_Peek( p_sys->s, &p_peek, 6 ) < 6 ) + if( stream_Peek( p_input->s, &p_peek, 6 ) < 6 ) { msg_Warn( p_input, "cannot peek" ); return 0; @@ -234,7 +223,7 @@ static int Demux( input_thread_t * p_input ) int i_skip = 0; int i_peek; - i_peek = stream_Peek( p_sys->s, &p_peek, 8096 ); + i_peek = stream_Peek( p_input->s, &p_peek, 8096 ); if( i_peek < 8 ) { msg_Warn( p_input, "cannot peek" ); @@ -255,7 +244,7 @@ static int Demux( input_thread_t * p_input ) } msg_Warn( p_input, "garbage=%d bytes", i_skip ); - stream_Read( p_sys->s, NULL, i_skip ); + stream_Read( p_input->s, NULL, i_skip ); return 1; } @@ -265,7 +254,7 @@ static int Demux( input_thread_t * p_input ) p_input->stream.p_selected_program, p_sys->i_time * 9 / 100 ); - if( ( p_pes = stream_PesPacket( p_sys->s, i_frame_size ) ) == NULL ) + if( ( p_pes = stream_PesPacket( p_input->s, i_frame_size ) ) == NULL ) { msg_Warn( p_input, "cannot read data" ); return 0; @@ -298,10 +287,6 @@ static void Close( vlc_object_t * p_this ) input_thread_t *p_input = (input_thread_t*)p_this; demux_sys_t *p_sys = p_input->p_demux_data; - if( p_sys->s ) - { - stream_Release( p_sys->s ); - } free( p_sys ); } diff --git a/modules/demux/aac.c b/modules/demux/aac.c index 1b21f11ae1cc..10001af0a64b 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.3 2003/09/07 22:48:29 fenrir Exp $ + * $Id: aac.c,v 1.4 2003/09/12 16:26:40 fenrir Exp $ * * Authors: Laurent Aimar <fenrir@via.ecp.fr> * @@ -54,7 +54,6 @@ static int Demux ( input_thread_t * ); struct demux_sys_t { - stream_t *s; mtime_t i_time; es_descriptor_t *p_es; @@ -139,14 +138,8 @@ static int Open( vlc_object_t * p_this ) p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) ); p_sys->i_time = 0; - if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL ) - { - msg_Err( p_input, "cannot create stream" ); - goto error; - } - /* peek the begining (10 is for adts header) */ - if( stream_Peek( p_sys->s, &p_peek, 10 ) < 10 ) + if( stream_Peek( p_input->s, &p_peek, 10 ) < 10 ) { msg_Err( p_input, "cannot peek" ); goto error; @@ -213,10 +206,6 @@ static int Open( vlc_object_t * p_this ) return VLC_SUCCESS; error: - if( p_sys->s ) - { - stream_Release( p_sys->s ); - } free( p_sys ); return VLC_EGENERIC; } @@ -235,7 +224,7 @@ static int Demux( input_thread_t * p_input ) uint8_t h[8]; uint8_t *p_peek; - if( stream_Peek( p_sys->s, &p_peek, 8 ) < 8 ) + if( stream_Peek( p_input->s, &p_peek, 8 ) < 8 ) { msg_Warn( p_input, "cannot peek" ); return 0; @@ -248,7 +237,7 @@ static int Demux( input_thread_t * p_input ) int i_skip = 0; int i_peek; - i_peek = stream_Peek( p_sys->s, &p_peek, 8096 ); + i_peek = stream_Peek( p_input->s, &p_peek, 8096 ); if( i_peek < 8 ) { msg_Warn( p_input, "cannot peek" ); @@ -269,7 +258,7 @@ static int Demux( input_thread_t * p_input ) } msg_Warn( p_input, "garbage=%d bytes", i_skip ); - stream_Read( p_sys->s, NULL, i_skip ); + stream_Read( p_input->s, NULL, i_skip ); return 1; } @@ -279,7 +268,7 @@ static int Demux( input_thread_t * p_input ) p_input->stream.p_selected_program, p_sys->i_time * 9 / 100 ); - if( ( p_pes = stream_PesPacket( p_sys->s, AAC_FRAME_SIZE( h ) ) ) == NULL ) + if( ( p_pes = stream_PesPacket( p_input->s, AAC_FRAME_SIZE( h ) ) )==NULL ) { msg_Warn( p_input, "cannot read data" ); return 0; @@ -312,10 +301,6 @@ static void Close( vlc_object_t * p_this ) input_thread_t *p_input = (input_thread_t*)p_this; demux_sys_t *p_sys = p_input->p_demux_data; - if( p_sys->s ) - { - stream_Release( p_sys->s ); - } free( p_sys ); } diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c index a0ff6830a40e..61780d321782 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.37 2003/09/07 22:48:29 fenrir Exp $ + * $Id: asf.c,v 1.38 2003/09/12 16:26:40 fenrir Exp $ * * Authors: Laurent Aimar <fenrir@via.ecp.fr> * @@ -76,8 +76,6 @@ struct demux_sys_t int64_t i_data_begin; int64_t i_data_end; - - stream_t *s; }; static mtime_t GetMoviePTS( demux_sys_t * ); @@ -123,20 +121,11 @@ static int Open( vlc_object_t * p_this ) p_sys->i_time = -1; p_sys->i_length = 0; - /* Create stream facilities */ - if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL ) - { - msg_Err( p_input, "cannot create stream" ); - free( p_sys ); - return VLC_EGENERIC; - } - /* Now load all object ( except raw data ) */ - stream_Control( p_sys->s, STREAM_CAN_FASTSEEK, &b_seekable ); - if( (p_sys->p_root = ASF_ReadObjectRoot( p_sys->s, b_seekable )) == NULL ) + stream_Control( p_input->s, STREAM_CAN_FASTSEEK, &b_seekable ); + if( (p_sys->p_root = ASF_ReadObjectRoot( p_input->s, b_seekable )) == NULL ) { msg_Warn( p_input, "ASF plugin discarded (not a valid file)" ); - stream_Release( p_sys->s ); free( p_sys ); return VLC_EGENERIC; } @@ -328,13 +317,13 @@ static int Open( vlc_object_t * p_this ) /* go to first packet */ - stream_Seek( p_sys->s, p_sys->i_data_begin ); + stream_Seek( p_input->s, p_sys->i_data_begin ); /* try to calculate movie time */ if( p_sys->p_fp->i_data_packets_count > 0 ) { int64_t i_count; - int64_t i_size = stream_Size( p_sys->s ); + int64_t i_size = stream_Size( p_input->s ); if( p_sys->i_data_end > 0 && i_size > p_sys->i_data_end ) { @@ -446,8 +435,7 @@ static int Open( vlc_object_t * p_this ) return VLC_SUCCESS; error: - ASF_FreeObjectRoot( p_sys->s, p_sys->p_root ); - stream_Release( p_sys->s ); + ASF_FreeObjectRoot( p_input->s, p_sys->p_root ); free( p_sys ); return VLC_EGENERIC; } @@ -486,7 +474,7 @@ static int Demux( input_thread_t *p_input ) msleep( p_input->i_pts_delay ); - i_offset = stream_Tell( p_sys->s ) - p_sys->i_data_begin; + i_offset = stream_Tell( p_input->s ) - p_sys->i_data_begin; if( i_offset < 0 ) { i_offset = 0; @@ -496,7 +484,7 @@ static int Demux( input_thread_t *p_input ) i_offset -= i_offset % p_sys->p_fp->i_min_data_packet_size; } - if( stream_Seek( p_sys->s, i_offset + p_sys->i_data_begin ) ) + if( stream_Seek( p_input->s, i_offset + p_sys->i_data_begin ) ) { msg_Warn( p_input, "cannot resynch after seek (EOF?)" ); return -1; @@ -568,7 +556,7 @@ static void Close( vlc_object_t * p_this ) msg_Dbg( p_input, "Freeing all memory" ); - ASF_FreeObjectRoot( p_sys->s, p_sys->p_root ); + ASF_FreeObjectRoot( p_input->s, p_sys->p_root ); for( i_stream = 0; i_stream < 128; i_stream++ ) { #define p_stream p_sys->stream[i_stream] @@ -582,7 +570,6 @@ static void Close( vlc_object_t * p_this ) } #undef p_stream } - stream_Release( p_sys->s ); free( p_sys ); } @@ -649,7 +636,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio ) int i_payload_length_type; - if( stream_Peek( p_sys->s, &p_peek, i_data_packet_min ) < i_data_packet_min ) + if( stream_Peek( p_input->s, &p_peek,i_data_packet_min)<i_data_packet_min ) { // EOF ? msg_Warn( p_input, "cannot peek while getting new packet, EOF ?" ); @@ -881,7 +868,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio ) } i_read = i_sub_payload_data_length + i_skip; - if((p_data = stream_DataPacket( p_sys->s,i_read,VLC_TRUE)) == NULL) + if((p_data = stream_DataPacket( p_input->s,i_read,VLC_TRUE))==NULL) { msg_Warn( p_input, "cannot read data" ); return( 0 ); @@ -905,7 +892,8 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio ) i_skip = 0; if( i_packet_size_left > 0 ) { - if( stream_Peek( p_sys->s, &p_peek, i_packet_size_left ) < i_packet_size_left ) + if( stream_Peek( p_input->s, &p_peek, i_packet_size_left ) + < i_packet_size_left ) { // EOF ? msg_Warn( p_input, "cannot peek, EOF ?" ); @@ -917,7 +905,8 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio ) if( i_packet_size_left > 0 ) { - if( stream_Read( p_sys->s, NULL, i_packet_size_left ) < i_packet_size_left ) + if( stream_Read( p_input->s, NULL, i_packet_size_left ) + < i_packet_size_left ) { msg_Warn( p_input, "cannot skip data, EOF ?" ); return( 0 ); @@ -933,7 +922,7 @@ loop_error_recovery: msg_Err( p_input, "unsupported packet header, fatal error" ); return( -1 ); } - stream_Read( p_sys->s, NULL, i_data_packet_min ); + stream_Read( p_input->s, NULL, i_data_packet_min ); return( 1 ); } diff --git a/modules/demux/au.c b/modules/demux/au.c index e769ddfd3b0b..e1e4a226fb72 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.6 2003/09/07 22:48:29 fenrir Exp $ + * $Id: au.c,v 1.7 2003/09/12 16:26:40 fenrir Exp $ * * Authors: Laurent Aimar <fenrir@via.ecp.fr> * @@ -92,8 +92,6 @@ typedef struct struct demux_sys_t { - stream_t *s; - au_t au; WAVEFORMATEX wf; @@ -135,18 +133,11 @@ static int Open( vlc_object_t * p_this ) p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) ); p_sys->i_time = 0; - - if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL ) - { - msg_Err( p_input, "cannot create stream" ); - goto error; - } - /* skip signature */ - stream_Read( p_sys->s, NULL, 4 ); /* cannot fail */ + stream_Read( p_input->s, NULL, 4 ); /* cannot fail */ /* read header */ - if( stream_Read( p_sys->s, &p_sys->au, sizeof( au_t ) ) < (int)sizeof( au_t ) ) + if( stream_Read( p_input->s, &p_sys->au, sizeof(au_t) )<(int)sizeof(au_t) ) { msg_Err( p_input, "cannot load header" ); goto error; @@ -174,7 +165,8 @@ static int Open( vlc_object_t * p_this ) /* skip extra header data */ if( p_sys->au.i_header_size > 4 + sizeof( au_t ) ) { - stream_Read( p_sys->s, NULL, p_sys->au.i_header_size - 4 - sizeof( au_t ) ); + stream_Read( p_input->s, + NULL, p_sys->au.i_header_size - 4 - sizeof( au_t ) ); } /* Create WAVEFORMATEX structure */ @@ -356,10 +348,6 @@ static int Open( vlc_object_t * p_this ) return VLC_SUCCESS; error: - if( p_sys->s ) - { - stream_Release( p_sys->s ); - } free( p_sys ); return VLC_EGENERIC; } @@ -376,12 +364,12 @@ static int DemuxPCM( input_thread_t *p_input ) if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT ) { - int64_t i_pos = stream_Tell( p_sys->s ); + int64_t i_pos = stream_Tell( p_input->s ); if( p_sys->wf.nBlockAlign != 0 ) { i_pos += p_sys->wf.nBlockAlign - i_pos % p_sys->wf.nBlockAlign; - if( stream_Seek( p_sys->s, i_pos ) ) + if( stream_Seek( p_input->s, i_pos ) ) { msg_Err( p_input, "Seek failed(cannot resync)" ); } @@ -392,7 +380,7 @@ static int DemuxPCM( input_thread_t *p_input ) p_input->stream.p_selected_program, p_sys->i_time * 9 / 100 ); - if( ( p_pes = stream_PesPacket( p_sys->s, p_sys->i_frame_size ) ) == NULL ) + if( ( p_pes = stream_PesPacket( p_input->s, p_sys->i_frame_size ) )==NULL ) { msg_Warn( p_input, "cannot read data" ); return 0; @@ -422,7 +410,6 @@ static void Close( vlc_object_t * p_this ) input_thread_t *p_input = (input_thread_t *)p_this; demux_sys_t *p_sys = p_input->p_demux_data; - stream_Release( p_sys->s ); free( p_sys ); } diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c index e61513f37e98..9070a157ee02 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.60 2003/09/07 22:48:29 fenrir Exp $ + * $Id: avi.c,v 1.61 2003/09/12 16:26:40 fenrir Exp $ * Authors: Laurent Aimar <fenrir@via.ecp.fr> * * This program is free software; you can redistribute it and/or modify @@ -150,14 +150,7 @@ static int Open( vlc_object_t * p_this ) p_avi->b_odml = VLC_FALSE; p_avi->b_interleaved = VLC_FALSE; - /* Create stream facilities */ - if( ( p_avi->s = stream_OpenInput( p_input ) ) == NULL ) - { - msg_Err( p_input, "cannot create stream_t" ); - free( p_avi ); - return VLC_EGENERIC; - } - stream_Control( p_avi->s, STREAM_CAN_FASTSEEK, &p_avi->b_seekable ); + stream_Control( p_input->s, STREAM_CAN_FASTSEEK, &p_avi->b_seekable ); p_input->pf_demux_control = Control; p_input->pf_demux = Demux_Seekable; @@ -167,7 +160,7 @@ static int Open( vlc_object_t * p_this ) p_input->pf_demux = Demux_UnSeekable; } - if( AVI_ChunkReadRoot( p_avi->s, &p_avi->ck_root ) ) + if( AVI_ChunkReadRoot( p_input->s, &p_avi->ck_root ) ) { msg_Err( p_input, "avi module discarded (invalid file)" ); return VLC_EGENERIC; @@ -507,7 +500,7 @@ static int Open( vlc_object_t * p_this ) if( p_avi->i_length ) { p_input->stream.i_mux_rate = - stream_Size( p_avi->s ) / 50 / p_avi->i_length; + stream_Size( p_input->s ) / 50 / p_avi->i_length; p_avi->b_interleaved = AVI_Interleaved( p_input ); msg_Dbg( p_input, "interleaved=%s", @@ -547,17 +540,16 @@ static int Open( vlc_object_t * p_this ) if( p_avi->b_seekable ) { /* we have read all chunk so go back to movi */ - stream_Seek( p_avi->s, p_movi->i_chunk_pos ); + stream_Seek( p_input->s, p_movi->i_chunk_pos ); } /* Skip movi header */ - stream_Read( p_avi->s, NULL, 12 ); + stream_Read( p_input->s, NULL, 12 ); p_avi->i_movi_begin = p_movi->i_chunk_pos; return VLC_SUCCESS; error: - AVI_ChunkFreeRoot( p_avi->s, &p_avi->ck_root ); - stream_Release( p_avi->s ); + AVI_ChunkFreeRoot( p_input->s, &p_avi->ck_root ); free( p_avi ); return VLC_EGENERIC; } @@ -584,9 +576,8 @@ static void Close ( vlc_object_t * p_this ) { subtitle_Close( p_avi->p_sub ); } - AVI_ChunkFreeRoot( p_avi->s, &p_avi->ck_root ); + AVI_ChunkFreeRoot( p_input->s, &p_avi->ck_root ); - stream_Release( p_avi->s ); free( p_avi ); } @@ -656,32 +647,8 @@ 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; - int i_percent; - /* first wait for empty buffer, arbitrary time FIXME */ - //msleep( DEFAULT_PTS_DELAY ); - - i_date = (mtime_t)1000000 * - (mtime_t)p_avi->i_length * - (mtime_t)stream_Tell( p_avi->s ) / - (mtime_t)stream_Size( p_avi->s ); - i_percent = 100 * stream_Tell( p_avi->s ) / - stream_Size( p_avi->s ); - - Seek( p_input, i_date, i_percent); - - if( p_avi->p_sub ) - { - subtitle_Seek( p_avi->p_sub, p_avi->i_time ); - } - } -#endif /* wait for the good time */ - p_avi->i_pcr = p_avi->i_time * 9 / 100; input_ClockManageRef( p_input, @@ -788,7 +755,7 @@ static int Demux_Seekable( input_thread_t *p_input ) * in case we fail we will disable all finished stream */ if( p_avi->i_movi_lastchunk_pos >= p_avi->i_movi_begin + 12 ) { - stream_Seek( p_avi->s, p_avi->i_movi_lastchunk_pos ); + stream_Seek( p_input->s, p_avi->i_movi_lastchunk_pos ); if( AVI_PacketNext( p_input ) ) { return( AVI_StreamStopFinishedStreams( p_input ) ? 0 : 1 ); @@ -796,7 +763,7 @@ static int Demux_Seekable( input_thread_t *p_input ) } else { - stream_Seek( p_avi->s, p_avi->i_movi_begin + 12 ); + stream_Seek( p_input->s, p_avi->i_movi_begin + 12 ); } for( ;; ) @@ -855,7 +822,7 @@ static int Demux_Seekable( input_thread_t *p_input ) } else { - stream_Seek( p_avi->s, i_pos ); + stream_Seek( p_input->s, i_pos ); } /* read thoses data */ @@ -888,7 +855,7 @@ static int Demux_Seekable( input_thread_t *p_input ) i_size += 8; // need to read and skip header } - if( ( p_pes = stream_PesPacket( p_avi->s, __EVEN( i_size ) ) ) == NULL ) + if( ( p_pes = stream_PesPacket( p_input->s, __EVEN( i_size ) ) )==NULL ) { msg_Warn( p_input, "failled reading data" ); AVI_StreamStop( p_input, i_stream ); @@ -1165,7 +1132,7 @@ static int Seek( input_thread_t *p_input, mtime_t i_date, int i_percent ) /* try to find chunk that is at i_percent or the file */ i_pos = __MAX( i_percent * - stream_Size( p_avi->s ) / 100, + stream_Size( p_input->s ) / 100, p_avi->i_movi_begin ); /* search first selected stream */ for( i_stream = 0, p_stream = NULL; @@ -1272,7 +1239,7 @@ static int Control( input_thread_t *p_input, int i_query, va_list args ) *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 ) + else if( stream_Size( p_input->s ) > 0 ) { unsigned int i; int64_t i_tmp; @@ -1293,7 +1260,7 @@ static int Control( input_thread_t *p_input, int i_query, va_list args ) } #undef tk } - *pf = (double)i64 / (double)stream_Size( p_sys->s ); + *pf = (double)i64 / (double)stream_Size( p_input->s ); return VLC_SUCCESS; } else @@ -1467,7 +1434,7 @@ static int AVI_StreamChunkFind( input_thread_t *p_input, if( p_avi->i_movi_lastchunk_pos >= p_avi->i_movi_begin + 12 ) { - stream_Seek( p_avi->s, p_avi->i_movi_lastchunk_pos ); + stream_Seek( p_input->s, p_avi->i_movi_lastchunk_pos ); if( AVI_PacketNext( p_input ) ) { return VLC_EGENERIC; @@ -1475,7 +1442,7 @@ static int AVI_StreamChunkFind( input_thread_t *p_input, } else { - stream_Seek( p_avi->s, p_avi->i_movi_begin + 12 ); + stream_Seek( p_input->s, p_avi->i_movi_begin + 12 ); } for( ;; ) @@ -1697,12 +1664,12 @@ static vlc_bool_t AVI_Interleaved( input_thread_t *p_input ) int64_t i_max; - if( stream_Size( p_sys->s ) <= 100 ) + if( stream_Size( p_input->s ) <= 100 ) { return VLC_FALSE; } - i_max = __MIN( 2000000, stream_Size( p_sys->s ) / 100 ); + i_max = __MIN( 2000000, stream_Size( p_input->s ) / 100 ); #define tk p_sys->pp_info[i] while( i_time < p_sys->i_length * (mtime_t)1000000) @@ -1896,16 +1863,15 @@ static void AVI_ParseStreamHeader( vlc_fourcc_t i_id, ****************************************************************************/ static int AVI_PacketGetHeader( input_thread_t *p_input, avi_packet_t *p_pk ) { - demux_sys_t *p_sys = p_input->p_demux_data; uint8_t *p_peek; - if( stream_Peek( p_sys->s, &p_peek, 16 ) < 16 ) + if( stream_Peek( p_input->s, &p_peek, 16 ) < 16 ) { return VLC_EGENERIC; } p_pk->i_fourcc = VLC_FOURCC( p_peek[0], p_peek[1], p_peek[2], p_peek[3] ); p_pk->i_size = GetDWLE( p_peek + 4 ); - p_pk->i_pos = stream_Tell( p_sys->s ); + p_pk->i_pos = stream_Tell( p_input->s ); if( p_pk->i_fourcc == AVIFOURCC_LIST || p_pk->i_fourcc == AVIFOURCC_RIFF ) { p_pk->i_type = VLC_FOURCC( p_peek[8], p_peek[9], @@ -1924,7 +1890,6 @@ static int AVI_PacketGetHeader( input_thread_t *p_input, avi_packet_t *p_pk ) static int AVI_PacketNext( input_thread_t *p_input ) { - demux_sys_t *p_sys = p_input->p_demux_data; avi_packet_t avi_ck; int i_skip = 0; @@ -1948,7 +1913,7 @@ static int AVI_PacketNext( input_thread_t *p_input ) i_skip = __EVEN( avi_ck.i_size ) + 8; } - if( stream_Read( p_sys->s, NULL, i_skip ) != i_skip ) + if( stream_Read( p_input->s, NULL, i_skip ) != i_skip ) { return VLC_EGENERIC; } @@ -1958,13 +1923,11 @@ static int AVI_PacketRead( input_thread_t *p_input, avi_packet_t *p_pk, pes_packet_t **pp_pes ) { - demux_sys_t *p_sys = p_input->p_demux_data; - size_t i_size; i_size = __EVEN( p_pk->i_size + 8 ); - if( ( *pp_pes = stream_PesPacket( p_sys->s, i_size ) ) == NULL ) + if( ( *pp_pes = stream_PesPacket( p_input->s, i_size ) ) == NULL ) { return VLC_EGENERIC; } @@ -1987,7 +1950,7 @@ static int AVI_PacketSearch( input_thread_t *p_input ) avi_packet_t avi_pk; for( ;; ) { - if( stream_Read( p_avi->s, NULL, 1 ) != 1 ) + if( stream_Read( p_input->s, NULL, 1 ) != 1 ) { return VLC_EGENERIC; } @@ -2182,8 +2145,8 @@ static void AVI_IndexLoad_indx( input_thread_t *p_input ) avi_chunk_indx_t ck_sub; for( i = 0; i < p_indx->i_entriesinuse; i++ ) { - if( stream_Seek( p_avi->s, p_indx->idx.super[i].i_offset )|| - AVI_ChunkRead( p_avi->s, &ck_sub, NULL ) ) + if( stream_Seek( p_input->s, p_indx->idx.super[i].i_offset )|| + AVI_ChunkRead( p_input->s, &ck_sub, NULL ) ) { break; } @@ -2253,9 +2216,9 @@ static void AVI_IndexCreate( input_thread_t *p_input ) p_avi->pp_info[i_stream]->p_index = NULL; } i_movi_end = __MIN( (off_t)(p_movi->i_chunk_pos + p_movi->i_chunk_size), - stream_Size( p_avi->s ) ); + stream_Size( p_input->s ) ); - stream_Seek( p_avi->s, p_movi->i_chunk_pos + 12 ); + stream_Seek( p_input->s, p_movi->i_chunk_pos + 12 ); msg_Warn( p_input, "creating index from LIST-movi, will take time !" ); for( ;; ) { @@ -2288,7 +2251,7 @@ static void AVI_IndexCreate( input_thread_t *p_input ) AVIFOURCC_RIFF, 1 ); msg_Dbg( p_input, "looking for new RIFF chunk" ); - if( stream_Seek( p_avi->s, p_avix->i_chunk_pos + 24 ) ) + if( stream_Seek( p_input->s, p_avix->i_chunk_pos + 24)) { goto print_stat; } diff --git a/modules/demux/avi/avi.h b/modules/demux/avi/avi.h index 99fda416370f..52ecbf7f34a6 100644 --- a/modules/demux/avi/avi.h +++ b/modules/demux/avi/avi.h @@ -2,7 +2,7 @@ * avi.h : AVI file Stream input module for vlc ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: avi.h,v 1.13 2003/08/22 22:52:48 fenrir Exp $ + * $Id: avi.h,v 1.14 2003/09/12 16:26:40 fenrir Exp $ * Authors: Laurent Aimar <fenrir@via.ecp.fr> * * This program is free software; you can redistribute it and/or modify @@ -69,8 +69,6 @@ typedef struct avi_stream_s struct demux_sys_t { - stream_t *s; - mtime_t i_time; mtime_t i_length; mtime_t i_pcr; diff --git a/modules/demux/mkv.cpp b/modules/demux/mkv.cpp index 18c686132a8d..f9afb2a2e239 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.26 2003/09/07 22:48:29 fenrir Exp $ + * $Id: mkv.cpp,v 1.27 2003/09/12 16:26:40 fenrir Exp $ * * Authors: Laurent Aimar <fenrir@via.ecp.fr> * @@ -233,8 +233,6 @@ typedef struct struct demux_sys_t { - stream_t *s; - vlc_stream_io_callback *in; EbmlStream *es; EbmlParser *ep; @@ -321,13 +319,7 @@ static int Open( vlc_object_t * p_this ) p_input->p_demux_data = p_sys = (demux_sys_t*)malloc(sizeof( demux_sys_t )); memset( p_sys, 0, sizeof( demux_sys_t ) ); - if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL ) - { - msg_Err( p_input, "cannot create stream" ); - free( p_sys ); - return VLC_EGENERIC; - } - p_sys->in = new vlc_stream_io_callback( p_sys->s ); + p_sys->in = new vlc_stream_io_callback( p_input->s ); p_sys->es = new EbmlStream( *p_sys->in ); p_sys->f_duration = -1; p_sys->i_timescale = MKVD_TIMECODESCALE; @@ -354,7 +346,6 @@ static int Open( vlc_object_t * p_this ) { msg_Err( p_input, "failed to create EbmlStream" ); delete p_sys->in; - stream_Release( p_sys->s ); free( p_sys ); return VLC_EGENERIC; } @@ -992,7 +983,7 @@ static int Open( vlc_object_t * p_this ) { vlc_bool_t b_seekable; - stream_Control( p_sys->s, STREAM_CAN_FASTSEEK, &b_seekable ); + stream_Control( p_input->s, STREAM_CAN_FASTSEEK, &b_seekable ); if( b_seekable ) { LoadCues( p_input ); @@ -1029,7 +1020,7 @@ static int Open( vlc_object_t * p_this ) if( p_sys->f_duration > 1001.0 ) { mtime_t i_duration = (mtime_t)( p_sys->f_duration / 1000.0 ); - p_input->stream.i_mux_rate = stream_Size( p_sys->s ) / 50 / i_duration; + p_input->stream.i_mux_rate = stream_Size( p_input->s )/50 / i_duration; } /* add all es */ @@ -1320,7 +1311,6 @@ static int Open( vlc_object_t * p_this ) error: delete p_sys->es; delete p_sys->in; - stream_Release( p_sys->s ); free( p_sys ); return VLC_EGENERIC; } @@ -1364,7 +1354,6 @@ static void Close( vlc_object_t *p_this ) delete p_sys->ep; delete p_sys->es; delete p_sys->in; - stream_Release( p_sys->s ); free( p_sys ); } @@ -1696,7 +1685,7 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent) /* seek without index or without date */ if( config_GetInt( p_input, "mkv-seek-percent" ) || !p_sys->b_cues || i_date < 0 ) { - int64_t i_pos = i_percent * stream_Size( p_sys->s ) / 100; + int64_t i_pos = i_percent * stream_Size( p_input->s ) / 100; msg_Dbg( p_input, "imprecise way of seeking" ); for( i_index = 0; i_index < p_sys->i_index; i_index++ ) @@ -1711,7 +1700,8 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent) i_index--; } - p_sys->in->setFilePointer( p_sys->index[i_index].i_position, seek_beginning ); + p_sys->in->setFilePointer( p_sys->index[i_index].i_position, + seek_beginning ); if( p_sys->index[i_index].i_position < i_pos ) { @@ -1757,7 +1747,7 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent) msg_Dbg( p_input, "seek got "I64Fd" (%d%%)", p_sys->index[i_index].i_time, (int)( 100 * p_sys->index[i_index].i_position / - stream_Size( p_sys->s ) ) ); + stream_Size( p_input->s ) ) ); p_sys->in->setFilePointer( p_sys->index[i_index].i_position, seek_beginning ); @@ -1839,12 +1829,12 @@ static int Demux( input_thread_t * p_input ) i_date = (mtime_t)1000000 * (mtime_t)i_duration* (mtime_t)p_sys->in->getFilePointer() / - (mtime_t)stream_Size( p_sys->s ); + (mtime_t)stream_Size( p_input->s ); } - if( stream_Size( p_sys->s ) > 0 ) + if( stream_Size( p_input->s ) > 0 ) { i_percent = 100 * p_sys->in->getFilePointer() / - stream_Size( p_sys->s ); + stream_Size( p_input->s ); } Seek( p_input, i_date, i_percent); @@ -2429,7 +2419,7 @@ static void InformationsCreate( input_thread_t *p_input ) { vlc_bool_t b_seekable; - stream_Control( p_sys->s, STREAM_CAN_FASTSEEK, &b_seekable ); + stream_Control( p_input->s, STREAM_CAN_FASTSEEK, &b_seekable ); if( b_seekable ) { LoadTags( p_input ); diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c index ecd84c0be4cf..9c15dd117255 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.36 2003/09/08 00:35:16 fenrir Exp $ + * $Id: mp4.c,v 1.37 2003/09/12 16:26:40 fenrir Exp $ * Authors: Laurent Aimar <fenrir@via.ecp.fr> * * This program is free software; you can redistribute it and/or modify @@ -142,14 +142,6 @@ static int Open( vlc_object_t * p_this ) p_input->p_demux_data = p_demux = malloc( sizeof( demux_sys_t ) ); memset( p_demux, 0, sizeof( demux_sys_t ) ); - /* Create stream facilities */ - if( ( p_demux->s= stream_OpenInput( p_input ) ) == NULL ) - { - msg_Err( p_input, "cannot create stream_t" ); - free( p_demux ); - return VLC_EGENERIC; - } - /* Now load all boxes ( except raw data ) */ if( ( p_demux->p_root = MP4_BoxGetRoot( p_input ) ) == NULL ) { @@ -398,7 +390,6 @@ static int Open( vlc_object_t * p_this ) return VLC_SUCCESS; error: - stream_Release( p_demux->s ); if( p_demux->p_root ) { MP4_BoxFree( p_input, p_demux->p_root ); @@ -513,7 +504,7 @@ static int Demux( input_thread_t *p_input ) //msg_Dbg( p_input, "stream %d size=%6d pos=%8lld", i_track, i_size, i_pos ); /* go,go go ! */ - if( stream_Seek( p_demux->s, i_pos ) ) + if( stream_Seek( p_input->s, i_pos ) ) { msg_Warn( p_input, "track[0x%x] will be disabled (eof?)", track.i_track_ID ); MP4_TrackUnselect( p_input, &track ); @@ -521,7 +512,7 @@ static int Demux( input_thread_t *p_input ) } /* now read pes */ - if( ( p_pes = stream_PesPacket( p_demux->s, i_size ) ) == NULL ) + if( ( p_pes = stream_PesPacket( p_input->s, i_size ) ) == NULL ) { msg_Warn( p_input, "track[0x%x] will be disabled (eof?)", track.i_track_ID ); MP4_TrackUnselect( p_input, &track ); diff --git a/modules/demux/mp4/mp4.h b/modules/demux/mp4/mp4.h index 53f664b23453..ee0c6dabc2bb 100644 --- a/modules/demux/mp4/mp4.h +++ b/modules/demux/mp4/mp4.h @@ -2,7 +2,7 @@ * mp4.h : MP4 file input module for vlc ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: mp4.h,v 1.7 2003/09/08 00:35:16 fenrir Exp $ + * $Id: mp4.h,v 1.8 2003/09/12 16:26:40 fenrir Exp $ * Authors: Laurent Aimar <fenrir@via.ecp.fr> * * This program is free software; you can redistribute it and/or modify @@ -127,8 +127,6 @@ typedef struct track_data_mp4_s *****************************************************************************/ struct demux_sys_t { - stream_t *s; - MP4_Box_t *p_root; /* container for the whole file */ mtime_t i_pcr; diff --git a/modules/demux/mpeg/mpga.c b/modules/demux/mpeg/mpga.c index fc7f04333134..067fb413a23b 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.4 2003/09/10 21:56:44 fenrir Exp $ + * $Id: mpga.c,v 1.5 2003/09/12 16:26:40 fenrir Exp $ * * Authors: Laurent Aimar <fenrir@via.ecp.fr> * @@ -54,7 +54,6 @@ static int Demux ( input_thread_t * ); struct demux_sys_t { - stream_t *s; mtime_t i_time; int i_bitrate_avg; /* extracted from Xing header */ @@ -241,12 +240,6 @@ static int Open( vlc_object_t * p_this ) p_sys->i_time = 0; p_sys->i_bitrate_avg = 0; - if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL ) - { - msg_Err( p_input, "cannot create stream" ); - goto error; - } - if( HeaderCheck( header ) ) { int i_xing; @@ -259,7 +252,7 @@ static int Open( vlc_object_t * p_this ) }; p_sys->i_bitrate_avg = MPGA_BITRATE( header ) * 1000; - if( ( i_xing = stream_Peek( p_sys->s, &p_xing, 1024 ) ) >= 21 ) + if( ( i_xing = stream_Peek( p_input->s, &p_xing, 1024 ) ) >= 21 ) { int i_skip; @@ -366,10 +359,6 @@ static int Open( vlc_object_t * p_this ) return VLC_SUCCESS; error: - if( p_sys->s ) - { - stream_Release( p_sys->s ); - } free( p_sys ); return VLC_EGENERIC; } @@ -388,7 +377,7 @@ static int Demux( input_thread_t * p_input ) uint32_t header; uint8_t *p_peek; - if( stream_Peek( p_sys->s, &p_peek, 4 ) < 4 ) + if( stream_Peek( p_input->s, &p_peek, 4 ) < 4 ) { msg_Warn( p_input, "cannot peek" ); return 0; @@ -401,7 +390,7 @@ static int Demux( input_thread_t * p_input ) int i_skip = 0; int i_peek; - i_peek = stream_Peek( p_sys->s, &p_peek, 8096 ); + i_peek = stream_Peek( p_input->s, &p_peek, 8096 ); if( i_peek < 4 ) { msg_Warn( p_input, "cannot peek" ); @@ -422,7 +411,7 @@ static int Demux( input_thread_t * p_input ) } msg_Warn( p_input, "garbage=%d bytes", i_skip ); - stream_Read( p_sys->s, NULL, i_skip ); + stream_Read( p_input->s, NULL, i_skip ); return 1; } @@ -430,7 +419,8 @@ static int Demux( input_thread_t * p_input ) p_input->stream.p_selected_program, p_sys->i_time * 9 / 100 ); - if( ( p_pes = stream_PesPacket( p_sys->s, mpga_frame_size( header ) ) ) == NULL ) + if( ( p_pes = stream_PesPacket( p_input->s, mpga_frame_size( header ) ) ) + == NULL ) { msg_Warn( p_input, "cannot read data" ); return 0; @@ -463,10 +453,6 @@ static void Close( vlc_object_t * p_this ) input_thread_t *p_input = (input_thread_t*)p_this; demux_sys_t *p_sys = p_input->p_demux_data; - if( p_sys->s ) - { - stream_Release( p_sys->s ); - } free( p_sys ); } diff --git a/modules/demux/sdp.c b/modules/demux/sdp.c index 4414605e826d..cbf2b76da98a 100644 --- a/modules/demux/sdp.c +++ b/modules/demux/sdp.c @@ -2,7 +2,7 @@ * sdp.c: SDP parser and builtin UDP/RTP/RTSP ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: sdp.c,v 1.10 2003/09/10 11:51:00 fenrir Exp $ + * $Id: sdp.c,v 1.11 2003/09/12 16:26:40 fenrir Exp $ * * Authors: Laurent Aimar <fenrir@via.ecp.fr> * @@ -75,8 +75,6 @@ struct access_sys_t struct demux_sys_t { - stream_t *s; - media_client_t *mc; /* try to detect end of stream */ @@ -255,11 +253,6 @@ static int SDPOpen( vlc_object_t * p_this ) var_Create( p_input, "rtsp-tcp", VLC_VAR_BOOL|VLC_VAR_DOINHERIT ); var_Get( p_input, "rtsp-tcp", &val ); p_sys->mc = media_client_create( val.b_bool ? 1 : 0 ); - if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL ) - { - msg_Err( p_input, "cannot create stream" ); - goto error; - } p_sys->i_no_data = 0; p_sys->b_received_data = VLC_FALSE; @@ -271,7 +264,8 @@ static int SDPOpen( vlc_object_t * p_this ) { int i_read; - i_read = stream_Read( p_sys->s, &psz_sdp[i_sdp], i_sdp_max - i_sdp -1 ); + i_read = stream_Read( p_input->s, + &psz_sdp[i_sdp], i_sdp_max - i_sdp -1 ); if( i_read < i_sdp_max - i_sdp -1 ) { if( i_read > 0 ) @@ -342,10 +336,6 @@ static int SDPOpen( vlc_object_t * p_this ) error: media_client_release( p_sys->mc ); - if( p_sys->s ) - { - stream_Release( p_sys->s ); - } free( p_sys ); return VLC_EGENERIC; } @@ -377,7 +367,6 @@ static void SDPClose( vlc_object_t * p_this ) } media_client_release( p_sys->mc ); - stream_Release( p_sys->s ); free( p_sys ); } diff --git a/modules/demux/wav.c b/modules/demux/wav.c index 026c274203d4..d3dc00187af9 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.6 2003/09/07 22:48:29 fenrir Exp $ + * $Id: wav.c,v 1.7 2003/09/12 16:26:40 fenrir Exp $ * * Authors: Laurent Aimar <fenrir@via.ecp.fr> * @@ -52,8 +52,6 @@ static int Demux ( input_thread_t * ); struct demux_sys_t { - stream_t *s; - WAVEFORMATEX *p_wf; es_descriptor_t *p_es; @@ -109,14 +107,8 @@ static int Open( vlc_object_t * p_this ) p_sys->p_es = NULL; p_sys->i_time = 0; - if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL ) - { - msg_Err( p_input, "cannot create stream" ); - goto error; - } - /* skip riff header */ - stream_Read( p_sys->s, NULL, 12 ); /* cannot fail as peek succeed */ + stream_Read( p_input->s, NULL, 12 ); /* cannot fail as peek succeed */ /* search fmt chunk */ if( ChunkFind( p_input, "fmt ", &i_size ) ) @@ -129,12 +121,13 @@ static int Open( vlc_object_t * p_this ) msg_Err( p_input, "invalid 'fmt ' chunk" ); goto error; } - stream_Read( p_sys->s, NULL, 8 ); /* cannot fail */ + stream_Read( p_input->s, NULL, 8 ); /* cannot fail */ /* load waveformatex */ p_sys->p_wf = malloc( __EVEN( i_size ) + 2 ); /* +2, for raw audio -> no cbSize */ p_sys->p_wf->cbSize = 0; - if( stream_Read( p_sys->s, p_sys->p_wf, __EVEN( i_size ) ) < (int)__EVEN( i_size ) ) + if( stream_Read( p_input->s, + p_sys->p_wf, __EVEN( i_size ) ) < (int)__EVEN( i_size ) ) { msg_Err( p_input, "cannot load 'fmt ' chunk" ); goto error; @@ -164,9 +157,9 @@ static int Open( vlc_object_t * p_this ) goto error; } - p_sys->i_data_pos = stream_Tell( p_sys->s ); + p_sys->i_data_pos = stream_Tell( p_input->s ); - stream_Read( p_sys->s, NULL, 8 ); /* cannot fail */ + stream_Read( p_input->s, NULL, 8 ); /* cannot fail */ wf_tag_to_fourcc( p_sys->p_wf->wFormatTag, &i_fourcc, &psz_name ); if( i_fourcc == VLC_FOURCC( 'u', 'n', 'd', 'f' ) ) @@ -254,10 +247,6 @@ relay: { free( p_sys->p_wf ); } - if( p_sys->s ) - { - stream_Release( p_sys->s ); - } free( p_sys ); return VLC_EGENERIC; @@ -276,11 +265,11 @@ static int Demux( input_thread_t *p_input ) if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT ) { - i_pos = stream_Tell( p_sys->s ); + i_pos = stream_Tell( p_input->s ); if( p_sys->p_wf->nBlockAlign != 0 ) { i_pos += p_sys->p_wf->nBlockAlign - i_pos % p_sys->p_wf->nBlockAlign; - if( stream_Seek( p_sys->s, i_pos ) ) + if( stream_Seek( p_input->s, i_pos ) ) { msg_Err( p_input, "stream_Sekk failed (cannot resync)" ); } @@ -291,7 +280,7 @@ static int Demux( input_thread_t *p_input ) p_input->stream.p_selected_program, p_sys->i_time * 9 / 100 ); - i_pos = stream_Tell( p_sys->s ); + i_pos = stream_Tell( p_input->s ); if( p_sys->i_data_size > 0 && i_pos >= p_sys->i_data_pos + p_sys->i_data_size ) @@ -300,7 +289,7 @@ static int Demux( input_thread_t *p_input ) return 0; } - if( ( p_pes = stream_PesPacket( p_sys->s, p_sys->i_frame_size ) ) == NULL ) + if( ( p_pes = stream_PesPacket( p_input->s, p_sys->i_frame_size ) )==NULL ) { msg_Warn( p_input, "cannot read data" ); return 0; @@ -330,7 +319,6 @@ static void Close ( vlc_object_t * p_this ) input_thread_t *p_input = (input_thread_t *)p_this; demux_sys_t *p_sys = p_input->p_demux_data; - stream_Release( p_sys->s ); free( p_sys->p_wf ); free( p_sys ); } @@ -342,14 +330,13 @@ static void Close ( vlc_object_t * p_this ) static int ChunkFind( input_thread_t *p_input, char *fcc, unsigned int *pi_size ) { - demux_sys_t *p_sys = p_input->p_demux_data; uint8_t *p_peek; for( ;; ) { int i_size; - if( stream_Peek( p_sys->s, &p_peek, 8 ) < 8 ) + if( stream_Peek( p_input->s, &p_peek, 8 ) < 8 ) { msg_Err( p_input, "cannot peek()" ); return VLC_EGENERIC; @@ -369,7 +356,7 @@ static int ChunkFind( input_thread_t *p_input, } i_size = __EVEN( i_size ) + 8; - if( stream_Read( p_sys->s, NULL, i_size ) != i_size ) + if( stream_Read( p_input->s, NULL, i_size ) != i_size ) { return VLC_EGENERIC; } diff --git a/src/input/input.c b/src/input/input.c index 30c4b0fec161..44cff37dc84a 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -4,7 +4,7 @@ * decoders. ***************************************************************************** * Copyright (C) 1998-2002 VideoLAN - * $Id: input.c,v 1.237 2003/09/07 22:51:11 fenrir Exp $ + * $Id: input.c,v 1.238 2003/09/12 16:26:40 fenrir Exp $ * * Authors: Christophe Massiot <massiot@via.ecp.fr> * @@ -152,6 +152,9 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, /* Set target */ p_input->psz_source = strdup( p_item->psz_uri ); + /* Stream */ + p_input->s = NULL; + /* Demux */ p_input->p_demux = NULL; p_input->pf_demux = NULL; @@ -626,6 +629,21 @@ static int InitThread( input_thread_t * p_input ) } } + /* Create the stream_t facilities */ + p_input->s = stream_OpenInput( p_input ); + if( p_input->s == NULL ) + { + /* should nver occur yet */ + + msg_Err( p_input, "cannot create stream_t !" ); + module_Unneed( p_input, p_input->p_access ); + if ( p_input->stream.p_sout != NULL ) + { + sout_DeleteInstance( p_input->stream.p_sout ); + } + return VLC_EGENERIC; + } + /* Find and open appropriate demux module */ p_input->p_demux = module_Need( p_input, "demux", p_input->psz_demux ); @@ -634,6 +652,7 @@ static int InitThread( input_thread_t * p_input ) { msg_Err( p_input, "no suitable demux module for `%s/%s://%s'", p_input->psz_access, p_input->psz_demux, p_input->psz_name ); + stream_Release( p_input->s ); module_Unneed( p_input, p_input->p_access ); if ( p_input->stream.p_sout != NULL ) { @@ -707,6 +726,9 @@ static void EndThread( input_thread_t * p_input ) /* Free demultiplexer's data */ module_Unneed( p_input, p_input->p_demux ); + /* Destroy the stream_t facilities */ + stream_Release( p_input->s ); + /* Close the access plug-in */ module_Unneed( p_input, p_input->p_access ); -- GitLab