Commit 05ca1094 authored by Laurent Aimar's avatar Laurent Aimar

* 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)
parent 98f58ea0
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* control the pace of reading. * control the pace of reading.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -313,6 +313,9 @@ struct input_thread_t ...@@ -313,6 +313,9 @@ struct input_thread_t
size_t i_mtu; size_t i_mtu;
int i_pts_delay; /* internal caching */ int i_pts_delay; /* internal caching */
/* Stream */
stream_t *s;
/* Demux module */ /* Demux module */
module_t * p_demux; module_t * p_demux;
int (* pf_demux ) ( input_thread_t * ); int (* pf_demux ) ( input_thread_t * );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ninput.h * ninput.h
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -24,6 +24,132 @@ ...@@ -24,6 +24,132 @@
#ifndef _NINPUT_H #ifndef _NINPUT_H
#define _NINPUT_H 1 #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 * \defgroup stream Stream
* *
...@@ -83,7 +209,6 @@ static int inline stream_Seek( stream_t *s, int64_t i_pos ) ...@@ -83,7 +209,6 @@ static int inline stream_Seek( stream_t *s, int64_t i_pos )
/** /**
* \defgroup demux Demux * \defgroup demux Demux
* XXX: don't look at it yet.
* @{ * @{
*/ */
enum demux_query_e enum demux_query_e
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* a52.c : Raw a52 Stream input module for vlc * a52.c : Raw a52 Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -53,7 +53,6 @@ static int Demux ( input_thread_t * ); ...@@ -53,7 +53,6 @@ static int Demux ( input_thread_t * );
struct demux_sys_t struct demux_sys_t
{ {
stream_t *s;
mtime_t i_time; mtime_t i_time;
es_descriptor_t *p_es; es_descriptor_t *p_es;
...@@ -132,13 +131,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -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_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
p_sys->i_time = 0; p_sys->i_time = 0;
if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL ) if( stream_Peek( p_input->s, &p_peek, 6 ) < 6 )
{
msg_Err( p_input, "cannot create stream" );
goto error;
}
if( stream_Peek( p_sys->s, &p_peek, 6 ) < 6 )
{ {
msg_Err( p_input, "cannot peek" ); msg_Err( p_input, "cannot peek" );
goto error; goto error;
...@@ -198,10 +191,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -198,10 +191,6 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -221,7 +210,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -221,7 +210,7 @@ static int Demux( input_thread_t * p_input )
uint8_t *p_peek; 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" ); msg_Warn( p_input, "cannot peek" );
return 0; return 0;
...@@ -234,7 +223,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -234,7 +223,7 @@ static int Demux( input_thread_t * p_input )
int i_skip = 0; int i_skip = 0;
int i_peek; 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 ) if( i_peek < 8 )
{ {
msg_Warn( p_input, "cannot peek" ); msg_Warn( p_input, "cannot peek" );
...@@ -255,7 +244,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -255,7 +244,7 @@ static int Demux( input_thread_t * p_input )
} }
msg_Warn( p_input, "garbage=%d bytes", i_skip ); 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; return 1;
} }
...@@ -265,7 +254,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -265,7 +254,7 @@ static int Demux( input_thread_t * p_input )
p_input->stream.p_selected_program, p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 ); 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" ); msg_Warn( p_input, "cannot read data" );
return 0; return 0;
...@@ -298,10 +287,6 @@ static void Close( vlc_object_t * p_this ) ...@@ -298,10 +287,6 @@ static void Close( vlc_object_t * p_this )
input_thread_t *p_input = (input_thread_t*)p_this; input_thread_t *p_input = (input_thread_t*)p_this;
demux_sys_t *p_sys = p_input->p_demux_data; demux_sys_t *p_sys = p_input->p_demux_data;
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys ); free( p_sys );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aac.c : Raw aac Stream input module for vlc * aac.c : Raw aac Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -54,7 +54,6 @@ static int Demux ( input_thread_t * ); ...@@ -54,7 +54,6 @@ static int Demux ( input_thread_t * );
struct demux_sys_t struct demux_sys_t
{ {
stream_t *s;
mtime_t i_time; mtime_t i_time;
es_descriptor_t *p_es; es_descriptor_t *p_es;
...@@ -139,14 +138,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -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_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
p_sys->i_time = 0; 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) */ /* 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" ); msg_Err( p_input, "cannot peek" );
goto error; goto error;
...@@ -213,10 +206,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -213,10 +206,6 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -235,7 +224,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -235,7 +224,7 @@ static int Demux( input_thread_t * p_input )
uint8_t h[8]; uint8_t h[8];
uint8_t *p_peek; 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" ); msg_Warn( p_input, "cannot peek" );
return 0; return 0;
...@@ -248,7 +237,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -248,7 +237,7 @@ static int Demux( input_thread_t * p_input )
int i_skip = 0; int i_skip = 0;
int i_peek; 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 ) if( i_peek < 8 )
{ {
msg_Warn( p_input, "cannot peek" ); msg_Warn( p_input, "cannot peek" );
...@@ -269,7 +258,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -269,7 +258,7 @@ static int Demux( input_thread_t * p_input )
} }
msg_Warn( p_input, "garbage=%d bytes", i_skip ); 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; return 1;
} }
...@@ -279,7 +268,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -279,7 +268,7 @@ static int Demux( input_thread_t * p_input )
p_input->stream.p_selected_program, p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 ); 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" ); msg_Warn( p_input, "cannot read data" );
return 0; return 0;
...@@ -312,10 +301,6 @@ static void Close( vlc_object_t * p_this ) ...@@ -312,10 +301,6 @@ static void Close( vlc_object_t * p_this )
input_thread_t *p_input = (input_thread_t*)p_this; input_thread_t *p_input = (input_thread_t*)p_this;
demux_sys_t *p_sys = p_input->p_demux_data; demux_sys_t *p_sys = p_input->p_demux_data;
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys ); free( p_sys );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* asf.c : ASFv01 file input module for vlc * asf.c : ASFv01 file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2003 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -76,8 +76,6 @@ struct demux_sys_t ...@@ -76,8 +76,6 @@ struct demux_sys_t
int64_t i_data_begin; int64_t i_data_begin;
int64_t i_data_end; int64_t i_data_end;
stream_t *s;
}; };
static mtime_t GetMoviePTS( demux_sys_t * ); static mtime_t GetMoviePTS( demux_sys_t * );
...@@ -123,20 +121,11 @@ static int Open( vlc_object_t * p_this ) ...@@ -123,20 +121,11 @@ static int Open( vlc_object_t * p_this )
p_sys->i_time = -1; p_sys->i_time = -1;
p_sys->i_length = 0; 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 ) */ /* Now load all object ( except raw data ) */
stream_Control( p_sys->s, STREAM_CAN_FASTSEEK, &b_seekable ); stream_Control( p_input->s, STREAM_CAN_FASTSEEK, &b_seekable );
if( (p_sys->p_root = ASF_ReadObjectRoot( p_sys->s, b_seekable )) == NULL ) if( (p_sys->p_root = ASF_ReadObjectRoot( p_input->s, b_seekable )) == NULL )
{ {
msg_Warn( p_input, "ASF plugin discarded (not a valid file)" ); msg_Warn( p_input, "ASF plugin discarded (not a valid file)" );
stream_Release( p_sys->s );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -328,13 +317,13 @@ static int Open( vlc_object_t * p_this ) ...@@ -328,13 +317,13 @@ static int Open( vlc_object_t * p_this )
/* go to first packet */ /* 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 */ /* try to calculate movie time */
if( p_sys->p_fp->i_data_packets_count > 0 ) if( p_sys->p_fp->i_data_packets_count > 0 )
{ {
int64_t i_count; 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 ) 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 ) ...@@ -446,8 +435,7 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
ASF_FreeObjectRoot( p_sys->s, p_sys->p_root ); ASF_FreeObjectRoot( p_input->s, p_sys->p_root );
stream_Release( p_sys->s );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -486,7 +474,7 @@ static int Demux( input_thread_t *p_input ) ...@@ -486,7 +474,7 @@ static int Demux( input_thread_t *p_input )
msleep( p_input->i_pts_delay ); 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 ) if( i_offset < 0 )
{ {
i_offset = 0; i_offset = 0;
...@@ -496,7 +484,7 @@ static int Demux( input_thread_t *p_input ) ...@@ -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; 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?)" ); msg_Warn( p_input, "cannot resynch after seek (EOF?)" );
return -1; return -1;
...@@ -568,7 +556,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -568,7 +556,7 @@ static void Close( vlc_object_t * p_this )
msg_Dbg( p_input, "Freeing all memory" ); 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++ ) for( i_stream = 0; i_stream < 128; i_stream++ )
{ {
#define p_stream p_sys->stream[i_stream] #define p_stream p_sys->stream[i_stream]
...@@ -582,7 +570,6 @@ static void Close( vlc_object_t * p_this ) ...@@ -582,7 +570,6 @@ static void Close( vlc_object_t * p_this )
} }
#undef p_stream #undef p_stream
} }
stream_Release( p_sys->s );
free( p_sys ); free( p_sys );
} }
...@@ -649,7 +636,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio ) ...@@ -649,7 +636,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
int i_payload_length_type; 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 ? // EOF ?
msg_Warn( p_input, "cannot peek while getting new packet, 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 ) ...@@ -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; 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" ); msg_Warn( p_input, "cannot read data" );
return( 0 ); return( 0 );
...@@ -905,7 +892,8 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio ) ...@@ -905,7 +892,8 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
i_skip = 0; i_skip = 0;
if( i_packet_size_left > 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 ? // EOF ?
msg_Warn( p_input, "cannot peek, 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 ) ...@@ -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( 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 ?" ); msg_Warn( p_input, "cannot skip data, EOF ?" );
return( 0 ); return( 0 );
...@@ -933,7 +922,7 @@ loop_error_recovery: ...@@ -933,7 +922,7 @@ loop_error_recovery:
msg_Err( p_input, "unsupported packet header, fatal error" ); msg_Err( p_input, "unsupported packet header, fatal error" );
return( -1 ); return( -1 );
} }
stream_Read( p_sys->s, NULL, i_data_packet_min ); stream_Read( p_input->s, NULL, i_data_packet_min );
return( 1 ); return( 1 );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* au.c : au file input module for vlc * au.c : au file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2003 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -92,8 +92,6 @@ typedef struct ...@@ -92,8 +92,6 @@ typedef struct
struct demux_sys_t struct demux_sys_t
{ {
stream_t *s;
au_t au; au_t au;
WAVEFORMATEX wf; WAVEFORMATEX wf;
...@@ -135,18 +133,11 @@ static int Open( vlc_object_t * p_this ) ...@@ -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_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
p_sys->i_time = 0; 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 */ /* skip signature */
stream_Read( p_sys->s, NULL, 4 ); /* cannot fail */ stream_Read( p_input->s, NULL, 4 ); /* cannot fail */
/* read header */ /* 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" ); msg_Err( p_input, "cannot load header" );
goto error; goto error;
...@@ -174,7 +165,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -174,7 +165,8 @@ static int Open( vlc_object_t * p_this )
/* skip extra header data */ /* skip extra header data */
if( p_sys->au.i_header_size > 4 + sizeof( au_t ) ) 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 */ /* Create WAVEFORMATEX structure */
...@@ -356,10 +348,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -356,10 +348,6 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -376,12 +364,12 @@ static int DemuxPCM( input_thread_t *p_input ) ...@@ -376,12 +364,12 @@ static int DemuxPCM( input_thread_t *p_input )
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT ) 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 ) if( p_sys->wf.nBlockAlign != 0 )
{ {
i_pos += p_sys->wf.nBlockAlign - i_pos % p_sys->wf.nBlockAlign; 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)" ); msg_Err( p_input, "Seek failed(cannot resync)" );
} }
...@@ -392,7 +380,7 @@ static int DemuxPCM( input_thread_t *p_input ) ...@@ -392,7 +380,7 @@ static int DemuxPCM( input_thread_t *p_input )
p_input->stream.p_selected_program, p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 ); 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" ); msg_Warn( p_input, "cannot read data" );
return 0; return 0;
...@@ -422,7 +410,6 @@ static void Close( vlc_object_t * p_this ) ...@@ -422,7 +410,6 @@ static void Close( vlc_object_t * p_this )
input_thread_t *p_input = (input_thread_t *)p_this; input_thread_t *p_input = (input_thread_t *)p_this;
demux_sys_t *p_sys = p_input->p_demux_data; demux_sys_t *p_sys = p_input->p_demux_data;
stream_Release( p_sys->s );
free( p_sys ); free( p_sys );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* avi.c : AVI file Stream input module for vlc * avi.c : AVI file Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -150,14 +150,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -150,14 +150,7 @@ static int Open( vlc_object_t * p_this )
p_avi->b_odml = VLC_FALSE; p_avi->b_odml = VLC_FALSE;
p_avi->b_interleaved = VLC_FALSE; p_avi->b_interleaved = VLC_FALSE;
/* Create stream facilities */ stream_Control( p_input->s, STREAM_CAN_FASTSEEK, &p_avi->b_seekable );
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 );
p_input->pf_demux_control = Control; p_input->pf_demux_control = Control;
p_input->pf_demux = Demux_Seekable; p_input->pf_demux = Demux_Seekable;
...@@ -167,7 +160,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -167,7 +160,7 @@ static int Open( vlc_object_t * p_this )
p_input->pf_demux = Demux_UnSeekable; 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)" ); msg_Err( p_input, "avi module discarded (invalid file)" );
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -507,7 +500,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -507,7 +500,7 @@ static int Open( vlc_object_t * p_this )
if( p_avi->i_length ) if( p_avi->i_length )
{ {
p_input->stream.i_mux_rate = 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 ); p_avi->b_interleaved = AVI_Interleaved( p_input );
msg_Dbg( p_input, "interleaved=%s", msg_Dbg( p_input, "interleaved=%s",
...@@ -547,17 +540,16 @@ static int Open( vlc_object_t * p_this ) ...@@ -547,17 +540,16 @@ static int Open( vlc_object_t * p_this )
if( p_avi->b_seekable ) if( p_avi->b_seekable )
{ {
/* we have read all chunk so go back to movi */ /* 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 */ /* 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; p_avi->i_movi_begin = p_movi->i_chunk_pos;
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
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 ); free( p_avi );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -584,9 +576,8 @@ static void Close ( vlc_object_t * p_this ) ...@@ -584,9 +576,8 @@ static void Close ( vlc_object_t * p_this )
{ {
subtitle_Close( p_avi->p_sub ); 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 ); free( p_avi );
} }
...@@ -656,32 +647,8 @@ static int Demux_Seekable( input_thread_t *p_input ) ...@@ -656,32 +647,8 @@ static int Demux_Seekable( input_thread_t *p_input )
msg_Warn( p_input, "no track selected, exiting..." ); msg_Warn( p_input, "no track selected, exiting..." );
return( 0 ); 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 */ /* wait for the good time */
p_avi->i_pcr = p_avi->i_time * 9 / 100; p_avi->i_pcr = p_avi->i_time * 9 / 100;
input_ClockManageRef( p_input, input_ClockManageRef( p_input,
...@@ -788,7 +755,7 @@ static int Demux_Seekable( input_thread_t *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 */ * in case we fail we will disable all finished stream */
if( p_avi->i_movi_lastchunk_pos >= p_avi->i_movi_begin + 12 ) 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 ) ) if( AVI_PacketNext( p_input ) )
{ {
return( AVI_StreamStopFinishedStreams( p_input ) ? 0 : 1 ); return( AVI_StreamStopFinishedStreams( p_input ) ? 0 : 1 );
...@@ -796,7 +763,7 @@ static int Demux_Seekable( input_thread_t *p_input ) ...@@ -796,7 +763,7 @@ static int Demux_Seekable( input_thread_t *p_input )
} }
else else
{ {
stream_Seek( p_avi->s, p_avi->i_movi_begin + 12 ); stream_Seek( p_input->s, p_avi->i_movi_begin + 12 );
} }
for( ;; ) for( ;; )
...@@ -855,7 +822,7 @@ static int Demux_Seekable( input_thread_t *p_input ) ...@@ -855,7 +822,7 @@ static int Demux_Seekable( input_thread_t *p_input )
} }
else else
{ {
stream_Seek( p_avi->s, i_pos ); stream_Seek( p_input->s, i_pos );
} }
/* read thoses data */ /* read thoses data */
...@@ -888,7 +855,7 @@ static int Demux_Seekable( input_thread_t *p_input ) ...@@ -888,7 +855,7 @@ static int Demux_Seekable( input_thread_t *p_input )
i_size += 8; // need to read and skip header 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" ); msg_Warn( p_input, "failled reading data" );
AVI_StreamStop( p_input, i_stream ); 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 ) ...@@ -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 */ /* try to find chunk that is at i_percent or the file */
i_pos = __MAX( i_percent * i_pos = __MAX( i_percent *
stream_Size( p_avi->s ) / 100, stream_Size( p_input->s ) / 100,
p_avi->i_movi_begin ); p_avi->i_movi_begin );
/* search first selected stream */ /* search first selected stream */
for( i_stream = 0, p_stream = NULL; 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 ) ...@@ -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 ); *pf = (double)p_sys->i_time / (double)( p_sys->i_length * (mtime_t)1000000 );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
else if( stream_Size( p_sys->s ) > 0 ) else if( stream_Size( p_input->s ) > 0 )
{ {
unsigned int i; unsigned int i;
int64_t i_tmp; int64_t i_tmp;
...@@ -1293,7 +1260,7 @@ static int Control( input_thread_t *p_input, int i_query, va_list args ) ...@@ -1293,7 +1260,7 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
} }
#undef tk #undef tk
} }
*pf = (double)i64 / (double)stream_Size( p_sys->s ); *pf = (double)i64 / (double)stream_Size( p_input->s );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
else else
...@@ -1467,7 +1434,7 @@ static int AVI_StreamChunkFind( input_thread_t *p_input, ...@@ -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 ) 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 ) ) if( AVI_PacketNext( p_input ) )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -1475,7 +1442,7 @@ static int AVI_StreamChunkFind( input_thread_t *p_input, ...@@ -1475,7 +1442,7 @@ static int AVI_StreamChunkFind( input_thread_t *p_input,
} }
else else
{ {
stream_Seek( p_avi->s, p_avi->i_movi_begin + 12 ); stream_Seek( p_input->s, p_avi->i_movi_begin + 12 );
} }
for( ;; ) for( ;; )
...@@ -1697,12 +1664,12 @@ static vlc_bool_t AVI_Interleaved( input_thread_t *p_input ) ...@@ -1697,12 +1664,12 @@ static vlc_bool_t AVI_Interleaved( input_thread_t *p_input )
int64_t i_max; int64_t i_max;
if( stream_Size( p_sys->s ) <= 100 ) if( stream_Size( p_input->s ) <= 100 )
{ {
return VLC_FALSE; 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] #define tk p_sys->pp_info[i]
while( i_time < p_sys->i_length * (mtime_t)1000000) while( i_time < p_sys->i_length * (mtime_t)1000000)
...@@ -1896,16 +1863,15 @@ static void AVI_ParseStreamHeader( vlc_fourcc_t i_id, ...@@ -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 ) 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; 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; return VLC_EGENERIC;
} }
p_pk->i_fourcc = VLC_FOURCC( p_peek[0], p_peek[1], p_peek[2], p_peek[3] ); 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_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 ) 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], 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 ) ...@@ -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 ) static int AVI_PacketNext( input_thread_t *p_input )
{ {
demux_sys_t *p_sys = p_input->p_demux_data;
avi_packet_t avi_ck; avi_packet_t avi_ck;
int i_skip = 0; int i_skip = 0;
...@@ -1948,7 +1913,7 @@ static int AVI_PacketNext( input_thread_t *p_input ) ...@@ -1948,7 +1913,7 @@ static int AVI_PacketNext( input_thread_t *p_input )
i_skip = __EVEN( avi_ck.i_size ) + 8; 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; return VLC_EGENERIC;
} }
...@@ -1958,13 +1923,11 @@ static int AVI_PacketRead( input_thread_t *p_input, ...@@ -1958,13 +1923,11 @@ static int AVI_PacketRead( input_thread_t *p_input,
avi_packet_t *p_pk, avi_packet_t *p_pk,
pes_packet_t **pp_pes ) pes_packet_t **pp_pes )
{ {
demux_sys_t *p_sys = p_input->p_demux_data;
size_t i_size; size_t i_size;
i_size = __EVEN( p_pk->i_size + 8 ); 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; return VLC_EGENERIC;
} }
...@@ -1987,7 +1950,7 @@ static int AVI_PacketSearch( input_thread_t *p_input ) ...@@ -1987,7 +1950,7 @@ static int AVI_PacketSearch( input_thread_t *p_input )
avi_packet_t avi_pk; avi_packet_t avi_pk;
for( ;; ) for( ;; )
{ {
if( stream_Read( p_avi->s, NULL, 1 ) != 1 ) if( stream_Read( p_input->s, NULL, 1 ) != 1 )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -2182,8 +2145,8 @@ static void AVI_IndexLoad_indx( input_thread_t *p_input ) ...@@ -2182,8 +2145,8 @@ static void AVI_IndexLoad_indx( input_thread_t *p_input )
avi_chunk_indx_t ck_sub; avi_chunk_indx_t ck_sub;
for( i = 0; i < p_indx->i_entriesinuse; i++ ) for( i = 0; i < p_indx->i_entriesinuse; i++ )
{ {
if( stream_Seek( p_avi->s, p_indx->idx.super[i].i_offset )|| if( stream_Seek( p_input->s, p_indx->idx.super[i].i_offset )||
AVI_ChunkRead( p_avi->s, &ck_sub, NULL ) ) AVI_ChunkRead( p_input->s, &ck_sub, NULL ) )
{ {
break; break;
} }
...@@ -2253,9 +2216,9 @@ static void AVI_IndexCreate( input_thread_t *p_input ) ...@@ -2253,9 +2216,9 @@ static void AVI_IndexCreate( input_thread_t *p_input )
p_avi->pp_info[i_stream]->p_index = NULL; 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), 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 !" ); msg_Warn( p_input, "creating index from LIST-movi, will take time !" );
for( ;; ) for( ;; )
{ {
...@@ -2288,7 +2251,7 @@ static void AVI_IndexCreate( input_thread_t *p_input ) ...@@ -2288,7 +2251,7 @@ static void AVI_IndexCreate( input_thread_t *p_input )
AVIFOURCC_RIFF, 1 ); AVIFOURCC_RIFF, 1 );
msg_Dbg( p_input, "looking for new RIFF chunk" ); 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; goto print_stat;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* avi.h : AVI file Stream input module for vlc * avi.h : AVI file Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -69,8 +69,6 @@ typedef struct avi_stream_s ...@@ -69,8 +69,6 @@ typedef struct avi_stream_s
struct demux_sys_t struct demux_sys_t
{ {
stream_t *s;
mtime_t i_time; mtime_t i_time;
mtime_t i_length; mtime_t i_length;
mtime_t i_pcr; mtime_t i_pcr;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mkv.cpp : matroska demuxer * mkv.cpp : matroska demuxer
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -233,8 +233,6 @@ typedef struct ...@@ -233,8 +233,6 @@ typedef struct
struct demux_sys_t struct demux_sys_t
{ {
stream_t *s;
vlc_stream_io_callback *in; vlc_stream_io_callback *in;
EbmlStream *es; EbmlStream *es;
EbmlParser *ep; EbmlParser *ep;
...@@ -321,13 +319,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -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 )); p_input->p_demux_data = p_sys = (demux_sys_t*)malloc(sizeof( demux_sys_t ));
memset( p_sys, 0, sizeof( demux_sys_t ) ); memset( p_sys, 0, sizeof( demux_sys_t ) );
if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL ) p_sys->in = new vlc_stream_io_callback( p_input->s );
{
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->es = new EbmlStream( *p_sys->in ); p_sys->es = new EbmlStream( *p_sys->in );
p_sys->f_duration = -1; p_sys->f_duration = -1;
p_sys->i_timescale = MKVD_TIMECODESCALE; p_sys->i_timescale = MKVD_TIMECODESCALE;
...@@ -354,7 +346,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -354,7 +346,6 @@ static int Open( vlc_object_t * p_this )
{ {
msg_Err( p_input, "failed to create EbmlStream" ); msg_Err( p_input, "failed to create EbmlStream" );
delete p_sys->in; delete p_sys->in;
stream_Release( p_sys->s );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -992,7 +983,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -992,7 +983,7 @@ static int Open( vlc_object_t * p_this )
{ {
vlc_bool_t b_seekable; 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 ) if( b_seekable )
{ {
LoadCues( p_input ); LoadCues( p_input );
...@@ -1029,7 +1020,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -1029,7 +1020,7 @@ static int Open( vlc_object_t * p_this )
if( p_sys->f_duration > 1001.0 ) if( p_sys->f_duration > 1001.0 )
{ {
mtime_t i_duration = (mtime_t)( p_sys->f_duration / 1000.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 */ /* add all es */
...@@ -1320,7 +1311,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -1320,7 +1311,6 @@ static int Open( vlc_object_t * p_this )
error: error:
delete p_sys->es; delete p_sys->es;
delete p_sys->in; delete p_sys->in;
stream_Release( p_sys->s );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -1364,7 +1354,6 @@ static void Close( vlc_object_t *p_this ) ...@@ -1364,7 +1354,6 @@ static void Close( vlc_object_t *p_this )
delete p_sys->ep; delete p_sys->ep;
delete p_sys->es; delete p_sys->es;
delete p_sys->in; delete p_sys->in;
stream_Release( p_sys->s );
free( p_sys ); free( p_sys );
} }
...@@ -1696,7 +1685,7 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent) ...@@ -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 */ /* seek without index or without date */
if( config_GetInt( p_input, "mkv-seek-percent" ) || !p_sys->b_cues || i_date < 0 ) 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" ); msg_Dbg( p_input, "imprecise way of seeking" );
for( i_index = 0; i_index < p_sys->i_index; i_index++ ) 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) ...@@ -1711,7 +1700,8 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent)
i_index--; 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 ) 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) ...@@ -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%%)", msg_Dbg( p_input, "seek got "I64Fd" (%d%%)",
p_sys->index[i_index].i_time, p_sys->index[i_index].i_time,
(int)( 100 * p_sys->index[i_index].i_position / (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, p_sys->in->setFilePointer( p_sys->index[i_index].i_position,
seek_beginning ); seek_beginning );
...@@ -1839,12 +1829,12 @@ static int Demux( input_thread_t * p_input ) ...@@ -1839,12 +1829,12 @@ static int Demux( input_thread_t * p_input )
i_date = (mtime_t)1000000 * i_date = (mtime_t)1000000 *
(mtime_t)i_duration* (mtime_t)i_duration*
(mtime_t)p_sys->in->getFilePointer() / (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() / i_percent = 100 * p_sys->in->getFilePointer() /
stream_Size( p_sys->s ); stream_Size( p_input->s );
} }
Seek( p_input, i_date, i_percent); Seek( p_input, i_date, i_percent);
...@@ -2429,7 +2419,7 @@ static void InformationsCreate( input_thread_t *p_input ) ...@@ -2429,7 +2419,7 @@ static void InformationsCreate( input_thread_t *p_input )
{ {
vlc_bool_t b_seekable; 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 ) if( b_seekable )
{ {
LoadTags( p_input ); LoadTags( p_input );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mp4.c : MP4 file input module for vlc * mp4.c : MP4 file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -142,14 +142,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -142,14 +142,6 @@ static int Open( vlc_object_t * p_this )
p_input->p_demux_data = p_demux = malloc( sizeof( demux_sys_t ) ); p_input->p_demux_data = p_demux = malloc( sizeof( demux_sys_t ) );
memset( p_demux, 0, 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 ) */ /* Now load all boxes ( except raw data ) */
if( ( p_demux->p_root = MP4_BoxGetRoot( p_input ) ) == NULL ) if( ( p_demux->p_root = MP4_BoxGetRoot( p_input ) ) == NULL )
{ {
...@@ -398,7 +390,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -398,7 +390,6 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
stream_Release( p_demux->s );
if( p_demux->p_root ) if( p_demux->p_root )
{ {
MP4_BoxFree( p_input, p_demux->p_root ); MP4_BoxFree( p_input, p_demux->p_root );
...@@ -513,7 +504,7 @@ static int Demux( input_thread_t *p_input ) ...@@ -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 ); //msg_Dbg( p_input, "stream %d size=%6d pos=%8lld", i_track, i_size, i_pos );
/* go,go go ! */ /* 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 ); msg_Warn( p_input, "track[0x%x] will be disabled (eof?)", track.i_track_ID );
MP4_TrackUnselect( p_input, &track ); MP4_TrackUnselect( p_input, &track );
...@@ -521,7 +512,7 @@ static int Demux( input_thread_t *p_input ) ...@@ -521,7 +512,7 @@ static int Demux( input_thread_t *p_input )
} }
/* now read pes */ /* 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 ); msg_Warn( p_input, "track[0x%x] will be disabled (eof?)", track.i_track_ID );
MP4_TrackUnselect( p_input, &track ); MP4_TrackUnselect( p_input, &track );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mp4.h : MP4 file input module for vlc * mp4.h : MP4 file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -127,8 +127,6 @@ typedef struct track_data_mp4_s ...@@ -127,8 +127,6 @@ typedef struct track_data_mp4_s
*****************************************************************************/ *****************************************************************************/
struct demux_sys_t struct demux_sys_t
{ {
stream_t *s;
MP4_Box_t *p_root; /* container for the whole file */ MP4_Box_t *p_root; /* container for the whole file */
mtime_t i_pcr; mtime_t i_pcr;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpga.c : MPEG-I/II Audio input module for vlc * mpga.c : MPEG-I/II Audio input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -54,7 +54,6 @@ static int Demux ( input_thread_t * ); ...@@ -54,7 +54,6 @@ static int Demux ( input_thread_t * );
struct demux_sys_t struct demux_sys_t
{ {
stream_t *s;
mtime_t i_time; mtime_t i_time;
int i_bitrate_avg; /* extracted from Xing header */ int i_bitrate_avg; /* extracted from Xing header */
...@@ -241,12 +240,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -241,12 +240,6 @@ static int Open( vlc_object_t * p_this )
p_sys->i_time = 0; p_sys->i_time = 0;
p_sys->i_bitrate_avg = 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 ) ) if( HeaderCheck( header ) )
{ {
int i_xing; int i_xing;
...@@ -259,7 +252,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -259,7 +252,7 @@ static int Open( vlc_object_t * p_this )
}; };
p_sys->i_bitrate_avg = MPGA_BITRATE( header ) * 1000; 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; int i_skip;
...@@ -366,10 +359,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -366,10 +359,6 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -388,7 +377,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -388,7 +377,7 @@ static int Demux( input_thread_t * p_input )
uint32_t header; uint32_t header;
uint8_t *p_peek; 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" ); msg_Warn( p_input, "cannot peek" );
return 0; return 0;
...@@ -401,7 +390,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -401,7 +390,7 @@ static int Demux( input_thread_t * p_input )
int i_skip = 0; int i_skip = 0;
int i_peek; 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 ) if( i_peek < 4 )
{ {
msg_Warn( p_input, "cannot peek" ); msg_Warn( p_input, "cannot peek" );
...@@ -422,7 +411,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -422,7 +411,7 @@ static int Demux( input_thread_t * p_input )
} }
msg_Warn( p_input, "garbage=%d bytes", i_skip ); 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; return 1;
} }
...@@ -430,7 +419,8 @@ static int Demux( input_thread_t * p_input ) ...@@ -430,7 +419,8 @@ static int Demux( input_thread_t * p_input )
p_input->stream.p_selected_program, p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 ); 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" ); msg_Warn( p_input, "cannot read data" );
return 0; return 0;
...@@ -463,10 +453,6 @@ static void Close( vlc_object_t * p_this ) ...@@ -463,10 +453,6 @@ static void Close( vlc_object_t * p_this )
input_thread_t *p_input = (input_thread_t*)p_this; input_thread_t *p_input = (input_thread_t*)p_this;
demux_sys_t *p_sys = p_input->p_demux_data; demux_sys_t *p_sys = p_input->p_demux_data;
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys ); free( p_sys );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sdp.c: SDP parser and builtin UDP/RTP/RTSP * sdp.c: SDP parser and builtin UDP/RTP/RTSP
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -75,8 +75,6 @@ struct access_sys_t ...@@ -75,8 +75,6 @@ struct access_sys_t
struct demux_sys_t struct demux_sys_t
{ {
stream_t *s;
media_client_t *mc; media_client_t *mc;
/* try to detect end of stream */ /* try to detect end of stream */
...@@ -255,11 +253,6 @@ static int SDPOpen( vlc_object_t * p_this ) ...@@ -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_Create( p_input, "rtsp-tcp", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
var_Get( p_input, "rtsp-tcp", &val ); var_Get( p_input, "rtsp-tcp", &val );
p_sys->mc = media_client_create( val.b_bool ? 1 : 0 ); 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->i_no_data = 0;
p_sys->b_received_data = VLC_FALSE; p_sys->b_received_data = VLC_FALSE;
...@@ -271,7 +264,8 @@ static int SDPOpen( vlc_object_t * p_this ) ...@@ -271,7 +264,8 @@ static int SDPOpen( vlc_object_t * p_this )
{ {
int i_read; 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 < i_sdp_max - i_sdp -1 )
{ {
if( i_read > 0 ) if( i_read > 0 )
...@@ -342,10 +336,6 @@ static int SDPOpen( vlc_object_t * p_this ) ...@@ -342,10 +336,6 @@ static int SDPOpen( vlc_object_t * p_this )
error: error:
media_client_release( p_sys->mc ); media_client_release( p_sys->mc );
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -377,7 +367,6 @@ static void SDPClose( vlc_object_t * p_this ) ...@@ -377,7 +367,6 @@ static void SDPClose( vlc_object_t * p_this )
} }
media_client_release( p_sys->mc ); media_client_release( p_sys->mc );
stream_Release( p_sys->s );
free( p_sys ); free( p_sys );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* wav.c : wav file input module for vlc * wav.c : wav file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -52,8 +52,6 @@ static int Demux ( input_thread_t * ); ...@@ -52,8 +52,6 @@ static int Demux ( input_thread_t * );
struct demux_sys_t struct demux_sys_t
{ {
stream_t *s;
WAVEFORMATEX *p_wf; WAVEFORMATEX *p_wf;
es_descriptor_t *p_es; es_descriptor_t *p_es;
...@@ -109,14 +107,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -109,14 +107,8 @@ static int Open( vlc_object_t * p_this )
p_sys->p_es = NULL; p_sys->p_es = NULL;
p_sys->i_time = 0; 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 */ /* 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 */ /* search fmt chunk */
if( ChunkFind( p_input, "fmt ", &i_size ) ) if( ChunkFind( p_input, "fmt ", &i_size ) )
...@@ -129,12 +121,13 @@ static int Open( vlc_object_t * p_this ) ...@@ -129,12 +121,13 @@ static int Open( vlc_object_t * p_this )
msg_Err( p_input, "invalid 'fmt ' chunk" ); msg_Err( p_input, "invalid 'fmt ' chunk" );
goto error; goto error;
} }
stream_Read( p_sys->s, NULL, 8 ); /* cannot fail */ stream_Read( p_input->s, NULL, 8 ); /* cannot fail */
/* load waveformatex */ /* load waveformatex */
p_sys->p_wf = malloc( __EVEN( i_size ) + 2 ); /* +2, for raw audio -> no cbSize */ p_sys->p_wf = malloc( __EVEN( i_size ) + 2 ); /* +2, for raw audio -> no cbSize */
p_sys->p_wf->cbSize = 0; 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" ); msg_Err( p_input, "cannot load 'fmt ' chunk" );
goto error; goto error;
...@@ -164,9 +157,9 @@ static int Open( vlc_object_t * p_this ) ...@@ -164,9 +157,9 @@ static int Open( vlc_object_t * p_this )
goto error; 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 ); wf_tag_to_fourcc( p_sys->p_wf->wFormatTag, &i_fourcc, &psz_name );
if( i_fourcc == VLC_FOURCC( 'u', 'n', 'd', 'f' ) ) if( i_fourcc == VLC_FOURCC( 'u', 'n', 'd', 'f' ) )
...@@ -254,10 +247,6 @@ relay: ...@@ -254,10 +247,6 @@ relay:
{ {
free( p_sys->p_wf ); free( p_sys->p_wf );
} }
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -276,11 +265,11 @@ static int Demux( input_thread_t *p_input ) ...@@ -276,11 +265,11 @@ static int Demux( input_thread_t *p_input )
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT ) 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 ) if( p_sys->p_wf->nBlockAlign != 0 )
{ {
i_pos += p_sys->p_wf->nBlockAlign - i_pos % p_sys->p_wf->nBlockAlign; 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)" ); msg_Err( p_input, "stream_Sekk failed (cannot resync)" );
} }
...@@ -291,7 +280,7 @@ static int Demux( input_thread_t *p_input ) ...@@ -291,7 +280,7 @@ static int Demux( input_thread_t *p_input )
p_input->stream.p_selected_program, p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 ); 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 && if( p_sys->i_data_size > 0 &&
i_pos >= p_sys->i_data_pos + p_sys->i_data_size ) i_pos >= p_sys->i_data_pos + p_sys->i_data_size )
...@@ -300,7 +289,7 @@ static int Demux( input_thread_t *p_input ) ...@@ -300,7 +289,7 @@ static int Demux( input_thread_t *p_input )
return 0; 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" ); msg_Warn( p_input, "cannot read data" );
return 0; return 0;
...@@ -330,7 +319,6 @@ static void Close ( vlc_object_t * p_this ) ...@@ -330,7 +319,6 @@ static void Close ( vlc_object_t * p_this )
input_thread_t *p_input = (input_thread_t *)p_this; input_thread_t *p_input = (input_thread_t *)p_this;
demux_sys_t *p_sys = p_input->p_demux_data; demux_sys_t *p_sys = p_input->p_demux_data;
stream_Release( p_sys->s );
free( p_sys->p_wf ); free( p_sys->p_wf );
free( p_sys ); free( p_sys );
} }
...@@ -342,14 +330,13 @@ static void Close ( vlc_object_t * p_this ) ...@@ -342,14 +330,13 @@ static void Close ( vlc_object_t * p_this )
static int ChunkFind( input_thread_t *p_input, static int ChunkFind( input_thread_t *p_input,
char *fcc, unsigned int *pi_size ) char *fcc, unsigned int *pi_size )
{ {
demux_sys_t *p_sys = p_input->p_demux_data;
uint8_t *p_peek; uint8_t *p_peek;
for( ;; ) for( ;; )
{ {
int i_size; 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()" ); msg_Err( p_input, "cannot peek()" );
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -369,7 +356,7 @@ static int ChunkFind( input_thread_t *p_input, ...@@ -369,7 +356,7 @@ static int ChunkFind( input_thread_t *p_input,
} }
i_size = __EVEN( i_size ) + 8; 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; return VLC_EGENERIC;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -152,6 +152,9 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, ...@@ -152,6 +152,9 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
/* Set target */ /* Set target */
p_input->psz_source = strdup( p_item->psz_uri ); p_input->psz_source = strdup( p_item->psz_uri );
/* Stream */
p_input->s = NULL;
/* Demux */ /* Demux */
p_input->p_demux = NULL; p_input->p_demux = NULL;
p_input->pf_demux = NULL; p_input->pf_demux = NULL;
...@@ -626,6 +629,21 @@ static int InitThread( input_thread_t * p_input ) ...@@ -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 */ /* Find and open appropriate demux module */
p_input->p_demux = module_Need( p_input, "demux", p_input->p_demux = module_Need( p_input, "demux",
p_input->psz_demux ); p_input->psz_demux );
...@@ -634,6 +652,7 @@ static int InitThread( input_thread_t * p_input ) ...@@ -634,6 +652,7 @@ static int InitThread( input_thread_t * p_input )
{ {
msg_Err( p_input, "no suitable demux module for `%s/%s://%s'", msg_Err( p_input, "no suitable demux module for `%s/%s://%s'",
p_input->psz_access, p_input->psz_demux, p_input->psz_name ); 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 ); module_Unneed( p_input, p_input->p_access );
if ( p_input->stream.p_sout != NULL ) if ( p_input->stream.p_sout != NULL )
{ {
...@@ -707,6 +726,9 @@ static void EndThread( input_thread_t * p_input ) ...@@ -707,6 +726,9 @@ static void EndThread( input_thread_t * p_input )
/* Free demultiplexer's data */ /* Free demultiplexer's data */
module_Unneed( p_input, p_input->p_demux ); module_Unneed( p_input, p_input->p_demux );
/* Destroy the stream_t facilities */
stream_Release( p_input->s );
/* Close the access plug-in */ /* Close the access plug-in */
module_Unneed( p_input, p_input->p_access ); module_Unneed( p_input, p_input->p_access );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment