summaryrefslogtreecommitdiff
path: root/gst-libs/gst/mpegts/gst-scte-section.h
blob: aee220d750e83649549bb57f33b78237cc431267 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*
 * gst-scte-section.h -
 * Copyright (C) 2013, CableLabs, Louisville, CO 80027
 *           (c) 2019, Centricular ltd
 *
 * Authors:
 *   RUIH Team <ruih@cablelabs.com>
 *   Edward Hervey <edward@centricular.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef GST_SCTE_SECTION_H
#define GST_SCTE_SECTION_H

#include <gst/gst.h>
#include <gst/mpegts/gstmpegtssection.h>
#include <gst/mpegts/gstmpegtsdescriptor.h>

G_BEGIN_DECLS

/**
 * GstMpegtsScteStreamType:
 * @GST_MPEGTS_STREAM_TYPE_SCTE_SUBTITLING:  SCTE-27 Subtitling
 * @GST_MPEGTS_STREAM_TYPE_SCTE_ISOCH_DATA:  SCTE-19 Isochronous data
 * @GST_MPEGTS_STREAM_TYPE_SCTE_SIT:         SCTE-35 Splice Information Table
 * @GST_MPEGTS_STREAM_TYPE_SCTE_DST_NRT:     SCTE-07 Data Service or
 * Network Resource Table
 * @GST_MPEGTS_STREAM_TYPE_SCTE_DSMCC_DCB:   Type B - DSM-CC Data Carousel
 * [IEC 13818-6])
 * @GST_MPEGTS_STREAM_TYPE_SCTE_SIGNALING:   Enhanced Television Application
 * Signaling (OC-SP-ETV-AM1.0.1-120614)
 * @GST_MPEGTS_STREAM_TYPE_SCTE_SYNC_DATA:   SCTE-07 Synchronous data
 * @GST_MPEGTS_STREAM_TYPE_SCTE_ASYNC_DATA:  SCTE-53 Asynchronous data
 *
 * Type of mpeg-ts streams for SCTE
 *
 */
typedef enum {

  /* 0x01 - 0x82 : defined in other specs */
  GST_MPEGTS_STREAM_TYPE_SCTE_SUBTITLING = 0x82,   /* Subtitling data */
  GST_MPEGTS_STREAM_TYPE_SCTE_ISOCH_DATA = 0x83,   /* Isochronous data */
  /* 0x84 - 0x85 : defined in other specs */
  GST_MPEGTS_STREAM_TYPE_SCTE_SIT        = 0x86,   /* Splice Information Table */
  /* 0x87 - 0x94 : defined in other specs */
  GST_MPEGTS_STREAM_TYPE_SCTE_DST_NRT    = 0x95,   /* DST / NRT data */
  /* 0x96 - 0xaf : defined in other specs */
  GST_MPEGTS_STREAM_TYPE_SCTE_DSMCC_DCB  = 0xb0,   /* Data Carousel Type B */
  /* 0xb1 - 0xbf : User Private (or defined in other specs) */
  GST_MPEGTS_STREAM_TYPE_SCTE_SIGNALING  = 0xc0,   /* EBIF Signaling */
  GST_MPEGTS_STREAM_TYPE_SCTE_SYNC_DATA  = 0xc2,   /* Synchronous data */
  GST_MPEGTS_STREAM_TYPE_SCTE_ASYNC_DATA = 0xc3,   /* Asynchronous data */
  /* 0xc4 - 0xff : User Private (or defined in other specs) */

} GstMpegtsScteStreamType;


/**
 * GstMpegtsSectionSCTETableID:
 * @GST_MTS_TABLE_ID_SCTE_EAS:    SCTE-18 Emergency Alert System
 * @GST_MTS_TABLE_ID_SCTE_EBIF:   CL-SP-ETV-AM 1.0.1 EBIF message
 * @GST_MTS_TABLE_ID_SCTE_EISS:   CL-SP-ETV-AM 1.0.1 EBIF Int. Signaling Sect.
 * @GST_MTS_TABLE_ID_SCTE_DII:    CL-SP-ETV-AM 1.0.1 DSMCC DII message
 * @GST_MTS_TABLE_ID_SCTE_DDB:    CL-SP-ETV-AM 1.0.1 DSMCC Data Download Block
 * @GST_MTS_TABLE_ID_SCTE_SPLICE: SCTE-35 splice information is carried in a
 * section stream on a separate PID in the program’s Map Table (PMT) allowing
 * Splice Event notifications to remain associated with the program and pass
 * through multiplexers.
 *
 * Values for a #GstMpegtsSection table_id.
 *
 * These are the registered SCTE table_id variants.
 *
 * see also: #GstMpegtsSectionTableID
 */
typedef enum {

  /* 0x01 - 0xd7 : defined in other specs */
  GST_MTS_TABLE_ID_SCTE_EAS      = 0xd8,     /* emergency alert information */
  /* 0xd8 - 0xdf : defined in other specs */
  GST_MTS_TABLE_ID_SCTE_EBIF     = 0xE0,     /* EBIF message */
  GST_MTS_TABLE_ID_SCTE_RESERVED = 0xE1,
  GST_MTS_TABLE_ID_SCTE_EISS     = 0xE2,     /* EBIF Int. Signaling Sect. */
  GST_MTS_TABLE_ID_SCTE_DII      = 0xE3,     /* DSMCC DII message */
  GST_MTS_TABLE_ID_SCTE_DDB      = 0xE4,     /* DSMCC Data Download Block */
  /* 0xe5 - 0xfb : defined in other specs */
  GST_MTS_TABLE_ID_SCTE_SPLICE   = 0xfc,     /* splice information table */

} GstMpegtsSectionSCTETableID;

/* Splice Information Table (SIT) */
#define GST_TYPE_MPEGTS_SCTE_SPLICE_EVENT (gst_mpegts_scte_splice_event_get_type);
typedef struct _GstMpegtsSCTESpliceEvent GstMpegtsSCTESpliceEvent;

struct _GstMpegtsSCTESpliceEvent {
  /* TRUE if from/to an insert event (else belongs to a schedule event) */
  gboolean insert_event;

  guint32 splice_event_id;
  gboolean splice_event_cancel_indicator;

  /* If splice_event_cancel_indicator == 0 */
  gboolean out_of_network_indicator;
  gboolean program_splice_flag;	  /* NOTE: Only program splice are supported */
  gboolean duration_flag;
  gboolean splice_immediate_flag; /* Only valid for insert_event */

  gboolean program_splice_time_specified;
  guint64 program_splice_time;

  gboolean break_duration_auto_return;
  guint64 break_duration;

  guint16 unique_program_id;
  guint8 avail_num;
  guint8 avails_expected;

};

/*
 * Types of descriptors
 *
 * Note: These are only for the descriptors *WITHIN* a SIT */
typedef enum {
  GST_MTS_SCTE_DESC_AVAIL        = 0x00,
  GST_MTS_SCTE_DESC_DTMF         = 0x01,
  GST_MTS_SCTE_DESC_SEGMENTATION = 0x02,
  GST_MTS_SCTE_DESC_TIME         = 0x03,
  GST_MTS_SCTE_DESC_AUDIO        = 0x04
} GstMpegtsSCTESpliceDescriptor;

typedef enum {
  GST_MTS_SCTE_SPLICE_COMMAND_NULL      = 0x00,
  GST_MTS_SCTE_SPLICE_COMMAND_SCHEDULE  = 0x04,
  GST_MTS_SCTE_SPLICE_COMMAND_INSERT    = 0x05,
  GST_MTS_SCTE_SPLICE_COMMAND_TIME      = 0x06,
  GST_MTS_SCTE_SPLICE_COMMAND_BANDWIDTH = 0x07,
  GST_MTS_SCTE_SPLICE_COMMAND_PRIVATE   = 0xff
} GstMpegtsSCTESpliceCommandType;

#define GST_TYPE_MPEGTS_SCTE_SIT (gst_mpegts_scte_sit_get_type());

typedef struct _GstMpegtsSCTESIT GstMpegtsSCTESIT;

struct _GstMpegtsSCTESIT
{
  /* Encryption not supported for now */
  gboolean encrypted_packet;
  guint8   encryption_algorithm;

  guint64  pts_adjustment;
  guint8   cw_index;
  guint16  tier;

  guint16  splice_command_length;
  GstMpegtsSCTESpliceCommandType splice_command_type;

  /* For time_signal commands */
  gboolean splice_time_specified;
  guint64  splice_time;

  GPtrArray *splices;

  GPtrArray *descriptors;
};

GST_MPEGTS_API
GType gst_mpegts_scte_sit_get_type (void);

GST_MPEGTS_API
GstMpegtsSCTESIT *gst_mpegts_scte_sit_new (void);

GST_MPEGTS_API
GstMpegtsSCTESIT *gst_mpegts_scte_null_new (void);

GST_MPEGTS_API
GstMpegtsSCTESIT *gst_mpegts_scte_cancel_new (guint32 event_id);

GST_MPEGTS_API
GstMpegtsSCTESIT *gst_mpegts_scte_splice_in_new (guint32 event_id,
						 guint64 splice_time);

GST_MPEGTS_API
GstMpegtsSCTESIT *gst_mpegts_scte_splice_out_new (guint32 event_id,
						  guint64 splice_time,
						  guint64 duration);


GST_MPEGTS_API
GType gst_mpegts_scte_splice_event_get_type (void);

GST_MPEGTS_API
GstMpegtsSCTESpliceEvent *gst_mpegts_scte_splice_event_new (void);

GST_MPEGTS_API
const GstMpegtsSCTESIT *gst_mpegts_section_get_scte_sit (GstMpegtsSection *section);

GST_MPEGTS_API
GstMpegtsSection *gst_mpegts_section_from_scte_sit (GstMpegtsSCTESIT * sit, guint16 pid);


G_END_DECLS

#endif  /* GST_SCTE_SECTION_H */