rtsp-server:wfd: Fix build error for gcc upgrade
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst-libs / gst / mpegts / gst-scte-section.h
1 /*
2  * gst-scte-section.h -
3  * Copyright (C) 2013, CableLabs, Louisville, CO 80027
4  *           (c) 2019, Centricular ltd
5  *
6  * Authors:
7  *   RUIH Team <ruih@cablelabs.com>
8  *   Edward Hervey <edward@centricular.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library 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 GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  */
25
26 #ifndef GST_SCTE_SECTION_H
27 #define GST_SCTE_SECTION_H
28
29 #include <gst/gst.h>
30 #include <gst/mpegts/gstmpegtssection.h>
31 #include <gst/mpegts/gstmpegtsdescriptor.h>
32
33 G_BEGIN_DECLS
34
35 /**
36  * GstMpegtsScteStreamType:
37  * @GST_MPEGTS_STREAM_TYPE_SCTE_SUBTITLING:  SCTE-27 Subtitling
38  * @GST_MPEGTS_STREAM_TYPE_SCTE_ISOCH_DATA:  SCTE-19 Isochronous data
39  * @GST_MPEGTS_STREAM_TYPE_SCTE_SIT:         SCTE-35 Splice Information Table
40  * @GST_MPEGTS_STREAM_TYPE_SCTE_DST_NRT:     SCTE-07 Data Service or
41  * Network Resource Table
42  * @GST_MPEGTS_STREAM_TYPE_SCTE_DSMCC_DCB:   Type B - DSM-CC Data Carousel
43  * [IEC 13818-6])
44  * @GST_MPEGTS_STREAM_TYPE_SCTE_SIGNALING:   Enhanced Television Application
45  * Signaling (OC-SP-ETV-AM1.0.1-120614)
46  * @GST_MPEGTS_STREAM_TYPE_SCTE_SYNC_DATA:   SCTE-07 Synchronous data
47  * @GST_MPEGTS_STREAM_TYPE_SCTE_ASYNC_DATA:  SCTE-53 Asynchronous data
48  *
49  * Type of mpeg-ts streams for SCTE. Most users would want to use the
50  * #GstMpegtsATSCStreamType instead since it also covers these stream types
51  *
52  */
53 typedef enum {
54
55   /* 0x01 - 0x7f : defined in other specs */
56   GST_MPEGTS_STREAM_TYPE_SCTE_SUBTITLING = 0x82,   /* Subtitling data */
57   GST_MPEGTS_STREAM_TYPE_SCTE_ISOCH_DATA = 0x83,   /* Isochronous data */
58   /* 0x84 - 0x85 : defined in other specs */
59   GST_MPEGTS_STREAM_TYPE_SCTE_SIT        = 0x86,   /* Splice Information Table */
60   /* 0x87 - 0x94 : defined in other specs */
61   GST_MPEGTS_STREAM_TYPE_SCTE_DST_NRT    = 0x95,   /* DST / NRT data */
62   /* 0x96 - 0xaf : defined in other specs */
63   GST_MPEGTS_STREAM_TYPE_SCTE_DSMCC_DCB  = 0xb0,   /* Data Carousel Type B */
64   /* 0xb1 - 0xbf : User Private (or defined in other specs) */
65   GST_MPEGTS_STREAM_TYPE_SCTE_SIGNALING  = 0xc0,   /* EBIF Signaling */
66   GST_MPEGTS_STREAM_TYPE_SCTE_SYNC_DATA  = 0xc2,   /* Synchronous data */
67   GST_MPEGTS_STREAM_TYPE_SCTE_ASYNC_DATA = 0xc3,   /* Asynchronous data */
68   /* 0xc4 - 0xff : User Private (or defined in other specs) */
69
70 } GstMpegtsScteStreamType;
71
72
73 /**
74  * GstMpegtsSectionSCTETableID:
75  * @GST_MTS_TABLE_ID_SCTE_EAS:    SCTE-18 Emergency Alert System
76  * @GST_MTS_TABLE_ID_SCTE_EBIF:   CL-SP-ETV-AM 1.0.1 EBIF message
77  * @GST_MTS_TABLE_ID_SCTE_EISS:   CL-SP-ETV-AM 1.0.1 EBIF Int. Signaling Sect.
78  * @GST_MTS_TABLE_ID_SCTE_DII:    CL-SP-ETV-AM 1.0.1 DSMCC DII message
79  * @GST_MTS_TABLE_ID_SCTE_DDB:    CL-SP-ETV-AM 1.0.1 DSMCC Data Download Block
80  * @GST_MTS_TABLE_ID_SCTE_SPLICE: SCTE-35 splice information is carried in a
81  * section stream on a separate PID in the program’s Map Table (PMT) allowing
82  * Splice Event notifications to remain associated with the program and pass
83  * through multiplexers.
84  *
85  * Values for a #GstMpegtsSection table_id.
86  *
87  * These are the registered SCTE table_id variants.
88  *
89  * see also: #GstMpegtsSectionTableID
90  */
91 typedef enum {
92
93   /* 0x01 - 0xd7 : defined in other specs */
94   GST_MTS_TABLE_ID_SCTE_EAS      = 0xd8,     /* emergency alert information */
95   /* 0xd8 - 0xdf : defined in other specs */
96   GST_MTS_TABLE_ID_SCTE_EBIF     = 0xE0,     /* EBIF message */
97   GST_MTS_TABLE_ID_SCTE_RESERVED = 0xE1,
98   GST_MTS_TABLE_ID_SCTE_EISS     = 0xE2,     /* EBIF Int. Signaling Sect. */
99   GST_MTS_TABLE_ID_SCTE_DII      = 0xE3,     /* DSMCC DII message */
100   GST_MTS_TABLE_ID_SCTE_DDB      = 0xE4,     /* DSMCC Data Download Block */
101   /* 0xe5 - 0xfb : defined in other specs */
102   GST_MTS_TABLE_ID_SCTE_SPLICE   = 0xfc,     /* splice information table */
103
104 } GstMpegtsSectionSCTETableID;
105
106 #define GST_MPEGTS_TYPE_SCTE_SPLICE_COMPONENT (gst_mpegts_scte_splice_component_get_type())
107 typedef struct _GstMpegtsSCTESpliceComponent GstMpegtsSCTESpliceComponent;
108
109 /**
110  * GstMpegtsSCTESpliceComponent:
111  * @tag: the elementary PID stream containing the Splice Point
112  * @splice_time_specified: Whether @splice_time was specified
113  * @splice_time: the presentation time of the signaled splice event
114  * @utc_splice_time: The UTC time of the signaled splice event
115  *
116  * Per-PID splice information.
117  *
118  * Since: 1.20
119  */
120 struct _GstMpegtsSCTESpliceComponent {
121   guint8 tag;
122
123   gboolean splice_time_specified; /* Only valid for insert_event */
124   guint64 splice_time; /* Only valid for insert_event */
125
126   guint32 utc_splice_time; /* Only valid for !insert_event (schedule) */
127 };
128
129 /* Splice Information Table (SIT) */
130 #define GST_TYPE_MPEGTS_SCTE_SPLICE_EVENT (gst_mpegts_scte_splice_event_get_type())
131 typedef struct _GstMpegtsSCTESpliceEvent GstMpegtsSCTESpliceEvent;
132
133 struct _GstMpegtsSCTESpliceEvent {
134   /* TRUE if from/to an insert event (else belongs to a schedule event) */
135   gboolean insert_event;
136
137   guint32 splice_event_id;
138   gboolean splice_event_cancel_indicator;
139
140   /* If splice_event_cancel_indicator == 0 */
141   gboolean out_of_network_indicator;
142   gboolean program_splice_flag;
143   gboolean duration_flag;
144
145   gboolean splice_immediate_flag; /* Only valid for insert_event */
146
147   gboolean program_splice_time_specified; /* Only valid for insert_event && program_splice */
148   guint64 program_splice_time; /* Only valid for insert_event && program_splice */
149
150   /**
151    * GstMpegtsSCTESpliceEvent.utc_splice_time:
152    *
153    * The UTC time of the signaled splice event
154    *
155    * Since: 1.20
156    */
157   guint32 utc_splice_time; /* Only valid for !insert_event (schedule) && program_splice */
158
159   /**
160    * GstMpegtsSCTESpliceEvent.components:
161    *
162    * Per-PID splice time information
163    *
164    * Since: 1.20
165    */
166   GPtrArray *components; /* Only valid for !program_splice */
167
168   gboolean break_duration_auto_return;
169   guint64 break_duration;
170
171   guint16 unique_program_id;
172   guint8 avail_num;
173   guint8 avails_expected;
174
175 };
176
177 /*
178  * Types of descriptors
179  *
180  * Note: These are only for the descriptors *WITHIN* a SIT */
181 typedef enum {
182   GST_MTS_SCTE_DESC_AVAIL        = 0x00,
183   GST_MTS_SCTE_DESC_DTMF         = 0x01,
184   GST_MTS_SCTE_DESC_SEGMENTATION = 0x02,
185   GST_MTS_SCTE_DESC_TIME         = 0x03,
186   GST_MTS_SCTE_DESC_AUDIO        = 0x04
187 } GstMpegtsSCTESpliceDescriptor;
188
189 typedef enum {
190   GST_MTS_SCTE_SPLICE_COMMAND_NULL      = 0x00,
191   GST_MTS_SCTE_SPLICE_COMMAND_SCHEDULE  = 0x04,
192   GST_MTS_SCTE_SPLICE_COMMAND_INSERT    = 0x05,
193   GST_MTS_SCTE_SPLICE_COMMAND_TIME      = 0x06,
194   GST_MTS_SCTE_SPLICE_COMMAND_BANDWIDTH = 0x07,
195   GST_MTS_SCTE_SPLICE_COMMAND_PRIVATE   = 0xff
196 } GstMpegtsSCTESpliceCommandType;
197
198 #define GST_TYPE_MPEGTS_SCTE_SIT (gst_mpegts_scte_sit_get_type())
199
200 typedef struct _GstMpegtsSCTESIT GstMpegtsSCTESIT;
201
202 struct _GstMpegtsSCTESIT
203 {
204   gboolean encrypted_packet;
205   guint8   encryption_algorithm;
206
207   guint64  pts_adjustment;
208   guint8   cw_index;
209   guint16  tier;
210
211   guint16  splice_command_length;
212
213   GstMpegtsSCTESpliceCommandType splice_command_type;
214
215   /* For time_signal commands */
216   gboolean splice_time_specified;
217   guint64  splice_time;
218
219   GPtrArray *splices;
220
221   GPtrArray *descriptors;
222
223   /**
224    * GstMpegtsSCTESIT.fully_parsed:
225    *
226    * When encrypted, or when encountering an unknown command type,
227    * we may still want to pass the sit through.
228    *
229    * Since: 1.20
230    */
231   gboolean fully_parsed;
232
233   /**
234    * GstMpegtsSCTESIT.is_running_time:
235    *
236    * When the SIT was constructed by the application, splice times
237    * are in running_time and must be translated before packetizing.
238    *
239    * Since: 1.20
240    */
241   gboolean is_running_time;
242 };
243
244 GST_MPEGTS_API
245 GType gst_mpegts_scte_sit_get_type (void);
246
247 GST_MPEGTS_API
248 GstMpegtsSCTESIT *gst_mpegts_scte_sit_new (void);
249
250 GST_MPEGTS_API
251 GstMpegtsSCTESIT *gst_mpegts_scte_null_new (void);
252
253 GST_MPEGTS_API
254 GstMpegtsSCTESIT *gst_mpegts_scte_cancel_new (guint32 event_id);
255
256 GST_MPEGTS_API
257 GstMpegtsSCTESIT *gst_mpegts_scte_splice_in_new (guint32 event_id,
258                                                  GstClockTime splice_time);
259
260 GST_MPEGTS_API
261 GstMpegtsSCTESIT *gst_mpegts_scte_splice_out_new (guint32 event_id,
262                                                   GstClockTime splice_time,
263                                                   GstClockTime duration);
264
265
266 GST_MPEGTS_API
267 GType gst_mpegts_scte_splice_event_get_type (void);
268
269 GST_MPEGTS_API
270 GstMpegtsSCTESpliceEvent *gst_mpegts_scte_splice_event_new (void);
271
272 GST_MPEGTS_API
273 const GstMpegtsSCTESIT *gst_mpegts_section_get_scte_sit (GstMpegtsSection *section);
274
275 GST_MPEGTS_API
276 GstMpegtsSection *gst_mpegts_section_from_scte_sit (GstMpegtsSCTESIT * sit, guint16 pid);
277
278 GST_MPEGTS_API
279 GType gst_mpegts_scte_splice_component_get_type (void);
280
281 GST_MPEGTS_API
282 GstMpegtsSCTESpliceComponent *gst_mpegts_scte_splice_component_new (guint8 tag);
283
284
285 G_END_DECLS
286
287 #endif  /* GST_SCTE_SECTION_H */