Table of Contents

Class TsFormatParser

Namespace
VAST.TS
Assembly
VAST.TS.dll

Provides MPEG-2 Transport Stream format parsing and encoding capabilities, including program association table (PAT) and program map table (PMT) processing, PES packet demultiplexing, and stream descriptor management.

public class TsFormatParser : IDisposable
Inheritance
TsFormatParser
Implements
Inherited Members

Constructors

TsFormatParser()

Initializes a new instance of the TsFormatParser class.

public TsFormatParser()

Properties

CombineOutputPackets

Gets or sets a value indicating whether output packets should be combined. When set, the value is propagated to all known PES streams.

public bool CombineOutputPackets { get; set; }

Property Value

bool

IgnoreScrambledFlag

Gets or sets a value indicating whether the scrambled flag should be ignored during parsing.

public bool IgnoreScrambledFlag { get; set; }

Property Value

bool

IgnoreTimestampJump

Gets or sets a value indicating whether timestamp jumps should be ignored. When set, the value is propagated to all known PES streams. Non-audio and non-video streams always ignore timestamp jumps regardless of this setting.

public bool IgnoreTimestampJump { get; set; }

Property Value

bool

IsLive

Gets or sets a value indicating whether the stream is live. Defaults to true.

public bool IsLive { get; set; }

Property Value

bool

LoosePesAssembling

Gets or sets a value indicating whether loose PES assembling mode is enabled. When set, the value is propagated to all known PID streams.

public bool LoosePesAssembling { get; set; }

Property Value

bool

MediaTypeConfirmationCount

Gets or sets the number of confirmations required before a media type is considered stable. When set, the value is propagated to all known PES streams.

public int MediaTypeConfirmationCount { get; set; }

Property Value

int

Mtu

Gets or sets the maximum transmission unit (MTU) size for output packets. When set, the value is propagated to all known PES streams.

public int Mtu { get; set; }

Property Value

int

PesFilter

Gets or sets the PES PID filter. When set, only elementary streams matching the specified PES PIDs are monitored, and all other elementary streams are removed.

public Dictionary<ushort, ushort> PesFilter { get; set; }

Property Value

Dictionary<ushort, ushort>

PmtFilter

Gets or sets the PMT PID filter. When set, only programs matching the specified PMT PIDs are monitored, and all other programs are discarded.

public HashSet<ushort> PmtFilter { get; set; }

Property Value

HashSet<ushort>

ProgramCount

Gets the number of discovered programs.

public int ProgramCount { get; }

Property Value

int

ProgramDescriptorDirty

Gets or sets a value indicating whether the program descriptor has been modified and needs to be re-read.

public bool ProgramDescriptorDirty { get; set; }

Property Value

bool

ProgramDescriptorReady

Gets or sets a value indicating whether the program descriptor is ready.

public bool ProgramDescriptorReady { get; set; }

Property Value

bool

StreamDetectionTimeout

Gets or sets the stream detection timeout in 100-nanosecond intervals. Defaults to 30 seconds.

public long StreamDetectionTimeout { get; set; }

Property Value

long

StreamDetectionTimeoutBytes

Gets or sets the stream detection timeout in bytes. Defaults to 1048576 (1 MB).

public long StreamDetectionTimeoutBytes { get; set; }

Property Value

long

StripDownMedia

Gets or sets a value indicating whether media data should be stripped down. When set, the value is propagated to all known PES streams.

public bool StripDownMedia { get; set; }

Property Value

bool

Methods

Decode(VersatileBuffer)

Decodes transport stream data from the specified data packet.

public List<VersatileBuffer> Decode(VersatileBuffer dataPacket)

Parameters

dataPacket VersatileBuffer

The data packet to decode, or null to process buffered data.

Returns

List<VersatileBuffer>

A list of decoded media sample buffers.

Decode(VersatileBuffer, int, int)

Decodes transport stream data from the specified data packet starting at the given position.

public List<VersatileBuffer> Decode(VersatileBuffer dataPacket, int position, int bytesToRead)

Parameters

dataPacket VersatileBuffer

The data packet to decode, or null to process buffered data.

position int

The byte offset within the data packet to start reading from.

bytesToRead int

The number of bytes to read from the data packet.

Returns

List<VersatileBuffer>

A list of decoded media sample buffers.

Decode(VersatileBufferStream)

Decodes transport stream data from the specified buffer stream.

public List<VersatileBuffer> Decode(VersatileBufferStream stream)

Parameters

stream VersatileBufferStream

The buffer stream to decode, or null to process buffered data.

Returns

List<VersatileBuffer>

A list of decoded media sample buffers.

DiscardStream(int, int, bool)

Discards or un-discards a specific stream or an entire program at the specified indices. When streamIndex is negative, the entire program is discarded or un-discarded.

public void DiscardStream(int programIndex, int streamIndex, bool discardValue)

Parameters

programIndex int

The zero-based index of the program.

streamIndex int

The zero-based index of the stream within the program, or a negative value to target the entire program.

discardValue bool

A value of true to discard the stream or program; false to un-discard it.

Discontinuity()

Signals a discontinuity to all known PID streams, resetting their internal state.

public void Discontinuity()

Dispose()

Releases all resources used by the TsFormatParser class.

public void Dispose()

Encode()

Encodes control information (PAT, PMT, and PCR packets) for all programs. This overload does not force encoding and respects the minimum interval between encodings.

public void Encode()

Encode(bool)

Encodes control information (PAT, PMT, and PCR packets) for all programs.

public void Encode(bool force)

Parameters

force bool

If true, forces encoding regardless of the minimum interval; otherwise, encoding is throttled to once every 50 milliseconds.

Encode(VersatileBuffer, int, int, long, long)

Encodes a media sample into PES packets and enqueues them for output.

public void Encode(VersatileBuffer sample, int programIndex, int streamIndex, long dts, long pts)

Parameters

sample VersatileBuffer

The media sample buffer to encode.

programIndex int

The zero-based index of the program.

streamIndex int

The zero-based index of the stream within the program.

dts long

The decode timestamp in 100-nanosecond intervals.

pts long

The presentation timestamp in 100-nanosecond intervals.

Flush()

Flushes all known PID streams, clears the output queue, trims the internal data stream, and releases any pre-decoded buffers.

public void Flush()

GetProgramPid(int)

Gets the PMT PID for the program at the specified index.

public int GetProgramPid(int programIndex)

Parameters

programIndex int

The zero-based index of the program.

Returns

int

The PMT PID of the program, or -1 if the index is out of range.

GetSendPacket()

Dequeues and returns the next packet from the send queue.

public VersatileBuffer GetSendPacket()

Returns

VersatileBuffer

The next VersatileBuffer packet, or null if the queue is empty.

GetSendPackets()

Dequeues and returns all packets from the send queue.

public List<VersatileBuffer> GetSendPackets()

Returns

List<VersatileBuffer>

A list of all VersatileBuffer packets from the output queue.

GetSendQueueCount()

Gets the number of packets currently in the send queue.

public int GetSendQueueCount()

Returns

int

The number of packets in the output queue.

GetStreamDescriptor(int)

Gets the stream descriptor containing media types for all streams in the specified program.

public List<MediaType> GetStreamDescriptor(int programIndex)

Parameters

programIndex int

The zero-based index of the program.

Returns

List<MediaType>

A list of MediaType instances describing each stream in the program.

SetStreamDescriptor(int, List<MediaType>)

Sets the stream descriptor for the specified program, creating or updating elementary streams and their corresponding PES stream handlers.

public void SetStreamDescriptor(int programIndex, List<MediaType> streamDescriptor)

Parameters

programIndex int

The zero-based index of the program.

streamDescriptor List<MediaType>

The list of MediaType instances describing each stream.