Table of Contents

Class ParseBinBlock

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

Provides automatic parsing and demuxing of media streams without decoding, exposing elementary streams.

public class ParseBinBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Examples

// Example 1: Extract streams for remuxing
var parseBin = new ParseBinBlock();
var muxer = new MP4MuxerBlock();

// Connect source to parser
pipeline.Connect(fileSource.Output, parseBin.Input);

// After pipeline starts, connect discovered streams
// (In practice, handle the OnPadAdded event)
pipeline.Connect(parseBin.Outputs[0], muxer.VideoInput);
pipeline.Connect(parseBin.Outputs[1], muxer.AudioInput);

// Example 2: Stream analysis without decoding
var parseBin = new ParseBinBlock();
pipeline.Connect(source.Output, parseBin.Input);

// Connect to analysis blocks that work with encoded data
pipeline.Connect(parseBin.Outputs[0], h264Analyzer.Input);

Remarks

The VisioForge.Core.MediaBlocks.Special.ParseBinBlock is a dynamic element that automatically detects and parses media container formats, extracting elementary streams without decoding them. Unlike VisioForge.Core.MediaBlocks.Special.DecodeBinBlock, which produces decoded raw audio/video, ParseBin outputs parsed but still encoded streams.

Key features and use cases:

  • Extracts elementary streams from containers (MP4, MKV, AVI, etc.)
  • Preserves original encoding for remuxing or transmuxing
  • Lower CPU usage compared to full decoding
  • Useful for stream analysis and metadata extraction
  • Ideal for changing container formats without re-encoding

The block dynamically creates output pads as streams are discovered:

  • Video streams appear on video output pads
  • Audio streams appear on audio output pads
  • Subtitle and other streams may also be exposed

Dynamic Pad Behavior: Output pads are created dynamically as the input stream is analyzed. Connect to the appropriate output pads after the pipeline starts and streams are discovered.

Constructors

ParseBinBlock()

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

public ParseBinBlock()

Remarks

Creates a parse bin with:

  • One input pad that accepts any media type
  • Pre-allocated video and audio output pads (connected dynamically)

Additional output pads may be created dynamically as streams are discovered. The actual number and types of output streams depend on the input media.

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[]

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 parsebin 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 parsebin element
  2. Registers for dynamic pad addition events
  3. Initializes the element in the pipeline
  4. Configures the input pad for receiving data

Output pads are not configured during build as they are created dynamically when streams are discovered during pipeline operation.

CleanUp()

Performs cleanup of the parsebin resources.

public void CleanUp()

Remarks

This method unregisters event handlers and clears references to the parsebin element. Note that the element disposal is commented out, which may be intentional to avoid issues with GStreamer's internal reference counting during pipeline teardown.

The cleanup process includes:

  • Unregistering the pad-added event handler
  • Clearing the element reference
  • Resetting the build state

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.ParseBinElement wrapper that manages the underlying parsebin.

Remarks

Use this to access parsebin-specific functionality or for advanced GStreamer operations not exposed through the block's public API.

GetElement()

Gets the underlying GStreamer parsebin element.

public Element GetElement()

Returns

Element

The native GStreamer parsebin element.

Remarks

Direct access to the GStreamer element allows for low-level configuration but should be used with caution to maintain pipeline integrity.

IsAvailable()

Determines whether the parsebin functionality is available in the current environment.

public static bool IsAvailable()

Returns

bool

true if parsebin is available; otherwise, false.

Remarks

ParseBin requires GStreamer base plugins to be installed. This method verifies that the necessary components are available in your GStreamer installation.

If this returns false, ensure that:

  • GStreamer base plugins are properly installed
  • The correct NuGet SDK redistribution packages are included
  • GStreamer is properly initialized

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the context.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The pipeline.

See Also