* 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)
* 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>
*
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 * );
* 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>
*
#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
*
/**
* \defgroup demux Demux
- * XXX: don't look at it yet.
* @{
*/
enum demux_query_e
* 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>
*
struct demux_sys_t
{
- stream_t *s;
mtime_t i_time;
es_descriptor_t *p_es;
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;
return VLC_SUCCESS;
error:
- if( p_sys->s )
- {
- stream_Release( p_sys->s );
- }
free( p_sys );
return VLC_EGENERIC;
}
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;
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" );
}
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;
}
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;
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 );
}
* 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>
*
struct demux_sys_t
{
- stream_t *s;
mtime_t i_time;
es_descriptor_t *p_es;
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;
return VLC_SUCCESS;
error:
- if( p_sys->s )
- {
- stream_Release( p_sys->s );
- }
free( p_sys );
return VLC_EGENERIC;
}
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;
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" );
}
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;
}
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;
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 );
}
* 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>
*
int64_t i_data_begin;
int64_t i_data_end;
-
- stream_t *s;
};
static mtime_t GetMoviePTS( demux_sys_t * );
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;
}
/* 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 )
{
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;
}
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;
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;
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]
}
#undef p_stream
}
- stream_Release( p_sys->s );
free( p_sys );
}
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 ?" );
}
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 );
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 ?" );
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 );
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 );
}
* 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>
*
struct demux_sys_t
{
- stream_t *s;
-
au_t au;
WAVEFORMATEX wf;
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;
/* 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 */
return VLC_SUCCESS;
error:
- if( p_sys->s )
- {
- stream_Release( p_sys->s );
- }
free( p_sys );
return VLC_EGENERIC;
}
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)" );
}
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;
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 );
}
* 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
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;
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;
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",
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;
}
{
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 );
}
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,
* 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 );
}
else
{
- stream_Seek( p_avi->s, p_avi->i_movi_begin + 12 );
+ stream_Seek( p_input->s, p_avi->i_movi_begin + 12 );
}
for( ;; )
}
else
{
- stream_Seek( p_avi->s, i_pos );
+ stream_Seek( p_input->s, i_pos );
}
/* read thoses data */
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 );
/* 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;
*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;
}
#undef tk
}
- *pf = (double)i64 / (double)stream_Size( p_sys->s );
+ *pf = (double)i64 / (double)stream_Size( p_input->s );
return VLC_SUCCESS;
}
else
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;
}
else
{
- stream_Seek( p_avi->s, p_avi->i_movi_begin + 12 );
+ stream_Seek( p_input->s, p_avi->i_movi_begin + 12 );
}
for( ;; )
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)
****************************************************************************/
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],
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;
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;
}
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;
}
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;
}
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;
}
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( ;; )
{
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;
}
* 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
struct demux_sys_t
{
- stream_t *s;
-
mtime_t i_time;
mtime_t i_length;
mtime_t i_pcr;
* 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>
*
struct demux_sys_t
{
- stream_t *s;
-
vlc_stream_io_callback *in;
EbmlStream *es;
EbmlParser *ep;
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;
{
msg_Err( p_input, "failed to create EbmlStream" );
delete p_sys->in;
- stream_Release( p_sys->s );
free( p_sys );
return VLC_EGENERIC;
}
{
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 );
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 */
error:
delete p_sys->es;
delete p_sys->in;
- stream_Release( p_sys->s );
free( p_sys );
return VLC_EGENERIC;
}
delete p_sys->ep;
delete p_sys->es;
delete p_sys->in;
- stream_Release( p_sys->s );
free( p_sys );
}
/* 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++ )
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 )
{
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 );
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);
{
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 );
* 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
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 )
{
return VLC_SUCCESS;
error:
- stream_Release( p_demux->s );
if( p_demux->p_root )
{
MP4_BoxFree( p_input, p_demux->p_root );
//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 );
}
/* 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 );
* 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
*****************************************************************************/
struct demux_sys_t
{
- stream_t *s;
-
MP4_Box_t *p_root; /* container for the whole file */
mtime_t i_pcr;
* 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>
*
struct demux_sys_t
{
- stream_t *s;
mtime_t i_time;
int i_bitrate_avg; /* extracted from Xing header */
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;
};
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;
return VLC_SUCCESS;
error:
- if( p_sys->s )
- {
- stream_Release( p_sys->s );
- }
free( p_sys );
return VLC_EGENERIC;
}
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;
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" );
}
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;
}
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;
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 );
}
* 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>
*
struct demux_sys_t
{
- stream_t *s;
-
media_client_t *mc;
/* try to detect end of stream */
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;
{
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 )
error:
media_client_release( p_sys->mc );
- if( p_sys->s )
- {
- stream_Release( p_sys->s );
- }
free( p_sys );
return VLC_EGENERIC;
}
}
media_client_release( p_sys->mc );
- stream_Release( p_sys->s );
free( p_sys );
}
* 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>
*
struct demux_sys_t
{
- stream_t *s;
-
WAVEFORMATEX *p_wf;
es_descriptor_t *p_es;
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 ) )
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;
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' ) )
{
free( p_sys->p_wf );
}
- if( p_sys->s )
- {
- stream_Release( p_sys->s );
- }
free( p_sys );
return VLC_EGENERIC;
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)" );
}
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 )
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;
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 );
}
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;
}
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;
}
* 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>
*
/* 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;
}
}
+ /* 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 );
{
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 )
{
/* 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 );