Sebastian Dröge | e6513c1 | 2013-07-14 12:12:42 +0200 | [diff] [blame] | 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 | |
| 37 | /* |
| 38 | * descriptor_tag TS PS Identification |
| 39 | * 0 n/a n/a Reserved |
| 40 | * 1 n/a n/a Reserved |
| 41 | * 2 X X video_stream_descriptor |
| 42 | * 3 X X audio_stream_descriptor |
| 43 | * 4 X X hierarchy_descriptor |
| 44 | * 5 X X registration_descriptor |
| 45 | * 6 X X data_stream_alignment_descriptor |
| 46 | * 7 X X target_background_grid_descriptor |
| 47 | * 8 X X video_window_descriptor |
| 48 | * 9 X X CA_descriptor |
| 49 | * 10 X X ISO_639_language_descriptor |
| 50 | * 11 X X system_clock_descriptor |
| 51 | * 12 X X multiplex_buffer_utilization_descriptor |
| 52 | * 13 X X copyright_descriptor |
| 53 | * 14 X maximum bitrate descriptor |
| 54 | * 15 X X private data indicator descriptor |
| 55 | * 16 X X smoothing buffer descriptor |
| 56 | * 17 X STD_descriptor |
| 57 | * 18 X X IBP descriptor |
| 58 | * 19-63 n/a n/a ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved |
| 59 | * 64-255 n/a n/a User Private |
| 60 | */ |
| 61 | |
| 62 | /** |
| 63 | * GstMpegTsDescriptorType: |
| 64 | * |
| 65 | * The type of #GstMpegTsDescriptor |
| 66 | * |
| 67 | * These values correspond to the registered descriptor type from |
| 68 | * the base MPEG-TS specifications (ITU H.222.0 | ISO/IEC 13818-1). |
| 69 | * |
| 70 | * Consult the relevant specifications for more details. |
| 71 | */ |
| 72 | typedef enum { |
| 73 | /* 0-18 ISO/IEC 13818-1 (H222.0 06/2012) */ |
| 74 | GST_MTS_DESC_RESERVED_00 = 0x00, |
| 75 | GST_MTS_DESC_RESERVED_01 = 0x01, |
| 76 | GST_MTS_DESC_VIDEO_STREAM = 0x02, |
| 77 | GST_MTS_DESC_AUDIO_STREAM = 0x03, |
| 78 | GST_MTS_DESC_HIERARCHY = 0x04, |
| 79 | GST_MTS_DESC_REGISTRATION = 0x05, |
| 80 | GST_MTS_DESC_DATA_STREAM_ALIGNMENT = 0x06, |
| 81 | GST_MTS_DESC_TARGET_BACKGROUND_GRID = 0x07, |
| 82 | GST_MTS_DESC_VIDEO_WINDOW = 0x08, |
| 83 | GST_MTS_DESC_CA = 0x09, |
| 84 | GST_MTS_DESC_ISO_639_LANGUAGE = 0x0A, |
| 85 | GST_MTS_DESC_SYSTEM_CLOCK = 0x0B, |
| 86 | GST_MTS_DESC_MULTIPLEX_BUFFER_UTILISATION = 0x0C, |
| 87 | GST_MTS_DESC_COPYRIGHT = 0x0D, |
| 88 | GST_MTS_DESC_MAXIMUM_BITRATE = 0x0E, |
| 89 | GST_MTS_DESC_PRIVATE_DATA_INDICATOR = 0x0F, |
| 90 | GST_MTS_DESC_SMOOTHING_BUFFER = 0x10, |
| 91 | GST_MTS_DESC_STD = 0x11, |
| 92 | GST_MTS_DESC_IBP = 0x12, |
| 93 | |
| 94 | /* 19-26 Defined in ISO/IEC 13818-6 (Extensions for DSM-CC) */ |
| 95 | GST_MTS_DESC_DSMCC_CAROUSEL_IDENTIFIER = 0x13, |
| 96 | GST_MTS_DESC_DSMCC_ASSOCIATION_TAG = 0x14, |
| 97 | GST_MTS_DESC_DSMCC_DEFERRED_ASSOCIATION_TAG = 0x15, |
| 98 | /* 0x16 is reserved (so far) */ |
| 99 | GST_MTS_DESC_DSMCC_NPT_REFERENCE = 0x17, |
| 100 | GST_MTS_DESC_DSMCC_NPT_ENDPOINT = 0x18, |
| 101 | GST_MTS_DESC_DSMCC_STREAM_MODE = 0x19, |
| 102 | GST_MTS_DESC_DSMCC_STREAM_EVENT = 0x1A, |
| 103 | |
| 104 | /* 27-54 Later additions to ISO/IEC 13818-1 (H222.0 06/2012) */ |
| 105 | GST_MTS_DESC_MPEG4_VIDEO = 0x1B, |
| 106 | GST_MTS_DESC_MPEG4_AUDIO = 0x1C, |
| 107 | GST_MTS_DESC_IOD = 0x1D, |
| 108 | GST_MTS_DESC_SL = 0x1E, |
| 109 | GST_MTS_DESC_FMC = 0x1F, |
| 110 | GST_MTS_DESC_EXTERNAL_ES_ID = 0x20, |
| 111 | GST_MTS_DESC_MUX_CODE = 0x21, |
| 112 | GST_MTS_DESC_FMX_BUFFER_SIZE = 0x22, |
| 113 | GST_MTS_DESC_MULTIPLEX_BUFFER = 0x23, |
| 114 | GST_MTS_DESC_CONTENT_LABELING = 0x24, |
| 115 | GST_MTS_DESC_METADATA_POINTER = 0x25, |
| 116 | GST_MTS_DESC_METADATA = 0x26, |
| 117 | GST_MTS_DESC_METADATA_STD = 0x27, |
| 118 | GST_MTS_DESC_AVC_VIDEO = 0x28, |
| 119 | /* defined in ISO/IEC 13818-11, MPEG-2 IPMP */ |
| 120 | GST_MTS_DESC_IPMP = 0x29, |
| 121 | GST_MTS_DESC_AVC_TIMING_AND_HRD = 0x2A, |
| 122 | GST_MTS_DESC_MPEG2_AAC_AUDIO = 0x2B, |
| 123 | GST_MTS_DESC_FLEX_MUX_TIMING = 0x2C, |
| 124 | GST_MTS_DESC_MPEG4_TEXT = 0x2D, |
| 125 | GST_MTS_DESC_MPEG4_AUDIO_EXTENSION = 0x2E, |
| 126 | GST_MTS_DESC_AUXILIARY_VIDEO_STREAM = 0x2F, |
| 127 | GST_MTS_DESC_SVC_EXTENSION = 0x30, |
| 128 | GST_MTS_DESC_MVC_EXTENSION = 0x31, |
| 129 | GST_MTS_DESC_J2K_VIDEO = 0x32, |
| 130 | GST_MTS_DESC_MVC_OPERATION_POINT = 0x33, |
| 131 | GST_MTS_DESC_MPEG2_STEREOSCOPIC_VIDEO_FORMAT = 0x34, |
| 132 | GST_MTS_DESC_STEREOSCOPIC_PROGRAM_INFO = 0x35, |
| 133 | GST_MTS_DESC_STEREOSCOPIC_VIDEO_INFO = 0x36, |
| 134 | |
| 135 | /* 55-63 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved */ |
| 136 | } GstMpegTsDescriptorType; |
| 137 | |
| 138 | /** |
| 139 | * GstMpegTsMiscDescriptorType: |
| 140 | * |
| 141 | * The type of #GstMpegTsDescriptor |
| 142 | * |
| 143 | * These values correspond to miscellaneous descriptor types that are |
| 144 | * not yet identified from known specifications. |
| 145 | */ |
| 146 | typedef enum { |
| 147 | /* 0x80 - 0xFE are user defined */ |
| 148 | GST_MTS_DESC_AC3_AUDIO_STREAM = 0x81, |
| 149 | GST_MTS_DESC_DTG_LOGICAL_CHANNEL = 0x83, /* from DTG D-Book */ |
| 150 | } GstMpegTsMiscDescriptorType; |
| 151 | |
| 152 | /** |
| 153 | * GstMpegTsATSCDescriptorType: |
| 154 | * |
| 155 | * These values correspond to the registered descriptor type from |
| 156 | * the various ATSC specifications. |
| 157 | * |
| 158 | * Consult the relevant specifications for more details. |
| 159 | */ |
| 160 | typedef enum { |
| 161 | /* ATSC A/65 2009 */ |
| 162 | GST_MTS_DESC_ATSC_STUFFING = 0x80, |
| 163 | GST_MTS_DESC_ATSC_AC3 = 0x83, |
| 164 | GST_MTS_DESC_ATSC_CAPTION_SERVICE = 0x86, |
| 165 | GST_MTS_DESC_ATSC_CONTENT_ADVISORY = 0x87, |
| 166 | GST_MTS_DESC_ATSC_EXTENDED_CHANNEL_NAME = 0xA0, |
| 167 | GST_MTS_DESC_ATSC_SERVICE_LOCATION = 0xA1, |
| 168 | GST_MTS_DESC_ATSC_TIME_SHIFTED_SERVICE = 0xA2, |
| 169 | GST_MTS_DESC_ATSC_COMPONENT_NAME = 0xA3, |
| 170 | GST_MTS_DESC_ATSC_DCC_DEPARTING_REQUEST = 0xA8, |
| 171 | GST_MTS_DESC_ATSC_DCC_ARRIVING_REQUEST = 0xA9, |
| 172 | GST_MTS_DESC_ATSC_REDISTRIBUTION_CONTROL = 0xAA, |
| 173 | GST_MTS_DESC_ATSC_GENRE = 0xAB, |
| 174 | GST_MTS_DESC_ATSC_PRIVATE_INFORMATION = 0xAD, |
| 175 | |
| 176 | /* ATSC A/53:3 2009 */ |
| 177 | GST_MTS_DESC_ATSC_ENHANCED_SIGNALING = 0xB2, |
| 178 | |
| 179 | /* ATSC A/90 */ |
| 180 | GST_MTS_DESC_ATSC_DATA_SERVICE = 0xA4, |
| 181 | GST_MTS_DESC_ATSC_PID_COUNT = 0xA5, |
| 182 | GST_MTS_DESC_ATSC_DOWNLOAD_DESCRIPTOR = 0xA6, |
| 183 | GST_MTS_DESC_ATSC_MULTIPROTOCOL_ENCAPSULATION = 0xA7, |
| 184 | GST_MTS_DESC_ATSC_MODULE_LINK = 0xB4, |
| 185 | GST_MTS_DESC_ATSC_CRC32 = 0xB5, |
| 186 | GST_MTS_DESC_ATSC_GROUP_LINK = 0xB8, |
| 187 | } GstMpegTsATSCDescriptorType; |
| 188 | |
| 189 | /** |
| 190 | * GstMpegTsISDBDescriptorType: |
| 191 | * |
| 192 | * These values correspond to the registered descriptor type from |
| 193 | * the various ISDB specifications. |
| 194 | * |
| 195 | * Consult the relevant specifications for more details. |
| 196 | */ |
| 197 | typedef enum { |
| 198 | /* ISDB ARIB B10 v4.6 */ |
| 199 | GST_MTS_DESC_ISDB_HIERARCHICAL_TRANSMISSION = 0xC0, |
| 200 | GST_MTS_DESC_ISDB_DIGITAL_COPY_CONTROL = 0xC1, |
| 201 | GST_MTS_DESC_ISDB_NETWORK_IDENTIFICATION = 0xC2, |
| 202 | GST_MTS_DESC_ISDB_PARTIAL_TS_TIME = 0xc3, |
| 203 | GST_MTS_DESC_ISDB_AUDIO_COMPONENT = 0xc4, |
| 204 | GST_MTS_DESC_ISDB_HYPERLINK = 0xc5, |
| 205 | GST_MTS_DESC_ISDB_TARGET_REGION = 0xc6, |
| 206 | GST_MTS_DESC_ISDB_DATA_CONTENT = 0xc7, |
| 207 | GST_MTS_DESC_ISDB_VIDEO_DECODE_CONTROL = 0xc8, |
| 208 | GST_MTS_DESC_ISDB_DOWNLOAD_CONTENT = 0xc9, |
| 209 | GST_MTS_DESC_ISDB_CA_EMM_TS = 0xca, |
| 210 | GST_MTS_DESC_ISDB_CA_CONTRACT_INFORMATION = 0xcb, |
| 211 | GST_MTS_DESC_ISDB_CA_SERVICE = 0xcc, |
| 212 | GST_MTS_DESC_ISDB_TS_INFORMATION = 0xcd, |
| 213 | GST_MTS_DESC_ISDB_EXTENDED_BROADCASTER = 0xce, |
| 214 | GST_MTS_DESC_ISDB_LOGO_TRANSMISSION = 0xcf, |
| 215 | GST_MTS_DESC_ISDB_BASIC_LOCAL_EVENT = 0xd0, |
| 216 | GST_MTS_DESC_ISDB_REFERENCE = 0xd1, |
| 217 | GST_MTS_DESC_ISDB_NODE_RELATION = 0xd2, |
| 218 | GST_MTS_DESC_ISDB_SHORT_NODE_INFORMATION = 0xd3, |
| 219 | GST_MTS_DESC_ISDB_STC_REFERENCE = 0xd4, |
| 220 | GST_MTS_DESC_ISDB_SERIES = 0xd5, |
| 221 | GST_MTS_DESC_ISDB_EVENT_GROUP = 0xd6, |
| 222 | GST_MTS_DESC_ISDB_SI_PARAMETER = 0xd7, |
| 223 | GST_MTS_DESC_ISDB_BROADCASTER_NAME = 0xd8, |
| 224 | GST_MTS_DESC_ISDB_COMPONENT_GROUP = 0xd9, |
| 225 | GST_MTS_DESC_ISDB_SI_PRIME_TS = 0xda, |
| 226 | GST_MTS_DESC_ISDB_BOARD_INFORMATION = 0xdb, |
| 227 | GST_MTS_DESC_ISDB_LDT_LINKAGE = 0xdc, |
| 228 | GST_MTS_DESC_ISDB_CONNECTED_TRANSMISSION = 0xdd, |
| 229 | GST_MTS_DESC_ISDB_CONTENT_AVAILABILITY = 0xde, |
| 230 | /* ... */ |
| 231 | GST_MTS_DESC_ISDB_SERVICE_GROUP = 0xe0 |
| 232 | |
| 233 | } GstMpegTsISDBDescriptorType; |
| 234 | |
| 235 | typedef struct _GstMpegTsDescriptor GstMpegTsDescriptor; |
| 236 | |
| 237 | #define GST_TYPE_MPEGTS_DESCRIPTOR (gst_mpegts_descriptor_get_type()) |
| 238 | GType gst_mpegts_descriptor_get_type (void); |
| 239 | |
| 240 | /** |
| 241 | * GstMpegTsDescriptor: |
Sebastian Dröge | dd8e115 | 2013-08-30 12:58:53 +0200 | [diff] [blame^] | 242 | * @tag: the type of descriptor |
| 243 | * @tag_extension: the extended type (if @descriptor_tag is 0x7f) |
| 244 | * @length: the length of the descriptor content (excluding tag/length field) |
| 245 | * @data: the full descriptor data (including tag, extension, length). The first |
| 246 | * two bytes are the @tag and @tag_extension. |
Sebastian Dröge | e6513c1 | 2013-07-14 12:12:42 +0200 | [diff] [blame] | 247 | * |
| 248 | * Mpeg-TS descriptor (ISO/IEC 13818-1). |
| 249 | */ |
| 250 | struct _GstMpegTsDescriptor |
| 251 | { |
Sebastian Dröge | dd8e115 | 2013-08-30 12:58:53 +0200 | [diff] [blame^] | 252 | guint8 tag; |
| 253 | guint8 tag_extension; |
| 254 | guint8 length; |
| 255 | const guint8 *data; |
Sebastian Dröge | e6513c1 | 2013-07-14 12:12:42 +0200 | [diff] [blame] | 256 | }; |
| 257 | |
Sebastian Dröge | dd8e115 | 2013-08-30 12:58:53 +0200 | [diff] [blame^] | 258 | GPtrArray *gst_mpegts_parse_descriptors (guint8 * buffer, gsize buf_len); |
Sebastian Dröge | e6513c1 | 2013-07-14 12:12:42 +0200 | [diff] [blame] | 259 | |
Sebastian Dröge | dd8e115 | 2013-08-30 12:58:53 +0200 | [diff] [blame^] | 260 | const GstMpegTsDescriptor * gst_mpegts_find_descriptor (GPtrArray *descriptors, |
Sebastian Dröge | e6513c1 | 2013-07-14 12:12:42 +0200 | [diff] [blame] | 261 | guint8 tag); |
| 262 | |
| 263 | /* GST_MTS_DESC_ISO_639_LANGUAGE (0x0A) */ |
| 264 | /** |
| 265 | * GstMpegTsISO639AudioType: |
| 266 | * |
| 267 | * Type of audio streams |
| 268 | * |
| 269 | * Defined in ITU H.222.0 Table 2-60 |
| 270 | */ |
| 271 | typedef enum { |
| 272 | GST_MPEGTS_AUDIO_TYPE_UNDEFINED = 0, |
| 273 | GST_MPEGTS_AUDIO_TYPE_CLEAN_EFFECTS, |
| 274 | GST_MPEGTS_AUDIO_TYPE_HEARING_IMPAIRED, |
| 275 | GST_MPEGTS_AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY |
| 276 | } GstMpegTsIso639AudioType; |
| 277 | |
| 278 | /* FIXME: Make two methods. One for getting the number of languages, |
| 279 | * and the other for getting the (allocated, null-terminated) language |
| 280 | * and audio type */ |
| 281 | typedef struct _GstMpegTsISO639LanguageDescriptor GstMpegTsISO639LanguageDescriptor; |
| 282 | struct _GstMpegTsISO639LanguageDescriptor |
| 283 | { |
| 284 | guint nb_language; |
| 285 | gchar language[64][3]; |
| 286 | GstMpegTsIso639AudioType audio_type[64]; |
| 287 | }; |
| 288 | |
| 289 | gboolean gst_mpegts_descriptor_parse_iso_639_language (const GstMpegTsDescriptor *descriptor, |
| 290 | GstMpegTsISO639LanguageDescriptor *res); |
| 291 | |
| 292 | |
| 293 | |
| 294 | /* GST_MTS_DESC_DTG_LOGICAL_CHANNEL (0x83) */ |
| 295 | typedef struct _GstMpegTsLogicalChannelDescriptor GstMpegTsLogicalChannelDescriptor; |
| 296 | typedef struct _GstMpegTsLogicalChannel GstMpegTsLogicalChannel; |
| 297 | |
| 298 | struct _GstMpegTsLogicalChannel |
| 299 | { |
| 300 | guint16 service_id; |
| 301 | gboolean visible_service; |
| 302 | guint16 logical_channel_number; |
| 303 | }; |
| 304 | |
| 305 | struct _GstMpegTsLogicalChannelDescriptor |
| 306 | { |
| 307 | guint nb_channels; |
| 308 | GstMpegTsLogicalChannel channels[64]; |
| 309 | }; |
| 310 | |
| 311 | /* FIXME : Maybe make two methods. One for getting the number of channels, |
| 312 | * and the other for getting the content for one channel ? */ |
| 313 | gboolean |
| 314 | gst_mpegts_descriptor_parse_logical_channel (const GstMpegTsDescriptor *descriptor, |
| 315 | GstMpegTsLogicalChannelDescriptor *res); |
| 316 | |
| 317 | #endif /* GST_MPEGTS_DESCRIPTOR_H */ |