gstmpegtsdescriptor.h 13 KB

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