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 @@
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.93 2003/08/02 15:22:07 fenrir Exp $
* $Id: input_ext-intf.h,v 1.94 2003/09/12 16:26:40 fenrir Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -313,6 +313,9 @@ struct input_thread_t
size_t i_mtu;
int i_pts_delay; /* internal caching */
/* Stream */
stream_t *s;
/* Demux module */
module_t * p_demux;
int (* pf_demux ) ( input_thread_t * );
......
......@@ -2,7 +2,7 @@
* ninput.h
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ninput.h,v 1.8 2003/09/07 22:45:16 fenrir Exp $
* $Id: ninput.h,v 1.9 2003/09/12 16:26:40 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -24,6 +24,132 @@
#ifndef _NINPUT_H
#define _NINPUT_H 1
#if 0
enum es_extra_type_e
{
ES_EXTRA_TYPE_UNKNOWN,
ES_EXTRA_TYPE_WAVEFORMATEX,
ES_EXTRA_TYPE_BITMAPINFOHEADER
};
typedef struct
{
int i_cat;
vlc_fourcc_t i_codec;
int i_group; /* eg -1. if >= 0 then a "group" (program) is
created for each value */
int i_priority; /* -2 : mean not selectable by the users
-1 : mean not selected by default even
when no other stream
>=0: priority */
char *psz_language;
char *psz_description;
struct
{
int i_samplerate;
int i_channels;
int i_bitrate;
int i_blockalign;
int i_bitspersample;
} audio;
struct
{
int i_width;
int i_height;
int i_display_width;
int i_display_height;
} video;
struct
{
char *psz_encoding;
} subs;
int i_extra_type;
int i_extra;
void *p_extra;
} es_format_t;
static inline void es_format_Init( es_format_t *fmt,
int i_cat, vlc_fourcc_t i_codec )
{
fmt->i_cat = i_cat;
fmt->i_codec = i_codec;
fmt->i_group = -1;
fmt->i_priority = 0;
fmt->psz_language = NULL;
fmt->psz_description = NULL;
fmt->audio.i_samplerate = 0;
fmt->audio.i_channels = 0;
fmt->audio.i_bitrate = 0;
fmt->audio.i_blockalign = 0;
fmt->audio.i_bitspersample = 0;
fmt->video.i_width = 0;
fmt->video.i_height = 0;
fmt->video.i_display_width = 0;
fmt->video.i_display_height = 0;
fmt->subs.psz_encoding = NULL;
fmt->i_extra_type = ES_EXTRA_TYPE_UNKNOWN;
fmt->i_extra = 0;
fmt->p_extra = NULL;
}
enum es_out_query_e
{
ES_OUT_SET_SELECT, /* arg1= es_out_id_t* arg2=vlc_bool_t */
ES_OUT_GET_SELECT /* arg1= es_out_id_t* arg2=vlc_bool_t* */
};
typedef struct es_out_t es_out_t;
typedef struct es_out_id_t es_out_id_t;
typedef struct es_out_sys_t es_out_sys_t;
struct es_out_t
{
es_out_id_t (*pf_add) ( es_out_t *, es_format_t * );
int (*pf_send) ( es_out_t *, es_out_id_t *, pes_packet_t * );
void (*pf_del) ( es_out_t *, es_out_id_t * );
int (*pf_control)( es_out_t *, int i_query, va_list );
es_out_sys_t *p_sys;
};
static inline es_out_id_t * es_out_Add( es_out_t *out, es_format_t *fmt )
{
return out->pf_add( out, fmt );
}
static inline void es_out_Del( es_out_t *out, es_out_id_t *id )
{
out->pf_del( out, id );
}
static inline int es_out_Send( es_out_t *out, es_out_id_t *id, pes_packet_t *p_pes )
{
return out->pf_send( out, id, p_pes );
}
static inline int es_out_vaControl( es_out_t *out, int i_query, va_list args )
{
return out->pf_control( out, i_query, args );
}
static inline int es_out_Control( es_out_t *out, int i_query, ... )
{
va_list args;
int i_result;
va_start( args, i_query );
i_result = es_out_vaControl( out, i_query, args );
va_end( args );
return i_result;
}
#endif
/**
* \defgroup stream Stream
*
......@@ -83,7 +209,6 @@ static int inline stream_Seek( stream_t *s, int64_t i_pos )
/**
* \defgroup demux Demux
* XXX: don't look at it yet.
* @{
*/
enum demux_query_e
......
......@@ -2,7 +2,7 @@
* a52.c : Raw a52 Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: a52sys.c,v 1.5 2003/09/07 22:48:29 fenrir Exp $
* $Id: a52sys.c,v 1.6 2003/09/12 16:26:40 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -53,7 +53,6 @@ static int Demux ( input_thread_t * );
struct demux_sys_t
{
stream_t *s;
mtime_t i_time;
es_descriptor_t *p_es;
......@@ -132,13 +131,7 @@ static int Open( vlc_object_t * p_this )
p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
p_sys->i_time = 0;
if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL )
{
msg_Err( p_input, "cannot create stream" );
goto error;
}
if( stream_Peek( p_sys->s, &p_peek, 6 ) < 6 )
if( stream_Peek( p_input->s, &p_peek, 6 ) < 6 )
{
msg_Err( p_input, "cannot peek" );
goto error;
......@@ -198,10 +191,6 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS;
error:
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys );
return VLC_EGENERIC;
}
......@@ -221,7 +210,7 @@ static int Demux( input_thread_t * p_input )
uint8_t *p_peek;
if( stream_Peek( p_sys->s, &p_peek, 6 ) < 6 )
if( stream_Peek( p_input->s, &p_peek, 6 ) < 6 )
{
msg_Warn( p_input, "cannot peek" );
return 0;
......@@ -234,7 +223,7 @@ static int Demux( input_thread_t * p_input )
int i_skip = 0;
int i_peek;
i_peek = stream_Peek( p_sys->s, &p_peek, 8096 );
i_peek = stream_Peek( p_input->s, &p_peek, 8096 );
if( i_peek < 8 )
{
msg_Warn( p_input, "cannot peek" );
......@@ -255,7 +244,7 @@ static int Demux( input_thread_t * p_input )
}
msg_Warn( p_input, "garbage=%d bytes", i_skip );
stream_Read( p_sys->s, NULL, i_skip );
stream_Read( p_input->s, NULL, i_skip );
return 1;
}
......@@ -265,7 +254,7 @@ static int Demux( input_thread_t * p_input )
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
if( ( p_pes = stream_PesPacket( p_sys->s, i_frame_size ) ) == NULL )
if( ( p_pes = stream_PesPacket( p_input->s, i_frame_size ) ) == NULL )
{
msg_Warn( p_input, "cannot read data" );
return 0;
......@@ -298,10 +287,6 @@ static void Close( vlc_object_t * p_this )
input_thread_t *p_input = (input_thread_t*)p_this;
demux_sys_t *p_sys = p_input->p_demux_data;
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys );
}
......
......@@ -2,7 +2,7 @@
* aac.c : Raw aac Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: aac.c,v 1.3 2003/09/07 22:48:29 fenrir Exp $
* $Id: aac.c,v 1.4 2003/09/12 16:26:40 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -54,7 +54,6 @@ static int Demux ( input_thread_t * );
struct demux_sys_t
{
stream_t *s;
mtime_t i_time;
es_descriptor_t *p_es;
......@@ -139,14 +138,8 @@ static int Open( vlc_object_t * p_this )
p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
p_sys->i_time = 0;
if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL )
{
msg_Err( p_input, "cannot create stream" );
goto error;
}
/* peek the begining (10 is for adts header) */
if( stream_Peek( p_sys->s, &p_peek, 10 ) < 10 )
if( stream_Peek( p_input->s, &p_peek, 10 ) < 10 )
{
msg_Err( p_input, "cannot peek" );
goto error;
......@@ -213,10 +206,6 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS;
error:
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys );
return VLC_EGENERIC;
}
......@@ -235,7 +224,7 @@ static int Demux( input_thread_t * p_input )
uint8_t h[8];
uint8_t *p_peek;
if( stream_Peek( p_sys->s, &p_peek, 8 ) < 8 )
if( stream_Peek( p_input->s, &p_peek, 8 ) < 8 )
{
msg_Warn( p_input, "cannot peek" );
return 0;
......@@ -248,7 +237,7 @@ static int Demux( input_thread_t * p_input )
int i_skip = 0;
int i_peek;
i_peek = stream_Peek( p_sys->s, &p_peek, 8096 );
i_peek = stream_Peek( p_input->s, &p_peek, 8096 );
if( i_peek < 8 )
{
msg_Warn( p_input, "cannot peek" );
......@@ -269,7 +258,7 @@ static int Demux( input_thread_t * p_input )
}
msg_Warn( p_input, "garbage=%d bytes", i_skip );
stream_Read( p_sys->s, NULL, i_skip );
stream_Read( p_input->s, NULL, i_skip );
return 1;
}
......@@ -279,7 +268,7 @@ static int Demux( input_thread_t * p_input )
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
if( ( p_pes = stream_PesPacket( p_sys->s, AAC_FRAME_SIZE( h ) ) ) == NULL )
if( ( p_pes = stream_PesPacket( p_input->s, AAC_FRAME_SIZE( h ) ) )==NULL )
{
msg_Warn( p_input, "cannot read data" );
return 0;
......@@ -312,10 +301,6 @@ static void Close( vlc_object_t * p_this )
input_thread_t *p_input = (input_thread_t*)p_this;
demux_sys_t *p_sys = p_input->p_demux_data;
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys );
}
......@@ -2,7 +2,7 @@
* asf.c : ASFv01 file input module for vlc
*****************************************************************************
* Copyright (C) 2002-2003 VideoLAN
* $Id: asf.c,v 1.37 2003/09/07 22:48:29 fenrir Exp $
* $Id: asf.c,v 1.38 2003/09/12 16:26:40 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -76,8 +76,6 @@ struct demux_sys_t
int64_t i_data_begin;
int64_t i_data_end;
stream_t *s;
};
static mtime_t GetMoviePTS( demux_sys_t * );
......@@ -123,20 +121,11 @@ static int Open( vlc_object_t * p_this )
p_sys->i_time = -1;
p_sys->i_length = 0;
/* Create stream facilities */
if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL )
{
msg_Err( p_input, "cannot create stream" );
free( p_sys );
return VLC_EGENERIC;
}
/* Now load all object ( except raw data ) */
stream_Control( p_sys->s, STREAM_CAN_FASTSEEK, &b_seekable );
if( (p_sys->p_root = ASF_ReadObjectRoot( p_sys->s, b_seekable )) == NULL )
stream_Control( p_input->s, STREAM_CAN_FASTSEEK, &b_seekable );
if( (p_sys->p_root = ASF_ReadObjectRoot( p_input->s, b_seekable )) == NULL )
{
msg_Warn( p_input, "ASF plugin discarded (not a valid file)" );
stream_Release( p_sys->s );
free( p_sys );
return VLC_EGENERIC;
}
......@@ -328,13 +317,13 @@ static int Open( vlc_object_t * p_this )
/* go to first packet */
stream_Seek( p_sys->s, p_sys->i_data_begin );
stream_Seek( p_input->s, p_sys->i_data_begin );
/* try to calculate movie time */
if( p_sys->p_fp->i_data_packets_count > 0 )
{
int64_t i_count;
int64_t i_size = stream_Size( p_sys->s );
int64_t i_size = stream_Size( p_input->s );
if( p_sys->i_data_end > 0 && i_size > p_sys->i_data_end )
{
......@@ -446,8 +435,7 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS;
error:
ASF_FreeObjectRoot( p_sys->s, p_sys->p_root );
stream_Release( p_sys->s );
ASF_FreeObjectRoot( p_input->s, p_sys->p_root );
free( p_sys );
return VLC_EGENERIC;
}
......@@ -486,7 +474,7 @@ static int Demux( input_thread_t *p_input )
msleep( p_input->i_pts_delay );
i_offset = stream_Tell( p_sys->s ) - p_sys->i_data_begin;
i_offset = stream_Tell( p_input->s ) - p_sys->i_data_begin;
if( i_offset < 0 )
{
i_offset = 0;
......@@ -496,7 +484,7 @@ static int Demux( input_thread_t *p_input )
i_offset -= i_offset % p_sys->p_fp->i_min_data_packet_size;
}
if( stream_Seek( p_sys->s, i_offset + p_sys->i_data_begin ) )
if( stream_Seek( p_input->s, i_offset + p_sys->i_data_begin ) )
{
msg_Warn( p_input, "cannot resynch after seek (EOF?)" );
return -1;
......@@ -568,7 +556,7 @@ static void Close( vlc_object_t * p_this )
msg_Dbg( p_input, "Freeing all memory" );
ASF_FreeObjectRoot( p_sys->s, p_sys->p_root );
ASF_FreeObjectRoot( p_input->s, p_sys->p_root );
for( i_stream = 0; i_stream < 128; i_stream++ )
{
#define p_stream p_sys->stream[i_stream]
......@@ -582,7 +570,6 @@ static void Close( vlc_object_t * p_this )
}
#undef p_stream
}
stream_Release( p_sys->s );
free( p_sys );
}
......@@ -649,7 +636,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
int i_payload_length_type;
if( stream_Peek( p_sys->s, &p_peek, i_data_packet_min ) < i_data_packet_min )
if( stream_Peek( p_input->s, &p_peek,i_data_packet_min)<i_data_packet_min )
{
// EOF ?
msg_Warn( p_input, "cannot peek while getting new packet, EOF ?" );
......@@ -881,7 +868,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
}
i_read = i_sub_payload_data_length + i_skip;
if((p_data = stream_DataPacket( p_sys->s,i_read,VLC_TRUE)) == NULL)
if((p_data = stream_DataPacket( p_input->s,i_read,VLC_TRUE))==NULL)
{
msg_Warn( p_input, "cannot read data" );
return( 0 );
......@@ -905,7 +892,8 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
i_skip = 0;
if( i_packet_size_left > 0 )
{
if( stream_Peek( p_sys->s, &p_peek, i_packet_size_left ) < i_packet_size_left )
if( stream_Peek( p_input->s, &p_peek, i_packet_size_left )
< i_packet_size_left )
{
// EOF ?
msg_Warn( p_input, "cannot peek, EOF ?" );
......@@ -917,7 +905,8 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
if( i_packet_size_left > 0 )
{
if( stream_Read( p_sys->s, NULL, i_packet_size_left ) < i_packet_size_left )
if( stream_Read( p_input->s, NULL, i_packet_size_left )
< i_packet_size_left )
{
msg_Warn( p_input, "cannot skip data, EOF ?" );
return( 0 );
......@@ -933,7 +922,7 @@ loop_error_recovery:
msg_Err( p_input, "unsupported packet header, fatal error" );
return( -1 );
}
stream_Read( p_sys->s, NULL, i_data_packet_min );
stream_Read( p_input->s, NULL, i_data_packet_min );
return( 1 );
}
......
......@@ -2,7 +2,7 @@
* au.c : au file input module for vlc
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: au.c,v 1.6 2003/09/07 22:48:29 fenrir Exp $
* $Id: au.c,v 1.7 2003/09/12 16:26:40 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -92,8 +92,6 @@ typedef struct
struct demux_sys_t
{
stream_t *s;
au_t au;
WAVEFORMATEX wf;
......@@ -135,18 +133,11 @@ static int Open( vlc_object_t * p_this )
p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
p_sys->i_time = 0;
if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL )
{
msg_Err( p_input, "cannot create stream" );
goto error;
}
/* skip signature */
stream_Read( p_sys->s, NULL, 4 ); /* cannot fail */
stream_Read( p_input->s, NULL, 4 ); /* cannot fail */
/* read header */
if( stream_Read( p_sys->s, &p_sys->au, sizeof( au_t ) ) < (int)sizeof( au_t ) )
if( stream_Read( p_input->s, &p_sys->au, sizeof(au_t) )<(int)sizeof(au_t) )
{
msg_Err( p_input, "cannot load header" );
goto error;
......@@ -174,7 +165,8 @@ static int Open( vlc_object_t * p_this )
/* skip extra header data */
if( p_sys->au.i_header_size > 4 + sizeof( au_t ) )
{
stream_Read( p_sys->s, NULL, p_sys->au.i_header_size - 4 - sizeof( au_t ) );
stream_Read( p_input->s,
NULL, p_sys->au.i_header_size - 4 - sizeof( au_t ) );
}
/* Create WAVEFORMATEX structure */
......@@ -356,10 +348,6 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS;
error:
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys );
return VLC_EGENERIC;
}
......@@ -376,12 +364,12 @@ static int DemuxPCM( input_thread_t *p_input )
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
{
int64_t i_pos = stream_Tell( p_sys->s );
int64_t i_pos = stream_Tell( p_input->s );
if( p_sys->wf.nBlockAlign != 0 )
{
i_pos += p_sys->wf.nBlockAlign - i_pos % p_sys->wf.nBlockAlign;
if( stream_Seek( p_sys->s, i_pos ) )
if( stream_Seek( p_input->s, i_pos ) )
{
msg_Err( p_input, "Seek failed(cannot resync)" );
}
......@@ -392,7 +380,7 @@ static int DemuxPCM( input_thread_t *p_input )
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
if( ( p_pes = stream_PesPacket( p_sys->s, p_sys->i_frame_size ) ) == NULL )
if( ( p_pes = stream_PesPacket( p_input->s, p_sys->i_frame_size ) )==NULL )
{
msg_Warn( p_input, "cannot read data" );
return 0;
......@@ -422,7 +410,6 @@ static void Close( vlc_object_t * p_this )
input_thread_t *p_input = (input_thread_t *)p_this;
demux_sys_t *p_sys = p_input->p_demux_data;
stream_Release( p_sys->s );
free( p_sys );
}
This diff is collapsed.
......@@ -2,7 +2,7 @@
* avi.h : AVI file Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: avi.h,v 1.13 2003/08/22 22:52:48 fenrir Exp $
* $Id: avi.h,v 1.14 2003/09/12 16:26:40 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -69,8 +69,6 @@ typedef struct avi_stream_s
struct demux_sys_t
{
stream_t *s;
mtime_t i_time;
mtime_t i_length;
mtime_t i_pcr;
......
......@@ -2,7 +2,7 @@
* mkv.cpp : matroska demuxer
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mkv.cpp,v 1.26 2003/09/07 22:48:29 fenrir Exp $
* $Id: mkv.cpp,v 1.27 2003/09/12 16:26:40 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -233,8 +233,6 @@ typedef struct
struct demux_sys_t
{
stream_t *s;
vlc_stream_io_callback *in;
EbmlStream *es;
EbmlParser *ep;
......@@ -321,13 +319,7 @@ static int Open( vlc_object_t * p_this )
p_input->p_demux_data = p_sys = (demux_sys_t*)malloc(sizeof( demux_sys_t ));
memset( p_sys, 0, sizeof( demux_sys_t ) );
if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL )
{
msg_Err( p_input, "cannot create stream" );
free( p_sys );
return VLC_EGENERIC;
}
p_sys->in = new vlc_stream_io_callback( p_sys->s );
p_sys->in = new vlc_stream_io_callback( p_input->s );
p_sys->es = new EbmlStream( *p_sys->in );
p_sys->f_duration = -1;
p_sys->i_timescale = MKVD_TIMECODESCALE;
......@@ -354,7 +346,6 @@ static int Open( vlc_object_t * p_this )
{
msg_Err( p_input, "failed to create EbmlStream" );
delete p_sys->in;
stream_Release( p_sys->s );
free( p_sys );
return VLC_EGENERIC;
}
......@@ -992,7 +983,7 @@ static int Open( vlc_object_t * p_this )
{
vlc_bool_t b_seekable;
stream_Control( p_sys->s, STREAM_CAN_FASTSEEK, &b_seekable );
stream_Control( p_input->s, STREAM_CAN_FASTSEEK, &b_seekable );
if( b_seekable )
{
LoadCues( p_input );
......@@ -1029,7 +1020,7 @@ static int Open( vlc_object_t * p_this )
if( p_sys->f_duration > 1001.0 )
{
mtime_t i_duration = (mtime_t)( p_sys->f_duration / 1000.0 );
p_input->stream.i_mux_rate = stream_Size( p_sys->s ) / 50 / i_duration;
p_input->stream.i_mux_rate = stream_Size( p_input->s )/50 / i_duration;
}
/* add all es */
......@@ -1320,7 +1311,6 @@ static int Open( vlc_object_t * p_this )
error:
delete p_sys->es;
delete p_sys->in;
stream_Release( p_sys->s );
free( p_sys );
return VLC_EGENERIC;
}
......@@ -1364,7 +1354,6 @@ static void Close( vlc_object_t *p_this )
delete p_sys->ep;
delete p_sys->es;
delete p_sys->in;
stream_Release( p_sys->s );
free( p_sys );
}
......@@ -1696,7 +1685,7 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent)
/* seek without index or without date */
if( config_GetInt( p_input, "mkv-seek-percent" ) || !p_sys->b_cues || i_date < 0 )
{
int64_t i_pos = i_percent * stream_Size( p_sys->s ) / 100;
int64_t i_pos = i_percent * stream_Size( p_input->s ) / 100;
msg_Dbg( p_input, "imprecise way of seeking" );
for( i_index = 0; i_index < p_sys->i_index; i_index++ )
......@@ -1711,7 +1700,8 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent)
i_index--;
}
p_sys->in->setFilePointer( p_sys->index[i_index].i_position, seek_beginning );
p_sys->in->setFilePointer( p_sys->index[i_index].i_position,
seek_beginning );
if( p_sys->index[i_index].i_position < i_pos )
{
......@@ -1757,7 +1747,7 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent)
msg_Dbg( p_input, "seek got "I64Fd" (%d%%)",
p_sys->index[i_index].i_time,
(int)( 100 * p_sys->index[i_index].i_position /
stream_Size( p_sys->s ) ) );
stream_Size( p_input->s ) ) );
p_sys->in->setFilePointer( p_sys->index[i_index].i_position,
seek_beginning );
......@@ -1839,12 +1829,12 @@ static int Demux( input_thread_t * p_input )
i_date = (mtime_t)1000000 *
(mtime_t)i_duration*
(mtime_t)p_sys->in->getFilePointer() /
(mtime_t)stream_Size( p_sys->s );
(mtime_t)stream_Size( p_input->s );
}
if( stream_Size( p_sys->s ) > 0 )
if( stream_Size( p_input->s ) > 0 )
{
i_percent = 100 * p_sys->in->getFilePointer() /
stream_Size( p_sys->s );
stream_Size( p_input->s );
}
Seek( p_input, i_date, i_percent);
......@@ -2429,7 +2419,7 @@ static void InformationsCreate( input_thread_t *p_input )
{
vlc_bool_t b_seekable;
stream_Control( p_sys->s, STREAM_CAN_FASTSEEK, &b_seekable );
stream_Control( p_input->s, STREAM_CAN_FASTSEEK, &b_seekable );
if( b_seekable )
{
LoadTags( p_input );
......
......@@ -2,7 +2,7 @@
* mp4.c : MP4 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mp4.c,v 1.36 2003/09/08 00:35:16 fenrir Exp $
* $Id: mp4.c,v 1.37 2003/09/12 16:26:40 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -142,14 +142,6 @@ static int Open( vlc_object_t * p_this )
p_input->p_demux_data = p_demux = malloc( sizeof( demux_sys_t ) );
memset( p_demux, 0, sizeof( demux_sys_t ) );
/* Create stream facilities */
if( ( p_demux->s= stream_OpenInput( p_input ) ) == NULL )
{
msg_Err( p_input, "cannot create stream_t" );
free( p_demux );
return VLC_EGENERIC;
}
/* Now load all boxes ( except raw data ) */
if( ( p_demux->p_root = MP4_BoxGetRoot( p_input ) ) == NULL )
{
......@@ -398,7 +390,6 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS;
error:
stream_Release( p_demux->s );
if( p_demux->p_root )
{
MP4_BoxFree( p_input, p_demux->p_root );
......@@ -513,7 +504,7 @@ static int Demux( input_thread_t *p_input )
//msg_Dbg( p_input, "stream %d size=%6d pos=%8lld", i_track, i_size, i_pos );
/* go,go go ! */
if( stream_Seek( p_demux->s, i_pos ) )
if( stream_Seek( p_input->s, i_pos ) )
{
msg_Warn( p_input, "track[0x%x] will be disabled (eof?)", track.i_track_ID );
MP4_TrackUnselect( p_input, &track );
......@@ -521,7 +512,7 @@ static int Demux( input_thread_t *p_input )
}
/* now read pes */
if( ( p_pes = stream_PesPacket( p_demux->s, i_size ) ) == NULL )
if( ( p_pes = stream_PesPacket( p_input->s, i_size ) ) == NULL )
{
msg_Warn( p_input, "track[0x%x] will be disabled (eof?)", track.i_track_ID );
MP4_TrackUnselect( p_input, &track );
......
......@@ -2,7 +2,7 @@
* mp4.h : MP4 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mp4.h,v 1.7 2003/09/08 00:35:16 fenrir Exp $
* $Id: mp4.h,v 1.8 2003/09/12 16:26:40 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -127,8 +127,6 @@ typedef struct track_data_mp4_s
*****************************************************************************/
struct demux_sys_t
{
stream_t *s;
MP4_Box_t *p_root; /* container for the whole file */
mtime_t i_pcr;
......
......@@ -2,7 +2,7 @@
* mpga.c : MPEG-I/II Audio input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mpga.c,v 1.4 2003/09/10 21:56:44 fenrir Exp $
* $Id: mpga.c,v 1.5 2003/09/12 16:26:40 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -54,7 +54,6 @@ static int Demux ( input_thread_t * );
struct demux_sys_t
{
stream_t *s;
mtime_t i_time;
int i_bitrate_avg; /* extracted from Xing header */
......@@ -241,12 +240,6 @@ static int Open( vlc_object_t * p_this )
p_sys->i_time = 0;
p_sys->i_bitrate_avg = 0;
if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL )
{
msg_Err( p_input, "cannot create stream" );
goto error;
}
if( HeaderCheck( header ) )
{
int i_xing;
......@@ -259,7 +252,7 @@ static int Open( vlc_object_t * p_this )
};
p_sys->i_bitrate_avg = MPGA_BITRATE( header ) * 1000;
if( ( i_xing = stream_Peek( p_sys->s, &p_xing, 1024 ) ) >= 21 )
if( ( i_xing = stream_Peek( p_input->s, &p_xing, 1024 ) ) >= 21 )
{
int i_skip;
......@@ -366,10 +359,6 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS;
error:
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys );
return VLC_EGENERIC;
}
......@@ -388,7 +377,7 @@ static int Demux( input_thread_t * p_input )
uint32_t header;
uint8_t *p_peek;
if( stream_Peek( p_sys->s, &p_peek, 4 ) < 4 )
if( stream_Peek( p_input->s, &p_peek, 4 ) < 4 )
{
msg_Warn( p_input, "cannot peek" );
return 0;
......@@ -401,7 +390,7 @@ static int Demux( input_thread_t * p_input )
int i_skip = 0;
int i_peek;
i_peek = stream_Peek( p_sys->s, &p_peek, 8096 );
i_peek = stream_Peek( p_input->s, &p_peek, 8096 );
if( i_peek < 4 )
{
msg_Warn( p_input, "cannot peek" );
......@@ -422,7 +411,7 @@ static int Demux( input_thread_t * p_input )
}
msg_Warn( p_input, "garbage=%d bytes", i_skip );
stream_Read( p_sys->s, NULL, i_skip );
stream_Read( p_input->s, NULL, i_skip );
return 1;
}
......@@ -430,7 +419,8 @@ static int Demux( input_thread_t * p_input )
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
if( ( p_pes = stream_PesPacket( p_sys->s, mpga_frame_size( header ) ) ) == NULL )
if( ( p_pes = stream_PesPacket( p_input->s, mpga_frame_size( header ) ) )
== NULL )
{
msg_Warn( p_input, "cannot read data" );
return 0;
......@@ -463,10 +453,6 @@ static void Close( vlc_object_t * p_this )
input_thread_t *p_input = (input_thread_t*)p_this;
demux_sys_t *p_sys = p_input->p_demux_data;
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys );
}
......@@ -2,7 +2,7 @@
* sdp.c: SDP parser and builtin UDP/RTP/RTSP
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: sdp.c,v 1.10 2003/09/10 11:51:00 fenrir Exp $
* $Id: sdp.c,v 1.11 2003/09/12 16:26:40 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -75,8 +75,6 @@ struct access_sys_t
struct demux_sys_t
{
stream_t *s;
media_client_t *mc;
/* try to detect end of stream */
......@@ -255,11 +253,6 @@ static int SDPOpen( vlc_object_t * p_this )
var_Create( p_input, "rtsp-tcp", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
var_Get( p_input, "rtsp-tcp", &val );
p_sys->mc = media_client_create( val.b_bool ? 1 : 0 );
if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL )
{
msg_Err( p_input, "cannot create stream" );
goto error;
}
p_sys->i_no_data = 0;
p_sys->b_received_data = VLC_FALSE;
......@@ -271,7 +264,8 @@ static int SDPOpen( vlc_object_t * p_this )
{
int i_read;
i_read = stream_Read( p_sys->s, &psz_sdp[i_sdp], i_sdp_max - i_sdp -1 );
i_read = stream_Read( p_input->s,
&psz_sdp[i_sdp], i_sdp_max - i_sdp -1 );
if( i_read < i_sdp_max - i_sdp -1 )
{
if( i_read > 0 )
......@@ -342,10 +336,6 @@ static int SDPOpen( vlc_object_t * p_this )
error:
media_client_release( p_sys->mc );
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys );
return VLC_EGENERIC;
}
......@@ -377,7 +367,6 @@ static void SDPClose( vlc_object_t * p_this )
}
media_client_release( p_sys->mc );
stream_Release( p_sys->s );
free( p_sys );
}
......
......@@ -2,7 +2,7 @@
* wav.c : wav file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: wav.c,v 1.6 2003/09/07 22:48:29 fenrir Exp $
* $Id: wav.c,v 1.7 2003/09/12 16:26:40 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -52,8 +52,6 @@ static int Demux ( input_thread_t * );
struct demux_sys_t
{
stream_t *s;
WAVEFORMATEX *p_wf;
es_descriptor_t *p_es;
......@@ -109,14 +107,8 @@ static int Open( vlc_object_t * p_this )
p_sys->p_es = NULL;
p_sys->i_time = 0;
if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL )
{
msg_Err( p_input, "cannot create stream" );
goto error;
}
/* skip riff header */
stream_Read( p_sys->s, NULL, 12 ); /* cannot fail as peek succeed */
stream_Read( p_input->s, NULL, 12 ); /* cannot fail as peek succeed */
/* search fmt chunk */
if( ChunkFind( p_input, "fmt ", &i_size ) )
......@@ -129,12 +121,13 @@ static int Open( vlc_object_t * p_this )
msg_Err( p_input, "invalid 'fmt ' chunk" );
goto error;
}
stream_Read( p_sys->s, NULL, 8 ); /* cannot fail */
stream_Read( p_input->s, NULL, 8 ); /* cannot fail */
/* load waveformatex */
p_sys->p_wf = malloc( __EVEN( i_size ) + 2 ); /* +2, for raw audio -> no cbSize */
p_sys->p_wf->cbSize = 0;
if( stream_Read( p_sys->s, p_sys->p_wf, __EVEN( i_size ) ) < (int)__EVEN( i_size ) )
if( stream_Read( p_input->s,
p_sys->p_wf, __EVEN( i_size ) ) < (int)__EVEN( i_size ) )
{
msg_Err( p_input, "cannot load 'fmt ' chunk" );
goto error;
......@@ -164,9 +157,9 @@ static int Open( vlc_object_t * p_this )
goto error;
}
p_sys->i_data_pos = stream_Tell( p_sys->s );
p_sys->i_data_pos = stream_Tell( p_input->s );
stream_Read( p_sys->s, NULL, 8 ); /* cannot fail */
stream_Read( p_input->s, NULL, 8 ); /* cannot fail */
wf_tag_to_fourcc( p_sys->p_wf->wFormatTag, &i_fourcc, &psz_name );
if( i_fourcc == VLC_FOURCC( 'u', 'n', 'd', 'f' ) )
......@@ -254,10 +247,6 @@ relay:
{
free( p_sys->p_wf );
}
if( p_sys->s )
{
stream_Release( p_sys->s );
}
free( p_sys );
return VLC_EGENERIC;
......@@ -276,11 +265,11 @@ static int Demux( input_thread_t *p_input )
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
{
i_pos = stream_Tell( p_sys->s );
i_pos = stream_Tell( p_input->s );
if( p_sys->p_wf->nBlockAlign != 0 )
{
i_pos += p_sys->p_wf->nBlockAlign - i_pos % p_sys->p_wf->nBlockAlign;
if( stream_Seek( p_sys->s, i_pos ) )
if( stream_Seek( p_input->s, i_pos ) )
{
msg_Err( p_input, "stream_Sekk failed (cannot resync)" );
}
......@@ -291,7 +280,7 @@ static int Demux( input_thread_t *p_input )
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
i_pos = stream_Tell( p_sys->s );
i_pos = stream_Tell( p_input->s );
if( p_sys->i_data_size > 0 &&
i_pos >= p_sys->i_data_pos + p_sys->i_data_size )
......@@ -300,7 +289,7 @@ static int Demux( input_thread_t *p_input )
return 0;
}
if( ( p_pes = stream_PesPacket( p_sys->s, p_sys->i_frame_size ) ) == NULL )
if( ( p_pes = stream_PesPacket( p_input->s, p_sys->i_frame_size ) )==NULL )
{
msg_Warn( p_input, "cannot read data" );
return 0;
......@@ -330,7 +319,6 @@ static void Close ( vlc_object_t * p_this )
input_thread_t *p_input = (input_thread_t *)p_this;
demux_sys_t *p_sys = p_input->p_demux_data;
stream_Release( p_sys->s );
free( p_sys->p_wf );
free( p_sys );
}
......@@ -342,14 +330,13 @@ static void Close ( vlc_object_t * p_this )
static int ChunkFind( input_thread_t *p_input,
char *fcc, unsigned int *pi_size )
{
demux_sys_t *p_sys = p_input->p_demux_data;
uint8_t *p_peek;
for( ;; )
{
int i_size;
if( stream_Peek( p_sys->s, &p_peek, 8 ) < 8 )
if( stream_Peek( p_input->s, &p_peek, 8 ) < 8 )
{
msg_Err( p_input, "cannot peek()" );
return VLC_EGENERIC;
......@@ -369,7 +356,7 @@ static int ChunkFind( input_thread_t *p_input,
}
i_size = __EVEN( i_size ) + 8;
if( stream_Read( p_sys->s, NULL, i_size ) != i_size )
if( stream_Read( p_input->s, NULL, i_size ) != i_size )
{
return VLC_EGENERIC;
}
......
......@@ -4,7 +4,7 @@
* decoders.
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: input.c,v 1.237 2003/09/07 22:51:11 fenrir Exp $
* $Id: input.c,v 1.238 2003/09/12 16:26:40 fenrir Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -152,6 +152,9 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
/* Set target */
p_input->psz_source = strdup( p_item->psz_uri );
/* Stream */
p_input->s = NULL;
/* Demux */
p_input->p_demux = NULL;
p_input->pf_demux = NULL;
......@@ -626,6 +629,21 @@ static int InitThread( input_thread_t * p_input )
}
}
/* Create the stream_t facilities */
p_input->s = stream_OpenInput( p_input );
if( p_input->s == NULL )
{
/* should nver occur yet */
msg_Err( p_input, "cannot create stream_t !" );
module_Unneed( p_input, p_input->p_access );
if ( p_input->stream.p_sout != NULL )
{
sout_DeleteInstance( p_input->stream.p_sout );
}
return VLC_EGENERIC;
}
/* Find and open appropriate demux module */
p_input->p_demux = module_Need( p_input, "demux",
p_input->psz_demux );
......@@ -634,6 +652,7 @@ static int InitThread( input_thread_t * p_input )
{
msg_Err( p_input, "no suitable demux module for `%s/%s://%s'",
p_input->psz_access, p_input->psz_demux, p_input->psz_name );
stream_Release( p_input->s );
module_Unneed( p_input, p_input->p_access );
if ( p_input->stream.p_sout != NULL )
{
......@@ -707,6 +726,9 @@ static void EndThread( input_thread_t * p_input )
/* Free demultiplexer's data */
module_Unneed( p_input, p_input->p_demux );
/* Destroy the stream_t facilities */
stream_Release( p_input->s );
/* Close the access plug-in */
module_Unneed( p_input, p_input->p_access );
......
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