From 5d3a0ca6a9e703a77338ab84df97c2d4a18310ca Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 14 Dec 2020 10:50:02 +0100 Subject: mpegts: Update documentation * Split up into appropriate individual header files * Document more sections and structures * Add well-known list of registration id Part-of: --- docs/libs/mpegts/index.md | 99 ++++++++++++++- gst-libs/gst/mpegts/gst-atsc-descriptor.h | 87 +++++++++++++ gst-libs/gst/mpegts/gst-atsc-section.c | 44 +++++++ gst-libs/gst/mpegts/gst-atsc-section.h | 70 +++++++++-- gst-libs/gst/mpegts/gst-dvb-section.c | 42 +++++++ gst-libs/gst/mpegts/gst-dvb-section.h | 64 +++++++++- gst-libs/gst/mpegts/gst-hdmv-section.h | 66 ++++++++++ gst-libs/gst/mpegts/gst-isdb-descriptor.h | 89 +++++++++++++ gst-libs/gst/mpegts/gst-scte-section.c | 1 + gst-libs/gst/mpegts/gst-scte-section.h | 5 +- gst-libs/gst/mpegts/gstmpegts-private.h | 1 + gst-libs/gst/mpegts/gstmpegtsdescriptor.c | 194 ++++++----------------------- gst-libs/gst/mpegts/gstmpegtsdescriptor.h | 162 ++++++++++++------------ gst-libs/gst/mpegts/gstmpegtssection.c | 200 +++++++++++++----------------- gst-libs/gst/mpegts/gstmpegtssection.h | 123 +++++++++++++----- gst-libs/gst/mpegts/meson.build | 4 + gst-libs/gst/mpegts/mpegts.c | 62 +++++++++ gst-libs/gst/mpegts/mpegts.h | 3 + 18 files changed, 929 insertions(+), 387 deletions(-) create mode 100644 gst-libs/gst/mpegts/gst-atsc-descriptor.h create mode 100644 gst-libs/gst/mpegts/gst-hdmv-section.h create mode 100644 gst-libs/gst/mpegts/gst-isdb-descriptor.h create mode 100644 gst-libs/gst/mpegts/mpegts.c diff --git a/docs/libs/mpegts/index.md b/docs/libs/mpegts/index.md index 460ea9633..af6997b3e 100644 --- a/docs/libs/mpegts/index.md +++ b/docs/libs/mpegts/index.md @@ -1,7 +1,104 @@ -# Mpeg TS helper library +# MPEG-TS helper library This library should be linked to by getting cflags and libs from gstreamer-plugins-bad-{{ gst_api_version.md }}.pc and adding -lgstmpegts-{{ gst_api_version.md }} to the library flags. > NOTE: This library API is considered *unstable* + +## Purpose + +The MPEG-TS helper library provides a collection of definitions, object, +enumerations and functions to assist with dealing with the base *MPEG 2 +Transport Stream* (MPEG-TS) format (as defined by `ISO/IEC 13818-1` and `ITU-T +H.222.0`) and its derivates (`DVB`, `ATSC`, `SCTE`, `ARIB`, `Blu-ray`, `AVCHD`, +...). + + +This library provides helpers for dealing with: + +* The various Section Information (SI) and Program-Specific Information (SI), + handled with the [GstMpegtsSection](GstMpegtsSection) object and related + functions. + +* The various descriptors present in SI/PSI, handled with the + [GstMpegtsDescriptor](GstMpegtsDescriptor) object and related functions. + + +This library does not cover: + +* Parsing MPEG-TS packets (PSI or PES) and extracting the sections. One can use + an existing demuxer/parser element for this, or parse the packets + themselves. + +* Generate and multiplex MPEG-TS packets and sections. One can use an existing + muxer element for this. + +Applications, or external elements, can interact with the existing MPEG-TS +elements via [messages](gst_message_new_mpegts_section) (to receive sections) or +[events](gst_mpegts_section_send_event) (to send sections). + +## Specification and References + +As much as possible, the information contained in this library is based on the +official Specification and/or References listed below: + +### `MPEG-TS` + +This is the base specification from which all variants are derived. It covers +the basic sections (for program signalling) and descriptors. All variants must +abide by this specification. + +* `ISO/IEC 13818-1` and `ITU-T H.222.0`: *"Information technology – Generic + coding of moving pictures and associated audio information: Systems"*. The two + specifications are identical, the ITU one is more easily available (*nudge*). + +### `SMPTE-RA` : *SMPTE Registration Authority* +The official registration authority for MPEG-TS. This is used for the base +[Registration Descriptor](gst_mpegts_descriptor_parse_registration) which +allows to unambiguously identify a stream when it is not specified in a standard +(yet). + +* + +### `DVB` : *Digital Video Broadcasting* + +This standards body covers the variant of MPEG-TS used in Europe, Oceania, and +most of Asia and Africa. The standards are actually published by the `ETSI` +(European Telecommunications Standards Institute). + +* `ETSI EN 300 468`: *"Digital Video Broadcasting (DVB); Specification for + Service Information (SI) in DVB systems"*. Covers all the sections and + descriptors used in DVB variants. +* `ETSI EN 101 154`: *"Digital Video Broadcasting (DVB);Specification for the + use of Video and Audio Coding in Broadcast and Broadband + Applications"*. Provides more details about signalling/sectios for audio/video + codecs. + +### `ATSC` : *Advanced Television Systems Committee* + +This set of standards covers the variants of MPEG-TS used in North America. +* `ATSC A/53-3` : *"ATSC Digital Television Standard, Part 3 – Service Multiplex + and Transport Subsystem Characteristics"*. How ATSC extends the base MPEG-TS. +* `ATSC A/65` : *"ATSC Standard:Program and System Information Protocol for + Terrestrial Broadcast and Cable"*. Covers all sections and descriptors used in + ATSC 1.0 variants. +* `ATSC A/90` : *"ATSC Data Broadcast Standard"*. Extensions for data transfer + (i.e. DSM-CC). +* `ATSC A/107` : *"ATSC 2.0 Standard"*. Adds a few more descriptors. +* `ATSC Code Points Registry` : The list of stream types, decriptor types, + etc... used by ATSC standards. + +### `SCTE` : *Society of Cable Telecommunications Engineers* + +This set of standards evolved in parallel with ATSC in North-America. Most of it +has been merged into ATSC and other standards since. + +* `ANSI/SCTE 35` : *"Digital Program Insertion Cueing Message for Cable"* + +### `DSM-CC` : "Digital Storage Media - Command & Control" + +This ISO standard is the base for asynchronously carrying "files" over mpeg-ts. + +* `ISO/IEC 13818-6` : *"Information technology — Generic coding of moving + pictures and associated audio information — Part 6: Extensions for DSM-CC"*. diff --git a/gst-libs/gst/mpegts/gst-atsc-descriptor.h b/gst-libs/gst/mpegts/gst-atsc-descriptor.h new file mode 100644 index 000000000..dc9037c5a --- /dev/null +++ b/gst-libs/gst/mpegts/gst-atsc-descriptor.h @@ -0,0 +1,87 @@ +/* + * gstmpegtsdescriptor.h - + * Copyright (C) 2020 Edward Hervey + * + * Authors: + * Edward Hervey + * + * 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_ATSC_DESCRIPTOR_H +#define GST_ATSC_DESCRIPTOR_H + +#include +#include + +G_BEGIN_DECLS + +/** + * SECTION:gst-atsc-descriptor + * @title: ATSC variants of MPEG-TS descriptors + * @short_description: Descriptors for the various ATSC specifications + * @include: gst/mpegts/mpegts.h + * + * This contains the various descriptors defined by the ATSC specifications + */ + +/** + * GstMpegtsATSCDescriptorType: + * + * These values correspond to the registered descriptor type from + * the various ATSC specifications. + * + * Consult the relevant specifications for more details. + */ +typedef enum { + /* ATSC A/65 2009 */ + GST_MTS_DESC_ATSC_STUFFING = 0x80, + GST_MTS_DESC_ATSC_AC3 = 0x81, + GST_MTS_DESC_ATSC_CAPTION_SERVICE = 0x86, + GST_MTS_DESC_ATSC_CONTENT_ADVISORY = 0x87, + GST_MTS_DESC_ATSC_EXTENDED_CHANNEL_NAME = 0xA0, + GST_MTS_DESC_ATSC_SERVICE_LOCATION = 0xA1, + GST_MTS_DESC_ATSC_TIME_SHIFTED_SERVICE = 0xA2, + GST_MTS_DESC_ATSC_COMPONENT_NAME = 0xA3, + GST_MTS_DESC_ATSC_DCC_DEPARTING_REQUEST = 0xA8, + GST_MTS_DESC_ATSC_DCC_ARRIVING_REQUEST = 0xA9, + GST_MTS_DESC_ATSC_REDISTRIBUTION_CONTROL = 0xAA, + GST_MTS_DESC_ATSC_GENRE = 0xAB, + GST_MTS_DESC_ATSC_PRIVATE_INFORMATION = 0xAD, + GST_MTS_DESC_ATSC_EAC3 = 0xCC, + + /* ATSC A/53:3 2009 */ + GST_MTS_DESC_ATSC_ENHANCED_SIGNALING = 0xB2, + + /* ATSC A/90 */ + GST_MTS_DESC_ATSC_DATA_SERVICE = 0xA4, + GST_MTS_DESC_ATSC_PID_COUNT = 0xA5, + GST_MTS_DESC_ATSC_DOWNLOAD_DESCRIPTOR = 0xA6, + GST_MTS_DESC_ATSC_MULTIPROTOCOL_ENCAPSULATION = 0xA7, + GST_MTS_DESC_ATSC_MODULE_LINK = 0xB4, + GST_MTS_DESC_ATSC_CRC32 = 0xB5, + GST_MTS_DESC_ATSC_GROUP_LINK = 0xB8, +} GstMpegtsATSCDescriptorType; + +/* For backwards compatibility */ +/** + * GST_MTS_DESC_AC3_AUDIO_STREAM: (skip) (attributes doc.skip=true) + */ +#define GST_MTS_DESC_AC3_AUDIO_STREAM GST_MTS_DESC_ATSC_AC3 + +G_END_DECLS + +#endif diff --git a/gst-libs/gst/mpegts/gst-atsc-section.c b/gst-libs/gst/mpegts/gst-atsc-section.c index 97743f7ae..64f6a8334 100644 --- a/gst-libs/gst/mpegts/gst-atsc-section.c +++ b/gst-libs/gst/mpegts/gst-atsc-section.c @@ -35,6 +35,50 @@ * @short_description: Sections for the various ATSC specifications * @include: gst/mpegts/mpegts.h * + * The list of section types defined and used by the ATSC specifications can be + * seen in %GstMpegtsSectionATSCTableID. + * + * # Supported ATSC MPEG-TS sections + * These are the sections for which parsing and packetizing code exists. + * + * ## Master Guide Table (MGT) + * See: + * * gst_mpegts_section_get_atsc_mgt() + * * %GstMpegtsAtscMGT + * * %GstMpegtsAtscMGTTable + * * gst_mpegts_atsc_mgt_new() + * + * ## Terrestrial (TVCT) and Cable (CVCT) Virtual Channel Table + * See: + * * gst_mpegts_section_get_atsc_tvct() + * * gst_mpegts_section_get_atsc_cvct() + * * %GstMpegtsAtscVCT + * * %GstMpegtsAtscVCTSource + * + * ## Rating Region Table (RRT) + * See: + * * gst_mpegts_section_get_atsc_rrt() + * * %GstMpegtsAtscRRT + * * gst_mpegts_atsc_rrt_new() + * + * ## Event Information Table (EIT) + * See: + * * gst_mpegts_section_get_atsc_eit() + * * %GstMpegtsAtscEIT + * * %GstMpegtsAtscEITEvent + * + * ## Extended Text Table (ETT) + * See: + * * gst_mpegts_section_get_atsc_ett() + * * %GstMpegtsAtscETT + * + * ## System Time Table (STT) + * See: + * * gst_mpegts_section_get_atsc_stt() + * * %GstMpegtsAtscSTT + * * gst_mpegts_atsc_stt_new() + * + * # API */ /* Terrestrial/Cable Virtual Channel Table TVCT/CVCT */ diff --git a/gst-libs/gst/mpegts/gst-atsc-section.h b/gst-libs/gst/mpegts/gst-atsc-section.h index b31bd1486..4d53ee837 100644 --- a/gst-libs/gst/mpegts/gst-atsc-section.h +++ b/gst-libs/gst/mpegts/gst-atsc-section.h @@ -32,16 +32,30 @@ G_BEGIN_DECLS /** * GstMpegtsSectionATSCTableID: + * @GST_MTS_TABLE_ID_ATSC_MASTER_GUIDE: Master Guide Table (MGT) + * @GST_MTS_TABLE_ID_ATSC_TERRESTRIAL_VIRTUAL_CHANNEL: Terrestrial Virtual Channel Table (TVCT) + * @GST_MTS_TABLE_ID_ATSC_CABLE_VIRTUAL_CHANNEL: Cable Virtual Channel Table (CVCT) + * @GST_MTS_TABLE_ID_ATSC_RATING_REGION: Rating Region Table (RRT) + * @GST_MTS_TABLE_ID_ATSC_EVENT_INFORMATION: Event Information Table (EIT) + * @GST_MTS_TABLE_ID_ATSC_CHANNEL_OR_EVENT_EXTENDED_TEXT: Extended Text Table (ETT) + * @GST_MTS_TABLE_ID_ATSC_SYSTEM_TIME: System Time Table (STT) + * @GST_MTS_TABLE_ID_ATSC_DATA_EVENT: A/90: Data Event Table (DET) + * @GST_MTS_TABLE_ID_ATSC_DATA_SERVICE: A/90: Data Service Table (DST) + * @GST_MTS_TABLE_ID_ATSC_NETWORK_RESOURCE: A/90: Network Resources Table (NRT) + * @GST_MTS_TABLE_ID_ATSC_LONG_TERM_SERVICE: A/90: Long Term Service Table (LTST) + * @GST_MTS_TABLE_ID_ATSC_DIRECTED_CHANNEL_CHANGE: Directed Channel Change Table (DCCT) + * @GST_MTS_TABLE_ID_ATSC_DIRECTED_CHANNEL_CHANGE_SECTION_CODE: Directed Channel Change Selection Code Table (DCCSCT) + * @GST_MTS_TABLE_ID_ATSC_SATELLITE_VIRTUAL_CHANNEL: A/81: Satellite Virtual Channel Table * * Values for a #GstMpegtsSection table_id. * - * These are the registered ATSC table_id variants. + * These are the registered ATSC section `table_id` variants. Unless specified + * otherwise, they are defined in the "ATSC A/65" specification. * - * see also: #GstMpegtsSectionTableID + * see also: #GstMpegtsSectionTableID and other variants. */ typedef enum { - /* ATSC (A/65) */ GST_MTS_TABLE_ID_ATSC_MASTER_GUIDE = 0xC7, GST_MTS_TABLE_ID_ATSC_TERRESTRIAL_VIRTUAL_CHANNEL = 0xC8, @@ -53,19 +67,57 @@ typedef enum { /* ATSC (A/90) */ GST_MTS_TABLE_ID_ATSC_DATA_EVENT = 0xCE, GST_MTS_TABLE_ID_ATSC_DATA_SERVICE = 0xCF, - /* 0xD0 ?? */ + + /* ATSC (A/57B) */ + /** + * GST_MTS_TABLE_ID_ATSC_PROGRAM_IDENTIFIER: + * + * A/57B: Program Identifier Table. + * + * Since: 1.20 + */ + GST_MTS_TABLE_ID_ATSC_PROGRAM_IDENTIFIER = 0xD0, + /* ATSC (A/90) */ GST_MTS_TABLE_ID_ATSC_NETWORK_RESOURCE = 0xD1, GST_MTS_TABLE_ID_ATSC_LONG_TERM_SERVICE = 0xD2, + /* ATSC (A/65) */ GST_MTS_TABLE_ID_ATSC_DIRECTED_CHANNEL_CHANGE = 0xD3, GST_MTS_TABLE_ID_ATSC_DIRECTED_CHANNEL_CHANGE_SECTION_CODE = 0xD4, - /* 0xD5 ?? */ + /* 0xD5-0xD9 covered in CEA/SCTE */ GST_MTS_TABLE_ID_ATSC_AGGREGATE_EVENT_INFORMATION = 0xD6, GST_MTS_TABLE_ID_ATSC_AGGREGATE_EXTENDED_TEXT = 0xD7, - /* 0xD8 ?? */ GST_MTS_TABLE_ID_ATSC_AGGREGATE_DATA_EVENT = 0xD9, + /* */ GST_MTS_TABLE_ID_ATSC_SATELLITE_VIRTUAL_CHANNEL = 0xDA, } GstMpegtsSectionATSCTableID; +/** + * GstMpegtsATSCStreamType: + * @GST_MPEGTS_STREAM_TYPE_ATSC_DCII_VIDEO: DigiCipher II video | Identical to ITU-T Rec. H.262 | ISO/IEC 13818-2 Video + * @GST_MPEGTS_STREAM_TYPE_ATSC_AUDIO_AC3: ATSC A/53 Audio | AC-3 + * @GST_MPEGTS_STREAM_TYPE_ATSC_SUBTITLING: SCTE-27 Subtitling + * @GST_MPEGTS_STREAM_TYPE_ATSC_ISOCH_DATA: SCTE-19 Isochronous data | Reserved + * @GST_MPEGTS_STREAM_TYPE_ATSC_SIT: SCTE-35 Splice Information Table + * @GST_MPEGTS_STREAM_TYPE_ATSC_AUDIO_EAC3: E-AC-3 A/52:2018 + * @GST_MPEGTS_STREAM_TYPE_ATSC_AUDIO_DTS_HD: E-AC-3 A/107 (ATSC 2.0) + * + * Type of mpeg-ts streams for ATSC, as defined by the ATSC Code Points + * Registry. For convenience, some stream types from %GstMpegtsScteStreamType + * are also included. + * + * Since: 1.20 + */ +typedef enum { + GST_MPEGTS_STREAM_TYPE_ATSC_DCII_VIDEO = 0x80, + GST_MPEGTS_STREAM_TYPE_ATSC_AUDIO_AC3 = 0x81, + GST_MPEGTS_STREAM_TYPE_ATSC_SUBTITLING = 0x82, + GST_MPEGTS_STREAM_TYPE_ATSC_ISOCH_DATA = 0x83, + /* 0x84-0x85 : RESERVED */ + GST_MPEGTS_STREAM_TYPE_ATSC_SIT = 0x86, + GST_MPEGTS_STREAM_TYPE_ATSC_AUDIO_EAC3 = 0x87, + GST_MPEGTS_STREAM_TYPE_ATSC_AUDIO_DTS_HD = 0x88, +} GstMpegtsATSCStreamType; + /* TVCT/CVCT */ #define GST_TYPE_MPEGTS_ATSC_VCT (gst_mpegts_atsc_vct_get_type ()) #define GST_TYPE_MPEGTS_ATSC_VCT_SOURCE (gst_mpegts_atsc_vct_source_get_type ()) @@ -92,7 +144,7 @@ typedef struct _GstMpegtsAtscVCT GstMpegtsAtscVCT; * @source_id: The source id * @descriptors: (element-type GstMpegtsDescriptor): an array of #GstMpegtsDescriptor * - * Source from a @GstMpegtsAtscVCT, can be used both for TVCT and CVCT tables + * Source from a %GstMpegtsAtscVCT, can be used both for TVCT and CVCT tables */ struct _GstMpegtsAtscVCTSource { @@ -214,7 +266,7 @@ GstMpegtsSection * gst_mpegts_section_from_atsc_mgt (GstMpegtsAtscMGT * mgt); GST_MPEGTS_API GstMpegtsAtscMGT * gst_mpegts_atsc_mgt_new (void); -/* Multiple string structure (used in ETT and EIT */ +/* Multiple string structure (used in ETT and EIT) */ #define GST_TYPE_MPEGTS_ATSC_STRING_SEGMENT (gst_mpegts_atsc_string_segment_get_type()) #define GST_TYPE_MPEGTS_ATSC_MULT_STRING (gst_mpegts_atsc_mult_string_get_type()) @@ -425,7 +477,7 @@ struct _GstMpegtsAtscRRTDimensionValue }; /** - * _GstMpegtsAtscRRTDimension: + * GstMpegtsAtscRRTDimension: * @names: (element-type GstMpegtsAtscMultString): the names * @graduated_scale: whether the ratings represent a graduated scale * @values_defined: the number of values defined for this dimension diff --git a/gst-libs/gst/mpegts/gst-dvb-section.c b/gst-libs/gst/mpegts/gst-dvb-section.c index 71fc65c0e..6b9eb49c2 100644 --- a/gst-libs/gst/mpegts/gst-dvb-section.c +++ b/gst-libs/gst/mpegts/gst-dvb-section.c @@ -44,6 +44,48 @@ * @short_description: Sections for the various DVB specifications * @include: gst/mpegts/mpegts.h * + * The list of section types defined and used by the DVB specifications can be + * seen in %GstMpegtsSectionDVBTableID. + * + * # Supported DVB MPEG-TS sections + * These are the sections for which parsing and packetizing code exists. + * + * ## Network Information Table (NIT) + * See: + * * gst_mpegts_section_get_nit() + * * %GstMpegtsNIT + * * %GstMpegtsNITStream + * * gst_mpegts_nit_new() + * + * ## Service Description Table (SDT) + * See: + * * gst_mpegts_section_get_sdt() + * * %GstMpegtsSDT + * * %GstMpegtsSDTService + * * gst_mpegts_sdt_new() + * + * ## Bouquet Association Table (BAT) + * See: + * * gst_mpegts_section_get_bat() + * * %GstMpegtsBAT + * * %GstMpegtsBATStream + * + * ## Event Information Table (EIT) + * See: + * * gst_mpegts_section_get_eit() + * * %GstMpegtsEIT + * * %GstMpegtsEITEvent + * + * ## Time Date Table (TDT) + * See: + * * gst_mpegts_section_get_tdt() + * + * ## Time Offset Table (TOT) + * See: + * * gst_mpegts_section_get_tot() + * * %GstMpegtsTOT + * + * # API */ diff --git a/gst-libs/gst/mpegts/gst-dvb-section.h b/gst-libs/gst/mpegts/gst-dvb-section.h index 28b4e1bf4..2fa2a9a42 100644 --- a/gst-libs/gst/mpegts/gst-dvb-section.h +++ b/gst-libs/gst/mpegts/gst-dvb-section.h @@ -32,10 +32,39 @@ G_BEGIN_DECLS /** * GstMpegtsSectionDVBTableID: + * @GST_MTS_TABLE_ID_NETWORK_INFORMATION_ACTUAL_NETWORK: Network Information Table (NIT), Actual Network + * @GST_MTS_TABLE_ID_NETWORK_INFORMATION_OTHER_NETWORK: Network Information Table (NIT), Other Network + * @GST_MTS_TABLE_ID_SERVICE_DESCRIPTION_ACTUAL_TS: Service Description Table (SDT), Actual Transport Stream + * @GST_MTS_TABLE_ID_SERVICE_DESCRIPTION_OTHER_TS: Service Description Table (SDT), Other Transport Stream + * @GST_MTS_TABLE_ID_BOUQUET_ASSOCIATION: Bouquet Association Table (BAT) + * @GST_MTS_TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_PRESENT: Event Information Table (EIT), Actual Transport Stream, present/following + * @GST_MTS_TABLE_ID_EVENT_INFORMATION_OTHER_TS_PRESENT: Event Information Table (EIT), Other Transport Stream, present/following + * @GST_MTS_TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_SCHEDULE_1: Event Information Table (EIT), Actual Transport Stream, Schedule (first) + * @GST_MTS_TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_SCHEDULE_N: Event Information Table (EIT), Actual Transport Stream, Schedule (last) + * @GST_MTS_TABLE_ID_EVENT_INFORMATION_OTHER_TS_SCHEDULE_1: Event Information Table (EIT), Other Transport Stream, Schedule (first) + * @GST_MTS_TABLE_ID_EVENT_INFORMATION_OTHER_TS_SCHEDULE_N: Event Information Table (EIT), Other Transport Stream, Schedule (last) + * @GST_MTS_TABLE_ID_TIME_DATE: Time Date Table (TDT) + * @GST_MTS_TABLE_ID_RUNNING_STATUS: Running Status Table (RST) + * @GST_MTS_TABLE_ID_STUFFING: Stuffing Table (ST) + * @GST_MTS_TABLE_ID_TIME_OFFSET: Time Offset Table (TOT) + * @GST_MTS_TABLE_ID_APPLICATION_INFORMATION_TABLE: ETSI TS 102 323: Application Information Table (AIT) + * @GST_MTS_TABLE_ID_CONTAINER: ETSI TS 102 323: Container Section + * @GST_MTS_TABLE_ID_RELATED_CONTENT: ETSI TS 102 323: Related Content Table (RCT) + * @GST_MTS_TABLE_ID_CONTENT_IDENTIFIER: ETSI TS 102 323: Content Identifier Table (CIT) + * @GST_MTS_TABLE_ID_MPE_FEC: ETSI TS 301 192: MPE-FEC Section + * @GST_MTS_TABLE_ID_RESOLUTION_NOTIFICATION: ETSI 103 323: Resolution Provider Notification Table (RNT) + * @GST_MTS_TABLE_ID_MPE_IFEC: ETSI TS 102 772: MPE-IFEC Section + * @GST_MTS_TABLE_ID_DISCONTINUITY_INFORMATION: Discontinuity Information Table (DIT) + * @GST_MTS_TABLE_ID_SELECTION_INFORMATION: Selection Information Table (SIT) + * @GST_MTS_TABLE_ID_CA_MESSAGE_ECM_0: ETSI TR 289: CA Message Table (CMT): ECM 0 + * @GST_MTS_TABLE_ID_CA_MESSAGE_ECM_1: ETSI TR 289: CA Message Table (CMT): ECM 1 + * @GST_MTS_TABLE_ID_CA_MESSAGE_SYSTEM_PRIVATE_1: ETSI TR 289: CA Message Table (CMT): CA System Private (First) + * @GST_MTS_TABLE_ID_CA_MESSAGE_SYSTEM_PRIVATE_N: ETSI TR 289: CA Message Table (CMT): CA System Private (Last) * * Values for a #GstMpegtsSection table_id. * - * These are the registered DVB table_id variants. + * These are the registered DVB table_id variants. Unless specified otherwise, + * they come from the DVB Specification for SI (ETSI EN 300 468). * * see also: #GstMpegtsSectionTableID */ @@ -46,6 +75,28 @@ typedef enum { GST_MTS_TABLE_ID_SERVICE_DESCRIPTION_ACTUAL_TS = 0x42, GST_MTS_TABLE_ID_SERVICE_DESCRIPTION_OTHER_TS = 0x46, GST_MTS_TABLE_ID_BOUQUET_ASSOCIATION = 0x4A, + + /* ETSI TS 102 006 */ + /** + * GST_MTS_TABLE_ID_UPDATE_NOTIFICATION: + * + * ETSI TS 102 006: Update Notification Table (UNT) + * + * Since: 1.20 + */ + GST_MTS_TABLE_ID_UPDATE_NOTIFICATION = 0x4B, + + /* ETSI EN 303 560 */ + /** + * GST_MTS_TABLE_ID_DOWNLOADABLE_FONT_INFO: + * + * ETSI EN 303 560: Downloadable Font Info + * + * Since: 1.20 + */ + GST_MTS_TABLE_ID_DOWNLOADABLE_FONT_INFO = 0x4C, + + /* EN 300 468 */ GST_MTS_TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_PRESENT = 0x4E, GST_MTS_TABLE_ID_EVENT_INFORMATION_OTHER_TS_PRESENT = 0x4F, GST_MTS_TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_SCHEDULE_1 = 0x50, @@ -74,6 +125,16 @@ typedef enum { /* TS 102 772 (DVB-SH Multi-Protocol Encapsulation) */ GST_MTS_TABLE_ID_MPE_IFEC = 0x7A, + /* TS 102 809 (DVB Hybrid Broadcast/Broadband) */ + /** + * GST_MTS_TABLE_ID_PROTECTION_MESSAGE: + * + * ETSI TS 102 809: Protection Message Section + * + * Since: 1.20 + */ + GST_MTS_TABLE_ID_PROTECTION_MESSAGE = 0x7B, + /* EN 300 468 (DVB) v 1.12.1 */ GST_MTS_TABLE_ID_DISCONTINUITY_INFORMATION = 0x7E, GST_MTS_TABLE_ID_SELECTION_INFORMATION = 0x7F, @@ -87,6 +148,7 @@ typedef enum { /* ... */ /* EN 301 790 (DVB interaction channel for satellite distribution channels) */ + /* Note: Not 100% sure we want those exposed here ... */ GST_MTS_TABLE_ID_SCT = 0xA0, GST_MTS_TABLE_ID_FCT = 0xA1, GST_MTS_TABLE_ID_TCT = 0xA2, diff --git a/gst-libs/gst/mpegts/gst-hdmv-section.h b/gst-libs/gst/mpegts/gst-hdmv-section.h new file mode 100644 index 000000000..e5356dc5f --- /dev/null +++ b/gst-libs/gst/mpegts/gst-hdmv-section.h @@ -0,0 +1,66 @@ +/* + * gst-hdmv-section.h - + * Copyright (C) 2020, Centricular ltd + * + * Authors: + * Edward Hervey + * + * 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_HDMV_SECTION_H +#define GST_HDMV_SECTION_H + +#include +#include +#include + +G_BEGIN_DECLS + +/** + * SECTION:gst-hdmv-section + * @title: HDMV variants of MPEG-TS (Bluray, AVCHD, ...) + * @short_description: Stream Types for the various Bluray specifications + * @include: gst/mpegts/mpegts.h + */ + +/** + * GstMpegtsHdmvStreamType: + * + * Type of mpeg-ts streams for Blu-ray formats. To be matched with the + * stream-type of a #GstMpegtsSection. + * + * Since: 1.20 + */ +typedef enum { + GST_MPEGTS_STREAM_TYPE_HDMV_AUDIO_LPCM = 0x80, + GST_MPEGTS_STREAM_TYPE_HDMV_AUDIO_AC3 = 0x81, + GST_MPEGTS_STREAM_TYPE_HDMV_AUDIO_DTS = 0x82, + GST_MPEGTS_STREAM_TYPE_HDMV_AUDIO_AC3_TRUE_HD = 0x83, + GST_MPEGTS_STREAM_TYPE_HDMV_AUDIO_AC3_PLUS = 0x84, + GST_MPEGTS_STREAM_TYPE_HDMV_AUDIO_DTS_HD = 0x85, + GST_MPEGTS_STREAM_TYPE_HDMV_AUDIO_DTS_HD_MASTER_AUDIO = 0x86, + GST_MPEGTS_STREAM_TYPE_HDMV_AUDIO_EAC3 = 0x87, + GST_MPEGTS_STREAM_TYPE_HDMV_SUBPICTURE_PGS = 0x90, + GST_MPEGTS_STREAM_TYPE_HDMV_IGS = 0x91, + GST_MPEGTS_STREAM_TYPE_HDMV_SUBTITLE = 0x92, + GST_MPEGTS_STREAM_TYPE_HDMV_AUDIO_AC3_PLUS_SECONDARY = 0xa1, + GST_MPEGTS_STREAM_TYPE_HDMV_AUDIO_DTS_HD_SECONDARY = 0xa2, +} GstMpegtsHdmvStreamType; + +G_END_DECLS + +#endif /* GST_HDMV_SECTION_H */ diff --git a/gst-libs/gst/mpegts/gst-isdb-descriptor.h b/gst-libs/gst/mpegts/gst-isdb-descriptor.h new file mode 100644 index 000000000..0206c669c --- /dev/null +++ b/gst-libs/gst/mpegts/gst-isdb-descriptor.h @@ -0,0 +1,89 @@ +/* + * gst-isdb-descriptor.h - + * Copyright (C) 2020 Edward Hervey + * + * Authors: + * Edward Hervey + * + * 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_ISDB_DESCRIPTOR_H +#define GST_ISDB_DESCRIPTOR_H + +#include +#include + +G_BEGIN_DECLS + +/** + * SECTION:gst-isdb-descriptor + * @title: ISDB variants of MPEG-TS descriptors + * @short_description: Descriptors for the various ISDB specifications + * @include: gst/mpegts/mpegts.h + * + * This contains the various descriptors defined by the ISDB specifications + */ + +/** + * GstMpegtsISDBDescriptorType: + * + * These values correspond to the registered descriptor type from + * the various ISDB specifications. + * + * Consult the relevant specifications for more details. + */ +typedef enum { + /* ISDB ARIB B10 v4.6 */ + GST_MTS_DESC_ISDB_HIERARCHICAL_TRANSMISSION = 0xC0, + GST_MTS_DESC_ISDB_DIGITAL_COPY_CONTROL = 0xC1, + GST_MTS_DESC_ISDB_NETWORK_IDENTIFICATION = 0xC2, + GST_MTS_DESC_ISDB_PARTIAL_TS_TIME = 0xc3, + GST_MTS_DESC_ISDB_AUDIO_COMPONENT = 0xc4, + GST_MTS_DESC_ISDB_HYPERLINK = 0xc5, + GST_MTS_DESC_ISDB_TARGET_REGION = 0xc6, + GST_MTS_DESC_ISDB_DATA_CONTENT = 0xc7, + GST_MTS_DESC_ISDB_VIDEO_DECODE_CONTROL = 0xc8, + GST_MTS_DESC_ISDB_DOWNLOAD_CONTENT = 0xc9, + GST_MTS_DESC_ISDB_CA_EMM_TS = 0xca, + GST_MTS_DESC_ISDB_CA_CONTRACT_INFORMATION = 0xcb, + GST_MTS_DESC_ISDB_CA_SERVICE = 0xcc, + GST_MTS_DESC_ISDB_TS_INFORMATION = 0xcd, + GST_MTS_DESC_ISDB_EXTENDED_BROADCASTER = 0xce, + GST_MTS_DESC_ISDB_LOGO_TRANSMISSION = 0xcf, + GST_MTS_DESC_ISDB_BASIC_LOCAL_EVENT = 0xd0, + GST_MTS_DESC_ISDB_REFERENCE = 0xd1, + GST_MTS_DESC_ISDB_NODE_RELATION = 0xd2, + GST_MTS_DESC_ISDB_SHORT_NODE_INFORMATION = 0xd3, + GST_MTS_DESC_ISDB_STC_REFERENCE = 0xd4, + GST_MTS_DESC_ISDB_SERIES = 0xd5, + GST_MTS_DESC_ISDB_EVENT_GROUP = 0xd6, + GST_MTS_DESC_ISDB_SI_PARAMETER = 0xd7, + GST_MTS_DESC_ISDB_BROADCASTER_NAME = 0xd8, + GST_MTS_DESC_ISDB_COMPONENT_GROUP = 0xd9, + GST_MTS_DESC_ISDB_SI_PRIME_TS = 0xda, + GST_MTS_DESC_ISDB_BOARD_INFORMATION = 0xdb, + GST_MTS_DESC_ISDB_LDT_LINKAGE = 0xdc, + GST_MTS_DESC_ISDB_CONNECTED_TRANSMISSION = 0xdd, + GST_MTS_DESC_ISDB_CONTENT_AVAILABILITY = 0xde, + /* ... */ + GST_MTS_DESC_ISDB_SERVICE_GROUP = 0xe0 + +} GstMpegtsISDBDescriptorType; + +G_END_DECLS + +#endif diff --git a/gst-libs/gst/mpegts/gst-scte-section.c b/gst-libs/gst/mpegts/gst-scte-section.c index 39a5b6001..e91191d12 100644 --- a/gst-libs/gst/mpegts/gst-scte-section.c +++ b/gst-libs/gst/mpegts/gst-scte-section.c @@ -35,6 +35,7 @@ * @short_description: Sections for the various SCTE specifications * @include: gst/mpegts/mpegts.h * + * This contains the %GstMpegtsSection relevent to SCTE specifications. */ /* Splice Information Table (SIT) */ diff --git a/gst-libs/gst/mpegts/gst-scte-section.h b/gst-libs/gst/mpegts/gst-scte-section.h index aee220d75..7242f4124 100644 --- a/gst-libs/gst/mpegts/gst-scte-section.h +++ b/gst-libs/gst/mpegts/gst-scte-section.h @@ -46,12 +46,13 @@ G_BEGIN_DECLS * @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 + * Type of mpeg-ts streams for SCTE. Most users would want to use the + * #GstMpegtsATSCStreamType instead since it also covers these stream types * */ typedef enum { - /* 0x01 - 0x82 : defined in other specs */ + /* 0x01 - 0x7f : 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 */ diff --git a/gst-libs/gst/mpegts/gstmpegts-private.h b/gst-libs/gst/mpegts/gstmpegts-private.h index 94199d9b0..3f5b09891 100644 --- a/gst-libs/gst/mpegts/gstmpegts-private.h +++ b/gst-libs/gst/mpegts/gstmpegts-private.h @@ -29,6 +29,7 @@ G_BEGIN_DECLS GST_DEBUG_CATEGORY_EXTERN (mpegts_debug); #define GST_CAT_DEFAULT mpegts_debug +G_GNUC_INTERNAL void __initialize_sections (void); G_GNUC_INTERNAL void __initialize_descriptors (void); G_GNUC_INTERNAL guint32 _calc_crc32 (const guint8 *data, guint datalen); G_GNUC_INTERNAL gchar *get_encoding_and_convert (const gchar *text, guint length); diff --git a/gst-libs/gst/mpegts/gstmpegtsdescriptor.c b/gst-libs/gst/mpegts/gstmpegtsdescriptor.c index 46e883dcf..e63aa5c22 100644 --- a/gst-libs/gst/mpegts/gstmpegtsdescriptor.c +++ b/gst-libs/gst/mpegts/gstmpegtsdescriptor.c @@ -47,46 +47,6 @@ static void _##name##_free (type * source) \ * @title: Base MPEG-TS descriptors * @short_description: Descriptors for ITU H.222.0 | ISO/IEC 13818-1 * @include: gst/mpegts/mpegts.h - * @symbols: - * - GstMpegtsDescriptor - * - GstMpegtsDescriptorType - * - GstMpegtsMiscDescriptorType - * - gst_mpegts_find_descriptor - * - gst_mpegts_parse_descriptors - * - gst_mpegts_descriptor_from_custom - * - gst_mpegts_descriptor_from_registration - * - GstMpegtsISO639LanguageDescriptor - * - GstMpegtsIso639AudioType - * - gst_mpegts_descriptor_parse_iso_639_language - * - gst_mpegts_descriptor_parse_iso_639_language_idx - * - gst_mpegts_descriptor_parse_iso_639_language_nb - * - gst_mpegts_iso_639_language_descriptor_free - * - GstMpegtsLogicalChannel - * - GstMpegtsLogicalChannelDescriptor - * - gst_mpegts_descriptor_parse_logical_channel - * - GST_TYPE_MPEGTS_DVB_CODE_RATE - * - GST_TYPE_MPEGTS_CABLE_OUTER_FEC_SCHEME - * - GST_TYPE_MPEGTS_MODULATION_TYPE - * - GST_TYPE_MPEGTS_SATELLITE_POLARIZATION_TYPE - * - GST_TYPE_MPEGTS_SATELLITE_ROLLOFF - * - GST_TYPE_MPEGTS_ISO_639_LANGUAGE - * - GST_TYPE_MPEGTS_DESCRIPTOR - * - GST_TYPE_MPEGTS_DVB_SERVICE_TYPE - * - GST_TYPE_MPEGTS_DESCRIPTOR_TYPE - * - GST_TYPE_MPEGTS_ISO639_AUDIO_TYPE - * - GST_TYPE_MPEGTS_DVB_DESCRIPTOR_TYPE - * - GST_TYPE_MPEGTS_MISC_DESCRIPTOR_TYPE - * - gst_mpegts_descriptor_get_type - * - gst_mpegts_iso_639_language_get_type - * - gst_mpegts_cable_outer_fec_scheme_get_type - * - gst_mpegts_modulation_type_get_type - * - gst_mpegts_satellite_polarization_type_get_type - * - gst_mpegts_satellite_rolloff_get_type - * - gst_mpegts_descriptor_type_get_type - * - gst_mpegts_dvb_descriptor_type_get_type - * - gst_mpegts_misc_descriptor_type_get_type - * - gst_mpegts_iso639_audio_type_get_type - * - gst_mpegts_dvb_service_type_get_type * * These are the base descriptor types and methods. * @@ -94,119 +54,6 @@ static void _##name##_free (type * source) \ * and other specifications mentioned in the documentation. */ -/* FIXME : Move this to proper file once we have a C file for ATSC/ISDB descriptors */ -/** - * SECTION:gst-atsc-descriptor - * @title: ATSC variants of MPEG-TS descriptors - * @short_description: Descriptors for the various ATSC specifications - * @include: gst/mpegts/mpegts.h - * @symbols: - * - GstMpegtsATSCDescriptorType - * - GST_TYPE_MPEGTS_ATSC_DESCRIPTOR_TYPE - * - gst_mpegts_atsc_descriptor_type_get_type - * - GstMpegtsDVBDescriptorType - * - GstMpegtsDVBExtendedDescriptorType - * - GstMpegtsContent - * - gst_mpegts_descriptor_parse_dvb_content - * - GstMpegtsComponentDescriptor - * - gst_mpegts_dvb_component_descriptor_free - * - gst_mpegts_descriptor_parse_dvb_component - * - GstMpegtsExtendedEventItem - * - GstMpegtsExtendedEventDescriptor - * - gst_mpegts_extended_event_descriptor_free - * - gst_mpegts_descriptor_parse_dvb_extended_event - * - GstMpegtsSatelliteDeliverySystemDescriptor - * - GstMpegtsDVBCodeRate - * - GstMpegtsModulationType - * - GstMpegtsSatellitePolarizationType - * - GstMpegtsSatelliteRolloff - * - gst_mpegts_descriptor_parse_satellite_delivery_system - * - GstMpegtsCableDeliverySystemDescriptor - * - GstMpegtsCableOuterFECScheme - * - gst_mpegts_descriptor_parse_cable_delivery_system - * - GstMpegtsTerrestrialDeliverySystemDescriptor - * - GstMpegtsTerrestrialTransmissionMode - * - GstMpegtsTerrestrialGuardInterval - * - GstMpegtsTerrestrialHierarchy - * - gst_mpegts_descriptor_parse_terrestrial_delivery_system - * - GstMpegtsT2DeliverySystemCellExtension - * - GstMpegtsT2DeliverySystemCell - * - GstMpegtsT2DeliverySystemDescriptor - * - gst_mpegts_t2_delivery_system_descriptor_free - * - gst_mpegts_descriptor_parse_dvb_t2_delivery_system - * - gst_mpegts_descriptor_parse_dvb_short_event - * - gst_mpegts_descriptor_parse_dvb_network_name - * - gst_mpegts_descriptor_from_dvb_network_name - * - GstMpegtsDVBServiceType - * - gst_mpegts_descriptor_parse_dvb_service - * - gst_mpegts_descriptor_from_dvb_service - * - GstMpegtsDVBTeletextType - * - gst_mpegts_descriptor_parse_dvb_teletext_idx - * - gst_mpegts_descriptor_parse_dvb_teletext_nb - * - gst_mpegts_descriptor_parse_dvb_subtitling_idx - * - gst_mpegts_descriptor_parse_dvb_subtitling_nb - * - gst_mpegts_descriptor_from_dvb_subtitling - * - GstMpegtsDVBLinkageType - * - GstMpegtsDVBLinkageHandOverType - * - GstMpegtsDVBLinkageMobileHandOver - * - GstMpegtsDVBLinkageEvent - * - GstMpegtsDVBLinkageExtendedEvent - * - GstMpegtsDVBLinkageDescriptor - * - gst_mpegts_dvb_linkage_descriptor_free - * - gst_mpegts_dvb_linkage_descriptor_get_mobile_hand_over - * - gst_mpegts_dvb_linkage_descriptor_get_event - * - gst_mpegts_dvb_linkage_descriptor_get_extended_event - * - gst_mpegts_descriptor_parse_dvb_linkage - * - gst_mpegts_descriptor_parse_dvb_private_data_specifier - * - gst_mpegts_descriptor_parse_dvb_frequency_list - * - GstMpegtsDataBroadcastDescriptor - * - gst_mpegts_dvb_data_broadcast_descriptor_free - * - gst_mpegts_descriptor_parse_dvb_data_broadcast - * - GstMpegtsDVBScramblingModeType - * - gst_mpegts_descriptor_parse_dvb_scrambling - * - gst_mpegts_descriptor_parse_dvb_data_broadcast_id - * - GstMpegtsDVBParentalRatingItem - * - gst_mpegts_descriptor_parse_dvb_parental_rating - * - gst_mpegts_descriptor_parse_dvb_stream_identifier - * - gst_mpegts_descriptor_parse_dvb_ca_identifier - * - GstMpegtsDVBServiceListItem - * - gst_mpegts_descriptor_parse_dvb_service_list - * - gst_mpegts_descriptor_parse_dvb_stuffing - * - gst_mpegts_descriptor_parse_dvb_bouquet_name - * - GstMpegtsDvbMultilingualNetworkNameItem - * - gst_mpegts_descriptor_parse_dvb_multilingual_network_name - * - GstMpegtsDvbMultilingualBouquetNameItem - * - gst_mpegts_descriptor_parse_dvb_multilingual_bouquet_name - * - GstMpegtsDvbMultilingualServiceNameItem - * - gst_mpegts_descriptor_parse_dvb_multilingual_service_name - * - GstMpegtsDvbMultilingualComponentItem - * - gst_mpegts_descriptor_parse_dvb_multilingual_component - * - GST_TYPE_MPEGTS_COMPONENT_DESCRIPTOR - * - GST_TYPE_MPEGTS_DVB_DATA_BROADCAST_DESCRIPTOR - * - GST_TYPE_MPEGTS_DVB_LINKAGE_DESCRIPTOR - * - GST_TYPE_MPEGTS_EXTENDED_EVENT_DESCRIPTOR - * - GST_TYPE_MPEGTS_T2_DELIVERY_SYSTEM_DESCRIPTOR - * - gst_mpegts_dvb_code_rate_get_type - * - gst_mpegts_component_descriptor_get_type - * - gst_mpegts_dvb_data_broadcast_descriptor_get_type - * - gst_mpegts_dvb_linkage_descriptor_get_type - * - gst_mpegts_extended_event_descriptor_get_type - * - gst_mpegts_t2_delivery_system_descriptor_get_type - * - */ - -/** - * SECTION:gst-isdb-descriptor - * @title: ISDB variants of MPEG-TS descriptors - * @short_description: Descriptors for the various ISDB specifications - * @include: gst/mpegts/mpegts.h - * @symbols: - * - GstMpegtsISDBDescriptorType - * - GST_TYPE_MPEGTS_ISDB_DESCRIPTOR_TYPE - * - gst_mpegts_isdb_descriptor_type_get_type - */ - - /* * TODO * @@ -1050,6 +897,47 @@ gst_mpegts_descriptor_from_registration (const gchar * format_identifier, return descriptor; } +/** + * gst_mpegts_descriptor_parse_registration: + * @descriptor: a %GST_MTS_DESC_REGISTRATION #GstMpegtsDescriptor + * @registration_id: (out): The registration ID (in host endiannes) + * @additional_info: (out) (allow-none) (array length=additional_info_length): The additional information + * @additional_info_length: (out) (allow-none): The size of @additional_info in bytes. + * + * Extracts the Registration information from @descriptor. + * + * Returns: %TRUE if parsing succeeded, else %FALSE. + * + * Since: 1.20 + */ + +gboolean +gst_mpegts_descriptor_parse_registration (GstMpegtsDescriptor * descriptor, + guint32 * registration_id, + guint8 ** additional_info, gsize * additional_info_length) +{ + guint8 *data; + + g_return_val_if_fail (descriptor != NULL && registration_id != NULL, FALSE); + + /* The smallest registration is 4 bytes */ + __common_desc_checks (descriptor, GST_MTS_DESC_REGISTRATION, 4, FALSE); + + data = (guint8 *) descriptor->data + 2; + *registration_id = GST_READ_UINT32_BE (data); + data += 4; + if (additional_info && additional_info_length) { + *additional_info_length = descriptor->length - 4; + if (descriptor->length > 4) { + *additional_info = data; + } else { + *additional_info = NULL; + } + } + + return TRUE; +} + /* GST_MTS_DESC_CA (0x09) */ /** diff --git a/gst-libs/gst/mpegts/gstmpegtsdescriptor.h b/gst-libs/gst/mpegts/gstmpegtsdescriptor.h index a775c296b..3e4d95d6c 100644 --- a/gst-libs/gst/mpegts/gstmpegtsdescriptor.h +++ b/gst-libs/gst/mpegts/gstmpegtsdescriptor.h @@ -148,93 +148,28 @@ typedef enum { */ typedef enum { /* 0x80 - 0xFE are user defined */ - GST_MTS_DESC_AC3_AUDIO_STREAM = 0x81, - GST_MTS_DESC_DTG_LOGICAL_CHANNEL = 0x83, /* from DTG D-Book */ + GST_MTS_DESC_DTG_LOGICAL_CHANNEL = 0x83, /* from DTG D-Book, only present in NIT */ } GstMpegtsMiscDescriptorType; /** - * GstMpegtsATSCDescriptorType: + * GstMpegtsSCTEDescriptorType: * - * These values correspond to the registered descriptor type from - * the various ATSC specifications. + * These values correspond to the ones defined by SCTE (amongst other in ANSI/SCTE 57) * - * Consult the relevant specifications for more details. + * Since: 1.20 */ typedef enum { - /* ATSC A/65 2009 */ - GST_MTS_DESC_ATSC_STUFFING = 0x80, - GST_MTS_DESC_ATSC_AC3 = 0x83, - GST_MTS_DESC_ATSC_CAPTION_SERVICE = 0x86, - GST_MTS_DESC_ATSC_CONTENT_ADVISORY = 0x87, - GST_MTS_DESC_ATSC_EXTENDED_CHANNEL_NAME = 0xA0, - GST_MTS_DESC_ATSC_SERVICE_LOCATION = 0xA1, - GST_MTS_DESC_ATSC_TIME_SHIFTED_SERVICE = 0xA2, - GST_MTS_DESC_ATSC_COMPONENT_NAME = 0xA3, - GST_MTS_DESC_ATSC_DCC_DEPARTING_REQUEST = 0xA8, - GST_MTS_DESC_ATSC_DCC_ARRIVING_REQUEST = 0xA9, - GST_MTS_DESC_ATSC_REDISTRIBUTION_CONTROL = 0xAA, - GST_MTS_DESC_ATSC_GENRE = 0xAB, - GST_MTS_DESC_ATSC_PRIVATE_INFORMATION = 0xAD, - GST_MTS_DESC_ATSC_EAC3 = 0xCC, - - /* ATSC A/53:3 2009 */ - GST_MTS_DESC_ATSC_ENHANCED_SIGNALING = 0xB2, - - /* ATSC A/90 */ - GST_MTS_DESC_ATSC_DATA_SERVICE = 0xA4, - GST_MTS_DESC_ATSC_PID_COUNT = 0xA5, - GST_MTS_DESC_ATSC_DOWNLOAD_DESCRIPTOR = 0xA6, - GST_MTS_DESC_ATSC_MULTIPROTOCOL_ENCAPSULATION = 0xA7, - GST_MTS_DESC_ATSC_MODULE_LINK = 0xB4, - GST_MTS_DESC_ATSC_CRC32 = 0xB5, - GST_MTS_DESC_ATSC_GROUP_LINK = 0xB8, -} GstMpegtsATSCDescriptorType; + GST_MTS_DESC_SCTE_STUFFING = 0x80, + GST_MTS_DESC_SCTE_AC3 = 0x81, + GST_MTS_DESC_SCTE_FRAME_RATE = 0x82, + GST_MTS_DESC_SCTE_EXTENDED_VIDEO = 0x83, + GST_MTS_DESC_SCTE_COMPONENT_NAME = 0x84, + GST_MTS_DESC_SCTE_FREQUENCY_SPEC = 0x90, + GST_MTS_DESC_SCTE_MODULATION_PARAMS = 0x91, + GST_MTS_DESC_SCTE_TRANSPORT_STREAM_ID = 0x92 +} GstMpegtsSCTEDescriptorType; + -/** - * GstMpegtsISDBDescriptorType: - * - * These values correspond to the registered descriptor type from - * the various ISDB specifications. - * - * Consult the relevant specifications for more details. - */ -typedef enum { - /* ISDB ARIB B10 v4.6 */ - GST_MTS_DESC_ISDB_HIERARCHICAL_TRANSMISSION = 0xC0, - GST_MTS_DESC_ISDB_DIGITAL_COPY_CONTROL = 0xC1, - GST_MTS_DESC_ISDB_NETWORK_IDENTIFICATION = 0xC2, - GST_MTS_DESC_ISDB_PARTIAL_TS_TIME = 0xc3, - GST_MTS_DESC_ISDB_AUDIO_COMPONENT = 0xc4, - GST_MTS_DESC_ISDB_HYPERLINK = 0xc5, - GST_MTS_DESC_ISDB_TARGET_REGION = 0xc6, - GST_MTS_DESC_ISDB_DATA_CONTENT = 0xc7, - GST_MTS_DESC_ISDB_VIDEO_DECODE_CONTROL = 0xc8, - GST_MTS_DESC_ISDB_DOWNLOAD_CONTENT = 0xc9, - GST_MTS_DESC_ISDB_CA_EMM_TS = 0xca, - GST_MTS_DESC_ISDB_CA_CONTRACT_INFORMATION = 0xcb, - GST_MTS_DESC_ISDB_CA_SERVICE = 0xcc, - GST_MTS_DESC_ISDB_TS_INFORMATION = 0xcd, - GST_MTS_DESC_ISDB_EXTENDED_BROADCASTER = 0xce, - GST_MTS_DESC_ISDB_LOGO_TRANSMISSION = 0xcf, - GST_MTS_DESC_ISDB_BASIC_LOCAL_EVENT = 0xd0, - GST_MTS_DESC_ISDB_REFERENCE = 0xd1, - GST_MTS_DESC_ISDB_NODE_RELATION = 0xd2, - GST_MTS_DESC_ISDB_SHORT_NODE_INFORMATION = 0xd3, - GST_MTS_DESC_ISDB_STC_REFERENCE = 0xd4, - GST_MTS_DESC_ISDB_SERIES = 0xd5, - GST_MTS_DESC_ISDB_EVENT_GROUP = 0xd6, - GST_MTS_DESC_ISDB_SI_PARAMETER = 0xd7, - GST_MTS_DESC_ISDB_BROADCASTER_NAME = 0xd8, - GST_MTS_DESC_ISDB_COMPONENT_GROUP = 0xd9, - GST_MTS_DESC_ISDB_SI_PRIME_TS = 0xda, - GST_MTS_DESC_ISDB_BOARD_INFORMATION = 0xdb, - GST_MTS_DESC_ISDB_LDT_LINKAGE = 0xdc, - GST_MTS_DESC_ISDB_CONNECTED_TRANSMISSION = 0xdd, - GST_MTS_DESC_ISDB_CONTENT_AVAILABILITY = 0xde, - /* ... */ - GST_MTS_DESC_ISDB_SERVICE_GROUP = 0xe0 - -} GstMpegtsISDBDescriptorType; typedef struct _GstMpegtsDescriptor GstMpegtsDescriptor; @@ -277,6 +212,69 @@ const GstMpegtsDescriptor * gst_mpegts_find_descriptor (GPtrArray *descriptors, GST_MPEGTS_API const GstMpegtsDescriptor * gst_mpegts_find_descriptor_with_extension (GPtrArray *descriptors, guint8 tag, guint8 tag_extension); +/** + * GstMpegtsRegistrationId: + * @GST_MTS_REGISTRATION_0: Undefined registration id + * @GST_MTS_REGISTRATION_AC_3: Audio AC-3, ATSC A/52 + * @GST_MTS_REGISTRATION_AC_4: Audio AC-4, ETSI 103 190-2 + * @GST_MTS_REGISTRATION_CUEI: SCTE 35, "Digital Program Insertion Cueing Message" + * @GST_MTS_REGISTRATION_drac: Dirac Video codec + * @GST_MTS_REGISTRATION_DTS1: DTS Audio + * @GST_MTS_REGISTRATION_DTS2: DTS Audio + * @GST_MTS_REGISTRATION_DTS3: DTS Audio + * @GST_MTS_REGISTRATION_EAC3: Enhanced AC-3 (i.e. EAC3) + * @GST_MTS_REGISTRATION_ETV1: Cablelabs ETV + * @GST_MTS_REGISTRATION_BSSD: SMPTE 302M, Mapping of AES3 Data in mpeg-ts + * @GST_MTS_REGISTRATION_GA94: ATSC A/53 compliant stream (i.e. ATSC) + * @GST_MTS_REGISTRATION_HDMV: Blu-ray, "System Description Blu-ray Disc + * Read-Only Format part 3 Audio Visual Basic Specifications" + * @GST_MTS_REGISTRATION_KLVA: SMPTE RP217 : Non-synchronized Mapping of KLV + * Packets in mpeg-ts + * @GST_MTS_REGISTRATION_OPUS: Opus Audio + * @GST_MTS_REGISTRATION_TSHV: HDV (Sony) + * @GST_MTS_REGISTRATION_VC_1: Video VC-1, SMPTE RP227 "VC-1 Bitstream Transport Encodings" + * @GST_MTS_REGISTRATION_OTHER_HEVC: HEVC / h265 + * + * Well-known registration ids, expressed as native-endian 32bit integers. These + * are used in descriptors of type %GST_MTS_DESC_REGISTRATION. Unless specified + * otherwise (by use of the "OTHER" prefix), they are all registered by the + * [SMPTE Registration Authority](https://smpte-ra.org/) or specified in + * "official" documentation for the given format. + * + * Since: 1.20 + */ + +/** + * REG_TO_UINT32: (skip) (attributes doc.skip=true) + */ +#define REG_TO_UINT32(a,b,c,d)((a) << 24 | (b) << 16 | (c) << 8 | (d)) + +typedef enum { + GST_MTS_REGISTRATION_0 = 0, + + /* SMPTE-RA registered */ + GST_MTS_REGISTRATION_AC_3 = REG_TO_UINT32 ('A', 'C', '-', '3'), + GST_MTS_REGISTRATION_CUEI = REG_TO_UINT32 ('C', 'U', 'E', 'I'), + GST_MTS_REGISTRATION_drac = REG_TO_UINT32 ('d', 'r', 'a', 'c'), + GST_MTS_REGISTRATION_DTS1 = REG_TO_UINT32 ('D', 'T', 'S', '1'), + GST_MTS_REGISTRATION_DTS2 = REG_TO_UINT32 ('D', 'T', 'S', '2'), + GST_MTS_REGISTRATION_DTS3 = REG_TO_UINT32 ('D', 'T', 'S', '3'), + GST_MTS_REGISTRATION_BSSD = REG_TO_UINT32 ('B', 'S', 'S', 'D'), + GST_MTS_REGISTRATION_EAC3 = REG_TO_UINT32 ('E', 'A', 'C', '3'), + GST_MTS_REGISTRATION_ETV1 = REG_TO_UINT32 ('E', 'T', 'V', '1'), + GST_MTS_REGISTRATION_GA94 = REG_TO_UINT32 ('G', 'A', '9', '4'), + GST_MTS_REGISTRATION_HDMV = REG_TO_UINT32 ('H', 'D', 'M', 'V'), + GST_MTS_REGISTRATION_KLVA = REG_TO_UINT32 ('K', 'L', 'V', 'A'), + GST_MTS_REGISTRATION_OPUS = REG_TO_UINT32 ('O', 'P', 'U', 'S'), + GST_MTS_REGISTRATION_TSHV = REG_TO_UINT32 ('T', 'S', 'H', 'V'), + GST_MTS_REGISTRATION_VC_1 = REG_TO_UINT32 ('V', 'C', '-', '1'), + + /* Self-registered by formats, but not in SMPTE-RA registry */ + GST_MTS_REGISTRATION_AC_4 = REG_TO_UINT32 ('A', 'C', '-', '4'), + + /* Found elsewhere */ + GST_MTS_REGISTRATION_OTHER_HEVC = REG_TO_UINT32 ('H', 'E', 'V', 'C') +} GstMpegtsRegistrationId; /* GST_MTS_DESC_REGISTRATION (0x05) */ @@ -285,6 +283,12 @@ GstMpegtsDescriptor *gst_mpegts_descriptor_from_registration ( const gchar *format_identifier, guint8 *additional_info, gsize additional_info_length); +GST_MPEGTS_API +gboolean gst_mpegts_descriptor_parse_registration(GstMpegtsDescriptor *descriptor, + guint32 *registration_id, + guint8 **additional_info, + gsize *additional_info_length); + /* GST_MTS_DESC_CA (0x09) */ GST_MPEGTS_API diff --git a/gst-libs/gst/mpegts/gstmpegtssection.c b/gst-libs/gst/mpegts/gstmpegtssection.c index f5077a952..2f2a96f84 100644 --- a/gst-libs/gst/mpegts/gstmpegtssection.c +++ b/gst-libs/gst/mpegts/gstmpegtssection.c @@ -38,78 +38,58 @@ #include "mpegts.h" #include "gstmpegts-private.h" -/** - * SECTION:gstmpegts - * @title: Mpeg-ts helper library - * @short_description: Mpeg-ts helper library for plugins and applications - * @include: gst/mpegts/mpegts.h - */ - /** * SECTION:gstmpegtssection * @title: Base MPEG-TS sections * @short_description: Sections for ITU H.222.0 | ISO/IEC 13818-1 * @include: gst/mpegts/mpegts.h - * @symbols: - * - GST_MPEGTS_SECTION_TYPE - * - GstMpegtsSection - * - GstMpegtsSectionTableID - * - GstMpegtsSectionType - * - gst_message_new_mpegts_section - * - gst_message_parse_mpegts_section - * - gst_mpegts_section_send_event - * - gst_event_parse_mpegts_section - * - gst_mpegts_section_packetize - * - gst_mpegts_section_new - * - gst_mpegts_section_ref - * - gst_mpegts_section_unref - * - GstMpegtsPatProgram - * - gst_mpegts_section_get_pat - * - gst_mpegts_pat_new - * - gst_mpegts_pat_program_new - * - gst_mpegts_section_from_pat - * - GstMpegtsPMT - * - GstMpegtsPMTStream - * - GstMpegtsStreamType - * - gst_mpegts_section_get_pmt - * - gst_mpegts_pmt_new - * - gst_mpegts_pmt_stream_new - * - gst_mpegts_section_from_pmt - * - gst_mpegts_section_get_tsdt - * - gst_mpegts_section_get_cat - * - GST_TYPE_MPEGTS_SECTION_TABLE_ID - * - GST_TYPE_MPEGTS_SECTION_TYPE - * - GST_TYPE_MPEGTS_SECTION_DVB_TABLE_ID - * - GST_MPEGTS_SECTION - * - GST_TYPE_MPEGTS_STREAM_TYPE - * - GST_TYPE_MPEGTS_PMT - * - GST_TYPE_MPEGTS_PMT_STREAM - * - GST_TYPE_MPEGTS_SECTION - * - gst_mpegts_section_table_id_get_type - * - gst_mpegts_section_type_get_type - * - gst_mpegts_pmt_get_type - * - gst_mpegts_pmt_stream_get_type - * - gst_mpegts_section_get_type - * - gst_mpegts_stream_type_get_type + * + * ## Generic usage of sections with %GstMpegtsSection + * + * The %GstMpegtsSection object is the representation of MPEG-TS Section (SI or + * PSI). + * + * Various elements can post those on the bus via %GstMessage of type + * %GST_MESSAGE_ELEMENT. The gst_message_parse_mpegts_section() function + * provides access to the section. + * + * Applications (or other elements) can create them either by using one of the + * `gst_mpegts_section_from_*` functions, or by providing the raw SI data via + * gst_mpegts_section_new(). + * + * Elements outputting MPEG-TS streams can also create sections using the + * various convenience functions and then get the packetized data (to be + * inserted in MPEG-TS packets) using gst_mpegts_section_packetize(). * * For more details, refer to the ITU H.222.0 or ISO/IEC 13818-1 specifications * and other specifications mentioned in the documentation. - */ - -/* - * TODO * - * * Check minimum size for section parsing in the various - * gst_mpegts_section_get_() methods + * # Supported base MPEG-TS sections + * These are the sections for which parsing and packetizing code exists. + * + * ## Program Association Table (PAT) + * See: + * * gst_mpegts_section_get_pat() + * * gst_mpegts_pat_program_new() + * * %GstMpegtsPatProgram + * + * ## Conditional Access Table (CAT) + * See: + * * gst_mpegts_section_get_cat() + * + * ## Program Map Table (PMT) + * See: + * * %GstMpegtsPMT + * * gst_mpegts_section_get_pmt() + * * gst_mpegts_pmt_new() + * * %GstMpegtsPMTStream * - * * Implement parsing code for - * * BAT - * * CAT - * * TSDT + * ## Transport Stream Description Table (TSDT) + * See: + * * gst_mpegts_section_get_tsdt() + * # API */ -GST_DEBUG_CATEGORY (mpegts_debug); - static GQuark QUARK_PAT; static GQuark QUARK_CAT; static GQuark QUARK_BAT; @@ -392,7 +372,8 @@ _mpegts_section_get_event (GstMpegtsSection * section) * * Extracts the #GstMpegtsSection contained in the @event #GstEvent * - * Returns: (transfer full): The extracted #GstMpegtsSection + * Returns: (transfer full): The extracted #GstMpegtsSection , or %NULL if the + * event did not contain a valid #GstMpegtsSection. */ GstMpegtsSection * gst_event_parse_mpegts_section (GstEvent * event) @@ -417,10 +398,10 @@ gst_event_parse_mpegts_section (GstEvent * event) * @element: (transfer none): The #GstElement to send to section event to * @section: (transfer none): The #GstMpegtsSection to put in the event * - * Creates a custom #GstEvent with a @GstMpegtsSection. - * The #GstEvent is sent to the @element #GstElement. + * Creates a custom #GstEvent with a @GstMpegtsSection and send it the @element + * #GstElement. * - * Returns: %TRUE if the event is sent + * Returns: %TRUE if the event was sent to the element. */ gboolean gst_mpegts_section_send_event (GstMpegtsSection * section, GstElement * element) @@ -509,12 +490,13 @@ _parse_pat (GstMpegtsSection * section) * * Returns the array of #GstMpegtsPatProgram contained in the section. * - * Note: The PAT "transport_id" field corresponds to the "subtable_extension" - * field of the provided @section. + * Note: The PAT `transport_stream_id` field corresponds to the + * "subtable_extension" field of the provided @section. * * Returns: (transfer container) (element-type GstMpegtsPatProgram): The - * #GstMpegtsPatProgram contained in the section, or %NULL if an error - * happened. Release with #g_ptr_array_unref when done. + * #GstMpegtsPatProgram contained in the section, or %NULL if an error happened + * or the @section did not contain a valid PAT. Release with #g_ptr_array_unref + * when done. */ GPtrArray * gst_mpegts_section_get_pat (GstMpegtsSection * section) @@ -535,7 +517,8 @@ gst_mpegts_section_get_pat (GstMpegtsSection * section) /** * gst_mpegts_pat_new: * - * Allocates a new #GPtrArray for #GstMpegtsPatProgram + * Allocates a new #GPtrArray for #GstMpegtsPatProgram. The array can be filled + * and then converted to a PAT section with gst_mpegts_section_from_pat(). * * Returns: (transfer full) (element-type GstMpegtsPatProgram): A newly allocated #GPtrArray */ @@ -782,7 +765,7 @@ error: * gst_mpegts_section_get_pmt: * @section: a #GstMpegtsSection of type %GST_MPEGTS_SECTION_PMT * - * Returns the #GstMpegtsPMT contained in the @section. + * Parses the Program Map Table contained in the @section. * * Returns: The #GstMpegtsPMT contained in the section, or %NULL if an error * happened. @@ -804,7 +787,9 @@ gst_mpegts_section_get_pmt (GstMpegtsSection * section) /** * gst_mpegts_pmt_new: * - * Allocates and initializes a new #GstMpegtsPMT. + * Allocates and initializes a new #GstMpegtsPMT. #GstMpegtsPMTStream can be + * added to the streams array, and global PMT #GstMpegtsDescriptor to the + * descriptors array. * * Returns: (transfer full): #GstMpegtsPMT */ @@ -982,11 +967,13 @@ _parse_cat (GstMpegtsSection * section) * gst_mpegts_section_get_cat: * @section: a #GstMpegtsSection of type %GST_MPEGTS_SECTION_CAT * + * Parses a Conditional Access Table. + * * Returns the array of #GstMpegtsDescriptor contained in the Conditional * Access Table. * - * Returns: (transfer container) (element-type GstMpegtsDescriptor): The - * #GstMpegtsDescriptor contained in the section, or %NULL if an error + * Returns: (transfer container) (element-type GstMpegtsDescriptor): The array + * of #GstMpegtsDescriptor contained in the section, or %NULL if an error * happened. Release with #g_array_unref when done. */ GPtrArray * @@ -1010,10 +997,12 @@ gst_mpegts_section_get_cat (GstMpegtsSection * section) * gst_mpegts_section_get_tsdt: * @section: a #GstMpegtsSection of type %GST_MPEGTS_SECTION_TSDT * + * Parses a Transport Stream Description Table. + * * Returns the array of #GstMpegtsDescriptor contained in the section * - * Returns: (transfer container) (element-type GstMpegtsDescriptor): The - * #GstMpegtsDescriptor contained in the section, or %NULL if an error + * Returns: (transfer container) (element-type GstMpegtsDescriptor): The array + * of #GstMpegtsDescriptor contained in the section, or %NULL if an error * happened. Release with #g_array_unref when done. */ GPtrArray * @@ -1030,39 +1019,7 @@ gst_mpegts_section_get_tsdt (GstMpegtsSection * section) } -/** - * gst_mpegts_initialize: - * - * Initializes the MPEG-TS helper library. Must be called before any - * usage. - */ -void -gst_mpegts_initialize (void) -{ - if (_gst_mpegts_section_type) - return; - - GST_DEBUG_CATEGORY_INIT (mpegts_debug, "mpegts", 0, "MPEG-TS helper library"); - - /* FIXME : Temporary hack to initialize section gtype */ - _gst_mpegts_section_type = gst_mpegts_section_get_type (); - - QUARK_PAT = g_quark_from_string ("pat"); - QUARK_CAT = g_quark_from_string ("cat"); - QUARK_PMT = g_quark_from_string ("pmt"); - QUARK_NIT = g_quark_from_string ("nit"); - QUARK_BAT = g_quark_from_string ("bat"); - QUARK_SDT = g_quark_from_string ("sdt"); - QUARK_EIT = g_quark_from_string ("eit"); - QUARK_TDT = g_quark_from_string ("tdt"); - QUARK_TOT = g_quark_from_string ("tot"); - QUARK_SECTION = g_quark_from_string ("section"); - - __initialize_descriptors (); -} -/* FIXME : Later on we might need to use more than just the table_id - * to figure out which type of section this is. */ static GstMpegtsSectionType _identify_section (guint16 pid, guint8 table_id) { @@ -1220,8 +1177,8 @@ _packetize_common_section (GstMpegtsSection * section, gsize length) /** * gst_mpegts_section_new: * @pid: the PID to which this section belongs - * @data: (transfer full) (array length=data_size): a pointer to the beginning of the section (i.e. the first byte - * should contain the table_id field). + * @data: (transfer full) (array length=data_size): a pointer to the beginning of + * the section (i.e. the first byte should contain the `table_id` field). * @data_size: size of the @data argument. * * Creates a new #GstMpegtsSection from the provided @data. @@ -1320,10 +1277,11 @@ bad_long_packet: * @section: (transfer none): the #GstMpegtsSection that holds the data * @output_size: (out): #gsize to hold the size of the data * - * If the data in @section has already been packetized, the data pointer is returned - * immediately. Otherwise, the data field is allocated and populated. + * Packetize (i.e. serialize) the @section. If the data in @section has already + * been packetized, the data pointer is returned immediately. Otherwise, the + * data field is allocated and populated. * - * Returns: (transfer none): pointer to section data, or %NULL on fail + * Returns: (transfer none): pointer to section data, or %NULL on failure. */ guint8 * gst_mpegts_section_packetize (GstMpegtsSection * section, gsize * output_size) @@ -1352,3 +1310,21 @@ gst_mpegts_section_packetize (GstMpegtsSection * section, gsize * output_size) return section->data; } + +void +__initialize_sections (void) +{ + /* FIXME : Temporary hack to initialize section gtype */ + _gst_mpegts_section_type = gst_mpegts_section_get_type (); + + QUARK_PAT = g_quark_from_string ("pat"); + QUARK_CAT = g_quark_from_string ("cat"); + QUARK_PMT = g_quark_from_string ("pmt"); + QUARK_NIT = g_quark_from_string ("nit"); + QUARK_BAT = g_quark_from_string ("bat"); + QUARK_SDT = g_quark_from_string ("sdt"); + QUARK_EIT = g_quark_from_string ("eit"); + QUARK_TDT = g_quark_from_string ("tdt"); + QUARK_TOT = g_quark_from_string ("tot"); + QUARK_SECTION = g_quark_from_string ("section"); +} diff --git a/gst-libs/gst/mpegts/gstmpegtssection.h b/gst-libs/gst/mpegts/gstmpegtssection.h index b25418352..95a72085a 100644 --- a/gst-libs/gst/mpegts/gstmpegtssection.h +++ b/gst-libs/gst/mpegts/gstmpegtssection.h @@ -58,9 +58,12 @@ GType gst_mpegts_section_get_type (void); * @GST_MPEGTS_SECTION_ATSC_ETT: ATSC Extended Text Table (A65) * @GST_MPEGTS_SECTION_ATSC_EIT: ATSC Event Information Table (A65) * @GST_MPEGTS_SECTION_ATSC_STT: ATSC System Time Table (A65) + * @GST_MPEGTS_SECTION_ATSC_RRT: ATSC Rating Region Table (A65) * @GST_MPEGTS_SECTION_SCTE_SIT: SCTE Splice Information Table (SCTE-35) * - * Types of #GstMpegtsSection that the library handles. + * Types of #GstMpegtsSection that the library handles. This covers all the + * MPEG-TS and derivate specification that the library can properly identify and + * use. */ typedef enum { GST_MPEGTS_SECTION_UNKNOWN = 0, @@ -86,6 +89,21 @@ typedef enum { /** * GstMpegtsSectionTableID: + * @GST_MTS_TABLE_ID_PROGRAM_ASSOCIATION: Program Association Table (PAT) + * @GST_MTS_TABLE_ID_CONDITIONAL_ACCESS: Conditional Access Table (CAT) + * @GST_MTS_TABLE_ID_TS_PROGRAM_MAP: Program Map Table (PMT) + * @GST_MTS_TABLE_ID_TS_DESCRIPTION: Transport Stream Description Table + * @GST_MTS_TABLE_ID_14496_SCENE_DESCRIPTION: ISO/IEC 14496 Scene Description Table + * @GST_MTS_TABLE_ID_14496_OBJET_DESCRIPTOR: ISO/IEC 14496 Object Descriptor Table + * @GST_MTS_TABLE_ID_METADATA: Metadata Section + * @GST_MTS_TABLE_ID_IPMP_CONTROL_INFORMATION: IPMP Control Information + * @GST_MTS_TABLE_ID_DSM_CC_MULTIPROTO_ENCAPSULATED_DATA: DSM-CC Multi-Protocol Encapsulated (MPE) Data + * @GST_MTS_TABLE_ID_DSM_CC_U_N_MESSAGES: DSM-CC U-N Messages + * @GST_MTS_TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGES: DSM-CC Download Data Messages + * @GST_MTS_TABLE_ID_DSM_CC_STREAM_DESCRIPTORS: DSM-CC Stream Descriptors + * @GST_MTS_TABLE_ID_DSM_CC_PRIVATE_DATA: DSM-CC Private Data + * @GST_MTS_TABLE_ID_DSM_CC_ADDRESSABLE_SECTIONS: DSM-CC Addressable Section + * @GST_MTS_TABLE_ID_UNSET: Unset section table_id (value is forbidden to use in actual sections) * * Values for a #GstMpegtsSection table_id * @@ -104,6 +122,32 @@ typedef enum { GST_MTS_TABLE_ID_14496_OBJET_DESCRIPTOR = 0x05, GST_MTS_TABLE_ID_METADATA = 0x06, GST_MTS_TABLE_ID_IPMP_CONTROL_INFORMATION = 0x07, + /** + * GST_MTS_TABLE_ID_14496_SECTION: + * + * ISO/IEC 14496 Section. + * + * Since: 1.20 + */ + GST_MTS_TABLE_ID_14496_SECTION = 0x08, + + /** + * GST_MTS_TABLE_ID_23001_11_SECTION: + * + * ISO/IEC 23001-11 (Green Access Unit) Section. + * + * Since: 1.20 + */ + GST_MTS_TABLE_ID_23001_11_SECTION = 0x09, + + /** + * GST_MTS_TABLE_ID_23001_10_SECTION: + * + * ISO/ISO 23001-10 (Quality Access Unit) Section. + * + * Since: 1.20 + */ + GST_MTS_TABLE_ID_23001_10_SECTION = 0x0A, /* 0x08 - 0x39 : ITU H.222.0 | ISO/IEC 13818-1 reserved */ @@ -120,22 +164,26 @@ typedef enum { } GstMpegtsSectionTableID; +/** + * GstMpegtsPacketizeFunc: (attributes doc.skip=true) + */ typedef gboolean (*GstMpegtsPacketizeFunc) (GstMpegtsSection *section); /** * GstMpegtsSection: - * @section_type: The type of section - * @pid: The pid on which this section was found - * @table_id: The table id of this section + * @section_type: The type of section. + * @pid: The PID on which this section was found or belongs to. + * @table_id: The table id of this section. See %GstMpegtsSectionTableID and + * derivates for more information. * @subtable_extension: This meaning differs per section. See the documentation - * of the parsed section type for the meaning of this field + * of the parsed section type for the meaning of this field * @version_number: Version of the section. * @current_next_indicator: Applies to current/next stream or not * @section_number: Number of the section (if multiple) * @last_section_number: Number of the last expected section (if multiple) - * @crc: CRC + * @crc: Checksum (if applicable) * - * Mpeg-TS Section Information (SI) (ISO/IEC 13818-1) + * Mpeg-TS Section Information (SI) (ISO/IEC 13818-1) object. */ struct _GstMpegtsSection { @@ -174,6 +222,7 @@ struct _GstMpegtsSection * FIXME : Maybe make public later on when allowing creation of * sections to that people can create private short sections ? */ gboolean short_section; + GstMpegtsPacketizeFunc packetizer; /* Padding for future extension */ @@ -230,9 +279,10 @@ typedef struct _GstMpegtsPMT GstMpegtsPMT; /** * GstMpegtsStreamType: * @GST_MPEGTS_STREAM_TYPE_RESERVED_00: ITU-T | ISO/IEC Reserved - * @GST_MPEGTS_STREAM_TYPE_VIDEO_MPEG1: ISO/IEC 11172-2 Video + * @GST_MPEGTS_STREAM_TYPE_VIDEO_MPEG1: ISO/IEC 11172-2 Video (i.e. MPEG-1 Video) * @GST_MPEGTS_STREAM_TYPE_VIDEO_MPEG2: Rec. ITU-T H.262 | ISO/IEC 13818-2 - * Video or ISO/IEC 11172-2 constrained parameter video stream + * Video or ISO/IEC 11172-2 constrained parameter video stream (i.e. + * MPEG-2 Video) * @GST_MPEGTS_STREAM_TYPE_AUDIO_MPEG1: ISO/IEC 11172-3 Audio * @GST_MPEGTS_STREAM_TYPE_AUDIO_MPEG2: ISO/IEC 13818-3 Audio * @GST_MPEGTS_STREAM_TYPE_PRIVATE_SECTIONS: private sections @@ -245,34 +295,34 @@ typedef struct _GstMpegtsPMT GstMpegtsPMT; * @GST_MPEGTS_STREAM_TYPE_DSMCC_C: ISO/IEC 13818-6 type C * @GST_MPEGTS_STREAM_TYPE_DSMCC_D: ISO/IEC 13818-6 type D * @GST_MPEGTS_STREAM_TYPE_AUXILIARY: auxiliary streams - * @GST_MPEGTS_STREAM_TYPE_AUDIO_AAC_ADTS: ISO/IEC 13818-7 Audio with ADTS - * transport syntax - * @GST_MPEGTS_STREAM_TYPE_VIDEO_MPEG4: ISO/IEC 14496-2 Visual - * @GST_MPEGTS_STREAM_TYPE_AUDIO_AAC_LATM: ISO/IEC 14496-3 Audio with the LATM - * transport syntax as defined in ISO/IEC 14496-3 + * @GST_MPEGTS_STREAM_TYPE_AUDIO_AAC_ADTS: ISO/IEC 13818-7 Audio (AAC) with ADTS + * transport syntax + * @GST_MPEGTS_STREAM_TYPE_VIDEO_MPEG4: ISO/IEC 14496-2 Visual (MPEG-4 Video) + * @GST_MPEGTS_STREAM_TYPE_AUDIO_AAC_LATM: ISO/IEC 14496-3 Audio (AAC) with the LATM + * transport syntax as defined in ISO/IEC 14496-3 * @GST_MPEGTS_STREAM_TYPE_SL_FLEXMUX_PES_PACKETS: ISO/IEC 14496-1 - * SL-packetized stream or FlexMux stream carried in PES packets + * SL-packetized stream or FlexMux stream carried in PES packets * @GST_MPEGTS_STREAM_TYPE_SL_FLEXMUX_SECTIONS: ISO/IEC 14496-1 SL-packetized - * stream or FlexMux stream carried in ISO/IEC 14496_sections + * stream or FlexMux stream carried in ISO/IEC 14496_sections * @GST_MPEGTS_STREAM_TYPE_SYNCHRONIZED_DOWNLOAD: ISO/IEC 13818-6 Synchronized - * Download Protocol + * Download Protocol * @GST_MPEGTS_STREAM_TYPE_METADATA_PES_PACKETS: Metadata carried in PES packets * @GST_MPEGTS_STREAM_TYPE_METADATA_SECTIONS: Metadata carried in metadata_sections * @GST_MPEGTS_STREAM_TYPE_METADATA_DATA_CAROUSEL: Metadata carried in ISO/IEC - * 13818-6 Data Carousel + * 13818-6 Data Carousel * @GST_MPEGTS_STREAM_TYPE_METADATA_OBJECT_CAROUSEL: Metadata carried in - * ISO/IEC 13818-6 Object Carousel + * ISO/IEC 13818-6 Object Carousel * @GST_MPEGTS_STREAM_TYPE_METADATA_SYNCHRONIZED_DOWNLOAD: Metadata carried in - * ISO/IEC 13818-6 Synchronized Download Protocol + * ISO/IEC 13818-6 Synchronized Download Protocol * @GST_MPEGTS_STREAM_TYPE_MPEG2_IPMP: IPMP stream (defined in ISO/IEC 13818-11, - * MPEG-2 IPMP) + * MPEG-2 IPMP) * @GST_MPEGTS_STREAM_TYPE_VIDEO_H264: AVC video stream conforming to one or * more profiles defined in Annex A of Rec. ITU-T H.264 | ISO/IEC 14496-10 or * AVC video sub-bitstream of SVC as defined in 2.1.78 or MVC base view * sub-bitstream, as defined in 2.1.85, or AVC video sub-bitstream of MVC, as * defined in 2.1.88 - * @GST_MPEGTS_STREAM_TYPE_AUDIO_AAC_CLEAN: ISO/IEC 14496-3 Audio, without - * using any additional transport syntax, such as DST, ALS and SLS + * @GST_MPEGTS_STREAM_TYPE_AUDIO_AAC_CLEAN: ISO/IEC 14496-3 (AAC) Audio, without + * using any additional transport syntax, such as DST, ALS and SLS * @GST_MPEGTS_STREAM_TYPE_MPEG4_TIMED_TEXT: ISO/IEC 14496-17 Text * @GST_MPEGTS_STREAM_TYPE_VIDEO_RVC: Auxiliary video stream as defined in * ISO/IEC 23002-3 @@ -283,16 +333,18 @@ typedef struct _GstMpegtsPMT GstMpegtsPMT; * of an AVC video stream conforming to one or more profiles defined in Annex H * of Rec. ITU-T H.264 | ISO/IEC 14496-10 * @GST_MPEGTS_STREAM_TYPE_VIDEO_JP2K: Video stream conforming to one or more - * profiles as defined in Rec. ITU-T T.800 | ISO/IEC 15444-1 + * profiles as defined in Rec. ITU-T T.800 | ISO/IEC 15444-1 (i.e. JPEG 2000) * @GST_MPEGTS_STREAM_TYPE_VIDEO_MPEG2_STEREO_ADDITIONAL_VIEW: Additional view * Rec. ITU-T H.262 | ISO/IEC 13818-2 video stream for service-compatible * stereoscopic 3D services * @GST_MPEGTS_STREAM_TYPE_VIDEO_H264_STEREO_ADDITIONAL_VIEW: Additional view * Rec. ITU-T H.264 | ISO/IEC 14496-10 video stream conforming to one or more * profiles defined in Annex A for service-compatible stereoscopic 3D services + * @GST_MPEGTS_STREAM_TYPE_VIDEO_HEVC: Rec. ITU-T H.265 | ISO/IEC 23008-2 video + * stream or an HEVC temporal video sub-bitstream * @GST_MPEGTS_STREAM_TYPE_IPMP_STREAM: IPMP stream * - * Type of mpeg-ts stream type. + * Type of MPEG-TS stream type. * * These values correspond to the base standard registered types. Depending * on the variant of mpeg-ts being used (Bluray, ATSC, DVB, ...), other @@ -339,8 +391,17 @@ typedef enum { GST_MPEGTS_STREAM_TYPE_VIDEO_H264_STEREO_ADDITIONAL_VIEW = 0x23, GST_MPEGTS_STREAM_TYPE_VIDEO_HEVC = 0x24, /* 0x24 - 0x7e : Rec. ITU-T H.222.0 | ISO/IEC 13818-1 Reserved */ - GST_MPEGTS_STREAM_TYPE_IPMP_STREAM = 0x7f + GST_MPEGTS_STREAM_TYPE_IPMP_STREAM = 0x7f, /* 0x80 - 0xff : User Private (or defined in other specs) */ + + /** + * GST_MPEGTS_STREAM_TYPE_USER_PRIVATE_EA: + * + * User Private stream id (used for VC-1) as defined by SMPTE RP227. + * + * Since: 1.20 + */ + GST_MPEGTS_STREAM_TYPE_USER_PRIVATE_EA = 0xea, } GstMpegtsStreamType; /** @@ -350,7 +411,7 @@ typedef enum { * @descriptors: (element-type GstMpegtsDescriptor): the descriptors of the * stream * - * An individual stream definition. + * An individual stream definition of a #GstMpegtsPMT. */ struct _GstMpegtsPMTStream { @@ -362,11 +423,13 @@ struct _GstMpegtsPMTStream /** * GstMpegtsPMT: - * @pcr_pid: PID of the stream containing PCR - * @descriptors: (element-type GstMpegtsDescriptor): array of #GstMpegtsDescriptor + * @pcr_pid: PID of the stream containing the PCR for this program. + * @program_number: The program to which this PMT is applicable. + * @descriptors: (element-type GstMpegtsDescriptor): Array of #GstMpegtsDescriptor * @streams: (element-type GstMpegtsPMTStream): Array of #GstMpegtsPMTStream * - * Program Map Table (ISO/IEC 13818-1). + * Program Map Table (ISO/IEC 13818-1). Provides the mappings between program + * numbers and the program elements that comprise them. * * The program_number is contained in the subtable_extension field of the * container #GstMpegtsSection. diff --git a/gst-libs/gst/mpegts/meson.build b/gst-libs/gst/mpegts/meson.build index 6aaf8474e..45f22c86d 100644 --- a/gst-libs/gst/mpegts/meson.build +++ b/gst-libs/gst/mpegts/meson.build @@ -1,4 +1,5 @@ mpegts_sources = [ + 'mpegts.c', 'gstmpegtssection.c', 'gstmpegtsdescriptor.c', 'gst-dvb-descriptor.c', @@ -12,8 +13,11 @@ mpegts_headers = [ 'gst-atsc-section.h', 'gst-dvb-section.h', 'gst-scte-section.h', + 'gst-hdmv-section.h', 'gstmpegtsdescriptor.h', + 'gst-atsc-descriptor.h', 'gst-dvb-descriptor.h', + 'gst-isdb-descriptor.h', 'mpegts-prelude.h', 'mpegts.h', ] diff --git a/gst-libs/gst/mpegts/mpegts.c b/gst-libs/gst/mpegts/mpegts.c new file mode 100644 index 000000000..5c1f40fb9 --- /dev/null +++ b/gst-libs/gst/mpegts/mpegts.c @@ -0,0 +1,62 @@ +/* + * gstmpegtssection.c - + * Copyright (C) 2013 Edward Hervey + * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. + * Copyright (C) 2007 Alessandro Decina + * 2010 Edward Hervey + * Author: Youness Alaoui , Collabora Ltd. + * Author: Sebastian Dröge , Collabora Ltd. + * Author: Edward Hervey , Collabora Ltd. + * + * Authors: + * Alessandro Decina + * Zaheer Abbas Merali + * Edward Hervey + * + * 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. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "mpegts.h" +#include "gstmpegts-private.h" + +/** + * SECTION:gstmpegts + * @title: Initialization + * @short_description: Initialization of the MPEG-TS helper library + * @include: gst/mpegts/mpegts.h + * + * Before any usage of this library, the initialization function should be called. + */ + +GST_DEBUG_CATEGORY (mpegts_debug); + +/** + * gst_mpegts_initialize: + * + * Initializes the MPEG-TS helper library. Must be called before any + * usage. + */ +void +gst_mpegts_initialize (void) +{ + GST_DEBUG_CATEGORY_INIT (mpegts_debug, "mpegts", 0, "MPEG-TS helper library"); + + __initialize_sections (); + __initialize_descriptors (); +} diff --git a/gst-libs/gst/mpegts/mpegts.h b/gst-libs/gst/mpegts/mpegts.h index a0e0f2f9f..80be35bb3 100644 --- a/gst-libs/gst/mpegts/mpegts.h +++ b/gst-libs/gst/mpegts/mpegts.h @@ -31,12 +31,15 @@ #include #include +#include #include +#include #include #include #include #include #include +#include G_BEGIN_DECLS -- cgit v1.2.1