Table of Contents

Class VideoRendererBlock

Namespace
VisioForge.Core.MediaBlocks.VideoRendering
Assembly
VisioForge.Core.dll

Cross-platform video renderer block providing display output for video streams. This block serves as the final destination for video in a media pipeline, rendering frames to various display surfaces across different platforms and UI frameworks. Features include hardware-accelerated rendering using platform-specific APIs (Direct3D 11 on Windows, OpenGL ES on mobile, Metal on Apple platforms), support for multiple UI frameworks (WPF, WinForms, MAUI, WinUI, Android Views, iOS/macOS views), subtitle overlay rendering, snapshot capture functionality, frame stepping, and playback rate control. The renderer automatically selects the optimal rendering path based on the platform and UI framework, providing native performance while maintaining a consistent API. Essential for media players, video editors, streaming clients, video conferencing apps, and any application requiring high-quality video display with minimal latency. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.

public class VideoRendererBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockRenderer, IGetVideoStreamInfo

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

VideoRendererBlock(MediaBlocksPipeline, IVideoView)

Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoRendering.VideoRendererBlock class.

public VideoRendererBlock(MediaBlocksPipeline pipeline, IVideoView videoView)

Parameters

pipeline MediaBlocksPipeline

Tthe pipeline.

videoView IVideoView

The video view.

VideoRendererBlock(MediaBlocksPipeline, nint)

Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoRendering.VideoRendererBlock class.

public VideoRendererBlock(MediaBlocksPipeline pipeline, nint windowHandle)

Parameters

pipeline MediaBlocksPipeline

Tthe pipeline.

windowHandle nint

The window handle.

Properties

Input

Gets the input.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets the inputs.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

IsSync

Gets or sets a value indicating whether to synchronize video rendering with the pipeline clock. Should be true for real-time playback to maintain audio/video sync, false for offline processing or transcoding where maximum throughput is desired.

public bool IsSync { get; set; }

Property Value

bool

Output

Gets the output.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets the outputs.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets or sets the video renderer configuration settings. Contains platform-specific rendering options, performance tuning parameters, and display preferences such as aspect ratio handling and scaling mode.

public VideoRendererSettingsX Settings { get; set; }

Property Value

VideoRendererSettingsX

SubtitleEnabled

Gets or sets a value indicating whether subtitle rendering is enabled. When enabled, subtitles from the stream or external file will be overlaid on the video.

public bool SubtitleEnabled { get; set; }

Property Value

bool

SubtitleExternalFile

Gets or sets the path to an external subtitle file (optional). Supports common subtitle formats like SRT, ASS, VTT. Takes precedence over embedded subtitles.

public string SubtitleExternalFile { get; set; }

Property Value

string

SubtitleSettings

Gets or sets the subtitle overlay configuration settings. Contains font, color, position, and styling options for subtitle rendering.

public SubtitleOverlaySettings SubtitleSettings { get; set; }

Property Value

SubtitleOverlaySettings

Type

Gets the type.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Builds this instance.

public override bool Build()

Returns

bool

true if successfull, false otherwise.

CleanUp()

Releases all resources and performs cleanup operations for this video renderer block. This method disposes of rendering elements, clears frame buffers, and releases display resources.

public void CleanUp()

ClearHandle()

Clears the window handle or display surface association. Call this before changing the rendering target or when the display window is destroyed.

public void ClearHandle()

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.

FrameStep(int, double)

Advances the video by a specified number of frames. Useful for frame-accurate seeking and video analysis applications.

public bool FrameStep(int framesCount, double rate)

Parameters

framesCount int

The number of frames to advance.

rate double

The rate at which to perform the frame step.

Returns

bool

true if frame stepping was successful; false otherwise.

GetCore()

Gets the core BaseElement wrapper that provides additional functionality around the platform-specific video renderer element.

public BaseElement GetCore()

Returns

BaseElement

The BaseElement wrapper instance that encapsulates the video renderer.

GetElement()

Gets the underlying GStreamer element that performs video rendering.

public Element GetElement()

Returns

Element

The GStreamer Element instance representing the video renderer.

GetVideoStreamInfo()

Gets detailed information about the current video stream being rendered. Includes resolution, frame rate, pixel format, and codec information.

public VideoStreamInfo GetVideoStreamInfo()

Returns

VideoStreamInfo

VideoStreamInfo containing stream metadata, or null if no stream is active.

GetVideoView()

Gets the video view interface associated with this renderer.

public IVideoView GetVideoView()

Returns

IVideoView

The IVideoView instance used for rendering, or null if using window handle.

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.

SetRate(double, Pipeline)

Sets the playback rate for the video renderer. Supports variable speed playback including slow motion and fast forward.

public bool SetRate(double rate, Pipeline pipeline)

Parameters

rate double

The playback rate (1.0 = normal, 0.5 = half speed, 2.0 = double speed).

pipeline Pipeline

The GStreamer pipeline containing this renderer.

Returns

bool

true if the rate was successfully set; false otherwise.

Snapshot_Get()

Gets the snapshot as SKBitmap.

public SKBitmap Snapshot_Get()

Returns

SKBitmap

SKBitmap.

Snapshot_GetAsync()

Gets the snapshot as SKBitmap (async).

public Task<SKBitmap> Snapshot_GetAsync()

Returns

Task<SKBitmap>

Task<SKBitmap>.

Snapshot_Save(string, SKEncodedImageFormat, int)

Saves snapshot to a file.

public bool Snapshot_Save(string filename, SKEncodedImageFormat format, int quality = 85)

Parameters

filename string

File name.

format SKEncodedImageFormat

Format.

quality int

Quality.

Returns

bool

true if successful, false otherwise.

Snapshot_SaveAsync(string, SKEncodedImageFormat, int)

Saves snapshot to a file (async).

public Task<bool> Snapshot_SaveAsync(string filename, SKEncodedImageFormat format, int quality = 85)

Parameters

filename string

File name.

format SKEncodedImageFormat

Format.

quality int

Quality.

Returns

Task<bool>

true if successful, false otherwise.

UpdateSubtitleOverlay(SubtitleOverlaySettings)

Updates the subtitle overlay settings in real-time. Changes take effect immediately without interrupting video playback.

public void UpdateSubtitleOverlay(SubtitleOverlaySettings settings)

Parameters

settings SubtitleOverlaySettings

The new subtitle overlay settings to apply.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Associates this video renderer block with a pipeline and initializes its internal context. This method is called internally when the block is added to a pipeline.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The MediaBlocksPipeline instance that will manage this block.

See Also