]> git.sesse.net Git - vlc/blob - include/mpeg_system.h
TS Input :
[vlc] / include / mpeg_system.h
1 /*****************************************************************************
2  * mpeg_system.h: structures of the input used to parse MPEG-1, MPEG-2 PS
3  * and TS system layers
4  *****************************************************************************
5  * Copyright (C) 1999, 2000 VideoLAN
6  * $Id: mpeg_system.h,v 1.2 2001/02/21 04:38:59 henri Exp $
7  *
8  * Authors:
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Constants
27  *****************************************************************************/
28 #define TS_PACKET_SIZE      188                       /* Size of a TS packet */
29 #define PSI_SECTION_SIZE    4096            /* Maximum size of a PSI section */
30
31 #define PAT_UNINITIALIZED    (1 << 6)
32 #define PMT_UNINITIALIZED    (1 << 6)
33
34 #define PSI_IS_PAT          0x00
35 #define PSI_IS_PMT          0x01
36 #define UNKNOWN_PSI         0xff
37
38 /*****************************************************************************
39  * psi_section_t
40  *****************************************************************************
41  * Describes a PSI section. Beware, it doesn't contain pointers to the TS
42  * packets that contain it as for a PES, but the data themselves
43  *****************************************************************************/
44 typedef struct psi_section_s
45 {
46     byte_t                  buffer[PSI_SECTION_SIZE];
47
48     u8                      i_section_number;
49     u8                      i_last_section_number;
50     u8                      i_version_number;
51     u16                     i_section_length;
52     u16                     i_read_in_section;
53     
54     /* the PSI is complete */
55     boolean_t               b_is_complete;
56     
57     /* packet missed up ? */
58     boolean_t               b_trash;
59
60     /*about sections  */ 
61     boolean_t               b_section_complete;
62
63     /* where are we currently ? */
64     byte_t                * p_current;
65
66 } psi_section_t;
67
68 /*****************************************************************************
69  * es_ts_data_t: extension of es_descriptor_t
70  *****************************************************************************/
71 typedef struct es_ts_data_s
72 {
73     boolean_t               b_psi;   /* Does the stream have to be handled by
74                                       *                    the PSI decoder ? */
75
76     int                     i_psi_type;  /* There are different types of PSI */
77     
78     psi_section_t *         p_psi_section;                    /* PSI packets */
79
80     /* Markers */
81     int                     i_continuity_counter;
82 } es_ts_data_t;
83
84 /*****************************************************************************
85  * pgrm_ts_data_t: extension of pgrm_descriptor_t
86  *****************************************************************************/
87 typedef struct pgrm_ts_data_s
88 {
89     u16                     i_pcr_pid;             /* PCR ES, for TS streams */
90     int                     i_pmt_version;
91 } pgrm_ts_data_t;
92
93 /*****************************************************************************
94  * stream_ts_data_t: extension of stream_descriptor_t
95  *****************************************************************************/
96 typedef struct stream_ts_data_s
97 {
98     int i_pat_version;          /* Current version of the PAT */
99 } stream_ts_data_t;
100
101 /*****************************************************************************
102  * stream_ps_data_t: extension of stream_descriptor_t
103  *****************************************************************************/
104 typedef struct stream_ps_data_s
105 {
106     boolean_t               b_has_PSM;                 /* very rare, in fact */
107
108     u8                      i_PSM_version;
109 } stream_ps_data_t;
110
111 /* PSM version is 5 bits, so -1 is not a valid value */
112 #define EMPTY_PSM_VERSION   -1
113
114
115 /*****************************************************************************
116  * Prototypes
117  *****************************************************************************/
118 void input_ParsePES( struct input_thread_s *, struct es_descriptor_s * );
119 void input_GatherPES( struct input_thread_s *, struct data_packet_s *,
120                       struct es_descriptor_s *, boolean_t, boolean_t );
121 es_descriptor_t * input_ParsePS( struct input_thread_s *,
122                                  struct data_packet_s * );
123 void input_DemuxPS( struct input_thread_s *, struct data_packet_s * );
124 void input_DemuxTS( struct input_thread_s *, struct data_packet_s * );
125 void input_DemuxPSI( input_thread_t *, data_packet_t *, es_descriptor_t *, 
126                      boolean_t, boolean_t );