-/*****************************************************************************
- * Constants related to input
- *****************************************************************************/
-#define TS_PACKET_SIZE 188 /* size of a TS packet */
-#define PES_HEADER_SIZE 14 /* size of the first part of a PES header */
-#define PSI_SECTION_SIZE 4096 /* Maximum size of a PSI section */
-
-/*****************************************************************************
- * ts_packet_t
- *****************************************************************************
- * Describe a TS packet.
- *****************************************************************************/
-typedef struct ts_packet_s
-{
- /* Nothing before this line, the code relies on that */
- byte_t buffer[TS_PACKET_SIZE]; /* raw TS data packet */
-
- /* Decoders information */
- unsigned int i_payload_start;
- /* start of the PES payload in this packet */
- unsigned int i_payload_end; /* guess ? :-) */
-
- /* Used to chain the TS packets that carry data for a same PES or PSI */
- struct ts_packet_s * p_prev_ts;
- struct ts_packet_s * p_next_ts;
-} ts_packet_t;
-
-/*****************************************************************************
- * pes_packet_t
- *****************************************************************************
- * Describes an PES packet, with its properties, and pointers to the TS packets
- * containing it.
- *****************************************************************************/
-typedef struct pes_packet_s
-{
- /* PES properties */
- boolean_t b_data_loss; /* The previous (at least) PES packet
- * has been lost. The decoders will have to find a way to recover. */
- boolean_t b_data_alignment; /* used to find the beginning of a
- * video or audio unit */
- boolean_t b_has_pts; /* is the following field set ? */
- mtime_t i_pts; /* the PTS for this packet (if set above) */
- boolean_t b_random_access;
- /* if TRUE, in the payload of this packet, there is the first byte
- * of a video sequence header, or the first byte of an audio frame.
- */
- u8 i_stream_id; /* payload type and id */
- int i_pes_size; /* size of the current PES packet */
- int i_ts_packets;/* number of TS packets in this PES */
-
- /* Demultiplexer environment */
- boolean_t b_discard_payload; /* is the packet messed up ? */
- byte_t * p_pes_header; /* pointer to the PES header */
- byte_t * p_pes_header_save; /* temporary buffer */
-
- /* Pointers to TS packets (TS packets are then linked by the p_prev_ts and
- p_next_ts fields of the ts_packet_t struct) */
- ts_packet_t * p_first_ts; /* The first TS packet containing this
- * PES (used by decoders). */
- ts_packet_t * p_last_ts; /* The last TS packet gathered at present
- * (used by the demultiplexer). */
-} pes_packet_t;
-
-/*****************************************************************************
- * 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];
-
- boolean_t b_running_section; /* Is there a section being decoded ? */
-
- u16 i_length;
- u16 i_current_position;
-} psi_section_t;
-
-
-/*****************************************************************************
- * es_descriptor_t: elementary stream descriptor
- *****************************************************************************
- * Describes an elementary stream, and includes fields required to handle and
- * demultiplex this elementary stream.
- *****************************************************************************/
-typedef struct es_descriptor_t
-{
- u16 i_id; /* stream ID, PID for TS streams */
- u8 i_type; /* stream type */
-
- boolean_t b_pcr; /* does the stream include a PCR ? */
- /* XXX?? b_pcr will be replaced by something else: since a PCR can't be shared
- * between several ES, we will probably store the PCR fields directly here,
- * and one of those fields will probably (again) be used as a test of the
- * PCR presence */
- boolean_t b_psi; /* does the stream have to be handled by the
- PSI decoder ? */
- /* Markers */
- int i_continuity_counter;
- boolean_t b_discontinuity;
- boolean_t b_random;
-
- /* PES packets */
- pes_packet_t * p_pes_packet;
- /* current PES packet we are gathering */
-
- /* PSI packets */
- psi_section_t * p_psi_section; /* idem for a PSI stream */
-
- /* Decoder informations */
- void * p_dec; /* p_dec is void *, since we don't know a
- * priori whether it is adec_thread_t or
- * vdec_thread_t. We will use explicit
- * casts. */
-
- /* XXX?? video stream descriptor ? */
- /* XXX?? audio stream descriptor ? */
- /* XXX?? hierarchy descriptor ? */
- /* XXX?? target background grid descriptor ? */
- /* XXX?? video window descriptor ? */
- /* XXX?? ISO 639 language descriptor ? */
-
-#ifdef STATS
- /* Stats */
- count_t c_bytes; /* total bytes read */
- count_t c_payload_bytes;/* total of payload usefull bytes */
- count_t c_packets; /* total packets read */
- count_t c_invalid_packets; /* invalid packets read */
- /* XXX?? ... other stats */
-#endif
-} es_descriptor_t;
-
-/* Special PID values - note that the PID is only on 13 bits, and that values
- * greater than 0x1fff have no meaning in a stream */
-#define PROGRAM_ASSOCIATION_TABLE_PID 0x0000
-#define CONDITIONNAL_ACCESS_TABLE_PID 0x0001 /* not used */
-#define EMPTY_PID 0xffff /* empty record in a table */
-
-/* ES streams types - see ISO/IEC 13818-1 table 2-29 numbers */
-#define MPEG1_VIDEO_ES 0x01
-#define MPEG2_VIDEO_ES 0x02
-#define MPEG1_AUDIO_ES 0x03
-#define MPEG2_AUDIO_ES 0x04
-#define AC3_AUDIO_ES 0x81
-#define DVD_SPU_ES 0x82 /* 0x82 might violate the norm */