Class VideoRendererBlock
- 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, IGetVideoStreamInfoInheritance
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
pipelineMediaBlocksPipeline-
Tthe pipeline.
videoViewIVideoView-
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
pipelineMediaBlocksPipeline-
Tthe pipeline.
windowHandlenint-
The window handle.
Properties
Input
Gets the input.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets the inputs.
public override MediaBlockPad[] Inputs { get; }Property Value
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
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 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
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
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
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
Type
Gets the type.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds this instance.
public override bool Build()Returns
- bool
-
trueif successfull,falseotherwise.
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
disposingbool-
trueto release both managed and unmanaged resources;falseto 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
framesCountint-
The number of frames to advance.
ratedouble-
The rate at which to perform the frame step.
Returns
- bool
-
trueif frame stepping was successful;falseotherwise.
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
-
trueif 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
ratedouble-
The playback rate (1.0 = normal, 0.5 = half speed, 2.0 = double speed).
pipelinePipeline-
The GStreamer pipeline containing this renderer.
Returns
- bool
-
trueif the rate was successfully set;falseotherwise.
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
Snapshot_Save(string, SKEncodedImageFormat, int)
Saves snapshot to a file.
public bool Snapshot_Save(string filename, SKEncodedImageFormat format, int quality = 85)Parameters
filenamestring-
File name.
formatSKEncodedImageFormat-
Format.
qualityint-
Quality.
Returns
- bool
-
trueif successful,falseotherwise.
Snapshot_SaveAsync(string, SKEncodedImageFormat, int)
Saves snapshot to a file (async).
public Task<bool> Snapshot_SaveAsync(string filename, SKEncodedImageFormat format, int quality = 85)Parameters
filenamestring-
File name.
formatSKEncodedImageFormat-
Format.
qualityint-
Quality.
Returns
UpdateSubtitleOverlay(SubtitleOverlaySettings)
Updates the subtitle overlay settings in real-time. Changes take effect immediately without interrupting video playback.
public void UpdateSubtitleOverlay(SubtitleOverlaySettings settings)Parameters
settingsSubtitleOverlaySettings-
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
pipelineMediaBlocksPipeline-
The MediaBlocksPipeline instance that will manage this block.