Class SRTSinkBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
Provides a media sink for streaming raw data over SRT (Secure Reliable Transport) protocol.
public class SRTSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Implements
Inherited Members
Extension Methods
Examples
// Create SRT sink for direct streaming
var settings = new SRTSinkSettings
{
Uri = "srt://streaming.server.com:9000",
Mode = SRTMode.Caller,
Latency = 80, // milliseconds
Passphrase = "mySecureKey",
StreamId = "live/channel1"
};
var srtSink = new SRTSinkBlock(settings);
// Connect a muxed stream
pipeline.Connect(mpegtsMuxer.Output, srtSink.Input);
Remarks
The SRTSinkBlock enables direct streaming of any media data over the SRT protocol, providing low-latency, secure, and reliable transport over unreliable networks. Unlike SRTMPEGTSSinkBlock, this sink transmits raw data without MPEG-TS multiplexing.
Key features include:
- Ultra-low latency streaming (as low as 60ms)
- Automatic packet loss recovery with ARQ
- AES-128/256 encryption for secure transmission
- Firewall and NAT traversal support
- Bandwidth-adaptive streaming
- Connection bonding for redundancy
Common use cases:
- Live event streaming and contribution
- Remote production over public internet
- First-mile contribution from field to studio
- Cloud-based video workflows
- Low-latency streaming for gaming and esports
The block accepts any type of data stream through its single input pad. For typical video streaming, the input should be a properly formatted stream (e.g., MPEG-TS) created by an upstream muxer.
Constructors
SRTSinkBlock(SRTSinkSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.SRTSinkBlock class with the specified settings.
public SRTSinkBlock(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 "SRTSink".
The input pad is configured to accept any media type, providing flexibility for different streaming scenarios.
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
Settings
Gets or sets the SRT sink configuration settings.
public SRTSinkSettings Settings { get; set; }Property Value
Remarks
The settings include URI, connection mode, latency, encryption, and other SRT-specific parameters. Changes to settings after building the block will not take effect.
Type
Gets the type.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds the SRT sink block and configures the streaming endpoint.
public override bool Build()Returns
- bool
-
trueif the block was successfully built; otherwise,false.
Remarks
This method initializes the underlying GStreamer SRT sink element with the configured settings. The sink accepts any type of data through its single "sink" pad.
The build process:
- Creates the SRT sink element
- Initializes it with connection settings
- Retrieves and assigns the static sink pad
Failure to get the sink pad will result in an error being logged and the
method returning false.
CleanUp()
Cleans up.
public void CleanUp()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 format is:
srt://hostname:port?param1=value1¶m2=value2
IsAvailable()
Determines whether the SRT sink functionality is available in the current environment.
public static bool IsAvailable()Returns
- bool
-
trueif SRT streaming is supported; otherwise,false.
Remarks
Availability depends on the presence of the required GStreamer SRT plugin (srtsink). The correct NuGet SDK redistribution package must be included in your project for this block to function.
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 with optional parameters:
- mode: caller or listener
- latency: target latency in milliseconds
- passphrase: encryption key
- streamid: stream identifier
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The pipeline.