Table of Contents

Class UniversalSourceBlockV2

Namespace
VisioForge.Core.MediaBlocks.Sources
Assembly
VisioForge.Core.dll

Universal source block that automatically creates the necessary pipeline based on file content.

public class UniversalSourceBlockV2 : SourceMediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Remarks

Pipeline construction algorithm (Build):

  1. Create a GStreamer source element based on URI scheme (filesrc, souphttpsrc, rtspsrc, etc.).
  2. For RTSP sources: connect through parsebin which auto-discovers and decodes streams via dynamic pads (VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2.OnParsebinPadAdded(System.Object,Gst.PadAddedArgs), VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2.OnRtspPadAdded(System.Object,Gst.PadAddedArgs)).
  3. For file/HTTP sources: use typefind to detect container format, then select an explicit demuxer (VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2.SelectDemuxer(System.String)) and parsers (VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2.SelectParser(System.String)).
  4. If the demuxer has static pads, link them immediately via VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2.ProcessStaticDemuxerPads; otherwise, wait for dynamic pad-added signals (VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2.OnDemuxerPadAdded(System.Object,Gst.PadAddedArgs)).
  5. For each media stream, create an output chain: queue → optional parser → decoder → converter → output pad (VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2.CreateVideoOutputChain(System.Int32), VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2.CreateAudioOutputChain(System.Int32), VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2.CreateSubtitleOutputChain(System.Int32)).
  6. Decoder selection (VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2.SelectDecoder(System.String)) considers hardware acceleration availability and falls back to software decoding when hardware is unavailable.

Key responsibilities: source element creation, format detection, demuxer/parser/decoder selection, output chain assembly, dynamic pad negotiation, hardware decoder fallback, and multi-stream output management.

This class delegates to GStreamer elements for the actual media processing. The VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2.StreamChain helper tracks per-stream element references (parser, decoder, converter, queues) for cleanup.

Constructors

UniversalSourceBlockV2(UniversalSourceSettingsV2)

Initializes a new instance of the VisioForge.Core.MediaBlocks.Sources.UniversalSourceBlockV2 class.

public UniversalSourceBlockV2(UniversalSourceSettingsV2 settings)

Parameters

settings UniversalSourceSettingsV2

The universal source settings.

Properties

AudioOutput

Gets the primary audio output pad.

public MediaBlockPad AudioOutput { get; }

Property Value

MediaBlockPad

AudioOutputs

Gets all audio output pads.

public List<MediaBlockPad> AudioOutputs { get; }

Property Value

List<MediaBlockPad>

Input

Gets the primary input pad (not used for file sources).

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets all input pads (empty for file sources).

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

MetadataOutput

Gets the primary metadata output pad.

public MediaBlockPad MetadataOutput { get; }

Property Value

MediaBlockPad

MetadataOutputs

Gets all metadata output pads.

public List<MediaBlockPad> MetadataOutputs { get; }

Property Value

List<MediaBlockPad>

Output

Gets the primary output pad (first available output).

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets all output pads.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets the source settings.

public UniversalSourceSettingsV2 Settings { get; }

Property Value

UniversalSourceSettingsV2

SubtitleOutput

Gets the primary subtitle output pad.

public MediaBlockPad SubtitleOutput { get; }

Property Value

MediaBlockPad

SubtitleOutputs

Gets all subtitle output pads.

public List<MediaBlockPad> SubtitleOutputs { get; }

Property Value

List<MediaBlockPad>

Type

Gets the type of this media block.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

VideoOutput

Gets the primary video output pad.

public MediaBlockPad VideoOutput { get; }

Property Value

MediaBlockPad

VideoOutputs

Gets all video output pads.

public List<MediaBlockPad> VideoOutputs { get; }

Property Value

List<MediaBlockPad>

Methods

Build()

Builds the media block.

public override bool Build()

Returns

bool

CleanUp()

Cleans up the block's internal resources.

public virtual void CleanUp()

Dispose(bool)

Cleans up the media block.

protected override void Dispose(bool disposing)

Parameters

disposing bool

GetCore()

Gets the core BaseElement wrapper.

public BaseElement GetCore()

Returns

BaseElement

Not applicable for this block, returns null.

GetElement()

Gets the main GStreamer element for this block.

public Element GetElement()

Returns

Element

The source element (as primary element).

SetContext(MediaBlocksPipeline)

Sets the pipeline context for this block.

public void SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The MediaBlocksPipeline instance.

IMediaBlockInternals.CleanUp()

IMediaBlockInternals cleanup implementation.

void IMediaBlockInternals.CleanUp()