* input_ext-plugins.h: structures of the input not exported to other modules,
* but exported to plug-ins
*****************************************************************************
- * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: input_ext-plugins.h,v 1.3 2001/11/11 01:32:03 stef Exp $
+ * Copyright (C) 1999-2002 VideoLAN
+ * $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
*/
/* FIXME: you've gotta move this move this, you've gotta move this move this */
-#define INPUT_READ_ONCE 7 /* We live in a world dominated by Ethernet. *
- * Ethernet MTU is 1500 bytes, so in a UDP *
- * packet we can put : 1500/188 = 7 TS *
- * packets. Have a nice day and merry Xmas. */
#define PADDING_PACKET_SIZE 188 /* Size of the NULL packet inserted in case
* of data loss (this should be < 188). */
#define PADDING_PACKET_NUMBER 10 /* Number of padding packets top insert to
* escape a decoder. */
+#define INPUT_DEFAULT_BUFSIZE 65536 /* Default buffer size to use when none
+ * is natural. */
#define NO_SEEK -1
-/*****************************************************************************
- * Prototypes from input_ext-dec.c
- *****************************************************************************/
-void InitBitstream ( struct bit_stream_s *, struct decoder_fifo_s *,
- void (* pf_bitstream_callback)( struct bit_stream_s *,
- boolean_t ),
- void * p_callback_arg );
-void NextDataPacket ( struct bit_stream_s * );
-
/*****************************************************************************
* Prototypes from input_programs.c
*****************************************************************************/
-int input_InitStream( struct input_thread_s *, size_t );
-void input_EndStream ( struct input_thread_s * );
-struct pgrm_descriptor_s * input_FindProgram( struct input_thread_s *, u16 );
-struct pgrm_descriptor_s * input_AddProgram ( struct input_thread_s *,
- u16, size_t );
-void input_DelProgram( struct input_thread_s *, struct pgrm_descriptor_s * );
-struct input_area_s * input_AddArea( struct input_thread_s * );
-void input_DelArea ( struct input_thread_s *, struct input_area_s * );
-struct es_descriptor_s * input_FindES( struct input_thread_s *, u16 );
-struct es_descriptor_s * input_AddES ( struct input_thread_s *,
- struct pgrm_descriptor_s *, u16,
- size_t );
-void input_DelES ( struct input_thread_s *, struct es_descriptor_s * );
-int input_SelectES ( struct input_thread_s *, struct es_descriptor_s * );
-int input_UnselectES( struct input_thread_s *, struct es_descriptor_s * );
+VLC_EXPORT( int, input_InitStream,( input_thread_t *, size_t ) );
+VLC_EXPORT( void, input_EndStream, ( input_thread_t * ) );
+VLC_EXPORT( pgrm_descriptor_t *, input_FindProgram,( input_thread_t *, uint16_t ) );
+VLC_EXPORT( pgrm_descriptor_t *, input_AddProgram, ( input_thread_t *, uint16_t, size_t ) );
+VLC_EXPORT( void, input_DelProgram,( input_thread_t *, pgrm_descriptor_t * ) );
+VLC_EXPORT( int, input_SetProgram,( input_thread_t *, pgrm_descriptor_t * ) );
+VLC_EXPORT( input_area_t *, input_AddArea,( input_thread_t *, uint16_t, uint16_t ) );
+VLC_EXPORT( void, input_DelArea, ( input_thread_t *, input_area_t * ) );
+VLC_EXPORT( es_descriptor_t *, input_FindES,( input_thread_t *, uint16_t ) );
+VLC_EXPORT( es_descriptor_t *, input_AddES, ( input_thread_t *, pgrm_descriptor_t *, uint16_t, int, char const *, size_t ) );
+VLC_EXPORT( void, input_DelES, ( input_thread_t *, es_descriptor_t * ) );
+VLC_EXPORT( int, input_SelectES, ( input_thread_t *, es_descriptor_t * ) );
+VLC_EXPORT( int, input_UnselectES,( input_thread_t *, es_descriptor_t * ) );
/*****************************************************************************
* Prototypes from input_dec.c
*****************************************************************************/
-//decoder_capabilities_s * input_ProbeDecoder( void );
-vlc_thread_t input_RunDecoder( struct decoder_capabilities_s *, void * );
-void input_EndDecoder( struct input_thread_s *, struct es_descriptor_s * );
-void input_DecodePES ( struct decoder_fifo_s *, struct pes_packet_s * );
-void input_EscapeDiscontinuity( struct input_thread_s *,
- struct pgrm_descriptor_s * );
-void input_EscapeAudioDiscontinuity( struct input_thread_s * );
+VLC_EXPORT( decoder_t *, input_RunDecoder, ( input_thread_t *, es_descriptor_t * ) );
+VLC_EXPORT( void, input_EndDecoder, ( input_thread_t *, es_descriptor_t * ) );
-/*****************************************************************************
- * Prototypes from input_clock.c
- *****************************************************************************/
-void input_ClockInit( struct pgrm_descriptor_s * );
-int input_ClockManageControl( struct input_thread_s *,
- struct pgrm_descriptor_s *, mtime_t );
-void input_ClockManageRef( struct input_thread_s *,
- struct pgrm_descriptor_s *, mtime_t );
-mtime_t input_ClockGetTS( struct input_thread_s *,
- struct pgrm_descriptor_s *, mtime_t );
+VLC_EXPORT( void, input_DecodePES, ( decoder_t *, pes_packet_t * ) );
+VLC_EXPORT( void, input_DecodeBlock,( decoder_t *, block_t * ) );
+
+void input_EscapeDiscontinuity( input_thread_t * );
+void input_EscapeAudioDiscontinuity( input_thread_t * );
/*****************************************************************************
- * Create a NULL packet for padding in case of a data loss
+ * Prototypes from es_out.c
*****************************************************************************/
-static __inline__ void input_NullPacket( input_thread_t * p_input,
- es_descriptor_t * p_es )
-{
- data_packet_t * p_pad_data;
- pes_packet_t * p_pes;
+/* input internal use only */
+es_out_t *input_EsOutNew( input_thread_t * );
+void input_EsOutDelete( es_out_t * );
- if( (p_pad_data = p_input->pf_new_packet(
- p_input->p_method_data,
- PADDING_PACKET_SIZE )) == NULL )
- {
- intf_ErrMsg("Out of memory");
- p_input->b_error = 1;
- return;
- }
-
- memset( p_pad_data->p_buffer, 0, PADDING_PACKET_SIZE );
- p_pad_data->b_discard_payload = 1;
- p_pes = p_es->p_pes;
-
- if( p_pes != NULL )
- {
- p_pes->b_discontinuity = 1;
- p_es->p_last->p_next = p_pad_data;
- p_es->p_last = p_pad_data;
- }
- else
- {
- if( (p_pes = p_input->pf_new_pes( p_input->p_method_data )) == NULL )
- {
- intf_ErrMsg("Out of memory");
- p_input->b_error = 1;
- return;
- }
-
- p_pes->i_rate = p_input->stream.control.i_rate;
- p_pes->p_first = p_pad_data;
- p_pes->b_discontinuity = 1;
- input_DecodePES( p_es->p_decoder_fifo, p_pes );
- }
-}
-
-
-/*
- * Optional netlist management
- */
+stream_t *input_StreamNew( input_thread_t * );
+void input_StreamDelete( stream_t * );
/*****************************************************************************
- * netlist_t: structure to manage a netlist
+ * Prototypes from input_clock.c
*****************************************************************************/
-typedef struct netlist_s
-{
- vlc_mutex_t lock;
-
- size_t i_buffer_size;
-
- /* Buffers */
- byte_t * p_buffers; /* Big malloc'ed area */
- data_packet_t * p_data; /* malloc'ed area */
- pes_packet_t * p_pes; /* malloc'ed area */
-
- /* FIFOs of free packets */
- data_packet_t ** pp_free_data;
- pes_packet_t ** pp_free_pes;
- struct iovec * p_free_iovec;
-
- /* FIFO size */
- unsigned int i_nb_iovec;
- unsigned int i_nb_pes;
- unsigned int i_nb_data;
-
- /* Index */
- unsigned int i_iovec_start, i_iovec_end;
- unsigned int i_data_start, i_data_end;
- unsigned int i_pes_start, i_pes_end;
-
- /* Reference counters for iovec */
- unsigned int * pi_refcount;
-
- /* Number of blocs read once by readv */
- unsigned int i_read_once;
-} netlist_t;
+void input_ClockInit( pgrm_descriptor_t * );
+VLC_EXPORT( int, input_ClockManageControl, ( input_thread_t *, pgrm_descriptor_t *, mtime_t ) );
+VLC_EXPORT( void, input_ClockManageRef, ( input_thread_t *, pgrm_descriptor_t *, mtime_t ) );
+VLC_EXPORT( mtime_t, input_ClockGetTS, ( input_thread_t *, pgrm_descriptor_t *, mtime_t ) );
/*****************************************************************************
- * Prototypes
+ * Prototypes from input_ext-plugins.h (buffers management)
*****************************************************************************/
-int input_NetlistInit( struct input_thread_s *,
- int i_nb_iovec,
- int i_nb_data,
- int i_nb_pes,
- size_t i_buffer_size,
- int i_read_once );
-
-struct iovec * input_NetlistGetiovec( void * p_method_data );
-void input_NetlistMviovec( void * , int,
- struct data_packet_s **);
-struct data_packet_s * input_NetlistNewPtr( void * );
-struct data_packet_s * input_NetlistNewPacket( void *, size_t );
-struct pes_packet_s * input_NetlistNewPES( void * );
-void input_NetlistDeletePacket( void *,
- struct data_packet_s * );
-void input_NetlistDeletePES( void *,
- struct pes_packet_s * );
-void input_NetlistEnd( struct input_thread_s * );
-
+#define input_BuffersInit(a) __input_BuffersInit(VLC_OBJECT(a))
+void * __input_BuffersInit( vlc_object_t * );
+VLC_EXPORT( void, input_BuffersEnd, ( input_thread_t *, input_buffers_t * ) );
+
+VLC_EXPORT( data_buffer_t *, input_NewBuffer, ( input_buffers_t *, size_t ) );
+VLC_EXPORT( void, input_ReleaseBuffer, ( input_buffers_t *, data_buffer_t * ) );
+VLC_EXPORT( data_packet_t *, input_ShareBuffer, ( input_buffers_t *, data_buffer_t * ) );
+VLC_EXPORT( data_packet_t *, input_NewPacket, ( input_buffers_t *, size_t ) );
+VLC_EXPORT( void, input_DeletePacket, ( input_buffers_t *, data_packet_t * ) );
+VLC_EXPORT( pes_packet_t *, input_NewPES, ( input_buffers_t * ) );
+VLC_EXPORT( ssize_t, input_FillBuffer, ( input_thread_t * ) );
+VLC_EXPORT( ssize_t, input_Peek, ( input_thread_t *, byte_t **, size_t ) );
+VLC_EXPORT( ssize_t, input_SplitBuffer, ( input_thread_t *, data_packet_t **, size_t ) );
+VLC_EXPORT( int, input_AccessInit, ( input_thread_t * ) );
+VLC_EXPORT( void, input_AccessReinit, ( input_thread_t * ) );
+VLC_EXPORT( void, input_AccessEnd, ( input_thread_t * ) );
/*
- * Optional MPEG demultiplexing
+ * Optional standard file descriptor operations (input_ext-plugins.h)
*/
/*****************************************************************************
- * Constants
+ * input_socket_t: private access plug-in data
*****************************************************************************/
-#define TS_PACKET_SIZE 188 /* Size of a TS packet */
-#define PSI_SECTION_SIZE 4096 /* Maximum size of a PSI section */
-
-#define PAT_UNINITIALIZED (1 << 6)
-#define PMT_UNINITIALIZED (1 << 6)
-
-#define PSI_IS_PAT 0x00
-#define PSI_IS_PMT 0x01
-#define UNKNOWN_PSI 0xff
-
-/*****************************************************************************
- * psi_section_t
- *****************************************************************************
- * Describes a PSI section. Beware, it doesn't contain pointers to the TS
- * packets that contain it as for a PES, but the data themselves
- *****************************************************************************/
-typedef struct psi_section_s
-{
- byte_t buffer[PSI_SECTION_SIZE];
-
- u8 i_section_number;
- u8 i_last_section_number;
- u8 i_version_number;
- u16 i_section_length;
- u16 i_read_in_section;
-
- /* the PSI is complete */
- boolean_t b_is_complete;
-
- /* packet missed up ? */
- boolean_t b_trash;
-
- /*about sections */
- boolean_t b_section_complete;
-
- /* where are we currently ? */
- byte_t * p_current;
-
-} psi_section_t;
-
-/*****************************************************************************
- * es_ts_data_t: extension of es_descriptor_t
- *****************************************************************************/
-typedef struct es_ts_data_s
-{
- boolean_t b_psi; /* Does the stream have to be handled by
- * the PSI decoder ? */
-
- int i_psi_type; /* There are different types of PSI */
-
- psi_section_t * p_psi_section; /* PSI packets */
-
- /* Markers */
- int i_continuity_counter;
-} es_ts_data_t;
-
-/*****************************************************************************
- * pgrm_ts_data_t: extension of pgrm_descriptor_t
- *****************************************************************************/
-typedef struct pgrm_ts_data_s
+struct input_socket_t
{
- u16 i_pcr_pid; /* PCR ES, for TS streams */
- int i_pmt_version;
-} pgrm_ts_data_t;
-
-/*****************************************************************************
- * stream_ts_data_t: extension of stream_descriptor_t
- *****************************************************************************/
-typedef struct stream_ts_data_s
-{
- int i_pat_version; /* Current version of the PAT */
-} stream_ts_data_t;
-
-/*****************************************************************************
- * stream_ps_data_t: extension of stream_descriptor_t
- *****************************************************************************/
-typedef struct stream_ps_data_s
-{
- boolean_t b_has_PSM; /* very rare, in fact */
-
- u8 i_PSM_version;
-} stream_ps_data_t;
-
-/* PSM version is 5 bits, so -1 is not a valid value */
-#define EMPTY_PSM_VERSION -1
-
-
-/*****************************************************************************
- * Prototypes
- *****************************************************************************/
-void input_ParsePES ( struct input_thread_s *, struct es_descriptor_s * );
-void input_GatherPES ( struct input_thread_s *, struct data_packet_s *,
- struct es_descriptor_s *, boolean_t, boolean_t );
-es_descriptor_t * input_ParsePS( struct input_thread_s *,
- struct data_packet_s * );
-void input_DemuxPS ( struct input_thread_s *, struct data_packet_s * );
-void input_DemuxTS ( struct input_thread_s *, struct data_packet_s * );
-void input_DemuxPSI ( struct input_thread_s *, struct data_packet_s *,
- struct es_descriptor_s *, boolean_t, boolean_t );
+ /* Unbuffered file descriptor */
+ int i_handle;
+};