Class MPEGTSSinkBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
Implements a sink block for creating MPEG Transport Stream (MPEG-TS) files or streams. Supports broadcasting, streaming, and digital TV distribution formats.
public class MPEGTSSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockDynamicInputsInheritance
Implements
Inherited Members
Extension Methods
Remarks
The MPEGTSSinkBlock creates MPEG Transport Streams, the standard format for: - Digital television broadcasting (DVB, ATSC, ISDB) - IPTV and streaming services - Blu-ray disc video - Network streaming protocols (HLS, MPEG-DASH)
MPEG-TS characteristics: - Fixed-size 188-byte packets for error resilience - Designed for unreliable transmission (broadcast, network) - Program Association Table (PAT) and Program Map Table (PMT) - Support for multiple programs in a single stream - PCR (Program Clock Reference) for synchronization
Key features: - Multiple video/audio/data streams per program - Service information (SI) tables - Conditional access support (encryption) - Time-stamped packets for live streaming - Can output to file or network stream
Common use cases: - Live TV broadcasting and recording - HLS streaming preparation - Network video distribution - Set-top box recording format - Professional broadcast workflows
Constructors
MPEGTSSinkBlock(MPEGTSSinkSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.MPEGTSSinkBlock class.
public MPEGTSSinkBlock(MPEGTSSinkSettings settings)Parameters
settingsMPEGTSSinkSettings-
The MPEG-TS configuration including output mode and muxing parameters.
Remarks
If FileOutput is false in settings, an output pad will be created for streaming the MPEG-TS data to another pipeline element (e.g., for network streaming).
Exceptions
- ArgumentNullException
-
Thrown when
settingsisnull.
Properties
Input
Gets the first input.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets the inputs.
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the output.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets the outputs.
public override MediaBlockPad[] Outputs { get; }Property Value
Type
Gets the type.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds the MPEG-TS sink and configures it for operation.
public override bool Build()Returns
- bool
-
trueif the build was successful; otherwise,false.
Remarks
This method:
- Creates the MPEG-TS muxer with specified settings
- Configures input pads for all elementary streams
- Sets up output (file or streaming pad)
- Initializes program tables and PIDs
CleanUp()
Performs cleanup of resources used by the MPEG-TS sink.
public void CleanUp()Remarks
This method ensures all packets are written, finalizes the transport stream structure, and releases the underlying muxer element.
CreateNewInput(MediaBlockPadMediaType)
Creates a new input pad for adding an elementary stream to the transport stream.
public MediaBlockPad CreateNewInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
The type of elementary stream (video, audio, or data).
Returns
- MediaBlockPad
-
A new VisioForge.Core.MediaBlocks.MediaBlockPad for connecting the media stream.
Remarks
Common stream types:
- Video: H.264/AVC, H.265/HEVC, MPEG-2
- Audio: AAC, MP3, AC-3, DTS
- Data: Teletext, subtitles, metadata Each stream is assigned a unique PID (Packet Identifier) in the transport stream.
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected override void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetCore()
Gets core.
public BaseElement GetCore()Returns
- BaseElement
-
VisioForge.Core.GStreamer.Base.BaseElement.
GetElement()
Gets the element.
public Element GetElement()Returns
- Element
-
Gst.Element.
GetFilenameOrURL()
Gets the output filename for the MPEG-TS file.
public string GetFilenameOrURL()Returns
- string
-
The full path to the output file, or
nullif configured for streaming output.
GetInput(MediaBlockPadMediaType)
Gets the existing input.
public MediaBlockPad GetInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
Type of the media.
Returns
- MediaBlockPad
-
MediaBlockPad.
IsAvailable()
Determines whether MPEG-TS muxing functionality is available on the current platform.
public static bool IsAvailable()Returns
- bool
-
trueif MPEG-TS sink is available; otherwise,false. Requires GStreamer's mpegtsmux element.
Remarks
MPEG-TS support is part of GStreamer's bad plugins package. This is a widely supported format across all platforms.
SetFilenameOrURL(string)
Sets the output filename for the MPEG-TS file.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The full path where the MPEG-TS file should be written.
Remarks
This only applies when the sink is configured for file output. For streaming output, use the output pad instead. Common extensions are .ts, .mts, or .m2ts.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The pipeline.