Table of Contents

Class RTMPSinkBlock

Namespace
VisioForge.Core.MediaBlocks.Sinks
Assembly
VisioForge.Core.dll

RTMP (Real-Time Messaging Protocol) sink block for streaming media to RTMP servers.

public class RTMPSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockDynamicInputs

Inheritance

Implements

Inherited Members

Extension Methods

Remarks

The RTMP sink block enables live streaming of audio and video content to RTMP-compatible streaming servers and platforms. RTMP is the de facto standard for live streaming, supported by major platforms like YouTube Live, Facebook Live, Twitch, and custom streaming servers like Wowza, nginx-rtmp, and Adobe Media Server.

Key Features:

  • Real-time streaming with low latency
  • Support for H.264 video and AAC/MP3 audio codecs
  • Authentication support for secure streaming
  • Automatic reconnection capabilities
  • Compatible with all major streaming platforms
  • Support for custom RTMP server implementations

Typical Use Cases:

  • Live streaming to YouTube, Facebook, Twitch, etc.
  • Broadcasting events, gaming sessions, or presentations
  • Setting up private streaming servers for internal use
  • Multi-platform simultaneous streaming
  • Professional broadcast workflows

Technical Requirements:

  • Video: H.264/AVC codec (baseline, main, or high profile)
  • Audio: AAC or MP3 codec
  • Stable network connection with sufficient upload bandwidth
  • RTMP URL format: rtmp://server:port/app/streamkey

Limitations:

  • Limited to H.264 video (no H.265/HEVC support in standard RTMP)
  • Maximum resolution depends on server and bandwidth
  • Requires pre-encoded streams (not a transcoding block)

Constructors

RTMPSinkBlock(RTMPSinkSettings)

Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.RTMPSinkBlock class with the specified settings.

public RTMPSinkBlock(RTMPSinkSettings settings)

Parameters

settings RTMPSinkSettings

The VisioForge.Core.Types.X.Sinks.RTMPSinkSettings object containing the RTMP server URL, authentication details, and streaming parameters. The Location property must contain a valid RTMP URL in the format: rtmp://server:port/app/streamkey

Properties

Input

Gets the first input pad from the collection of available inputs.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets all available input pads for connecting multiple media streams.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the output pad for this sink block.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets all output pads for this sink block.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets or sets the RTMP sink configuration settings.

public RTMPSinkSettings Settings { get; set; }

Property Value

RTMPSinkSettings

Type

Gets the media block type identifier for the RTMP sink.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Builds and initializes the RTMP sink pipeline components.

public override bool Build()

Returns

bool

true if the sink was successfully built and configured for streaming; false if initialization failed, the RTMP URL is invalid, or required pads couldn't be allocated.

Remarks

This method creates the underlying GStreamer RTMP sink element and configures it with the provided server URL and settings. It also sets up input pads for video and audio streams. The sink will attempt to connect to the RTMP server when the pipeline starts playing.

CleanUp()

Cleans up resources and disconnects from the RTMP server.

public void CleanUp()

Remarks

This method closes any active RTMP connection, disposes of the underlying GStreamer element, and resets the build state. The sink can be rebuilt with new settings after cleanup if needed.

CreateNewInput(MediaBlockPadMediaType)

Creates a new input pad for connecting a media stream of the specified type.

public MediaBlockPad CreateNewInput(MediaBlockPadMediaType mediaType)

Parameters

mediaType MediaBlockPadMediaType

The type of media stream to accept. RTMP supports: VisioForge.Core.MediaBlocks.MediaBlockPadMediaType.Video for H.264 encoded video streams and VisioForge.Core.MediaBlocks.MediaBlockPadMediaType.Audio for AAC or MP3 encoded audio streams.

Returns

MediaBlockPad

A new VisioForge.Core.MediaBlocks.MediaBlockPad configured for the specified media type, ready to receive pre-encoded streams for RTMP transmission.

Remarks

RTMP has specific codec requirements. Ensure your streams are properly encoded before connecting to this sink (H.264 for video, AAC/MP3 for audio).

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

GetCore()

Gets the core GStreamer wrapper element for advanced pipeline integration.

public BaseElement GetCore()

Returns

BaseElement

The VisioForge.Core.GStreamer.Base.BaseElement wrapper providing access to the underlying GStreamer RTMP sink element for advanced configuration and error handling.

GetElement()

Gets the native GStreamer element for direct GStreamer API access.

public Element GetElement()

Returns

Element

The underlying Gst.Element representing the RTMP sink, allowing direct access to GStreamer properties like location, timeout settings, etc.

GetFilenameOrURL()

Gets the RTMP server URL where the stream is being sent.

public string GetFilenameOrURL()

Returns

string

The complete RTMP URL including server, application, and stream key. Format: rtmp://server:port/application/streamkey

GetInput(MediaBlockPadMediaType)

Gets an existing input pad that matches the specified media type.

public MediaBlockPad GetInput(MediaBlockPadMediaType mediaType)

Parameters

mediaType MediaBlockPadMediaType

The media type to search for among existing input pads.

Returns

MediaBlockPad

The first VisioForge.Core.MediaBlocks.MediaBlockPad that matches the specified media type, or null if no matching input pad exists.

IsAvailable()

Determines whether this media block is available. Correct NuGet SDK redist should be included into your project.

public static bool IsAvailable()

Returns

bool

true if this media block is available; otherwise, false.

SetFilenameOrURL(string)

Sets the RTMP server URL for streaming.

public void SetFilenameOrURL(string value)

Parameters

value string

The RTMP URL where the stream should be sent. Must be in the format: rtmp://server:port/application/streamkey. For example: rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx

Remarks

Changing the URL during an active stream is not supported and will likely cause connection errors. Stop the pipeline before changing the destination.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the pipeline context for this media block.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The VisioForge.Core.MediaBlocks.MediaBlocksPipeline that owns this sink block, providing access to the pipeline context and logging facilities.

Remarks

This method is called internally by the pipeline during initialization and should not be called directly by user code.

See Also