1 /*
2  * mpegtspacketizer.h -
3  * Copyright (C) 2013 Edward Hervey
4  *
5  * Authors:
6  *   Edward Hervey <edward@collabora.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef GST_DVB_SECTION_H
25 #define GST_DVB_SECTION_H
26 
27 #include <gst/gst.h>
28 #include <gst/mpegts/gstmpegtssection.h>
29 #include <gst/mpegts/gstmpegtsdescriptor.h>
30 
31 G_BEGIN_DECLS
32 
33 /**
34  * GstMpegtsSectionDVBTableID:
35  *
36  * Values for a #GstMpegtsSection table_id.
37  *
38  * These are the registered DVB table_id variants.
39  *
40  * see also: #GstMpegtsSectionTableID
41  */
42 typedef enum {
43   /* EN 300 468 (DVB) v 1.12.1 */
44   GST_MTS_TABLE_ID_NETWORK_INFORMATION_ACTUAL_NETWORK	= 0x40,
45   GST_MTS_TABLE_ID_NETWORK_INFORMATION_OTHER_NETWORK	= 0x41,
46   GST_MTS_TABLE_ID_SERVICE_DESCRIPTION_ACTUAL_TS	= 0x42,
47   GST_MTS_TABLE_ID_SERVICE_DESCRIPTION_OTHER_TS		= 0x46,
48   GST_MTS_TABLE_ID_BOUQUET_ASSOCIATION			= 0x4A,
49   GST_MTS_TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_PRESENT	= 0x4E,
50   GST_MTS_TABLE_ID_EVENT_INFORMATION_OTHER_TS_PRESENT	= 0x4F,
51   GST_MTS_TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_SCHEDULE_1	= 0x50,
52   GST_MTS_TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_SCHEDULE_N	= 0x5F,
53   GST_MTS_TABLE_ID_EVENT_INFORMATION_OTHER_TS_SCHEDULE_1	= 0x60,
54   GST_MTS_TABLE_ID_EVENT_INFORMATION_OTHER_TS_SCHEDULE_N	= 0x6F,
55   GST_MTS_TABLE_ID_TIME_DATE				= 0x70,
56   GST_MTS_TABLE_ID_RUNNING_STATUS			= 0x71,
57   GST_MTS_TABLE_ID_STUFFING				= 0x72,
58   GST_MTS_TABLE_ID_TIME_OFFSET				= 0x73,
59 
60   /* TS 102 812 (MHP v1.1.3) */
61   GST_MTS_TABLE_ID_APPLICATION_INFORMATION_TABLE	= 0x74,
62 
63   /* TS 102 323 (DVB TV Anytime v1.5.1) */
64   GST_MTS_TABLE_ID_CONTAINER				= 0x75,
65   GST_MTS_TABLE_ID_RELATED_CONTENT			= 0x76,
66   GST_MTS_TABLE_ID_CONTENT_IDENTIFIER			= 0x77,
67 
68   /* EN 301 192 (DVB specification for data broadcasting) */
69   GST_MTS_TABLE_ID_MPE_FEC				= 0x78,
70 
71   /* TS 102 323 (DVB TV Anytime v1.5.1) */
72   GST_MTS_TABLE_ID_RESOLUTION_NOTIFICATION		= 0x79,
73 
74   /* TS 102 772 (DVB-SH Multi-Protocol Encapsulation) */
75   GST_MTS_TABLE_ID_MPE_IFEC				= 0x7A,
76 
77   /* EN 300 468 (DVB) v 1.12.1 */
78   GST_MTS_TABLE_ID_DISCONTINUITY_INFORMATION		= 0x7E,
79   GST_MTS_TABLE_ID_SELECTION_INFORMATION		= 0x7F,
80 
81   /* ETR 289 (DVB Support for use of scrambling and CA) */
82   GST_MTS_TABLE_ID_CA_MESSAGE_ECM_0			= 0x80,
83   GST_MTS_TABLE_ID_CA_MESSAGE_ECM_1			= 0x81,
84   GST_MTS_TABLE_ID_CA_MESSAGE_SYSTEM_PRIVATE_1		= 0x82,
85   GST_MTS_TABLE_ID_CA_MESSAGE_SYSTEM_PRIVATE_N		= 0x8F,
86 
87   /* ... */
88 
89   /* EN 301 790 (DVB interaction channel for satellite distribution channels) */
90   GST_MTS_TABLE_ID_SCT					= 0xA0,
91   GST_MTS_TABLE_ID_FCT					= 0xA1,
92   GST_MTS_TABLE_ID_TCT					= 0xA2,
93   GST_MTS_TABLE_ID_SPT					= 0xA3,
94   GST_MTS_TABLE_ID_CMT					= 0xA4,
95   GST_MTS_TABLE_ID_TBTP					= 0xA5,
96   GST_MTS_TABLE_ID_PCR_PACKET_PAYLOAD			= 0xA6,
97   GST_MTS_TABLE_ID_TRANSMISSION_MODE_SUPPORT_PAYLOAD	= 0xAA,
98   GST_MTS_TABLE_ID_TIM					= 0xB0,
99   GST_MTS_TABLE_ID_LL_FEC_PARITY_DATA_TABLE		= 0xB1
100 
101 } GstMpegtsSectionDVBTableID;
102 
103 /**
104  * GstMpegtsRunningStatus:
105  *
106  * Running status of a service.
107  *
108  * Corresponds to table 6 of ETSI EN 300 468 (v1.13.0)
109  */
110 typedef enum
111 {
112   GST_MPEGTS_RUNNING_STATUS_UNDEFINED = 0,
113   GST_MPEGTS_RUNNING_STATUS_NOT_RUNNING,
114   GST_MPEGTS_RUNNING_STATUS_STARTS_IN_FEW_SECONDS,
115   GST_MPEGTS_RUNNING_STATUS_PAUSING,
116   GST_MPEGTS_RUNNING_STATUS_RUNNING,
117   GST_MPEGTS_RUNNING_STATUS_OFF_AIR
118 } GstMpegtsRunningStatus;
119 
120 
121 
122 /* NIT */
123 
124 typedef struct _GstMpegtsNITStream GstMpegtsNITStream;
125 typedef struct _GstMpegtsNIT GstMpegtsNIT;
126 
127 #define GST_TYPE_MPEGTS_NIT (gst_mpegts_nit_get_type())
128 #define GST_TYPE_MPEGTS_NIT_STREAM (gst_mpegts_nit_stream_get_type())
129 
130 /**
131  * GstMpegtsNITStream:
132  * @transport_stream_id:
133  * @original_network_id:
134  * @descriptors: (element-type GstMpegtsDescriptor):
135  *
136  */
137 struct _GstMpegtsNITStream
138 {
139   guint16  transport_stream_id;
140   guint16  original_network_id;
141 
142   GPtrArray  *descriptors;
143 };
144 
145 /**
146  * GstMpegtsNIT:
147  * @actual_network: Whether this NIT corresponds to the actual stream
148  * @network_id: ID of the network that this NIT describes
149  * @descriptors: (element-type GstMpegtsDescriptor): the global descriptors
150  * @streams: (element-type GstMpegtsNITStream): the streams
151  *
152  * Network Information Table (ISO/IEC 13818-1 / EN 300 468)
153  *
154  */
155 struct _GstMpegtsNIT
156 {
157   gboolean   actual_network;
158   guint16    network_id;
159 
160   GPtrArray  *descriptors;
161 
162   GPtrArray *streams;
163 };
164 
165 GST_MPEGTS_API
166 GType gst_mpegts_nit_get_type (void);
167 
168 GST_MPEGTS_API
169 GType gst_mpegts_nit_stream_get_type (void);
170 
171 GST_MPEGTS_API
172 const GstMpegtsNIT *gst_mpegts_section_get_nit (GstMpegtsSection *section);
173 
174 GST_MPEGTS_API
175 GstMpegtsSection *gst_mpegts_section_from_nit (GstMpegtsNIT *nit);
176 
177 GST_MPEGTS_API
178 GstMpegtsNIT *gst_mpegts_nit_new (void);
179 
180 GST_MPEGTS_API
181 GstMpegtsNITStream *gst_mpegts_nit_stream_new (void);
182 
183 
184 /* BAT */
185 
186 typedef struct _GstMpegtsBATStream GstMpegtsBATStream;
187 typedef struct _GstMpegtsBAT GstMpegtsBAT;
188 
189 #define GST_TYPE_MPEGTS_BAT (gst_mpegts_bat_get_type())
190 #define GST_TYPE_MPEGTS_BAT_STREAM (gst_mpegts_bat_get_type())
191 
192 struct _GstMpegtsBATStream
193 {
194   guint16   transport_stream_id;
195   guint16   original_network_id;
196 
197   GPtrArray   *descriptors;
198 };
199 
200 /**
201  * GstMpegtsBAT:
202  * @descriptors: (element-type GstMpegtsDescriptor):
203  * @streams: (element-type GstMpegtsBATStream):
204  *
205  * DVB Bouquet Association Table (EN 300 468)
206  */
207 struct _GstMpegtsBAT
208 {
209   GPtrArray  *descriptors;
210 
211   GPtrArray  *streams;
212 };
213 
214 GST_MPEGTS_API
215 GType gst_mpegts_bat_get_type (void);
216 
217 GST_MPEGTS_API
218 GType gst_mpegts_bat_stream_get_type (void);
219 
220 GST_MPEGTS_API
221 const GstMpegtsBAT *gst_mpegts_section_get_bat (GstMpegtsSection *section);
222 
223 /* SDT */
224 #define GST_TYPE_MPEGTS_SDT (gst_mpegts_sdt_get_type())
225 #define GST_TYPE_MPEGTS_SDT_SERVICE (gst_mpegts_sdt_service_get_type())
226 
227 typedef struct _GstMpegtsSDTService GstMpegtsSDTService;
228 typedef struct _GstMpegtsSDT GstMpegtsSDT;
229 
230 /**
231  * GstMpegtsSDTService:
232  * @service_id: The program number this table belongs to
233  * @EIT_schedule_flag: EIT schedule information is present in this transport stream
234  * @EIT_present_following_flag: EIT present/following information is present in this transport stream
235  * @running_status: Status of this service
236  * @free_CA_mode: True if one or more streams is controlled by a CA system
237  * @descriptors: (element-type GstMpegtsDescriptor): List of descriptors
238  *
239  */
240 struct _GstMpegtsSDTService
241 {
242   guint16    service_id;
243 
244   gboolean   EIT_schedule_flag;
245   gboolean   EIT_present_following_flag;
246   GstMpegtsRunningStatus running_status;
247   gboolean   free_CA_mode;
248 
249   GPtrArray    *descriptors;
250 };
251 
252 /**
253  * GstMpegtsSDT:
254  * @original_network_id: Network ID of the originating delivery system
255  * @actual_ts: True if the table describes this transport stream
256  * @transport_stream_id: ID of this transport stream
257  * @services: (element-type GstMpegtsSDTService): List of services
258  *
259  * Service Description Table (EN 300 468)
260  *
261  */
262 struct _GstMpegtsSDT
263 {
264   guint16    original_network_id;
265   gboolean   actual_ts;
266   guint16    transport_stream_id;
267 
268   GPtrArray *services;
269 };
270 
271 GST_MPEGTS_API
272 GType gst_mpegts_sdt_get_type (void);
273 
274 GST_MPEGTS_API
275 GType gst_mpegts_sdt_service_get_type (void);
276 
277 GST_MPEGTS_API
278 const GstMpegtsSDT *gst_mpegts_section_get_sdt (GstMpegtsSection *section);
279 
280 GST_MPEGTS_API
281 GstMpegtsSection *gst_mpegts_section_from_sdt (GstMpegtsSDT * sdt);
282 
283 GST_MPEGTS_API
284 GstMpegtsSDT *gst_mpegts_sdt_new (void);
285 
286 GST_MPEGTS_API
287 GstMpegtsSDTService *gst_mpegts_sdt_service_new (void);
288 
289 /* EIT */
290 
291 #define GST_TYPE_MPEGTS_EIT (gst_mpegts_eit_get_type())
292 #define GST_TYPE_MPEGTS_EIT_EVENT (gst_mpegts_eit_event_get_type())
293 
294 typedef struct _GstMpegtsEITEvent GstMpegtsEITEvent;
295 typedef struct _GstMpegtsEIT GstMpegtsEIT;
296 
297 /**
298  * GstMpegtsEITEvent:
299  * @descriptors: (element-type GstMpegtsDescriptor): List of descriptors
300  *
301  * Event from a @GstMpegtsEIT
302  */
303 struct _GstMpegtsEITEvent
304 {
305   guint16      event_id;
306 
307   GstDateTime *start_time;
308   guint32      duration;
309 
310   GstMpegtsRunningStatus running_status;
311   gboolean     free_CA_mode;
312 
313   GPtrArray   *descriptors;
314 };
315 
316 /**
317  * GstMpegtsEIT:
318  * @events: (element-type GstMpegtsEITEvent): List of events
319  *
320  * Event Information Table (EN 300 468)
321  *
322  */
323 struct _GstMpegtsEIT
324 {
325   guint16        transport_stream_id;
326   guint16        original_network_id;
327   guint8         segment_last_section_number;
328   guint8         last_table_id;
329 
330   gboolean       actual_stream;
331   gboolean       present_following;
332 
333   GPtrArray     *events;
334 };
335 
336 GST_MPEGTS_API
337 GType gst_mpegts_eit_get_type (void);
338 
339 GST_MPEGTS_API
340 GType gst_mpegts_eit_event_get_type (void);
341 
342 GST_MPEGTS_API
343 const GstMpegtsEIT *gst_mpegts_section_get_eit (GstMpegtsSection *section);
344 
345 /* TDT */
346 
347 GST_MPEGTS_API
348 GstDateTime *gst_mpegts_section_get_tdt (GstMpegtsSection *section);
349 
350 /* TOT */
351 
352 typedef struct _GstMpegtsTOT GstMpegtsTOT;
353 #define GST_TYPE_MPEGTS_TOT (gst_mpegts_tot_get_type())
354 /**
355  * GstMpegtsTOT:
356  * @descriptors: (element-type GstMpegtsDescriptor): List of descriptors
357  *
358  * Time Offset Table (EN 300 468)
359  *
360  */
361 struct _GstMpegtsTOT
362 {
363   GstDateTime   *utc_time;
364 
365   GPtrArray     *descriptors;
366 };
367 
368 GST_MPEGTS_API
369 GType gst_mpegts_tot_get_type (void);
370 
371 GST_MPEGTS_API
372 const GstMpegtsTOT *gst_mpegts_section_get_tot (GstMpegtsSection *section);
373 
374 G_END_DECLS
375 
376 #endif				/* GST_MPEGTS_SECTION_H */
377