- * Prototypes from input_ext-plugins.h (buffers management)
- *****************************************************************************/
-#ifndef __PLUGIN__
-void * input_BuffersInit( void );
-void input_BuffersEnd( struct input_buffers_s * );
-struct data_buffer_s * input_NewBuffer( struct input_buffers_s *, size_t );
-void input_ReleaseBuffer( struct input_buffers_s *, struct data_buffer_s * );
-struct data_packet_s * input_ShareBuffer( struct input_buffers_s *,
- struct data_buffer_s * );
-struct data_packet_s * input_NewPacket( struct input_buffers_s *, size_t );
-void input_DeletePacket( struct input_buffers_s *, struct data_packet_s * );
-struct pes_packet_s * input_NewPES( struct input_buffers_s * );
-void input_DeletePES( struct input_buffers_s *, struct pes_packet_s * );
-ssize_t input_FillBuffer( struct input_thread_s * );
-ssize_t input_Peek( struct input_thread_s *, byte_t **, size_t );
-ssize_t input_SplitBuffer( struct input_thread_s *, data_packet_t **, size_t );
-int input_AccessInit( struct input_thread_s * );
-void input_AccessReinit( struct input_thread_s * );
-void input_AccessEnd( struct input_thread_s * );
-#else
-# define input_BuffersInit p_symbols->input_BuffersInit
-# define input_BuffersEnd p_symbols->input_BuffersEnd
-# define input_NewBuffer p_symbols->input_NewBuffer
-# define input_ReleaseBuffer p_symbols->input_ReleaseBuffer
-# define input_ShareBuffer p_symbols->input_ShareBuffer
-# define input_NewPacket p_symbols->input_NewPacket
-# define input_DeletePacket p_symbols->input_DeletePacket
-# define input_NewPES p_symbols->input_NewPES
-# define input_DeletePES p_symbols->input_DeletePES
-# define input_FillBuffer p_symbols->input_FillBuffer
-# define input_Peek p_symbols->input_Peek
-# define input_SplitBuffer p_symbols->input_SplitBuffer
-# define input_AccessInit p_symbols->input_AccessInit
-# define input_AccessReinit p_symbols->input_AccessReinit
-# define input_AccessEnd p_symbols->input_AccessEnd
-#endif
-
-/*****************************************************************************
- * Create a NULL packet for padding in case of a data loss
- *****************************************************************************/
-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;
-
- if( (p_pad_data = input_NewPacket( p_input->p_method_data,
- PADDING_PACKET_SIZE )) == NULL )
- {
- intf_ErrMsg("input error: no new packet");
- p_input->b_error = 1;
- return;
- }
-
- memset( p_pad_data->p_payload_start, 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_pes->p_last->p_next = p_pad_data;
- p_pes->p_last = p_pad_data;
- p_pes->i_nb_data++;
- }
- else
- {
- if( (p_pes = input_NewPES( p_input->p_method_data )) == NULL )
- {
- intf_ErrMsg("input error: no PES packet");
- p_input->b_error = 1;
- return;
- }
-
- p_pes->i_rate = p_input->stream.control.i_rate;
- p_pes->p_first = p_pes->p_last = p_pad_data;
- p_pes->i_nb_data = 1;
- p_pes->b_discontinuity = 1;
- input_DecodePES( p_es->p_decoder_fifo, p_pes );
- }
-}
-
-
-/*
- * Optional MPEG demultiplexing
- */
-
-/*****************************************************************************
- * Constants
- *****************************************************************************/
-#define TS_PACKET_SIZE 188 /* Size of a TS packet */
-#define TS_SYNC_CODE 0x47 /* First byte 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_callback_t
- ****************************************************************************
- * Used by TS demux to handle a PSI, either with the builtin decoder, either
- * with a library such as libdvbpsi
- ****************************************************************************/
-typedef void( * psi_callback_t )(
- input_thread_t * p_input,
- data_packet_t * p_data,
- es_descriptor_t * p_es,
- boolean_t b_unit_start );
-
-
-/*****************************************************************************
- * 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
-{
- u16 i_pcr_pid; /* PCR ES, for TS streams */
- int i_pmt_version;
- /* libdvbpsi pmt decoder handle */
- void * p_pmt_handle;
-} pgrm_ts_data_t;
-
-/*****************************************************************************
- * stream_ts_data_t: extension of stream_descriptor_t