Class SRTMPEGTSSinkBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
Provides a media sink for streaming MPEG-TS content over SRT (Secure Reliable Transport) protocol.
public class SRTMPEGTSSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockDynamicInputsInheritance
Implements
Inherited Members
Extension Methods
Examples
// Create SRT MPEG-TS sink for streaming
var settings = new SRTSinkSettings
{
Uri = "srt://192.168.1.100:9000",
Mode = SRTMode.Caller,
Latency = 120, // milliseconds
Passphrase = "secretkey" // Optional encryption
};
var srtSink = new SRTMPEGTSSinkBlock(settings);
// Create inputs for streams
var videoInput = srtSink.CreateNewInput(MediaBlockPadMediaType.Video);
var audioInput = srtSink.CreateNewInput(MediaBlockPadMediaType.Audio);
// Connect encoded streams
pipeline.Connect(h264Encoder.Output, videoInput);
pipeline.Connect(aacEncoder.Output, audioInput);
Remarks
The SRTMPEGTSSinkBlock combines MPEG-TS multiplexing with SRT streaming to enable low-latency, secure, and reliable media transport over unreliable networks. It multiplexes audio and video streams into MPEG-TS format and transmits them using the SRT protocol.
Key features include:
- Low-latency streaming with SRT protocol benefits
- Automatic packet loss recovery and retransmission
- AES encryption support for secure transmission
- Dynamic input creation for multiple streams
- Firewall and NAT traversal capabilities
- Bandwidth efficiency with ARQ (Automatic Repeat Request)
Common use cases:
- Live broadcast contribution over public internet
- Remote production and cloud-based workflows
- Point-to-point video transport with security
- Low-latency streaming for interactive applications
- Reliable media delivery over unpredictable networks
The block expects pre-encoded streams compatible with MPEG-TS format (H.264/H.265 video, AAC/MP3 audio). It first multiplexes streams into MPEG-TS, then transmits via SRT.
Constructors
SRTMPEGTSSinkBlock(SRTSinkSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.SRTMPEGTSSinkBlock class with the specified settings.
public SRTMPEGTSSinkBlock(SRTSinkSettings settings)Parameters
settingsSRTSinkSettings-
The SRT sink configuration settings that define connection and streaming parameters.
Remarks
The settings must specify a valid SRT URI and connection mode before building the block. The block name is automatically set to "SRTMPEGTSSinkBlock".
This sink combines MPEG-TS multiplexing with SRT transport, making it suitable for professional streaming applications requiring reliability and low latency.
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 SRT MPEG-TS sink block and configures input pads for streaming.
public override bool Build()Returns
- bool
-
trueif the block was successfully built; otherwise,false.
Remarks
This method initializes the underlying GStreamer pipeline that combines MPEG-TS multiplexing with SRT output. The pipeline structure is:
[inputs] -> mpegtsmux -> srtsink
All input pads use the "sink_%d" template from the MPEG-TS muxer, which accepts various elementary stream formats. The muxer output is then sent to the SRT sink for network transmission.
If the internal element's input is null, the build will fail with an appropriate error message logged to the context.
CleanUp()
Cleans up.
public void CleanUp()CreateNewInput(MediaBlockPadMediaType)
Creates a new input pad for the specified media type to support multi-stream MPEG-TS.
public MediaBlockPad CreateNewInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
The type of media stream (video, audio, or subtitle) for the new input.
Returns
- MediaBlockPad
-
A new VisioForge.Core.MediaBlocks.MediaBlockPad configured for the specified media type.
Remarks
This method enables dynamic creation of inputs for multi-stream MPEG-TS multiplexing. All inputs share the same "sink_%d" pad template, allowing flexible stream configuration.
The MPEG-TS format supports multiple elementary streams, making it suitable for multi-language audio, multiple video angles, or subtitle tracks.
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 SRT streaming URI.
public string GetFilenameOrURL()Returns
- string
-
The configured SRT URI as a string.
Remarks
This method implements the IMediaBlockSink interface requirement and returns the SRT URI from the settings. The URI typically follows the format:
srt://hostname:port?options
GetInput(MediaBlockPadMediaType)
Retrieves an existing input pad of the specified media type.
public MediaBlockPad GetInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
The media type to search for.
Returns
- MediaBlockPad
-
The first VisioForge.Core.MediaBlocks.MediaBlockPad matching the specified type, or
nullif none exists.
Remarks
This method returns the first input pad that matches the requested media type. If multiple inputs of the same type exist, only the first one is returned. Use VisioForge.Core.MediaBlocks.Sinks.SRTMPEGTSSinkBlock.Inputs to access all input pads.
IsAvailable()
Determines whether the SRT MPEG-TS sink functionality is available in the current environment.
public static bool IsAvailable()Returns
- bool
-
trueif SRT streaming with MPEG-TS is supported; otherwise,false.
Remarks
Availability depends on the presence of required GStreamer plugins (mpegtsmux, srtsink) and the correct NuGet SDK redistribution package must be included in your project. Both MPEG-TS multiplexing and SRT protocol support are required.
SetFilenameOrURL(string)
Sets the SRT streaming URI.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The new SRT URI string.
Remarks
This method updates the URI in the settings. Changes made after the block is built will not take effect until the block is rebuilt.
The URI should follow the SRT protocol format:
srt://hostname:port?param1=value1¶m2=value2
Common parameters include mode (caller/listener), latency, passphrase, and streamid.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The pipeline.