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_ATSC_SECTION_H
25 #define GST_ATSC_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  * GstMpegtsSectionATSCTableID:
35  *
36  * Values for a #GstMpegtsSection table_id.
37  *
38  * These are the registered ATSC table_id variants.
39  *
40  * see also: #GstMpegtsSectionTableID
41  */
42 typedef enum {
43 
44 
45   /* ATSC (A/65) */
46   GST_MTS_TABLE_ID_ATSC_MASTER_GUIDE                    = 0xC7,
47   GST_MTS_TABLE_ID_ATSC_TERRESTRIAL_VIRTUAL_CHANNEL     = 0xC8,
48   GST_MTS_TABLE_ID_ATSC_CABLE_VIRTUAL_CHANNEL           = 0xC9,
49   GST_MTS_TABLE_ID_ATSC_RATING_REGION                   = 0xCA,
50   GST_MTS_TABLE_ID_ATSC_EVENT_INFORMATION               = 0xCB,
51   GST_MTS_TABLE_ID_ATSC_CHANNEL_OR_EVENT_EXTENDED_TEXT  = 0xCC,
52   GST_MTS_TABLE_ID_ATSC_SYSTEM_TIME                     = 0xCD,
53   /* ATSC (A/90) */
54   GST_MTS_TABLE_ID_ATSC_DATA_EVENT                      = 0xCE,
55   GST_MTS_TABLE_ID_ATSC_DATA_SERVICE                    = 0xCF,
56   /* 0xD0 ?? */
57   GST_MTS_TABLE_ID_ATSC_NETWORK_RESOURCE                = 0xD1,
58   GST_MTS_TABLE_ID_ATSC_LONG_TERM_SERVICE               = 0xD2,
59   GST_MTS_TABLE_ID_ATSC_DIRECTED_CHANNEL_CHANGE         = 0xD3,
60   GST_MTS_TABLE_ID_ATSC_DIRECTED_CHANNEL_CHANGE_SECTION_CODE = 0xD4,
61   /* 0xD5 ?? */
62   GST_MTS_TABLE_ID_ATSC_AGGREGATE_EVENT_INFORMATION     = 0xD6,
63   GST_MTS_TABLE_ID_ATSC_AGGREGATE_EXTENDED_TEXT         = 0xD7,
64   /* 0xD8 ?? */
65   GST_MTS_TABLE_ID_ATSC_AGGREGATE_DATA_EVENT            = 0xD9,
66   GST_MTS_TABLE_ID_ATSC_SATELLITE_VIRTUAL_CHANNEL       = 0xDA,
67 } GstMpegtsSectionATSCTableID;
68 
69 /* TVCT/CVCT */
70 #define GST_TYPE_MPEGTS_ATSC_VCT (gst_mpegts_atsc_vct_get_type ())
71 #define GST_TYPE_MPEGTS_ATSC_VCT_SOURCE (gst_mpegts_atsc_vct_source_get_type ())
72 
73 typedef struct _GstMpegtsAtscVCTSource GstMpegtsAtscVCTSource;
74 typedef struct _GstMpegtsAtscVCT GstMpegtsAtscVCT;
75 
76 /**
77  * GstMpegtsAtscVCTSource:
78  * @short_name: The short name of a source
79  * @major_channel_number: The major channel number
80  * @minor_channel_number: The minor channel number
81  * @modulation_mode: The modulation mode
82  * @carrier_frequency: The carrier frequency
83  * @channel_TSID: The transport stream ID
84  * @program_number: The program number (see #GstMpegtsPatProgram)
85  * @ETM_location: The ETM location
86  * @access_controlled: is access controlled
87  * @hidden: is hidden
88  * @path_select: is path select, CVCT only
89  * @out_of_band: is out of band, CVCT only
90  * @hide_guide: is hide guide
91  * @service_type: The service type
92  * @source_id: The source id
93  * @descriptors: (element-type GstMpegtsDescriptor): an array of #GstMpegtsDescriptor
94  *
95  * Source from a @GstMpegtsAtscVCT, can be used both for TVCT and CVCT tables
96  */
97 struct _GstMpegtsAtscVCTSource
98 {
99   gchar    *short_name;
100   guint16   major_channel_number;
101   guint16   minor_channel_number;
102   guint8    modulation_mode;
103   guint32   carrier_frequency;
104   guint16   channel_TSID;
105   guint16   program_number;
106   /* FIXME: */
107   guint8    ETM_location;
108   gboolean  access_controlled;
109   gboolean  hidden;
110   gboolean  path_select; /* CVCT only - reserved bit in TVCT */
111   gboolean  out_of_band; /* CVCT only - reserved bit in TVCT */
112   gboolean  hide_guide;
113   /* FIXME: */
114   guint8    service_type;
115   guint16   source_id;
116   GPtrArray *descriptors;
117 };
118 
119 /**
120  * GstMpegtsAtscVCT:
121  * @transport_stream_id: The transport stream
122  * @protocol_version: The protocol version
123  * @sources: (element-type GstMpegtsAtscVCTSource): sources
124  * @descriptors: (element-type GstMpegtsDescriptor): descriptors
125  *
126  * Represents both:
127  *   Terrestrial Virtual Channel Table (A65)
128  *   Cable Virtual Channel Table (A65)
129  *
130  */
131 struct _GstMpegtsAtscVCT
132 {
133   guint16   transport_stream_id;
134   guint8    protocol_version;
135   GPtrArray *sources;
136   GPtrArray *descriptors;
137 };
138 
139 GST_MPEGTS_API
140 GType gst_mpegts_atsc_vct_get_type (void);
141 
142 GST_MPEGTS_API
143 GType gst_mpegts_atsc_vct_source_get_type (void);
144 
145 GST_MPEGTS_API
146 const GstMpegtsAtscVCT * gst_mpegts_section_get_atsc_tvct (GstMpegtsSection * section);
147 
148 GST_MPEGTS_API
149 const GstMpegtsAtscVCT * gst_mpegts_section_get_atsc_cvct (GstMpegtsSection * section);
150 
151 /* MGT */
152 #define GST_TYPE_MPEGTS_ATSC_MGT (gst_mpegts_atsc_mgt_get_type ())
153 #define GST_TYPE_MPEGTS_ATSC_MGT_TABLE (gst_mpegts_atsc_mgt_table_get_type ())
154 
155 typedef struct _GstMpegtsAtscMGTTable GstMpegtsAtscMGTTable;
156 typedef struct _GstMpegtsAtscMGT GstMpegtsAtscMGT;
157 
158 typedef enum {
159   GST_MPEGTS_ATSC_MGT_TABLE_TYPE_EIT0 = 0x0100,
160   GST_MPEGTS_ATSC_MGT_TABLE_TYPE_EIT127 = 0x017F,
161   GST_MPEGTS_ATSC_MGT_TABLE_TYPE_ETT0 = 0x0200,
162   GST_MPEGTS_ATSC_MGT_TABLE_TYPE_ETT127 = 0x027F
163 } GstMpegtsAtscMGTTableType;
164 
165 /**
166  * GstMpegtsAtscMGTTable:
167  * @table_type: #GstMpegtsAtscMGTTableType
168  * @pid: The packet ID
169  * @version_number: The version number
170  * @number_bytes:
171  * @descriptors: (element-type GstMpegtsDescriptor): descriptors
172  *
173  * Source from a @GstMpegtsAtscMGT
174  */
175 struct _GstMpegtsAtscMGTTable
176 {
177   guint16 table_type;
178   guint16 pid;
179   guint8  version_number;
180   guint32 number_bytes;
181   GPtrArray *descriptors;
182 };
183 
184 /**
185  * GstMpegtsAtscMGT:
186  * @protocol_version: The protocol version
187  * @tables_defined: The numbers of subtables
188  * @tables: (element-type GstMpegtsAtscMGTTable): the tables
189  * @descriptors: (element-type GstMpegtsDescriptor): descriptors
190  *
191  * Master Guide Table (A65)
192  *
193  */
194 struct _GstMpegtsAtscMGT
195 {
196   guint8  protocol_version;
197   guint16 tables_defined;
198   GPtrArray *tables;
199   GPtrArray *descriptors;
200 };
201 
202 GST_MPEGTS_API
203 GType gst_mpegts_atsc_mgt_get_type (void);
204 
205 GST_MPEGTS_API
206 GType gst_mpegts_atsc_mgt_table_get_type (void);
207 
208 GST_MPEGTS_API
209 const GstMpegtsAtscMGT * gst_mpegts_section_get_atsc_mgt (GstMpegtsSection * section);
210 
211 /* Multiple string structure (used in ETT and EIT */
212 
213 #define GST_TYPE_MPEGTS_ATSC_STRING_SEGMENT (gst_mpegts_atsc_string_segment_get_type())
214 #define GST_TYPE_MPEGTS_ATSC_MULT_STRING (gst_mpegts_atsc_mult_string_get_type())
215 
216 typedef struct _GstMpegtsAtscStringSegment GstMpegtsAtscStringSegment;
217 typedef struct _GstMpegtsAtscMultString GstMpegtsAtscMultString;
218 
219 /**
220  * GstMpegtsAtscStringSegment:
221  * @compression_type: The compression type
222  * @mode: The mode
223  * @compressed_data_size: The size of compressed data
224  * @compressed_data: The compressed data
225  * @cached_string:
226  *
227  * A string segment
228  */
229 struct _GstMpegtsAtscStringSegment {
230   guint8 compression_type;
231   guint8 mode;
232   guint8 compressed_data_size;
233   guint8 *compressed_data;
234 
235   gchar *cached_string;
236 };
237 
238 GST_MPEGTS_API
239 const gchar * gst_mpegts_atsc_string_segment_get_string (GstMpegtsAtscStringSegment * seg);
240 
241 /**
242  * GstMpegtsAtscMultString:
243  * @iso_639_langcode: The ISO639 language code
244  * @segments: (element-type GstMpegtsAtscStringSegment)
245  *
246  */
247 struct _GstMpegtsAtscMultString {
248   gchar      iso_639_langcode[4];
249   GPtrArray *segments;
250 };
251 
252 GST_MPEGTS_API
253 GType gst_mpegts_atsc_string_segment_get_type (void);
254 
255 GST_MPEGTS_API
256 GType gst_mpegts_atsc_mult_string_get_type (void);
257 
258 /* EIT */
259 
260 #define GST_TYPE_MPEGTS_ATSC_EIT_EVENT (gst_mpegts_atsc_eit_event_get_type())
261 #define GST_TYPE_MPEGTS_ATSC_EIT (gst_mpegts_atsc_eit_get_type())
262 
263 typedef struct _GstMpegtsAtscEITEvent GstMpegtsAtscEITEvent;
264 typedef struct _GstMpegtsAtscEIT GstMpegtsAtscEIT;
265 
266 /**
267  * GstMpegtsAtscEITEvent:
268  * @event_id: The event id
269  * @start_time: The start time
270  * @etm_location: The etm location
271  * @length_in_seconds: The length in seconds
272  * @titles: (element-type GstMpegtsAtscMultString): the titles
273  * @descriptors: (element-type GstMpegtsDescriptor): descriptors
274  *
275  * An ATSC EIT Event
276  */
277 struct _GstMpegtsAtscEITEvent {
278   guint16        event_id;
279   guint32        start_time;
280   guint8         etm_location;
281   guint32        length_in_seconds;
282   GPtrArray     *titles;
283 
284   GPtrArray *descriptors;
285 };
286 
287 /**
288  * GstMpegtsAtscEIT:
289  * @source_id: The source id
290  * @protocol_version: The protocol version
291  * @events: (element-type GstMpegtsAtscEITEvent): Events
292  *
293  * Event Information Table (ATSC)
294  *
295  */
296 struct _GstMpegtsAtscEIT
297 {
298   guint16        source_id;
299   guint8         protocol_version;
300 
301   GPtrArray     *events;
302 };
303 
304 GST_MPEGTS_API
305 GType gst_mpegts_atsc_eit_event_get_type (void);
306 
307 GST_MPEGTS_API
308 GType gst_mpegts_atsc_eit_get_type (void);
309 
310 GST_MPEGTS_API
311 const GstMpegtsAtscEIT *gst_mpegts_section_get_atsc_eit (GstMpegtsSection *section);
312 
313 /* ETT */
314 
315 #define GST_TYPE_MPEGTS_ATSC_ETT (gst_mpegts_atsc_ett_get_type())
316 
317 typedef struct _GstMpegtsAtscETT GstMpegtsAtscETT;
318 
319 /**
320  * GstMpegtsAtscETT:
321  * @ett_table_id_extension:
322  * @protocol_version: The protocol version
323  * @etm_id: The etm id
324  * @messages: (element-type GstMpegtsAtscMultString): List of texts
325  *
326  * Extended Text Table (ATSC)
327  *
328  */
329 struct _GstMpegtsAtscETT
330 {
331   guint16        ett_table_id_extension;
332   guint16        protocol_version;
333   guint32        etm_id;
334 
335   GPtrArray     *messages;
336 };
337 
338 GST_MPEGTS_API
339 GType gst_mpegts_atsc_ett_get_type (void);
340 
341 GST_MPEGTS_API
342 const GstMpegtsAtscETT *gst_mpegts_section_get_atsc_ett (GstMpegtsSection *section);
343 
344 /* STT */
345 #define GST_TYPE_MPEGTS_ATSC_STT (gst_mpegts_atsc_stt_get_type ())
346 
347 typedef struct _GstMpegtsAtscSTT GstMpegtsAtscSTT;
348 
349 /**
350  * GstMpegtsAtscSTT:
351  * @protocol_version: The protocol version
352  * @system_time: The system time
353  * @gps_utc_offset: The GPS to UTC offset
354  * @ds_status:
355  * @ds_dayofmonth: The day of month
356  * @ds_hour: The hour
357  * @descriptors: (element-type GstMpegtsDescriptor): descriptors
358  * @utc_datetime: The UTC date and time
359  *
360  * System Time Table (A65)
361  *
362  */
363 struct _GstMpegtsAtscSTT
364 {
365   guint8     protocol_version;
366   guint32    system_time;
367   guint8     gps_utc_offset;
368   gboolean   ds_status;
369   guint8     ds_dayofmonth;
370   guint8     ds_hour;
371   GPtrArray *descriptors;
372 
373   GstDateTime *utc_datetime;
374 };
375 
376 GST_MPEGTS_API
377 GType gst_mpegts_atsc_stt_get_type (void);
378 
379 GST_MPEGTS_API
380 const GstMpegtsAtscSTT * gst_mpegts_section_get_atsc_stt (GstMpegtsSection * section);
381 /* FIXME receive a non-const parameter but we only provide a const getter */
382 
383 GST_MPEGTS_API
384 GstDateTime * gst_mpegts_atsc_stt_get_datetime_utc (GstMpegtsAtscSTT * stt);
385 
386 G_END_DECLS
387 
388 #endif				/* GST_MPEGTS_SECTION_H */
389