Transport Stream

This module contains elements for handling ISO/IEC 13818-1 Transport Streams.

Loadable Module Properties

Module Name Streamer Transport Stream Elements
File Name libtselements.so
Class Count 14

Element Quick Index

TS Socket Relay Element, TS Catalog Element, TS Continuity Counter Element, TS Program Selector Element, TS Program Clock Reference Element, TS Video Stream Info Decoder Element, TS Audio Stream Info Decoder Element, TS Subtitle Stream Info Decoder Element, TS Demuxer Element, TS Video Selector Element, TS Audio Selector Element, TS Subtitle Selector Element, TS PES Filter Element, TS DSM-CC Element.

Typical Transport Stream pipeline.

General Framing Requirents

The audio elementary stream must be aligned to segment boundaries as described in the Framing Element section.

TS Socket Relay Element

The TS Socket Relay Element does not perform any processing of the stream. Its sole purpose is to support the Socket Relay feature of the TOI Media Player Status interface available at the application layer. Using this feature an application may request individual elementary streams to be sent to a UNIX domain socket of its choice. One possible use for this mechanism is a Teletext decoder application that needs to read the teletext information embedded in the Transport Stream.

Class Properties

Name TS Socket Relay Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS Socket Relay
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream
Output Formats MPEG-2/Transport Stream
Trait SocketRelay

Metadata

This element immediately recommits all metadata to its output pad.

Theory of Operation

All stream data and all metadata is passed straight through this element. In case any socket relays are set up, it sends the complete Transport Stream packets in those elementary streams to the respective UNIX domain socket.

TS Catalog Element

The TS Catalog Element decodes the Program Association Table (PAT) and the Program Map Table (PMT) of each program listed in the PAT. This information is committed as metadata for easy access by other elements later in the pipeline.

Class Properties

Name TS Catalog Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS Catalog
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream
Output Formats MPEG-2/Transport Stream

Metadata

Key Input Output
PATProducedCommitted
PMT.*ProducedCommitted
_CatalogInfo ProducedPublished

Theory of Operation

The element collects the PAT in the stream and all PTMs listed in the PAT. It considers sections with a correct CRC_32 checksum only.

When the element finds a valid PAT it commits the complete section in binary form as metadata with the key PAT and then begins searching for a PMT for each of the programs listed in the PAT. For each valid PMT it finds, it commits the complete section in binary form as metadata with the key PMT.<id> where <id> is the pid in which the PMT was found.

The element does not recommit metadata when the same PAT and PMTs are repeated in the stream. If the element finds a new version of the PAT, it starts over and commits that PAT and also commits the PMT for each program listed in the new PAT, when those PMTs are found in the stream. If the element finds a new version of a PMT, it just commits that single PMT as metadata.

TS Continuity Counter Element

The TS Continuity Counter Element analyzes the continuity counter field and prints messages on the log if discontinuities are detected.

Class Properties

Name TS Continuity Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS Continuity Counter
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream
Output Formats MPEG-2/Transport Stream

Metadata

This element immediately recommits all metadata to its output pad.

Theory of Operation

The element uses the continuity counter and payload unit start indicator field together with the discontinuity indicator in the adaptation field to detect stream discontinuities. The element only remembers the previous counter value so more than two duplicated counter values are not detected.

TS Program Selector Element

The TS Program Selector Element filters out one of the programs listed in the Program Association Table (PAT). Elementary streams that are not listed in the Program Map Table (PMT) of that program are released from the pipeline.

Class Properties

Name TS Program Selector Descriptor
Version 1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

NameTS Program Selector
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream
Output Formats MPEG-2/Transport Stream

Metadata

Key Input Output
PATRequiredReleased
PMT.*RequiredReleased
PMTProducedCommitted
_ActiveProgramProducedCommitted

Theory of Operation

The element listens to the _RequestProgram parameter on the blackboard which identifies the program number of the selected program. All elementary streams not listed in the PMT of that program is released from the pipeline, so that only the elementary streams of the selected program is committed to the next element in the pipeline.

As default, the element will select the first program listed in the PAT.

In case the PAT changes, the element will try to locate the previously selected program in the new PAT. If there is a program which has the same program number and the same PTM pid in the new PAT as was selected in the old PAT, the element will assume it is the same program. Otherwise it will select the default program.

TS Program Clock Reference Element

The TS Program Clock Reference Element decodes the Program Clock Reference (PCR) carried in adaptation fields embedded into the ISO/IEC 13818-1 Transport Stream.

Class Properties

Name TS Program Clock Reference Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS Program Clock Reference
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream
Output Formats MPEG-2/Transport Stream
Trait ClockReference

Metadata

Key Input Output
PMTRequiredCommitted
PCRProducedCommitted

Theory of Operation

The element decodes the adaptation fields embedded in the elementary stream identified by the PCR_PID field in the PMT of the selected program. When it finds an adaptation field containing a PCR it calls the SetClockReference method in the IStreamClock interface to inform the pump framework about the timing properties of the stream.

The PCR is committed as metadata periodically with a frequency of about 2 Hz.

TS Video Stream Info Decoder Element

The TS Video Stream Info Decoder Element decodes relevant metadata for all video elementary streams in the ISO/IEC 13818-1 Transport Stream.

Class Properties

Name TS Video Stream Info Decoder Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS Video Stream Info Decoder
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream|
MPEG-2/Transport Stream/*
Output Formats Output same as input

Metadata

Key Input Output
PMTRequiredCommitted
_VideoComponentFlagProducedCommitted
_VideoStreamInfo.* ProducedCommitted
_VideoStreamList ProducedCommitted

Theory of Operation

The element examines the PMT for elementary streams with a stream type signalling it is a video stream. It looks for the following stream types in the stream_type field of the PMT.

ValueDescription
0x01ISO/IEC 11172 Video
0x02ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream
0x10ISO/IEC 14496-2 Visual
0x80User Private. Special rules apply, see below.

Some encoders are known to label ISO/IEC 13818-2 Video as stream type 0x80. To support this use, the element accepts stream type 0x80 as ISO/IEC 13818-2 Video if the PCR_PID field in the PMT points to the same elementary stream. Please note that this makes assumptions about the stream beyond the ISO/IEC 138181-1 system specification.

The element commits decoded stream information for each video stream pid as metadata with the _VideoStreamInfo key. It also commits the _VideoComponentFlag metadata with the string value "true" if at lease one video stream exists and "false" otherwise. A list of video stream pids is committed in _VideoStreamList. The _VideoStreamInfo and _VideoStreamList parameters are described in greater detail in the Complex Metadata section.

TS Audio Stream Info Decoder Element

The TS Audio Stream Info Decoder Element decodes relevant metadata for all audio elementary streams in the ISO/IEC 13818-1 Transport Stream.

Class Properties

Name TS Audio Stream Info Decoder Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS Audio Stream Info Decoder
Type Intermediate
Priority500
Input Formats MPEG-2/Transport Stream|
MPEG-2/Transport Stream/*
Output Formats Output same as input

Metadata

Key Input Output
PMTRequiredCommitted
_AudioComponentFlagProducedCommitted
_AudioStreamInfo.* ProducedCommitted
_AudioStreamList ProducedCommitted

Theory of Operation

The element examines the PMT for elementary streams with a stream type signalling it is a audio stream. It looks for the following stream types in the stream_type field of the PMT.

ValueDescription
0x03ISO/IEC 11172 Audio
0x04ISO/IEC 13818-3 Audio
0x81User Private. Used for ATSC AC3.
OtherDVB AC3 if DVB AC-3 descriptor (tag 0x6a) is present.

DVB AC3 is usually carried as stream type 0x06 but the element just looks at the presence of the DVB AC-3 descriptor.

The element looks for the ISO 639 language descriptor (tag 0x0a) to determine the language used in the audio track. For ISO/IEC 11172 audio in dual mono mode, the first language in the descriptor is used for the left channel and the second language is used for the right channel. If there is no language descriptor present, the element will label the audio track language as unknown.

The element commits decoded stream information for each audio stream pid as metadata with the _AudioStreamInfo key. It also commits the _AudioComponentFlag metadata with the string value "true" if at lease one audio stream exists and "false" otherwise. A list of audio stream pids is committed in _AudioStreamList. The _AudioStreamInfo and _AudioStreamList parameters are described in greater detail in the Complex Metadata section.

TS Subtitle Stream Info Decoder Element

The TS Subtitle Stream Info Decoder Element decodes relevant metadata for all subtitle elementary streams in the ISO/IEC 13818-1 Transport Stream.

Class Properties

Name TS Subtitle Stream Info Decoder Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS Subtitle Stream Info Decoder
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream|
MPEG-2/Transport Stream/*
Output Formats Output same as input

Metadata

Key Input Output
PMTRequiredCommitted
_SubtitleStreamInfo.* ProducedCommitted
_SubtitleStreamList ProducedCommitted
_TeletextStreamInfo.*ProducedCommitted
_TeletextStreamList ProducedCommitted

Theory of Operation

The element looks in the PMT for elementary streams with stream type 0x06 (ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data) that carry either a DVB teletext descriptor (tag 0x56) or a DVB subtitles descriptor (tag 0x59).

The element commits decoded stream information for each subtitle stream pid as metadata with the _SubtitleStreamInfo key. It also commits a list of subtitles stream pids in _SubtitleStreamList. The _SubtitleStreamInfo and _SubtitleStreamList parameters are described in greater detail in the Complex Metadata section.

TS Demuxer Element

The TS Demuxer Element branches the pipeline and splits the program into groups for video, audio, subtitles, and DSM-CC streams.

Class Properties

Name TS Demuxer Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS Demuxer Decoder
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream
Output Formats MPEG-2/Transport Stream/[Multi Video|Multi Audio|Multi Subtitle|DSM-CC]

Metadata

Key Input Output
PMTRequiredCommitted

Theory of Operation

The element branches the pipeline and splits the program into groups for video, audio, subtitles, and DSM-CC streams which are committed to different output pads. It looks at each individual stream listed in the PMT and decides which output pad to send it to.

Elementary streams with stream type 0x01, 0x02 and 0x10 are committed to the output pad with the MPEG-2/Transport Stream/Multi Video format. This is also the case if a stream has stream type 0x80 provided it also is the PCR stream.

Elementary streams with stream type 0x03, 0x04, and 0x81 are committed to the MPEG-2/Transport Stream/Multi Audio format pad. This is also true for any stream carrying the DVB AC-3 descriptor.

Elementary streams carrying the DVB teletext descriptor or the DVB subtitles descriptor are committed to the MPEG-2/Transport Stream/Multi Subtitle format pad.

The output pad with the MPEG-2/Transport Stream/DSM-CC format receives elementary streams with stream type 0x0c.

TS Video Selector Element

The TS Video Selector Element selects one of the video streams and commits that stream to the output pad and releases any other data.

Class Properties

Name TS Video Selector Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS Video Selector Decoder
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream/Multi Video
Output Formats MPEG-2/Transport Stream/Single Video

Metadata

Key Input Output
_VideoStreamList RequiredCommitted
_ActiveVideoStreamProducedCommitted

Theory of Operation

The element filters the stream based on the value of the _RequestVideoStream blackboard parameter, which holds the pid of the video stream selected by the user. If this parameter does not exist, the element chooses the first pid in the _VideoStreamList as default. The _VideoStreamList parameter is described in greater detail in the Complex Metadata section.

TS Audio Selector Element

The TS Audio Selector Element selects one of the audio streams and commits that stream to the output pad and releases any other data.

Class Properties

Name TS Audio Selector Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS Audio Selector Decoder
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream/Multi Audio
Output Formats MPEG-2/Transport Stream/Single Audio

Metadata

Key Input Output
_AudioStreamList RequiredCommitted
_ActiveAudioStreamProducedCommitted

Theory of Operation

The element filters the stream based on the value of the _RequestAudioStream blackboard parameter, which holds the pid of the audio stream selected by the user. If this parameter does not exist, the element chooses the first pid in the _AudioStreamList as default. The _AudioStreamList parameter is described in greater detail in the Complex Metadata section.

TS Subtitle Selector Element

The TS Subtitle Selector Element selects one of the subtitles streams and commits that stream to the output pad and releases any other data.

Class Properties

Name TS Subtitles Selector Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS Subtitles Selector Decoder
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream/Multi Subtitles
Output Formats MPEG-2/Transport Stream/[DVB Subtitle|Teletext Subtitle]

Metadata

Key Input Output
_PlaybackModeRequiredCommitted
_ActiveSubtitleStreamProducedCommitted

Theory of Operation

The element filters the stream based on the value of the _RequestSubtitleStream blackboard parameter, which holds the pid of the subtitles stream selected by the user. If this parameter does not exist, the element releases all subtitles streams.

TS PES Filter Element

The TS PES Filter Element emits a PES_START metadata at the beginning for each PES packet in the Transport Stream.

Class Properties

Name TS PES Filter Descriptor
Version1
Interface Name IElementDescriptor
Binding C++

Element Descriptor

Name TS PES Filter
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream/*
Output Formats Output same as input

Metadata

Key Input Output
PES_STARTProducedCommitted

Theory of Operation

The element looks at the payload_unit_start_indicator field of the Transport Stream packet header. When this bit is set the element emits a metadata with key PES_START and empty value.

TS DSM-CC Element

The TS DSM-CC Element decodes DSM-CC information embedded in the stream in accordance to ISO/IEC 13818-6. The element looks for DSM-CC stream descriptors both in the PMT and in DSM-CC sections in the data stream.

Class Properties

Name TS DSM-CC Descriptor
Version1
Interface Name IElementDescriptor
BindingC++

Element Descriptor

Name TS DSM-CC
TypeIntermediate
Priority500
Input Formats MPEG-2/Transport Stream/DSM-CC
Output Formats MPEG-2/Transport Stream/DSM-CC
TraitNptPosition

Metadata

Key Input Output
PMTRequiredCommitted
PCRRequiredCommitted
_NptPositionProducedCommitted
_NptPaceProducedCommitted

Theory of Operation

The element looks for DSM-CC stream descriptors in the stream. These descriptors may be emedded in the stream in several different ways. The element looks in the PMT's list of descriptors that are not associated to any specific elementary stream. It also decodes the data stream for DSM-CC sections with table_id 0x3d DSM-CC Sections containing Stream Descriptors.

If the element finds a NPT Reference descriptor (tag 23) it uses the clock reference and scale to reconstruct valid position and pace values which are committed as metadata.

If the element finds a Stream Mode descriptor (tag 25) with a streamMode field set to End of Stream (value 7), it will assume that end of stream has been reached if the stream was playing forward, and that beginning of stream has been reached if the stream was playing backwards. These conditions are signalled by setting the _EndOfStream parameter on the blackboard.