mpegtsdemux: Switch to MPEG-TS SI library

* Only mpeg-ts section packetization remains.
* Improve code to detect duplicated sections as early as possible
* Add FIXME for various issues that need fixing (but are not regressions)

https://bugzilla.gnome.org/show_bug.cgi?id=702724
This commit is contained in:
Edward Hervey 2013-06-23 08:43:23 +02:00
parent 3665e8543a
commit 92edd82c86
12 changed files with 714 additions and 3830 deletions

View file

@ -1,18 +1,18 @@
plugin_LTLIBRARIES = libgstmpegtsdemux.la
libgstmpegtsdemux_la_SOURCES = \
gsttsdemux.c \
gstmpegdesc.c \
mpegtsbase.c \
mpegtspacketizer.c \
mpegtsbase.c \
mpegtsparse.c \
tsdemux.c \
gsttsdemux.c \
pesparse.c
libgstmpegtsdemux_la_CFLAGS = \
$(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) $(GST_CFLAGS)
libgstmpegtsdemux_la_LIBADD = \
$(top_builddir)/gst-libs/gst/mpegts/libgstmpegts-$(GST_API_VERSION).la \
$(GST_PLUGINS_BASE_LIBS) -lgsttag-$(GST_API_VERSION) \
$(GST_BASE_LIBS) $(GST_LIBS)
libgstmpegtsdemux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)

View file

@ -27,116 +27,6 @@
#ifndef __GST_MPEG_DEFS_H__
#define __GST_MPEG_DEFS_H__
/*
* PES stream_id assignments:
*
* 1011 1100 program_stream_map
* 1011 1101 private_stream_1
* 1011 1110 padding_stream
* 1011 1111 private_stream_2
* 110x xxxx ISO/IEC 13818-3 or ISO/IEC 11172-3 audio stream number x xxxx
* 1110 xxxx ITU-T Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 11172-2 video stream number xxxx
* 1111 0000 ECM_stream
* 1111 0001 EMM_stream
* 1111 0010 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A or ISO/IEC 13818-6_DSMCC_stream
* 1111 0011 ISO/IEC_13522_stream
* 1111 0100 ITU-T Rec. H.222.1 type A
* 1111 0101 ITU-T Rec. H.222.1 type B
* 1111 0110 ITU-T Rec. H.222.1 type C
* 1111 0111 ITU-T Rec. H.222.1 type D
* 1111 1000 ITU-T Rec. H.222.1 type E
* 1111 1001 ancillary_stream
* 1111 1010 ISO/IEC 14496-1_SL-packetized_stream
* 1111 1011 ISO/IEC 14496-1_FlexMux_stream
* 1111 1100 metadata stream
* 1111 1101 extended_stream_id
* 1111 1110 reserved data stream
* 1111 1111 program_stream_directory
*/
#define ID_PS_END_CODE 0xB9
#define ID_PS_PACK_START_CODE 0xBA
#define ID_PS_SYSTEM_HEADER_START_CODE 0xBB
#define ID_PS_PROGRAM_STREAM_MAP 0xBC
#define ID_PRIVATE_STREAM_1 0xBD
#define ID_PADDING_STREAM 0xBE
#define ID_PRIVATE_STREAM_2 0xBF
#define ID_ISO_IEC_MPEG12_AUDIO_STREAM_0 0xC0
#define ID_ISO_IEC_MPEG12_AUDIO_STREAM_32 0xDF
#define ID_ISO_IEC_MPEG12_VIDEO_STREAM_0 0xE0
#define ID_ISO_IEC_MPEG12_VIDEO_STREAM_16 0xEF
#define ID_ECM_STREAM 0xF0
#define ID_EMM_STREAM 0xF1
#define ID_DSMCC_STREAM 0xF2
#define ID_ISO_IEC_13522_STREAM 0xF3
#define ID_ITU_TREC_H222_TYPE_A_STREAM 0xF4
#define ID_ITU_TREC_H222_TYPE_B_STREAM 0xF5
#define ID_ITU_TREC_H222_TYPE_C_STREAM 0xF6
#define ID_ITU_TREC_H222_TYPE_D_STREAM 0xF7
#define ID_ITU_TREC_H222_TYPE_E_STREAM 0xF8
#define ID_ANCILLARY_STREAM 0xF9
#define ID_14496_1_SL_PACKETIZED_STREAM 0xFA
#define ID_14496_1_SL_FLEXMUX_STREAM 0xFB
#define ID_METADATA_STREAM 0xFC
#define ID_EXTENDED_STREAM_ID 0xFD
#define ID_RESERVED_STREAM_3 0xFE
#define ID_PROGRAM_STREAM_DIRECTORY 0xFF
/*
* PES stream_id_extension assignments (if stream_id == ID_EXTENDED_STREAM_ID)
*
* 000 0000 IPMP Control Information stream
* 000 0001 IPMP Stream
* 000 0010 - 001 0001 ISO/IEC 14496-17 text Streams
* 001 0010 - 010 0001 ISO/IEC 23002-3 auxiliary video data Streams
* ... .... - 011 1111 Reserved
*
* PRIVATE STREAM RANGES (But known as used)
* 101 0101 - 101 1111 VC-1
* 110 0000 - 110 1111 Dirac (VC-1)
*
* 111 0001 AC3 or independent sub-stream 0 of EAC3/DD+
* DTS or core sub-stream
* 111 0010 dependent sub-stream of EAC3/DD+
* DTS extension sub-stream
* Secondary EAC3/DD+
* Secondary DTS-HD LBR
* 111 0110 AC3 in MLP/TrueHD
* 1xx xxxx private_stream
*/
#define EXT_ID_IPMP_CONTORL_INFORMATION_STREAM 0x00
#define EXT_ID_IPMP_STREAM 0x01
/* VC-1 */
#define EXT_ID_VC1_FIRST 0x55
#define EXT_ID_VC1_LAST 0x5F
/* BDMV */
#define PACKET_VIDEO_START_CODE 0x000001E0
#define PACKET_AUDIO_START_CODE 0x000001C0
#define PICTURE_START_CODE 0x00000100
#define USER_DATA_START_CODE 0x000001B2
#define SEQUENCE_HEADER_CODE 0x000001B3
#define SEQUENCE_ERROR_CODE 0x000001B4
#define EXTENSION_START_CODE 0x000001B5
#define SEQUENCE_END_CODE 0x000001B7
#define GROUP_START_CODE 0x000001B8
#define AC3_SYNC_WORD 0x0b770000
#define MPEG_TS_SYNC_BYTE 0x00000047
/* Reserved PIDs */
#define PID_PAT 0x0000
#define PID_CAT 0x0001
#define PID_TSDT 0x0002
#define PID_IPMP_CIT 0x0003
#define PID_RESERVED_FIRST 0x0004
#define PID_RESERVED_LAST 0x000F
#define PID_NULL_PACKET 0x1FFF
/* Stream type assignments
*
* 0x00 ITU-T | ISO/IEC Reserved
@ -179,6 +69,9 @@
* 0x7F IPMP stream
* 0x80-0xFF User Private
*/
/* FIXME : Move well-defined Stream type to an enum in the mpegts library */
#define ST_RESERVED 0x00
#define ST_VIDEO_MPEG1 0x01
#define ST_VIDEO_MPEG2 0x02
@ -238,85 +131,6 @@
#define ST_HDV_AUX_A 0xa0
#define ST_HDV_AUX_V 0xa1
/* Un-official time-code stream */
#define ST_PS_TIMECODE 0xd2
/* Internal stream types >= 0x100 */
#define ST_GST_AUDIO_RAWA52 0x181
/* Used when we don't yet know which stream type it will be in a PS stream */
#define ST_GST_VIDEO_MPEG1_OR_2 0x102
/* Table IDs */
/* ITU H.222.0 / IEC 13818-1 */
#define TABLE_ID_PROGRAM_ASSOCIATION 0x00
#define TABLE_ID_CONDITIONAL_ACCESS 0x01
#define TABLE_ID_TS_PROGRAM_MAP 0x02
#define TABLE_ID_TS_DESCRIPTION 0x03
#define TABLE_ID_14496_SCENE_DESCRIPTION 0x04
#define TABLE_ID_14496_OBJET_DESCRIPTOR 0x05
#define TABLE_ID_METADATA 0x06
#define TABLE_ID_IPMP_CONTROL_INFORMATION 0x07
/* IEC 13818-6 (DSM-CC) */
#define TABLE_ID_DSM_CC_MULTIPROTO_ENCAPSULATED_DATA 0x3A
#define TABLE_ID_DSM_CC_U_N_MESSAGES 0x3B
#define TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGES 0x3C
#define TABLE_ID_DSM_CC_STREAM_DESCRIPTORS 0x3D
#define TABLE_ID_DSM_CC_PRIVATE_DATA 0x3E
#define TABLE_ID_DSM_CC_ADDRESSABLE_SECTIONS 0x3F
/* EN 300 468 (DVB) v 1.12.1 */
#define TABLE_ID_NETWORK_INFORMATION_ACTUAL_NETWORK 0x40
#define TABLE_ID_NETWORK_INFORMATION_OTHER_NETWORK 0x41
#define TABLE_ID_SERVICE_DESCRIPTION_ACTUAL_TS 0x42
#define TABLE_ID_SERVICE_DESCRIPTION_OTHER_TS 0x46
#define TABLE_ID_BOUQUET_ASSOCIATION 0x4A
#define TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_PRESENT 0x4E
#define TABLE_ID_EVENT_INFORMATION_OTHER_TS_PRESENT 0x4F
#define TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_SCHEDULE_1 0x50 /* First */
#define TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_SCHEDULE_N 0x5F /* Last */
#define TABLE_ID_EVENT_INFORMATION_OTHER_TS_SCHEDULE_1 0x60 /* First */
#define TABLE_ID_EVENT_INFORMATION_OTHER_TS_SCHEDULE_N 0x6F /* Last */
#define TABLE_ID_TIME_DATE 0x70
#define TABLE_ID_RUNNING_STATUS 0x71
#define TABLE_ID_STUFFING 0x72
#define TABLE_ID_TIME_OFFSET 0x73
/* TS 102 812 (MHP v1.1.3) */
#define TABLE_ID_APPLICATION_INFORMATION_TABLE 0x74
/* TS 102 323 (DVB TV Anytime v1.5.1) */
#define TABLE_ID_CONTAINER 0x75
#define TABLE_ID_RELATED_CONTENT 0x76
#define TABLE_ID_CONTENT_IDENTIFIER 0x77
/* EN 301 192 (DVB specification for data broadcasting) */
#define TABLE_ID_MPE_FEC 0x78
/* TS 102 323 (DVB TV Anytime v1.5.1) */
#define TABLE_ID_RESOLUTION_NOTIFICATION 0x79
/* TS 102 772 (DVB-SH Multi-Protocol Encapsulation) */
#define TABLE_ID_MPE_IFEC 0x7A
/* EN 300 468 (DVB) v 1.12.1 */
#define TABLE_ID_DISCONTINUITY_INFORMATION 0x7E
#define TABLE_ID_SELECTION_INFORMATION 0x7F
/* ETR 289 (DVB Support for use of scrambling and CA) */
#define TABLE_ID_CA_MESSAGE_ECM_0 0x80
#define TABLE_ID_CA_MESSAGE_ECM_1 0x81
#define TABLE_ID_CA_MESSAGE_SYSTEM_PRIVATE_1 0x82 /* First */
#define TABLE_ID_CA_MESSAGE_SYSTEM_PRIVATE_N 0x8F /* Last */
/* ... */
/* EN 301 790 (DVB interaction channel for satellite distribution channels) */
#define TABLE_ID_SCT 0xA0
#define TABLE_ID_FCT 0xA1
#define TABLE_ID_TCT 0xA2
#define TABLE_ID_SPT 0xA3
#define TABLE_ID_CMT 0xA4
#define TABLE_ID_TBTP 0xA5
#define TABLE_ID_PCR_PACKET_PAYLOAD 0xA6
#define TABLE_ID_TRANSMISSION_MODE_SUPPORT_PAYLOAD 0xAA
#define TABLE_ID_TIM 0xB0
#define TABLE_ID_LL_FEC_PARITY_DATA_TABLE 0xB1
/* ATSC (FILLME) */
/* ISDB (FILLME) */
/* Unset */
#define TABLE_ID_UNSET 0xFF
#define CLOCK_BASE 9LL
#define CLOCK_FREQ (CLOCK_BASE * 10000)
@ -342,8 +156,4 @@
if ((*data & 0x01) != 0x01) goto lost_sync_label; \
target |= ((guint64) (*data++ & 0xFE)) >> 1;
/* some extra GstFlowReturn values used internally */
#define GST_FLOW_NEED_MORE_DATA GST_FLOW_CUSTOM_SUCCESS
#define GST_FLOW_LOST_SYNC GST_FLOW_CUSTOM_SUCCESS_1
#endif /* __GST_MPEG_DEFS_H__ */

View file

@ -1,201 +0,0 @@
/*
*
* 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.
*
* The Original Code is Fluendo MPEG Demuxer plugin.
*
* The Initial Developer of the Original Code is Fluendo, S.L.
* Portions created by Fluendo, S.L. are Copyright (C) 2005
* Fluendo, S.L. All Rights Reserved.
*
* Contributor(s): Wim Taymans <wim@fluendo.com>
*
*/
#include <string.h>
#include <gst/gst.h>
#include "gstmpegdesc.h"
GST_DEBUG_CATEGORY (gstmpegtsdesc_debug);
#define GST_CAT_DEFAULT (gstmpegtsdesc_debug)
static guint
gst_mpeg_descriptor_parse_1 (guint8 * data, guint size)
{
#ifndef GST_DISABLE_GST_DEBUG
guint8 tag;
#endif
guint8 length;
/* need at least 2 bytes for tag and length */
if (size < 2)
return 0;
#ifndef GST_DISABLE_GST_DEBUG
tag = *data++;
#else
data++;
#endif
length = *data++;
size -= 2;
GST_DEBUG ("tag: 0x%02x, length: %d", tag, length);
if (length > size)
return 0;
GST_MEMDUMP ("tag contents:", data, length);
return length + 2;
}
gboolean
gst_mpeg_descriptor_parse (GstMPEGDescriptor * result, guint8 * data,
guint size)
{
guint8 *current;
guint consumed, total, n_desc;
g_return_val_if_fail (data != NULL, FALSE);
current = data;
total = 0;
n_desc = 0;
result->n_desc = 0;
do {
consumed = gst_mpeg_descriptor_parse_1 (current, size);
if (consumed > 0) {
current += consumed;
total += consumed;
size -= consumed;
n_desc++;
}
}
while (consumed > 0);
GST_DEBUG ("parsed %d descriptors", n_desc);
if (total == 0)
return FALSE;
result->n_desc = n_desc;
result->data_length = total;
result->data = data;
return TRUE;
}
guint
gst_mpeg_descriptor_n_desc (GstMPEGDescriptor * desc)
{
g_return_val_if_fail (desc != NULL, 0);
return desc->n_desc;
}
guint8 *
gst_mpeg_descriptor_find (GstMPEGDescriptor * desc, gint tag)
{
guint8 length;
guint8 *current;
guint size;
g_return_val_if_fail (desc != NULL, NULL);
current = desc->data;
length = desc->data_length;
while (length > 0) {
if (DESC_TAG (current) == tag)
return current;
size = DESC_LENGTH (current) + 2;
current += size;
length -= size;
}
return NULL;
}
/* array needs freeing afterwards */
GArray *
gst_mpeg_descriptor_find_all (GstMPEGDescriptor * desc, gint tag)
{
GArray *all;
guint8 length;
guint8 *current;
guint size;
g_return_val_if_fail (desc != NULL, NULL);
all = g_array_new (TRUE, TRUE, sizeof (guint8 *));
current = desc->data;
length = desc->data_length;
while (length > 0) {
if (DESC_TAG (current) == tag)
g_array_append_val (all, current);
size = DESC_LENGTH (current) + 2;
current += size;
length -= size;
}
GST_DEBUG ("found tag 0x%02x %d times", tag, all->len);
return all;
}
guint8 *
gst_mpeg_descriptor_nth (GstMPEGDescriptor * desc, guint i)
{
guint8 length;
guint8 *current;
guint size;
g_return_val_if_fail (desc != NULL, NULL);
if (i > desc->n_desc)
return NULL;
current = desc->data;
length = desc->data_length;
while (length > 0) {
if (i == 0)
return current;
size = DESC_LENGTH (current) + 2;
current += size;
length -= size;
i--;
}
return NULL;
}
void
gst_mpegtsdesc_init_debug (void)
{
GST_DEBUG_CATEGORY_INIT (gstmpegtsdesc_debug, "mpegtsdesc", 0,
"MPEG transport stream parser (descriptor)");
}

View file

@ -30,185 +30,8 @@
#include <glib.h>
/*
* descriptor_tag TS PS Identification
* 0 n/a n/a Reserved
* 1 n/a n/a Reserved
* 2 X X video_stream_descriptor
* 3 X X audio_stream_descriptor
* 4 X X hierarchy_descriptor
* 5 X X registration_descriptor
* 6 X X data_stream_alignment_descriptor
* 7 X X target_background_grid_descriptor
* 8 X X video_window_descriptor
* 9 X X CA_descriptor
* 10 X X ISO_639_language_descriptor
* 11 X X system_clock_descriptor
* 12 X X multiplex_buffer_utilization_descriptor
* 13 X X copyright_descriptor
* 14 X maximum bitrate descriptor
* 15 X X private data indicator descriptor
* 16 X X smoothing buffer descriptor
* 17 X STD_descriptor
* 18 X X IBP descriptor
* 19-63 n/a n/a ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved
* 64-255 n/a n/a User Private
*/
#define DESC_VIDEO_STREAM 0x02
#define DESC_AUDIO_STREAM 0x03
#define DESC_HIERARCHY 0x04
#define DESC_REGISTRATION 0x05
#define DESC_DATA_STREAM_ALIGNMENT 0x06
#define DESC_TARGET_BACKGROUND_GRID 0x07
#define DESC_VIDEO_WINDOW 0x08
#define DESC_CA 0x09
#define DESC_ISO_639_LANGUAGE 0x0A
#define DESC_SYSTEM_CLOCK 0x0B
#define DESC_MULTIPLEX_BUFFER_UTILISATION 0x0C
#define DESC_COPYRIGHT 0x0D
#define DESC_MAXIMUM_BITRATE 0x0E
#define DESC_PRIVATE_DATA_INDICATOR 0x0F
#define DESC_SMOOTHING_BUFFER 0x10
#define DESC_STD 0x11
#define DESC_IBP 0x12
/* 19-26 Defined in ISO/IEC 13818-6 (Extensions for DSM-CC) */
#define DESC_DVB_CAROUSEL_IDENTIFIER 0x13
/* 27-54 Later additions to ISO/IEC 13818-1 (H222.0 06/2012) */
#define DESC_MPEG4_VIDEO 0x1B
#define DESC_MPEG4_AUDIO 0x1C
#define DESC_IOD 0x1D
#define DESC_SL 0x1E
#define DESC_FMC 0x1F
#define DESC_EXTERNAL_ES_ID 0x20
#define DESC_MUX_CODE 0x21
#define DESC_FMX_BUFFER_SIZE 0x22
#define DESC_MULTIPLEX_BUFFER 0x23
#define DESC_CONTENT_LABELING 0x24
#define DESC_METADATA_POINTER 0x25
#define DESC_METADATA 0x26
#define DESC_METADATA_STD 0x27
#define DESC_AVC_VIDEO 0x28
/* defined in ISO/IEC 13818-11, MPEG-2 IPMP */
#define DESC_IPMP 0x29
#define DESC_AVC_TIMING_AND_HRD 0x2A
#define DESC_MPEG2_AAC_AUDIO 0x2B
#define DESC_FLEX_MUX_TIMING 0x2C
#define DESC_MPEG4_TEXT 0x2D
#define DESC_MPEG4_AUDIO_EXTENSION 0x2E
#define DESC_AUXILIARY_VIDEO_STREAM 0x2F
#define DESC_SVC_EXTENSION 0x30
#define DESC_MVC_EXTENSION 0x31
#define DESC_J2K_VIDEO 0x32
#define DESC_MVC_OPERATION_POINT 0x33
#define DESC_MPEG2_STEREOSCOPIC_VIDEO_FORMAT 0x34
#define DESC_STEREOSCOPIC_PROGRAM_INFO 0x35
#define DESC_STEREOSCOPIC_VIDEO_INFO 0x36
/* 55-63 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved */
/* 64-127 DVB tags ETSI EN 300 468
* (Specification for Service Information (SI) in DVB systems)
*/
#define DESC_DVB_NETWORK_NAME 0x40
#define DESC_DVB_SERVICE_LIST 0x41
#define DESC_DVB_STUFFING 0x42
#define DESC_DVB_SATELLITE_DELIVERY_SYSTEM 0x43
#define DESC_DVB_CABLE_DELIVERY_SYSTEM 0x44
#define DESC_DVB_VBI_DATA 0x45
#define DESC_DVB_VBI_TELETEXT 0x46
#define DESC_DVB_BOUQUET_NAME 0x47
#define DESC_DVB_SERVICE 0x48
#define DESC_DVB_COUNTRY_AVAILABILITY 0x49
#define DESC_DVB_LINKAGE 0x4A
#define DESC_DVB_NVOD_REFERENCE 0x4B
#define DESC_DVB_TIME_SHIFTED_SERVICE 0x4C
#define DESC_DVB_SHORT_EVENT 0x4D
#define DESC_DVB_EXTENDED_EVENT 0x4E
#define DESC_DVB_TIME_SHIFTED_EVENT 0x4F
#define DESC_DVB_COMPONENT 0x50
#define DESC_DVB_MOSAIC 0x51
#define DESC_DVB_STREAM_IDENTIFIER 0x52
#define DESC_DVB_CA_IDENTIFIER 0x53
#define DESC_DVB_CONTENT 0x54
#define DESC_DVB_PARENTAL_RATING 0x55
#define DESC_DVB_TELETEXT 0x56
#define DESC_DVB_TELEPHONE 0x57
#define DESC_DVB_LOCAL_TIME_OFFSET 0x58
#define DESC_DVB_SUBTITLING 0x59
#define DESC_DVB_TERRESTRIAL_DELIVERY_SYSTEM 0x5A
#define DESC_DVB_MULTILINGUAL_NETWORK_NAME 0x5B
#define DESC_DVB_MULTILINGUAL_BOUQUET_NAME 0x5C
#define DESC_DVB_MULTILINGUAL_SERVICE_NAME 0x5D
#define DESC_DVB_MULTILINGUAL_COMPONENT 0x5E
#define DESC_DVB_PRIVATE_DATA 0x5F
#define DESC_DVB_SERVICE_MOVE 0x60
#define DESC_DVB_SHORT_SMOOTHING_BUFFER 0x61
#define DESC_DVB_FREQUENCY_LIST 0x62
#define DESC_DVB_PARTIAL_TRANSPORT_STREAM 0x63
#define DESC_DVB_DATA_BROADCAST 0x64
#define DESC_DVB_SCRAMBLING 0x65
#define DESC_DVB_DATA_BROADCAST_ID 0x66
#define DESC_DVB_TRANSPORT_STREAM 0x67
#define DESC_DVB_DSNG 0x68
#define DESC_DVB_PDC 0x69
#define DESC_DVB_AC3 0x6A
#define DESC_DVB_ANCILLARY_DATA 0x6B
#define DESC_DVB_CELL_LIST 0x6C
#define DESC_DVB_CELL_FREQUENCY_LINK 0x6D
#define DESC_DVB_ANNOUNCEMENT_SUPPORT 0x6E
#define DESC_DVB_APPLICATION_SIGNALLING 0x6F
#define DESC_DVB_ADAPTATION_FIELD_DATA 0x70
#define DESC_DVB_SERVICE_IDENTIFIER 0x71
#define DESC_DVB_SERVICE_AVAILABILITY 0x72
#define DESC_DVB_DEFAULT_AUTHORITY 0x73
#define DESC_DVB_RELATED_CONTENT 0x74
#define DESC_DVB_TVA_ID 0x75
#define DESC_DVB_CONTENT_IDENTIFIER 0x76
#define DESC_DVB_TIMESLICE_FEC_IDENTIFIER 0x77
#define DESC_DVB_ECM_REPETITION_RATE 0x78
#define DESC_DVB_S2_SATELLITE_DELIVERY_SYSTEM 0x79
#define DESC_DVB_ENHANCED_AC3 0x7A
#define DESC_DVB_DTS 0x7B
#define DESC_DVB_AAC 0x7C
/* 0x7D and 0x7E are reserved for future use */
#define DESC_DVB_EXTENSION 0x7F
/* 0x80 - 0xFE are user defined */
#define DESC_AC3_AUDIO_STREAM 0x81
#define DESC_DTG_LOGICAL_CHANNEL 0x83 /* from DTG D-Book */
/* ATSC A/65 2009 */
#define DESC_ATSC_STUFFING 0x80
#define DESC_ATSC_AC3 0x83
#define DESC_ATSC_CAPTION_SERVICE 0x86
#define DESC_ATSC_CONTENT_ADVISORY 0x87
#define DESC_ATSC_EXTENDED_CHANNEL_NAME 0xA0
#define DESC_ATSC_SERVICE_LOCATION 0xA1
#define DESC_ATSC_TIME_SHIFTED_SERVICE 0xA2
#define DESC_ATSC_COMPONENT_NAME 0xA3
#define DESC_ATSC_DCC_DEPARTING_REQUEST 0xA8
#define DESC_ATSC_DCC_ARRIVING_REQUEST 0xA9
#define DESC_ATSC_REDISTRIBUTION_CONTROL 0xAA
#define DESC_ATSC_GENRE 0xAB
#define DESC_ATSC_PRIVATE_INFORMATION 0xAD
/* ATSC A/53:3 2009 */
#define DESC_ATSC_ENHANCED_SIGNALING 0xB2
/* ATSC A/90 */
#define DESC_ATSC_ASSOCIATION_TAG 0x14
#define DESC_ATSC_DATA_SERVICE 0xA4
#define DESC_ATSC_PID_COUNT 0xA5
#define DESC_ATSC_DOWNLOAD_DESCRIPTOR 0xA6
#define DESC_ATSC_MULTIPROTOCOL_ENCAPSULATION 0xA7
#define DESC_ATSC_MODULE_LINK 0xB4
#define DESC_ATSC_CRC32 0xB5
#define DESC_ATSC_GROUP_LINK 0xB8
/* Others */
#define DESC_DIRAC_TC_PRIVATE 0xAC
/* 0xFF is forbidden */
@ -389,6 +212,12 @@
/* AC3_audio_stream_descriptor */
#define DESC_AC_AUDIO_STREAM_bsid(desc) ((desc)[2] & 0x1f)
/* FIXME : Move list of well know registration ids to an enum
* in the mpegts library.
*
* See http://www.smpte-ra.org/mpegreg/mpegreg.html for a full list
* */
/* registration_descriptor format IDs */
#define DRF_ID_HDMV 0x48444d56
#define DRF_ID_VC1 0x56432D31 /* defined in RP227 */
@ -397,20 +226,4 @@
#define DRF_ID_DTS3 0x44545333
#define DRF_ID_S302M 0x42535344
typedef struct
{
guint n_desc;
guint8 data_length;
guint8 *data;
} GstMPEGDescriptor;
G_GNUC_INTERNAL void gst_mpegtsdesc_init_debug (void);
G_GNUC_INTERNAL gboolean gst_mpeg_descriptor_parse (GstMPEGDescriptor *result, guint8 * data, guint size);
G_GNUC_INTERNAL guint gst_mpeg_descriptor_n_desc (GstMPEGDescriptor * desc);
G_GNUC_INTERNAL guint8 *gst_mpeg_descriptor_find (GstMPEGDescriptor * desc, gint tag);
G_GNUC_INTERNAL GArray *gst_mpeg_descriptor_find_all (GstMPEGDescriptor * desc, gint tag);
G_GNUC_INTERNAL guint8 *gst_mpeg_descriptor_nth (GstMPEGDescriptor * desc, guint i);
#endif /* __GST_MPEG_DESC_H__ */

View file

@ -21,6 +21,7 @@
#include "config.h"
#endif
#include <gst/mpegts/mpegts.h>
#include "mpegtsbase.h"
#include "mpegtspacketizer.h"
#include "mpegtsparse.h"
@ -30,6 +31,7 @@
static gboolean
plugin_init (GstPlugin * plugin)
{
gst_mpegts_initialize ();
if (!gst_mpegtsbase_plugin_init (plugin))
return FALSE;
if (!gst_mpegtsparse_plugin_init (plugin))

File diff suppressed because it is too large Load diff

View file

@ -59,7 +59,7 @@ struct _MpegTSBaseStream
{
guint16 pid;
guint8 stream_type;
GstStructure* stream_info;
GstMpegTSPMTStream *stream;
};
struct _MpegTSBaseProgram
@ -67,7 +67,8 @@ struct _MpegTSBaseProgram
gint program_number;
guint16 pmt_pid;
guint16 pcr_pid;
GstStructure *pmt_info;
GstMpegTSSection *section;
const GstMpegTSPMT *pmt;
MpegTSBaseStream **streams;
GList *stream_list;
gint patcount;
@ -110,7 +111,7 @@ struct _MpegTSBase {
* accessed from the application thread and the streaming thread */
GHashTable *programs;
GstStructure *pat;
GArray *pat;
MpegTSPacketizer2 *packetizer;
/* arrays that say whether a pid is a known psi pid or a pes pid */
@ -145,7 +146,7 @@ struct _MpegTSBaseClass {
/* Virtual methods */
void (*reset) (MpegTSBase *base);
GstFlowReturn (*push) (MpegTSBase *base, MpegTSPacketizerPacket *packet, MpegTSPacketizerSection * section);
GstFlowReturn (*push) (MpegTSBase *base, MpegTSPacketizerPacket *packet, GstMpegTSSection * section);
/* takes ownership of @event */
gboolean (*push_event) (MpegTSBase *base, GstEvent * event);
@ -190,16 +191,14 @@ G_GNUC_INTERNAL GType mpegts_base_get_type(void);
G_GNUC_INTERNAL MpegTSBaseProgram *mpegts_base_get_program (MpegTSBase * base, gint program_number);
G_GNUC_INTERNAL MpegTSBaseProgram *mpegts_base_add_program (MpegTSBase * base, gint program_number, guint16 pmt_pid);
G_GNUC_INTERNAL guint8 *mpegts_get_descriptor_from_stream (MpegTSBaseStream * stream, guint8 tag);
G_GNUC_INTERNAL guint8 *mpegts_get_descriptor_from_program (MpegTSBaseProgram * program, guint8 tag);
G_GNUC_INTERNAL const guint8 *mpegts_get_descriptor_from_stream (MpegTSBaseStream * stream, guint8 tag);
G_GNUC_INTERNAL const guint8 *mpegts_get_descriptor_from_program (MpegTSBaseProgram * program, guint8 tag);
G_GNUC_INTERNAL gboolean
mpegts_base_handle_seek_event(MpegTSBase * base, GstPad * pad, GstEvent * event);
G_GNUC_INTERNAL gboolean gst_mpegtsbase_plugin_init (GstPlugin * plugin);
G_GNUC_INTERNAL gboolean mpegts_base_handle_psi (MpegTSBase * base, MpegTSPacketizerSection * section);
G_GNUC_INTERNAL void mpegts_base_program_remove_stream (MpegTSBase * base, MpegTSBaseProgram * program, guint16 pid);
G_GNUC_INTERNAL void mpegts_base_remove_program(MpegTSBase *base, gint program_number);

File diff suppressed because it is too large Load diff

View file

@ -28,6 +28,7 @@
#include <gst/base/gstadapter.h>
#include <glib.h>
#include <gst/mpegts/mpegts.h>
#include "gstmpegdefs.h"
#define MPEGTS_NORMAL_PACKETSIZE 188
@ -62,18 +63,24 @@ typedef struct _MpegTSPacketizerPrivate MpegTSPacketizerPrivate;
typedef struct
{
guint16 pid;
guint continuity_counter;
/* Section data (reused) */
/* Section data (always newly allocated) */
guint8 *section_data;
/* Expected length of the section */
guint section_length;
/* Allocated length of section_data */
guint section_allocated;
/* Current offset in section_data */
guint16 section_offset;
/* Values for pending section */
/* table_id of the pending section_data */
guint8 section_table_id;
guint8 table_id;
guint section_length;
guint8 version_number;
guint16 subtable_extension;
guint8 section_number;
guint8 last_section_number;
GSList *subtables;
@ -110,12 +117,16 @@ struct _MpegTSPacketizer2Class {
GObjectClass object_class;
};
#define FLAGS_SCRAMBLED(f) (f & 0xc0)
#define FLAGS_HAS_AFC(f) (f & 0x20)
#define FLAGS_HAS_PAYLOAD(f) (f & 0x10)
#define FLAGS_CONTINUITY_COUNTER(f) (f & 0x0f)
typedef struct
{
gint16 pid;
guint8 payload_unit_start_indicator;
guint8 adaptation_field_control;
guint8 continuity_counter;
guint8 scram_afc_cc;
guint8 *payload;
guint8 *data_start;
@ -129,23 +140,6 @@ typedef struct
GstClockTime origts;
} MpegTSPacketizerPacket;
typedef struct
{
gboolean complete;
/* GstBuffer *buffer; */
guint8 *data;
guint section_length;
guint64 offset;
gint16 pid;
guint8 table_id;
guint16 subtable_extension;
guint8 version_number;
guint8 current_next_indicator;
guint32 crc;
} MpegTSPacketizerSection;
typedef struct
{
guint8 table_id;
@ -154,9 +148,17 @@ typedef struct
* section_syntax_indicator is 0, sub_table_extension will be set to 0 */
guint16 subtable_extension;
guint8 version_number;
GList * crc;
guint8 last_section_number;
/* table of bits, whether the section was seen or not.
* Use MPEGTS_BIT_* macros to check */
/* Size is 32, because there's a maximum of 256 (32*8) section_number */
guint8 seen_section[32];
} MpegTSPacketizerStreamSubtable;
#define MPEGTS_BIT_SET(field, offs) ((field)[(offs) >> 3] |= (1 << ((offs) & 0x7)))
#define MPEGTS_BIT_UNSET(field, offs) ((field)[(offs) >> 3] &= ~(1 << ((offs) & 0x7)))
#define MPEGTS_BIT_IS_SET(field, offs) ((field)[(offs) >> 3] & (1 << ((offs) & 0x7)))
typedef enum {
PACKET_BAD = FALSE,
PACKET_OK = TRUE,
@ -179,24 +181,8 @@ G_GNUC_INTERNAL void mpegts_packetizer_clear_packet (MpegTSPacketizer2 *packetiz
G_GNUC_INTERNAL void mpegts_packetizer_remove_stream(MpegTSPacketizer2 *packetizer,
gint16 pid);
G_GNUC_INTERNAL gboolean mpegts_packetizer_push_section (MpegTSPacketizer2 *packetzer,
MpegTSPacketizerPacket *packet, MpegTSPacketizerSection *section);
G_GNUC_INTERNAL GstStructure *mpegts_packetizer_parse_cat (MpegTSPacketizer2 *packetizer,
MpegTSPacketizerSection *section);
G_GNUC_INTERNAL GstStructure *mpegts_packetizer_parse_pat (MpegTSPacketizer2 *packetizer,
MpegTSPacketizerSection *section);
G_GNUC_INTERNAL GstStructure *mpegts_packetizer_parse_pmt (MpegTSPacketizer2 *packetizer,
MpegTSPacketizerSection *section);
G_GNUC_INTERNAL GstStructure *mpegts_packetizer_parse_nit (MpegTSPacketizer2 *packetizer,
MpegTSPacketizerSection *section);
G_GNUC_INTERNAL GstStructure *mpegts_packetizer_parse_sdt (MpegTSPacketizer2 *packetizer,
MpegTSPacketizerSection *section);
G_GNUC_INTERNAL GstStructure *mpegts_packetizer_parse_eit (MpegTSPacketizer2 *packetizer,
MpegTSPacketizerSection *section);
G_GNUC_INTERNAL GstStructure *mpegts_packetizer_parse_tdt (MpegTSPacketizer2 *packetizer,
MpegTSPacketizerSection *section);
G_GNUC_INTERNAL GstStructure *mpegts_packetizer_parse_tot (MpegTSPacketizer2 *packetizer,
MpegTSPacketizerSection *section);
G_GNUC_INTERNAL GstMpegTSSection *mpegts_packetizer_push_section (MpegTSPacketizer2 *packetzer,
MpegTSPacketizerPacket *packet);
/* Only valid if calculate_offset is TRUE */
G_GNUC_INTERNAL guint mpegts_packetizer_get_seen_pcr (MpegTSPacketizer2 *packetizer);

View file

@ -91,7 +91,7 @@ mpegts_parse_program_stopped (MpegTSBase * base, MpegTSBaseProgram * program);
static GstFlowReturn
mpegts_parse_push (MpegTSBase * base, MpegTSPacketizerPacket * packet,
MpegTSPacketizerSection * section);
GstMpegTSSection * section);
static MpegTSParsePad *mpegts_parse_create_tspad (MpegTSParse2 * parse,
const gchar * name);
@ -342,7 +342,7 @@ mpegts_parse_release_pad (GstElement * element, GstPad * pad)
static GstFlowReturn
mpegts_parse_tspad_push_section (MpegTSParse2 * parse, MpegTSParsePad * tspad,
MpegTSPacketizerSection * section, MpegTSPacketizerPacket * packet)
GstMpegTSSection * section, MpegTSPacketizerPacket * packet)
{
GstFlowReturn ret = GST_FLOW_OK;
gboolean to_push = TRUE;
@ -420,7 +420,7 @@ pad_clear_for_push (GstPad * pad, MpegTSParse2 * parse)
static GstFlowReturn
mpegts_parse_push (MpegTSBase * base, MpegTSPacketizerPacket * packet,
MpegTSPacketizerSection * section)
GstMpegTSSection * section)
{
MpegTSParse2 *parse = (MpegTSParse2 *) base;
guint32 pads_cookie;
@ -598,8 +598,6 @@ gst_mpegtsparse_plugin_init (GstPlugin * plugin)
GST_DEBUG_CATEGORY_INIT (mpegts_parse_debug, "tsparse", 0,
"MPEG transport stream parser");
gst_mpegtsdesc_init_debug ();
return gst_element_register (plugin, "tsparse",
GST_RANK_NONE, GST_TYPE_MPEGTS_PARSE);
}

View file

@ -26,6 +26,91 @@
G_BEGIN_DECLS
/*
* PES stream_id assignments:
*
* 1011 1100 program_stream_map
* 1011 1101 private_stream_1
* 1011 1110 padding_stream
* 1011 1111 private_stream_2
* 110x xxxx ISO/IEC 13818-3 or ISO/IEC 11172-3 audio stream number x xxxx
* 1110 xxxx ITU-T Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 11172-2 video stream number xxxx
* 1111 0000 ECM_stream
* 1111 0001 EMM_stream
* 1111 0010 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A or ISO/IEC 13818-6_DSMCC_stream
* 1111 0011 ISO/IEC_13522_stream
* 1111 0100 ITU-T Rec. H.222.1 type A
* 1111 0101 ITU-T Rec. H.222.1 type B
* 1111 0110 ITU-T Rec. H.222.1 type C
* 1111 0111 ITU-T Rec. H.222.1 type D
* 1111 1000 ITU-T Rec. H.222.1 type E
* 1111 1001 ancillary_stream
* 1111 1010 ISO/IEC 14496-1_SL-packetized_stream
* 1111 1011 ISO/IEC 14496-1_FlexMux_stream
* 1111 1100 metadata stream
* 1111 1101 extended_stream_id
* 1111 1110 reserved data stream
* 1111 1111 program_stream_directory
*/
#define ID_PS_END_CODE 0xB9
#define ID_PS_PACK_START_CODE 0xBA
#define ID_PS_SYSTEM_HEADER_START_CODE 0xBB
#define ID_PS_PROGRAM_STREAM_MAP 0xBC
#define ID_PRIVATE_STREAM_1 0xBD
#define ID_PADDING_STREAM 0xBE
#define ID_PRIVATE_STREAM_2 0xBF
#define ID_ISO_IEC_MPEG12_AUDIO_STREAM_0 0xC0
#define ID_ISO_IEC_MPEG12_AUDIO_STREAM_32 0xDF
#define ID_ISO_IEC_MPEG12_VIDEO_STREAM_0 0xE0
#define ID_ISO_IEC_MPEG12_VIDEO_STREAM_16 0xEF
#define ID_ECM_STREAM 0xF0
#define ID_EMM_STREAM 0xF1
#define ID_DSMCC_STREAM 0xF2
#define ID_ISO_IEC_13522_STREAM 0xF3
#define ID_ITU_TREC_H222_TYPE_A_STREAM 0xF4
#define ID_ITU_TREC_H222_TYPE_B_STREAM 0xF5
#define ID_ITU_TREC_H222_TYPE_C_STREAM 0xF6
#define ID_ITU_TREC_H222_TYPE_D_STREAM 0xF7
#define ID_ITU_TREC_H222_TYPE_E_STREAM 0xF8
#define ID_ANCILLARY_STREAM 0xF9
#define ID_14496_1_SL_PACKETIZED_STREAM 0xFA
#define ID_14496_1_SL_FLEXMUX_STREAM 0xFB
#define ID_METADATA_STREAM 0xFC
#define ID_EXTENDED_STREAM_ID 0xFD
#define ID_RESERVED_STREAM_3 0xFE
#define ID_PROGRAM_STREAM_DIRECTORY 0xFF
/*
* PES stream_id_extension assignments (if stream_id == ID_EXTENDED_STREAM_ID)
*
* 000 0000 IPMP Control Information stream
* 000 0001 IPMP Stream
* 000 0010 - 001 0001 ISO/IEC 14496-17 text Streams
* 001 0010 - 010 0001 ISO/IEC 23002-3 auxiliary video data Streams
* ... .... - 011 1111 Reserved
*
* PRIVATE STREAM RANGES (But known as used)
* 101 0101 - 101 1111 VC-1
* 110 0000 - 110 1111 Dirac (VC-1)
*
* 111 0001 AC3 or independent sub-stream 0 of EAC3/DD+
* DTS or core sub-stream
* 111 0010 dependent sub-stream of EAC3/DD+
* DTS extension sub-stream
* Secondary EAC3/DD+
* Secondary DTS-HD LBR
* 111 0110 AC3 in MLP/TrueHD
* 1xx xxxx private_stream
*/
#define EXT_ID_IPMP_CONTORL_INFORMATION_STREAM 0x00
#define EXT_ID_IPMP_STREAM 0x01
/* VC-1 */
#define EXT_ID_VC1_FIRST 0x55
#define EXT_ID_VC1_LAST 0x5F
typedef enum {
PES_FLAG_PRIORITY = 1 << 3, /* PES_priority (present: high-priority) */
PES_FLAG_DATA_ALIGNMENT = 1 << 2, /* data_alignment_indicator */
@ -57,7 +142,7 @@ typedef enum {
} PESParsingResult;
typedef struct {
guint8 stream_id; /* See ID_* in gstmpegdefs.h */
guint8 stream_id; /* See ID_* above */
guint16 packet_length; /* The size of the PES header and PES data
* (if 0 => unbounded packet) */
guint16 header_size; /* The complete size of the PES header */

View file

@ -227,7 +227,7 @@ gst_ts_demux_program_stopped (MpegTSBase * base, MpegTSBaseProgram * program);
static void gst_ts_demux_reset (MpegTSBase * base);
static GstFlowReturn
gst_ts_demux_push (MpegTSBase * base, MpegTSPacketizerPacket * packet,
MpegTSPacketizerSection * section);
GstMpegTSSection * section);
static void gst_ts_demux_flush (MpegTSBase * base, gboolean hard);
static void
gst_ts_demux_stream_added (MpegTSBase * base, MpegTSBaseStream * stream,
@ -634,15 +634,18 @@ done:
static void
gst_ts_demux_create_tags (TSDemuxStream * stream)
{
guint8 *desc = NULL;
MpegTSBaseStream *bstream = (MpegTSBaseStream *) stream;
const guint8 *desc = NULL;
int i;
desc = mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_ISO_639_LANGUAGE);
desc =
mpegts_get_descriptor_from_stream (bstream,
GST_MTS_DESC_ISO_639_LANGUAGE);
if (!desc) {
desc = mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_DVB_SUBTITLING);
desc =
mpegts_get_descriptor_from_stream (bstream,
GST_MTS_DESC_DVB_SUBTITLING);
}
if (desc) {
@ -674,8 +677,6 @@ gst_ts_demux_create_tags (TSDemuxStream * stream)
gst_tag_list_add (stream->taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_LANGUAGE_CODE, (lc) ? lc : lang_code, NULL);
}
g_free (desc);
}
}
@ -687,7 +688,7 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
gchar *name = NULL;
GstCaps *caps = NULL;
GstPadTemplate *template = NULL;
guint8 *desc = NULL;
const guint8 *desc = NULL;
GstPad *pad = NULL;
gst_ts_demux_create_tags (stream);
@ -695,27 +696,31 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
GST_LOG ("Attempting to create pad for stream 0x%04x with stream_type %d",
bstream->pid, bstream->stream_type);
/* FIXME : Extract the registration descriptor in mpegtsbase for each
* program and stream. This will help provide cleaner detection of all the
* mpeg-ts variants (Bluray, HDV, ...) and "private" types (dirac, vc1,
* ac3, eac3, ... */
/* First handle BluRay-specific stream types since there is some overlap
* between BluRay and non-BluRay streay type identifiers */
desc = mpegts_get_descriptor_from_program (program, DESC_REGISTRATION);
desc =
mpegts_get_descriptor_from_program (program, GST_MTS_DESC_REGISTRATION);
if (desc) {
if (DESC_REGISTRATION_format_identifier (desc) == DRF_ID_HDMV) {
switch (bstream->stream_type) {
case ST_BD_AUDIO_AC3:
{
guint8 *ac3_desc;
const guint8 *ac3_desc;
/* ATSC ac3 audio descriptor */
ac3_desc =
mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_AC3_AUDIO_STREAM);
GST_MTS_DESC_AC3_AUDIO_STREAM);
if (ac3_desc && DESC_AC_AUDIO_STREAM_bsid (ac3_desc) != 16) {
GST_LOG ("ac3 audio");
template = gst_static_pad_template_get (&audio_template);
name = g_strdup_printf ("audio_%04x", bstream->pid);
caps = gst_caps_new_empty_simple ("audio/x-ac3");
g_free (ac3_desc);
} else {
template = gst_static_pad_template_get (&audio_template);
name = g_strdup_printf ("audio_%04x", bstream->pid);
@ -745,7 +750,6 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
break;
}
}
g_free (desc);
}
if (template && name && caps)
goto done;
@ -755,6 +759,8 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
case ST_VIDEO_MPEG1:
case ST_VIDEO_MPEG2:
case ST_PS_VIDEO_MPEG2_DCII:
/* FIXME : Use DCII registration code (ETV1 ?) to handle that special
* Stream type (ST_PS_VIDEO_MPEG2_DCII) */
GST_LOG ("mpeg video");
template = gst_static_pad_template_get (&video_template);
name = g_strdup_printf ("video_%04x", bstream->pid);
@ -775,51 +781,50 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
break;
case ST_PRIVATE_DATA:
GST_LOG ("private data");
/* FIXME: Move all of this into a common method (there might be other
* types also, depending on registratino descriptors also
*/
desc = mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_DVB_AC3);
GST_MTS_DESC_DVB_AC3);
if (desc) {
GST_LOG ("ac3 audio");
template = gst_static_pad_template_get (&audio_template);
name = g_strdup_printf ("audio_%04x", bstream->pid);
caps = gst_caps_new_empty_simple ("audio/x-ac3");
g_free (desc);
break;
}
desc = mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_DVB_ENHANCED_AC3);
GST_MTS_DESC_DVB_ENHANCED_AC3);
if (desc) {
GST_LOG ("ac3 audio");
template = gst_static_pad_template_get (&audio_template);
name = g_strdup_printf ("audio_%04x", bstream->pid);
caps = gst_caps_new_empty_simple ("audio/x-eac3");
g_free (desc);
break;
}
desc = mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_DVB_TELETEXT);
GST_MTS_DESC_DVB_TELETEXT);
if (desc) {
GST_LOG ("teletext");
template = gst_static_pad_template_get (&private_template);
name = g_strdup_printf ("private_%04x", bstream->pid);
caps = gst_caps_new_empty_simple ("private/teletext");
g_free (desc);
break;
}
desc =
mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_DVB_SUBTITLING);
GST_MTS_DESC_DVB_SUBTITLING);
if (desc) {
GST_LOG ("subtitling");
template = gst_static_pad_template_get (&private_template);
name = g_strdup_printf ("private_%04x", bstream->pid);
caps = gst_caps_new_empty_simple ("subpicture/x-dvb");
g_free (desc);
break;
}
desc = mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_REGISTRATION);
GST_MTS_DESC_REGISTRATION);
if (desc) {
switch (DESC_REGISTRATION_format_identifier (desc)) {
case DRF_ID_DTS1:
@ -837,7 +842,6 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
caps = gst_caps_new_empty_simple ("audio/x-smpte-302m");
break;
}
g_free (desc);
}
if (template)
break;
@ -852,12 +856,14 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
}
break;
case ST_HDV_AUX_V:
/* FIXME : Should only be used with specific PMT registration_descriptor */
/* We don't expose those streams since they're only helper streams */
/* template = gst_static_pad_template_get (&private_template); */
/* name = g_strdup_printf ("private_%04x", bstream->pid); */
/* caps = gst_caps_new_simple ("hdv/aux-v", NULL); */
break;
case ST_HDV_AUX_A:
/* FIXME : Should only be used with specific PMT registration_descriptor */
/* We don't expose those streams since they're only helper streams */
/* template = gst_static_pad_template_get (&private_template); */
/* name = g_strdup_printf ("private_%04x", bstream->pid); */
@ -903,7 +909,7 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
case ST_VIDEO_DIRAC:
desc =
mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_REGISTRATION);
GST_MTS_DESC_REGISTRATION);
if (desc) {
if (DESC_LENGTH (desc) >= 4) {
if (DESC_REGISTRATION_format_identifier (desc) == 0x64726163) {
@ -914,7 +920,6 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
caps = gst_caps_new_empty_simple ("video/x-dirac");
}
}
g_free (desc);
}
break;
case ST_PRIVATE_EA: /* Try to detect a VC1 stream */
@ -922,14 +927,13 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
gboolean is_vc1 = FALSE;
desc =
mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_REGISTRATION);
GST_MTS_DESC_REGISTRATION);
if (desc) {
if (DESC_LENGTH (desc) >= 4) {
if (DESC_REGISTRATION_format_identifier (desc) == DRF_ID_VC1) {
is_vc1 = TRUE;
}
}
g_free (desc);
}
if (!is_vc1) {
GST_WARNING ("0xea private stream type found but no descriptor "
@ -946,25 +950,22 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
case ST_PS_AUDIO_AC3:
/* DVB_ENHANCED_AC3 */
desc = mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_DVB_ENHANCED_AC3);
GST_MTS_DESC_DVB_ENHANCED_AC3);
if (desc) {
template = gst_static_pad_template_get (&audio_template);
name = g_strdup_printf ("audio_%04x", bstream->pid);
caps = gst_caps_new_empty_simple ("audio/x-eac3");
g_free (desc);
break;
}
/* DVB_AC3 */
desc =
mpegts_get_descriptor_from_stream ((MpegTSBaseStream *) stream,
DESC_DVB_AC3);
GST_MTS_DESC_DVB_AC3);
if (!desc)
GST_WARNING ("AC3 stream type found but no corresponding "
"descriptor to differentiate between AC3 and EAC3. "
"Assuming plain AC3.");
else
g_free (desc);
template = gst_static_pad_template_get (&audio_template);
name = g_strdup_printf ("audio_%04x", bstream->pid);
caps = gst_caps_new_empty_simple ("audio/x-ac3");
@ -1295,6 +1296,7 @@ gst_ts_demux_queue_data (GstTSDemux * demux, TSDemuxStream * stream,
{
guint8 *data;
guint size;
guint8 cc = FLAGS_CONTINUITY_COUNTER (packet->scram_afc_cc);
GST_LOG ("pid: 0x%04x state:%d", stream->stream.pid, stream->state);
@ -1302,17 +1304,16 @@ gst_ts_demux_queue_data (GstTSDemux * demux, TSDemuxStream * stream,
data = packet->payload;
if (stream->continuity_counter == CONTINUITY_UNSET) {
GST_DEBUG ("CONTINUITY: Initialize to %d", packet->continuity_counter);
} else if ((packet->continuity_counter == stream->continuity_counter + 1 ||
(stream->continuity_counter == MAX_CONTINUITY &&
packet->continuity_counter == 0))) {
GST_LOG ("CONTINUITY: Got expected %d", packet->continuity_counter);
GST_DEBUG ("CONTINUITY: Initialize to %d", cc);
} else if ((cc == stream->continuity_counter + 1 ||
(stream->continuity_counter == MAX_CONTINUITY && cc == 0))) {
GST_LOG ("CONTINUITY: Got expected %d", cc);
} else {
GST_ERROR ("CONTINUITY: Mismatch packet %d, stream %d",
packet->continuity_counter, stream->continuity_counter);
cc, stream->continuity_counter);
stream->state = PENDING_PACKET_DISCONT;
}
stream->continuity_counter = packet->continuity_counter;
stream->continuity_counter = cc;
if (stream->state == PENDING_PACKET_EMPTY) {
if (G_UNLIKELY (!packet->payload_unit_start_indicator)) {
@ -1544,22 +1545,21 @@ beach:
static GstFlowReturn
gst_ts_demux_handle_packet (GstTSDemux * demux, TSDemuxStream * stream,
MpegTSPacketizerPacket * packet, MpegTSPacketizerSection * section)
MpegTSPacketizerPacket * packet, GstMpegTSSection * section)
{
GstFlowReturn res = GST_FLOW_OK;
GST_LOG ("pid 0x%04x pusi:%d, afc:%d, cont:%d, payload:%p", packet->pid,
packet->payload_unit_start_indicator, packet->adaptation_field_control,
packet->continuity_counter, packet->payload);
packet->payload_unit_start_indicator, packet->scram_afc_cc & 0x30,
FLAGS_CONTINUITY_COUNTER (packet->scram_afc_cc), packet->payload);
if (section) {
GST_LOG ("section complete:%d, buffer size %d",
section->complete, section->section_length);
GST_LOG ("Got section, returning");
return res;
}
if (G_UNLIKELY (packet->payload_unit_start_indicator) &&
packet->adaptation_field_control & 0x10)
FLAGS_HAS_PAYLOAD (packet->scram_afc_cc))
/* Flush previous data */
res = gst_ts_demux_push_pending_data (demux, stream);
@ -1598,7 +1598,7 @@ gst_ts_demux_flush (MpegTSBase * base, gboolean hard)
static GstFlowReturn
gst_ts_demux_push (MpegTSBase * base, MpegTSPacketizerPacket * packet,
MpegTSPacketizerSection * section)
GstMpegTSSection * section)
{
GstTSDemux *demux = GST_TS_DEMUX_CAST (base);
TSDemuxStream *stream = NULL;