]> git.sesse.net Git - vlc/blob - modules/demux/mpeg/system.h
* modules/demux/mpeg: Added DVB stream type for A/52 streams (0x6),
[vlc] / modules / demux / mpeg / system.h
1 /*****************************************************************************
2  * system.h: MPEG demultiplexing.
3  *****************************************************************************
4  * Copyright (C) 1999-2002 VideoLAN
5  * $Id: system.h,v 1.3 2002/10/20 12:23:48 massiot Exp $
6  *
7  * Authors: Christophe Massiot <massiot@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*
25  * Optional MPEG demultiplexing
26  */
27
28 /*****************************************************************************
29  * Constants
30  *****************************************************************************/
31 #define TS_PACKET_SIZE      188                       /* Size of a TS packet */
32 #define TS_SYNC_CODE        0x47                /* First byte of a TS packet */
33 #define PSI_SECTION_SIZE    4096            /* Maximum size of a PSI section */
34
35 #define PAT_UNINITIALIZED    (1 << 6)
36 #define PMT_UNINITIALIZED    (1 << 6)
37
38 #define PSI_IS_PAT          0x00
39 #define PSI_IS_PMT          0x01
40 #define UNKNOWN_PSI         0xff
41
42 /* ES streams types - see ISO/IEC 13818-1 table 2-29 numbers.
43  * these values are used in mpeg_system.c, and in
44  * the following plugins: mpeg_ts, mpeg_ts_dvbpsi, satellite. */
45 #define MPEG1_VIDEO_ES      0x01
46 #define MPEG2_VIDEO_ES      0x02
47 #define MPEG1_AUDIO_ES      0x03
48 #define MPEG2_AUDIO_ES      0x04
49 #define A52DVB_AUDIO_ES     0x06
50 #define A52_AUDIO_ES        0x81
51 /* These ones might violate the usage : */
52 #define DVD_SPU_ES          0x82
53 #define LPCM_AUDIO_ES       0x83
54 #define SDDS_AUDIO_ES       0x84
55 #define DTS_AUDIO_ES        0x85
56 /* These ones are only here to work around a bug in VLS - VLS doesn't
57  * skip the first bytes of the PES payload (stream private ID) when
58  * streaming. This is incompatible with all equipments. 'B' is for
59  * buggy. Please note that they are associated with FOURCCs '***b'.
60  * --Meuuh 2002-08-30
61  */
62 #define A52B_AUDIO_ES       0x91
63 #define DVDB_SPU_ES         0x92
64 #define LPCMB_AUDIO_ES      0x93
65
66 /****************************************************************************
67  * psi_callback_t
68  ****************************************************************************
69  * Used by TS demux to handle a PSI, either with the builtin decoder, either
70  * with a library such as libdvbpsi
71  ****************************************************************************/
72 typedef void( * psi_callback_t )( 
73         input_thread_t  * p_input,
74         data_packet_t   * p_data,
75         es_descriptor_t * p_es,
76         vlc_bool_t        b_unit_start );
77
78
79 /****************************************************************************
80  * mpeg_demux_t
81  ****************************************************************************
82  * Demux callbacks exported by the helper plugin
83  ****************************************************************************/
84 typedef struct mpeg_demux_t
85 {
86     module_t * p_module;
87
88     ssize_t           (*pf_read_ps)  ( input_thread_t *, data_packet_t ** );
89     es_descriptor_t * (*pf_parse_ps) ( input_thread_t *, data_packet_t * );
90     void              (*pf_demux_ps) ( input_thread_t *, data_packet_t * );
91
92     ssize_t           (*pf_read_ts)  ( input_thread_t *, data_packet_t ** );
93     void              (*pf_demux_ts) ( input_thread_t *, data_packet_t *,
94                                        psi_callback_t );
95 } mpeg_demux_t;
96
97 /*****************************************************************************
98  * psi_section_t
99  *****************************************************************************
100  * Describes a PSI section. Beware, it doesn't contain pointers to the TS
101  * packets that contain it as for a PES, but the data themselves
102  *****************************************************************************/
103 typedef struct psi_section_t
104 {
105     byte_t                  buffer[PSI_SECTION_SIZE];
106
107     u8                      i_section_number;
108     u8                      i_last_section_number;
109     u8                      i_version_number;
110     u16                     i_section_length;
111     u16                     i_read_in_section;
112     
113     /* the PSI is complete */
114     vlc_bool_t              b_is_complete;
115     
116     /* packet missed up ? */
117     vlc_bool_t              b_trash;
118
119     /*about sections  */ 
120     vlc_bool_t              b_section_complete;
121
122     /* where are we currently ? */
123     byte_t                * p_current;
124
125 } psi_section_t;
126
127 /*****************************************************************************
128  * es_ts_data_t: extension of es_descriptor_t
129  *****************************************************************************/
130 typedef struct es_ts_data_t
131 {
132     vlc_bool_t              b_psi;   /* Does the stream have to be handled by
133                                       *                    the PSI decoder ? */
134
135     int                     i_psi_type;  /* There are different types of PSI */
136     
137     psi_section_t *         p_psi_section;                    /* PSI packets */
138
139     /* Markers */
140     int                     i_continuity_counter;
141 } es_ts_data_t;
142
143 /*****************************************************************************
144  * pgrm_ts_data_t: extension of pgrm_descriptor_t
145  *****************************************************************************/
146 typedef struct pgrm_ts_data_t
147 {
148     u16                     i_pcr_pid;             /* PCR ES, for TS streams */
149     int                     i_pmt_version;
150     /* libdvbpsi pmt decoder handle */
151     void *                  p_pmt_handle;
152 } pgrm_ts_data_t;
153
154 /*****************************************************************************
155  * stream_ts_data_t: extension of stream_descriptor_t
156  *****************************************************************************/
157 typedef struct stream_ts_data_t
158 {
159     int i_pat_version;          /* Current version of the PAT */
160     /* libdvbpsi pmt decoder handle */
161     void *                  p_pat_handle;
162 } stream_ts_data_t;
163
164 /*****************************************************************************
165  * stream_ps_data_t: extension of stream_descriptor_t
166  *****************************************************************************/
167 typedef struct stream_ps_data_t
168 {
169     vlc_bool_t              b_has_PSM;                 /* very rare, in fact */
170
171     u8                      i_PSM_version;
172 } stream_ps_data_t;
173
174 /* PSM version is 5 bits, so -1 is not a valid value */
175 #define EMPTY_PSM_VERSION   -1
176