1 /* 2 * gstmpegtsdescriptor.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 * Some parts of this code come from the Fluendo MPEG Demuxer plugin. 24 * 25 * The Initial Developer of the Original Code is Fluendo, S.L. 26 * Portions created by Fluendo, S.L. are Copyright (C) 2005 27 * Fluendo, S.L. All Rights Reserved. 28 * 29 * Contributor(s): Wim Taymans <wim@fluendo.com> 30 */ 31 32 #ifndef GST_MPEGTS_DESCRIPTOR_H 33 #define GST_MPEGTS_DESCRIPTOR_H 34 35 #include <gst/gst.h> 36 #include <gst/mpegts/mpegts-prelude.h> 37 38 G_BEGIN_DECLS 39 40 /* 41 * descriptor_tag TS PS Identification 42 * 0 n/a n/a Reserved 43 * 1 n/a n/a Reserved 44 * 2 X X video_stream_descriptor 45 * 3 X X audio_stream_descriptor 46 * 4 X X hierarchy_descriptor 47 * 5 X X registration_descriptor 48 * 6 X X data_stream_alignment_descriptor 49 * 7 X X target_background_grid_descriptor 50 * 8 X X video_window_descriptor 51 * 9 X X CA_descriptor 52 * 10 X X ISO_639_language_descriptor 53 * 11 X X system_clock_descriptor 54 * 12 X X multiplex_buffer_utilization_descriptor 55 * 13 X X copyright_descriptor 56 * 14 X maximum bitrate descriptor 57 * 15 X X private data indicator descriptor 58 * 16 X X smoothing buffer descriptor 59 * 17 X STD_descriptor 60 * 18 X X IBP descriptor 61 * 19-63 n/a n/a ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved 62 * 64-255 n/a n/a User Private 63 */ 64 65 /** 66 * GstMpegtsDescriptorType: 67 * 68 * The type of #GstMpegtsDescriptor 69 * 70 * These values correspond to the registered descriptor type from 71 * the base MPEG-TS specifications (ITU H.222.0 | ISO/IEC 13818-1). 72 * 73 * Consult the relevant specifications for more details. 74 */ 75 typedef enum { 76 /* 0-18 ISO/IEC 13818-1 (H222.0 06/2012) */ 77 GST_MTS_DESC_RESERVED_00 = 0x00, 78 GST_MTS_DESC_RESERVED_01 = 0x01, 79 GST_MTS_DESC_VIDEO_STREAM = 0x02, 80 GST_MTS_DESC_AUDIO_STREAM = 0x03, 81 GST_MTS_DESC_HIERARCHY = 0x04, 82 GST_MTS_DESC_REGISTRATION = 0x05, 83 GST_MTS_DESC_DATA_STREAM_ALIGNMENT = 0x06, 84 GST_MTS_DESC_TARGET_BACKGROUND_GRID = 0x07, 85 GST_MTS_DESC_VIDEO_WINDOW = 0x08, 86 GST_MTS_DESC_CA = 0x09, 87 GST_MTS_DESC_ISO_639_LANGUAGE = 0x0A, 88 GST_MTS_DESC_SYSTEM_CLOCK = 0x0B, 89 GST_MTS_DESC_MULTIPLEX_BUFFER_UTILISATION = 0x0C, 90 GST_MTS_DESC_COPYRIGHT = 0x0D, 91 GST_MTS_DESC_MAXIMUM_BITRATE = 0x0E, 92 GST_MTS_DESC_PRIVATE_DATA_INDICATOR = 0x0F, 93 GST_MTS_DESC_SMOOTHING_BUFFER = 0x10, 94 GST_MTS_DESC_STD = 0x11, 95 GST_MTS_DESC_IBP = 0x12, 96 97 /* 19-26 Defined in ISO/IEC 13818-6 (Extensions for DSM-CC) */ 98 GST_MTS_DESC_DSMCC_CAROUSEL_IDENTIFIER = 0x13, 99 GST_MTS_DESC_DSMCC_ASSOCIATION_TAG = 0x14, 100 GST_MTS_DESC_DSMCC_DEFERRED_ASSOCIATION_TAG = 0x15, 101 /* 0x16 is reserved (so far) */ 102 GST_MTS_DESC_DSMCC_NPT_REFERENCE = 0x17, 103 GST_MTS_DESC_DSMCC_NPT_ENDPOINT = 0x18, 104 GST_MTS_DESC_DSMCC_STREAM_MODE = 0x19, 105 GST_MTS_DESC_DSMCC_STREAM_EVENT = 0x1A, 106 107 /* 27-54 Later additions to ISO/IEC 13818-1 (H222.0 06/2012) */ 108 GST_MTS_DESC_MPEG4_VIDEO = 0x1B, 109 GST_MTS_DESC_MPEG4_AUDIO = 0x1C, 110 GST_MTS_DESC_IOD = 0x1D, 111 GST_MTS_DESC_SL = 0x1E, 112 GST_MTS_DESC_FMC = 0x1F, 113 GST_MTS_DESC_EXTERNAL_ES_ID = 0x20, 114 GST_MTS_DESC_MUX_CODE = 0x21, 115 GST_MTS_DESC_FMX_BUFFER_SIZE = 0x22, 116 GST_MTS_DESC_MULTIPLEX_BUFFER = 0x23, 117 GST_MTS_DESC_CONTENT_LABELING = 0x24, 118 GST_MTS_DESC_METADATA_POINTER = 0x25, 119 GST_MTS_DESC_METADATA = 0x26, 120 GST_MTS_DESC_METADATA_STD = 0x27, 121 GST_MTS_DESC_AVC_VIDEO = 0x28, 122 /* defined in ISO/IEC 13818-11, MPEG-2 IPMP */ 123 GST_MTS_DESC_IPMP = 0x29, 124 GST_MTS_DESC_AVC_TIMING_AND_HRD = 0x2A, 125 GST_MTS_DESC_MPEG2_AAC_AUDIO = 0x2B, 126 GST_MTS_DESC_FLEX_MUX_TIMING = 0x2C, 127 GST_MTS_DESC_MPEG4_TEXT = 0x2D, 128 GST_MTS_DESC_MPEG4_AUDIO_EXTENSION = 0x2E, 129 GST_MTS_DESC_AUXILIARY_VIDEO_STREAM = 0x2F, 130 GST_MTS_DESC_SVC_EXTENSION = 0x30, 131 GST_MTS_DESC_MVC_EXTENSION = 0x31, 132 GST_MTS_DESC_J2K_VIDEO = 0x32, 133 GST_MTS_DESC_MVC_OPERATION_POINT = 0x33, 134 GST_MTS_DESC_MPEG2_STEREOSCOPIC_VIDEO_FORMAT = 0x34, 135 GST_MTS_DESC_STEREOSCOPIC_PROGRAM_INFO = 0x35, 136 GST_MTS_DESC_STEREOSCOPIC_VIDEO_INFO = 0x36, 137 138 /* 55-63 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved */ 139 } GstMpegtsDescriptorType; 140 141 /** 142 * GstMpegtsMiscDescriptorType: 143 * 144 * The type of #GstMpegtsDescriptor 145 * 146 * These values correspond to miscellaneous descriptor types that are 147 * not yet identified from known specifications. 148 */ 149 typedef enum { 150 /* 0x80 - 0xFE are user defined */ 151 GST_MTS_DESC_AC3_AUDIO_STREAM = 0x81, 152 GST_MTS_DESC_DTG_LOGICAL_CHANNEL = 0x83, /* from DTG D-Book */ 153 } GstMpegtsMiscDescriptorType; 154 155 /** 156 * GstMpegtsATSCDescriptorType: 157 * 158 * These values correspond to the registered descriptor type from 159 * the various ATSC specifications. 160 * 161 * Consult the relevant specifications for more details. 162 */ 163 typedef enum { 164 /* ATSC A/65 2009 */ 165 GST_MTS_DESC_ATSC_STUFFING = 0x80, 166 GST_MTS_DESC_ATSC_AC3 = 0x83, 167 GST_MTS_DESC_ATSC_CAPTION_SERVICE = 0x86, 168 GST_MTS_DESC_ATSC_CONTENT_ADVISORY = 0x87, 169 GST_MTS_DESC_ATSC_EXTENDED_CHANNEL_NAME = 0xA0, 170 GST_MTS_DESC_ATSC_SERVICE_LOCATION = 0xA1, 171 GST_MTS_DESC_ATSC_TIME_SHIFTED_SERVICE = 0xA2, 172 GST_MTS_DESC_ATSC_COMPONENT_NAME = 0xA3, 173 GST_MTS_DESC_ATSC_DCC_DEPARTING_REQUEST = 0xA8, 174 GST_MTS_DESC_ATSC_DCC_ARRIVING_REQUEST = 0xA9, 175 GST_MTS_DESC_ATSC_REDISTRIBUTION_CONTROL = 0xAA, 176 GST_MTS_DESC_ATSC_GENRE = 0xAB, 177 GST_MTS_DESC_ATSC_PRIVATE_INFORMATION = 0xAD, 178 GST_MTS_DESC_ATSC_EAC3 = 0xCC, 179 180 /* ATSC A/53:3 2009 */ 181 GST_MTS_DESC_ATSC_ENHANCED_SIGNALING = 0xB2, 182 183 /* ATSC A/90 */ 184 GST_MTS_DESC_ATSC_DATA_SERVICE = 0xA4, 185 GST_MTS_DESC_ATSC_PID_COUNT = 0xA5, 186 GST_MTS_DESC_ATSC_DOWNLOAD_DESCRIPTOR = 0xA6, 187 GST_MTS_DESC_ATSC_MULTIPROTOCOL_ENCAPSULATION = 0xA7, 188 GST_MTS_DESC_ATSC_MODULE_LINK = 0xB4, 189 GST_MTS_DESC_ATSC_CRC32 = 0xB5, 190 GST_MTS_DESC_ATSC_GROUP_LINK = 0xB8, 191 } GstMpegtsATSCDescriptorType; 192 193 /** 194 * GstMpegtsISDBDescriptorType: 195 * 196 * These values correspond to the registered descriptor type from 197 * the various ISDB specifications. 198 * 199 * Consult the relevant specifications for more details. 200 */ 201 typedef enum { 202 /* ISDB ARIB B10 v4.6 */ 203 GST_MTS_DESC_ISDB_HIERARCHICAL_TRANSMISSION = 0xC0, 204 GST_MTS_DESC_ISDB_DIGITAL_COPY_CONTROL = 0xC1, 205 GST_MTS_DESC_ISDB_NETWORK_IDENTIFICATION = 0xC2, 206 GST_MTS_DESC_ISDB_PARTIAL_TS_TIME = 0xc3, 207 GST_MTS_DESC_ISDB_AUDIO_COMPONENT = 0xc4, 208 GST_MTS_DESC_ISDB_HYPERLINK = 0xc5, 209 GST_MTS_DESC_ISDB_TARGET_REGION = 0xc6, 210 GST_MTS_DESC_ISDB_DATA_CONTENT = 0xc7, 211 GST_MTS_DESC_ISDB_VIDEO_DECODE_CONTROL = 0xc8, 212 GST_MTS_DESC_ISDB_DOWNLOAD_CONTENT = 0xc9, 213 GST_MTS_DESC_ISDB_CA_EMM_TS = 0xca, 214 GST_MTS_DESC_ISDB_CA_CONTRACT_INFORMATION = 0xcb, 215 GST_MTS_DESC_ISDB_CA_SERVICE = 0xcc, 216 GST_MTS_DESC_ISDB_TS_INFORMATION = 0xcd, 217 GST_MTS_DESC_ISDB_EXTENDED_BROADCASTER = 0xce, 218 GST_MTS_DESC_ISDB_LOGO_TRANSMISSION = 0xcf, 219 GST_MTS_DESC_ISDB_BASIC_LOCAL_EVENT = 0xd0, 220 GST_MTS_DESC_ISDB_REFERENCE = 0xd1, 221 GST_MTS_DESC_ISDB_NODE_RELATION = 0xd2, 222 GST_MTS_DESC_ISDB_SHORT_NODE_INFORMATION = 0xd3, 223 GST_MTS_DESC_ISDB_STC_REFERENCE = 0xd4, 224 GST_MTS_DESC_ISDB_SERIES = 0xd5, 225 GST_MTS_DESC_ISDB_EVENT_GROUP = 0xd6, 226 GST_MTS_DESC_ISDB_SI_PARAMETER = 0xd7, 227 GST_MTS_DESC_ISDB_BROADCASTER_NAME = 0xd8, 228 GST_MTS_DESC_ISDB_COMPONENT_GROUP = 0xd9, 229 GST_MTS_DESC_ISDB_SI_PRIME_TS = 0xda, 230 GST_MTS_DESC_ISDB_BOARD_INFORMATION = 0xdb, 231 GST_MTS_DESC_ISDB_LDT_LINKAGE = 0xdc, 232 GST_MTS_DESC_ISDB_CONNECTED_TRANSMISSION = 0xdd, 233 GST_MTS_DESC_ISDB_CONTENT_AVAILABILITY = 0xde, 234 /* ... */ 235 GST_MTS_DESC_ISDB_SERVICE_GROUP = 0xe0 236 237 } GstMpegtsISDBDescriptorType; 238 239 typedef struct _GstMpegtsDescriptor GstMpegtsDescriptor; 240 241 #define GST_TYPE_MPEGTS_DESCRIPTOR (gst_mpegts_descriptor_get_type()) 242 GST_MPEGTS_API 243 GType gst_mpegts_descriptor_get_type (void); 244 245 /** 246 * GstMpegtsDescriptor: 247 * @tag: the type of descriptor 248 * @tag_extension: the extended type (if @descriptor_tag is 0x7f) 249 * @length: the length of the descriptor content (excluding tag/length field) 250 * @data: the full descriptor data (including tag, extension, length). The first 251 * two bytes are the @tag and @length. 252 * 253 * Mpeg-TS descriptor (ISO/IEC 13818-1). 254 */ 255 struct _GstMpegtsDescriptor 256 { 257 guint8 tag; 258 guint8 tag_extension; 259 guint8 length; 260 guint8 *data; 261 262 /*< private >*/ 263 /* Padding for future extension */ 264 gpointer _gst_reserved[GST_PADDING]; 265 }; 266 267 GST_MPEGTS_API 268 void gst_mpegts_descriptor_free (GstMpegtsDescriptor *desc); 269 270 GST_MPEGTS_API 271 GPtrArray *gst_mpegts_parse_descriptors (guint8 * buffer, gsize buf_len); 272 273 GST_MPEGTS_API 274 const GstMpegtsDescriptor * gst_mpegts_find_descriptor (GPtrArray *descriptors, 275 guint8 tag); 276 277 /* GST_MTS_DESC_REGISTRATION (0x05) */ 278 279 GST_MPEGTS_API 280 GstMpegtsDescriptor *gst_mpegts_descriptor_from_registration ( 281 const gchar *format_identifier, 282 guint8 *additional_info, gsize additional_info_length); 283 284 /* GST_MTS_DESC_CA (0x09) */ 285 286 GST_MPEGTS_API 287 gboolean gst_mpegts_descriptor_parse_ca (GstMpegtsDescriptor *descriptor, 288 guint16 *ca_system_id, 289 guint16 *ca_pid, 290 const guint8 **private_data, 291 gsize *private_data_size); 292 293 /* GST_MTS_DESC_ISO_639_LANGUAGE (0x0A) */ 294 /** 295 * GstMpegtsISO639AudioType: 296 * 297 * Type of audio streams 298 * 299 * Defined in ITU H.222.0 Table 2-60 300 */ 301 typedef enum { 302 GST_MPEGTS_AUDIO_TYPE_UNDEFINED = 0, 303 GST_MPEGTS_AUDIO_TYPE_CLEAN_EFFECTS, 304 GST_MPEGTS_AUDIO_TYPE_HEARING_IMPAIRED, 305 GST_MPEGTS_AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY 306 } GstMpegtsIso639AudioType; 307 308 typedef struct _GstMpegtsISO639LanguageDescriptor GstMpegtsISO639LanguageDescriptor; 309 struct _GstMpegtsISO639LanguageDescriptor 310 { 311 guint nb_language; 312 gchar *language[64]; 313 GstMpegtsIso639AudioType audio_type[64]; 314 }; 315 316 #define GST_TYPE_MPEGTS_ISO_639_LANGUAGE (gst_mpegts_iso_639_language_get_type ()) 317 GST_MPEGTS_API 318 GType gst_mpegts_iso_639_language_get_type (void); 319 320 GST_MPEGTS_API 321 void gst_mpegts_iso_639_language_descriptor_free (GstMpegtsISO639LanguageDescriptor * desc); 322 323 GST_MPEGTS_API 324 gboolean gst_mpegts_descriptor_parse_iso_639_language (const GstMpegtsDescriptor *descriptor, 325 GstMpegtsISO639LanguageDescriptor **res); 326 327 GST_MPEGTS_API 328 gboolean gst_mpegts_descriptor_parse_iso_639_language_idx (const GstMpegtsDescriptor *descriptor, 329 guint idx, gchar **lang, 330 GstMpegtsIso639AudioType *audio_type); 331 332 GST_MPEGTS_API 333 guint gst_mpegts_descriptor_parse_iso_639_language_nb (const GstMpegtsDescriptor *descriptor); 334 335 GST_MPEGTS_API 336 GstMpegtsDescriptor * gst_mpegts_descriptor_from_iso_639_language (const gchar * language); 337 338 339 340 /* GST_MTS_DESC_DTG_LOGICAL_CHANNEL (0x83) */ 341 typedef struct _GstMpegtsLogicalChannelDescriptor GstMpegtsLogicalChannelDescriptor; 342 typedef struct _GstMpegtsLogicalChannel GstMpegtsLogicalChannel; 343 344 struct _GstMpegtsLogicalChannel 345 { 346 guint16 service_id; 347 gboolean visible_service; 348 guint16 logical_channel_number; 349 }; 350 351 struct _GstMpegtsLogicalChannelDescriptor 352 { 353 guint nb_channels; 354 GstMpegtsLogicalChannel channels[64]; 355 }; 356 357 #define GST_TYPE_MPEGTS_LOGICAL_CHANNEL_DESCRIPTOR (gst_mpegts_logical_channel_descriptor_get_type()) 358 359 GST_MPEGTS_API 360 GType gst_mpegts_logical_channel_descriptor_get_type(void); 361 362 #define GST_TYPE_MPEGTS_LOGICAL_CHANNEL (gst_mpegts_logical_channel_get_type()) 363 364 GST_MPEGTS_API 365 GType gst_mpegts_logical_channel_get_type(void); 366 367 /* FIXME : Maybe make two methods. One for getting the number of channels, 368 * and the other for getting the content for one channel ? */ 369 GST_MPEGTS_API 370 gboolean 371 gst_mpegts_descriptor_parse_logical_channel (const GstMpegtsDescriptor *descriptor, 372 GstMpegtsLogicalChannelDescriptor *res); 373 374 GST_MPEGTS_API 375 GstMpegtsDescriptor * 376 gst_mpegts_descriptor_from_custom (guint8 tag, const guint8 *data, gsize length); 377 378 GST_MPEGTS_API 379 GstMpegtsDescriptor * 380 gst_mpegts_descriptor_from_custom_with_extension (guint8 tag, guint8 tag_extension, const guint8 *data, gsize length); 381 382 G_END_DECLS 383 384 #endif /* GST_MPEGTS_DESCRIPTOR_H */ 385