Table of Contents

Class NullRendererBlock

Namespace
VisioForge.Core.MediaBlocks.Special
Assembly
VisioForge.Core.dll

Provides a sink element that consumes media data without producing any output, useful for testing and analysis.

public class NullRendererBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockRenderer

Inheritance

Implements

Inherited Members

Extension Methods

Examples

// Example 1: Discard video while keeping audio
var nullRenderer = new NullRendererBlock(MediaBlockPadMediaType.Video)
{
    IsSync = true  // Keep synchronized with audio
};
pipeline.Connect(demuxer.VideoOutput, nullRenderer.Input);
pipeline.Connect(demuxer.AudioOutput, audioRenderer.Input);

// Example 2: Benchmark decoding performance
var nullRenderer = new NullRendererBlock(MediaBlockPadMediaType.Video)
{
    IsSync = false  // Process as fast as possible
};
pipeline.Connect(decoder.Output, nullRenderer.Input);

// Example 3: Test pipeline without rendering
var videoNull = new NullRendererBlock(MediaBlockPadMediaType.Video);
var audioNull = new NullRendererBlock(MediaBlockPadMediaType.Audio);
pipeline.Connect(source.VideoOutput, videoNull.Input);
pipeline.Connect(source.AudioOutput, audioNull.Input);

Remarks

The VisioForge.Core.MediaBlocks.Special.NullRendererBlock acts as a "black hole" for media streams, accepting any type of media data (audio, video, or other) and discarding it. Despite not producing output, it can maintain synchronization with the pipeline clock when configured to do so.

Common use cases include:

  • Testing pipeline performance without actual rendering overhead
  • Analyzing streams without displaying or playing them
  • Benchmarking encoding/decoding performance
  • Discarding unwanted streams in multi-stream pipelines
  • Pipeline debugging and development

The block supports synchronization control through the VisioForge.Core.MediaBlocks.Special.NullRendererBlock.IsSync property:

  • When true: Maintains timing synchronization (default for playback)
  • When false: Processes data as fast as possible (ideal for transcoding)

This block implements VisioForge.Core.MediaBlocks.IMediaBlockRenderer, marking it as a terminal element in the pipeline.

Constructors

NullRendererBlock(MediaBlockPadMediaType)

Initializes a new instance of the VisioForge.Core.MediaBlocks.Special.NullRendererBlock class.

public NullRendererBlock(MediaBlockPadMediaType padMediaType)

Parameters

padMediaType MediaBlockPadMediaType

The type of media this renderer will accept and discard.

Remarks

The media type determines what kind of data the null renderer will accept. Common types include:

  • VisioForge.Core.MediaBlocks.MediaBlockPadMediaType.Video - For discarding video streams
  • VisioForge.Core.MediaBlocks.MediaBlockPadMediaType.Audio - For discarding audio streams
  • VisioForge.Core.MediaBlocks.MediaBlockPadMediaType.Auto - For accepting any media type

The renderer is created with synchronization enabled by default. Adjust VisioForge.Core.MediaBlocks.Special.NullRendererBlock.IsSync after construction if needed.

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 the renderer should synchronize with the pipeline clock.

public bool IsSync { get; set; }

Property Value

bool

Remarks

Synchronization behavior:

  • true: Respects timestamps and maintains real-time playback speed. Use for playback applications where timing matters.
  • false: Processes data without timing constraints. Use for transcoding, analysis, or performance testing.

When multiple streams are present (e.g., audio and video), synchronization ensures they remain aligned. For single-stream processing or when timing doesn't matter, disabling sync can significantly improve processing speed.

Output

Gets the output.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets the outputs.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Type

Gets the type.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Builds and initializes the null renderer element within the pipeline.

public override bool Build()

Returns

bool

true if the element was successfully built and initialized; otherwise, false.

Remarks

This method performs the following operations:

  1. Creates the underlying GStreamer null renderer element
  2. Initializes it with the current synchronization settings
  3. Configures the input pad for media reception

The method is idempotent and can be safely called multiple times. Errors during initialization are logged to the pipeline context.

CleanUp()

Performs cleanup of the null renderer resources.

public void CleanUp()

Remarks

This method safely disposes of the underlying GStreamer element and resets the build state. It handles exceptions during disposal to prevent cascading failures during pipeline shutdown.

The cleanup process includes:

  • Setting the element to NULL state (handled by BaseElement)
  • Disposing of the GStreamer element wrapper
  • Clearing internal references

This method is called automatically during disposal and should not be called directly by user code.

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.

public BaseElement GetCore()

Returns

BaseElement

The VisioForge.Core.GStreamer.Base.NullRenderer wrapper that manages the underlying GStreamer element.

Remarks

This provides access to the wrapper class for advanced operations or direct GStreamer element manipulation when needed.

GetElement()

Gets the underlying GStreamer element.

public Element GetElement()

Returns

Element

The native GStreamer fakesink element used for null rendering.

Remarks

Direct access to the GStreamer element should be used carefully. Most operations should go through the block's public API.

IsAvailable()

Determines whether the null renderer functionality is available in the current environment.

public static bool IsAvailable()

Returns

bool

true if the null renderer is available; otherwise, false.

Remarks

The null renderer is a core GStreamer element and should be available in all standard GStreamer installations. If this returns false, it indicates a problem with the GStreamer installation or initialization.

Always verify availability before creating instances, especially in environments where GStreamer installation might be incomplete or customized.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the context.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The pipeline.

See Also