Commit f3f41176 authored by Laurent Aimar's avatar Laurent Aimar

* all: make stream_t using function pointers (needed to have multiple

 implementations, not yet used).
parent 33464f10
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* control the pace of reading. * control the pace of reading.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2003 VideoLAN * Copyright (C) 1999, 2000, 2003 VideoLAN
* $Id: input_ext-intf.h,v 1.102 2003/12/03 13:27:51 rocky Exp $ * $Id: input_ext-intf.h,v 1.103 2004/01/26 20:48:09 fenrir Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#ifndef _VLC_INPUT_EXT_INTF_H #ifndef _VLC_INPUT_EXT_INTF_H
#define _VLC_INPUT_EXT_INTF_H 1 #define _VLC_INPUT_EXT_INTF_H 1
#include "vlc_block.h"
#include "ninput.h" #include "ninput.h"
/* /*
...@@ -237,9 +238,8 @@ struct stream_descriptor_t ...@@ -237,9 +238,8 @@ struct stream_descriptor_t
int b_new_mute; /* int because it can be -1 */ int b_new_mute; /* int because it can be -1 */
vlc_cond_t stream_wait; /* interface -> input in case of a vlc_cond_t stream_wait; /* interface -> input in case of a
* status change request */ * status change request */
/* Demultiplexer data */ /* Demultiplexer data */
stream_sys_t * p_demux_data; void * p_demux_data;
/* Programs descriptions */ /* Programs descriptions */
unsigned int i_pgrm_number; /* size of the following array */ unsigned int i_pgrm_number; /* size of the following array */
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* but exported to plug-ins * but exported to plug-ins
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2002 VideoLAN * Copyright (C) 1999-2002 VideoLAN
* $Id: input_ext-plugins.h,v 1.46 2003/11/30 22:47:55 gbazin Exp $ * $Id: input_ext-plugins.h,v 1.47 2004/01/26 20:48:09 fenrir Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -71,6 +71,9 @@ void input_EscapeAudioDiscontinuity( input_thread_t * ); ...@@ -71,6 +71,9 @@ void input_EscapeAudioDiscontinuity( input_thread_t * );
es_out_t *input_EsOutNew( input_thread_t * ); es_out_t *input_EsOutNew( input_thread_t * );
void input_EsOutDelete( es_out_t * ); void input_EsOutDelete( es_out_t * );
stream_t *input_StreamNew( input_thread_t * );
void input_StreamDelete( stream_t * );
/***************************************************************************** /*****************************************************************************
* Prototypes from input_clock.c * Prototypes from input_clock.c
*****************************************************************************/ *****************************************************************************/
......
...@@ -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.25 2004/01/21 17:01:54 fenrir Exp $ * $Id: ninput.h,v 1.26 2004/01/26 20:48:09 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -121,41 +121,121 @@ enum stream_query_e ...@@ -121,41 +121,121 @@ enum stream_query_e
STREAM_GET_MTU, /**< arg1= int * res=cannot fail (0 if no sense)*/ STREAM_GET_MTU, /**< arg1= int * res=cannot fail (0 if no sense)*/
}; };
/* Stream */ /**
VLC_EXPORT( stream_t *, stream_OpenInput, ( input_thread_t * ) ); * stream_t definition
VLC_EXPORT( void, stream_Release, ( stream_t * ) ); */
VLC_EXPORT( int, stream_vaControl, ( stream_t *, int i_query, va_list ) ); struct stream_t
VLC_EXPORT( int, stream_Control, ( stream_t *, int i_query, ... ) ); {
VLC_EXPORT( int, stream_Read, ( stream_t *, void *p_read, int i_read ) ); VLC_COMMON_MEMBERS
VLC_EXPORT( int, stream_Peek, ( stream_t *, uint8_t **pp_peek, int i_peek ) );
VLC_EXPORT( char *, stream_ReadLine, ( stream_t * ) ); block_t *(*pf_block) ( stream_t *, int i_size );
VLC_EXPORT( block_t *, stream_Block, ( stream_t *, int i_size ) ); int (*pf_read) ( stream_t *, void *p_read, int i_read );
int (*pf_peek) ( stream_t *, uint8_t **pp_peek, int i_peek );
int (*pf_control)( stream_t *, int i_query, va_list );
stream_sys_t *p_sys;
};
/**
* Try to read "i_read" bytes into a buffer pointed by "p_read". If
* "p_read" is NULL then data are skipped instead of read. The return
* value is the real numbers of bytes read/skip. If this value is less
* than i_read that means that it's the end of the stream.
*/
static inline int stream_Read( stream_t *s, void *p_read, int i_read )
{
return s->pf_read( s, p_read, i_read );
}
/**
* Store in pp_peek a pointer to the next "i_peek" bytes in the stream
* \return The real numbers of valid bytes, if it's less
* or equal to 0, *pp_peek is invalid.
* \note pp_peek is a pointer to internal buffer and it will be invalid as
* soons as other stream_* functions are called.
* \note Due to input limitation, it could be less than i_peek without meaning
* the end of the stream (but only when you have i_peek >=
* p_input->i_bufsize)
*/
static inline int stream_Peek( stream_t *s, uint8_t **pp_peek, int i_peek )
{
return s->pf_peek( s, pp_peek, i_peek );
}
static int64_t inline stream_Tell( stream_t *s ) /**
* Use to control the "stream_t *". Look at #stream_query_e for
* possible "i_query" value and format arguments. Return VLC_SUCCESS
* if ... succeed ;) and VLC_EGENERIC if failed or unimplemented
*/
static inline int stream_vaControl( stream_t *s, int i_query, va_list args )
{
return s->pf_control( s, i_query, args );
}
static inline int stream_Control( stream_t *s, int i_query, ... )
{
va_list args;
int i_result;
va_start( args, i_query );
i_result = s->pf_control( s, i_query, args );
va_end( args );
return i_result;
}
static inline int64_t stream_Tell( stream_t *s )
{ {
int64_t i_pos; int64_t i_pos;
stream_Control( s, STREAM_GET_POSITION, &i_pos ); stream_Control( s, STREAM_GET_POSITION, &i_pos );
return i_pos; return i_pos;
} }
static int64_t inline stream_Size( stream_t *s ) static inline int64_t stream_Size( stream_t *s )
{ {
int64_t i_pos; int64_t i_pos;
stream_Control( s, STREAM_GET_SIZE, &i_pos ); stream_Control( s, STREAM_GET_SIZE, &i_pos );
return i_pos; return i_pos;
} }
static int inline stream_MTU( stream_t *s ) static inline int stream_MTU( stream_t *s )
{ {
int i_mtu; int i_mtu;
return stream_Control( s, STREAM_GET_POSITION, &i_mtu ); stream_Control( s, STREAM_GET_MTU, &i_mtu );
return i_mtu;
} }
static inline int stream_Seek( stream_t *s, int64_t i_pos )
static int inline stream_Seek( stream_t *s, int64_t i_pos )
{ {
return stream_Control( s, STREAM_SET_POSITION, i_pos ); return stream_Control( s, STREAM_SET_POSITION, i_pos );
} }
/**
* Read "i_size" bytes and store them in a block_t. If less than "i_size"
* bytes are available then return what is left and if nothing is availble,
* return NULL.
*/
static inline block_t *stream_Block( stream_t *s, int i_size )
{
if( i_size <= 0 ) return NULL;
if( s->pf_block )
{
return s->pf_block( s, i_size );
}
else
{
/* emulate block read */
block_t *p_bk = block_New( s, i_size );
if( p_bk )
{
p_bk->i_buffer = stream_Read( s, p_bk->p_buffer, i_size );
if( p_bk->i_buffer > 0 )
{
return p_bk;
}
}
if( p_bk ) block_Release( p_bk );
return NULL;
}
}
VLC_EXPORT( char *, stream_ReadLine, ( stream_t * ) );
/** /**
* @} * @}
*/ */
...@@ -165,7 +245,6 @@ static int inline stream_Seek( stream_t *s, int64_t i_pos ) ...@@ -165,7 +245,6 @@ static int inline stream_Seek( stream_t *s, int64_t i_pos )
* @{ * @{
*/ */
struct demux_t struct demux_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions * Collection of useful common types and macros definitions
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.105 2004/01/25 21:39:37 gbazin Exp $ * $Id: vlc_common.h,v 1.106 2004/01/26 20:48:09 fenrir Exp $
* *
* Authors: Samuel Hocevar <sam@via.ecp.fr> * Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -222,7 +222,6 @@ typedef struct es_sys_t es_sys_t; ...@@ -222,7 +222,6 @@ typedef struct es_sys_t es_sys_t;
typedef struct pgrm_descriptor_t pgrm_descriptor_t; typedef struct pgrm_descriptor_t pgrm_descriptor_t;
typedef struct pgrm_sys_t pgrm_sys_t; typedef struct pgrm_sys_t pgrm_sys_t;
typedef struct stream_descriptor_t stream_descriptor_t; typedef struct stream_descriptor_t stream_descriptor_t;
typedef struct stream_sys_t stream_sys_t;
/* Format */ /* Format */
typedef struct audio_format_t audio_format_t; typedef struct audio_format_t audio_format_t;
...@@ -232,7 +231,8 @@ typedef struct es_format_t es_format_t; ...@@ -232,7 +231,8 @@ typedef struct es_format_t es_format_t;
typedef struct video_palette_t video_palette_t; typedef struct video_palette_t video_palette_t;
/* NInput */ /* NInput */
typedef struct stream_t stream_t; typedef struct stream_sys_t stream_sys_t;
typedef struct stream_t stream_t;
typedef struct es_out_t es_out_t; typedef struct es_out_t es_out_t;
typedef struct es_out_id_t es_out_id_t; typedef struct es_out_id_t es_out_id_t;
typedef struct es_out_sys_t es_out_sys_t; typedef struct es_out_sys_t es_out_sys_t;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2004 VideoLAN * Copyright (C) 1998-2004 VideoLAN
* $Id: input.c,v 1.279 2004/01/26 20:26:54 gbazin Exp $ * $Id: input.c,v 1.280 2004/01/26 20:48:10 fenrir Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -736,7 +736,7 @@ static int InitThread( input_thread_t * p_input ) ...@@ -736,7 +736,7 @@ static int InitThread( input_thread_t * p_input )
} }
/* Create the stream_t facilities */ /* Create the stream_t facilities */
p_input->s = stream_OpenInput( p_input ); p_input->s = input_StreamNew( p_input );
if( p_input->s == NULL ) if( p_input->s == NULL )
{ {
/* should never occur yet */ /* should never occur yet */
...@@ -768,7 +768,7 @@ static int InitThread( input_thread_t * p_input ) ...@@ -768,7 +768,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 ); input_StreamDelete( 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 )
{ {
...@@ -945,7 +945,7 @@ static void EndThread( input_thread_t * p_input ) ...@@ -945,7 +945,7 @@ static void EndThread( input_thread_t * p_input )
} }
/* Destroy the stream_t facilities */ /* Destroy the stream_t facilities */
if( p_input->s ) stream_Release( p_input->s ); if( p_input->s ) input_StreamDelete( p_input->s );
/* Destroy es out */ /* Destroy es out */
if( p_input->p_es_out ) input_EsOutDelete( p_input->p_es_out ); if( p_input->p_es_out ) input_EsOutDelete( p_input->p_es_out );
......
This diff is collapsed.
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