Class UniversalDemuxBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sources
- Assembly
- VisioForge.Core.dll
Universal demultiplexer block for extracting streams from any supported container format. This versatile block automatically detects and parses various container formats (MP4, MKV, AVI, WebM, etc.) and separates them into individual video, audio, subtitle, and metadata streams. Supports multiple streams of each type, automatic format detection, stream selection, and optimized handling based on MediaFileInfo. Essential for general-purpose media playback, transcoding workflows, multi-stream processing, and applications requiring format-agnostic demultiplexing capabilities. Provides comprehensive stream routing with optional null sinks. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.
public class UniversalDemuxBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Implements
Inherited Members
Extension Methods
Constructors
UniversalDemuxBlock(IUniversalDemuxSettings, MediaFileInfo, bool, bool, bool, bool)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sources.UniversalDemuxBlock class with custom settings and stream extraction options.
public UniversalDemuxBlock(IUniversalDemuxSettings settings, MediaFileInfo info, bool renderVideo = true, bool renderAudio = true, bool renderSubtitle = false, bool renderMetadata = false)Parameters
settingsIUniversalDemuxSettings-
The demuxer configuration settings.
infoMediaFileInfo-
The media file information containing stream details. Required for proper stream support.
renderVideobool-
if set to
trueextract and output video streams. renderAudiobool-
if set to
trueextract and output audio streams. renderSubtitlebool-
if set to
trueextract and output subtitle streams. renderMetadatabool-
if set to
trueextract and output metadata streams.
UniversalDemuxBlock(MediaFileInfo, bool, bool, bool, bool)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sources.UniversalDemuxBlock class with default settings and stream extraction options.
public UniversalDemuxBlock(MediaFileInfo info, bool renderVideo = true, bool renderAudio = true, bool renderSubtitle = false, bool renderMetadata = false)Parameters
infoMediaFileInfo-
The media file information containing stream details. Required for proper stream support.
renderVideobool-
if set to
trueextract and output video streams. renderAudiobool-
if set to
trueextract and output audio streams. renderSubtitlebool-
if set to
trueextract and output subtitle streams. renderMetadatabool-
if set to
trueextract and output metadata streams.
Properties
AudioOutputs
Gets all audio output pads for extracted audio streams. The number of pads matches the number of audio streams in the container.
public MediaBlockPad[] AudioOutputs { get; }Property Value
Input
Gets the input.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets the inputs.
public override MediaBlockPad[] Inputs { get; }Property Value
MetadataOutputs
Gets all metadata output pads for extracted metadata streams.
public MediaBlockPad[] MetadataOutputs { get; }Property Value
Output
Gets the output.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets the outputs.
public override MediaBlockPad[] Outputs { get; }Property Value
SubtitleOutputs
Gets all subtitle output pads for extracted subtitle streams. The number of pads matches the number of subtitle streams in the container.
public MediaBlockPad[] SubtitleOutputs { get; }Property Value
Type
Gets the type.
public override MediaBlockType Type { get; }Property Value
VideoOutputs
Gets all video output pads for extracted video streams. The number of pads matches the number of video streams in the container.
public MediaBlockPad[] VideoOutputs { get; }Property Value
Methods
Build()
Constructs and initializes the universal demux and all associated queue elements. This method creates the demux element, sets up dynamic pad handlers for each stream type, creates queue or null sink elements based on rendering options, and establishes output connections.
public override bool Build()Returns
- bool
-
trueif the demux was successfully built and configured;falseif initialization failed.
CleanUp()
Releases all resources and performs cleanup operations for this universal demux block. This method disposes of the demux element, all queue elements, null renderers, and clears all collections before resetting the build state.
public void CleanUp()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.
GetAudioOutput()
Gets the first audio output pad if available. Convenience method for accessing the primary audio stream.
public MediaBlockPad GetAudioOutput()Returns
- MediaBlockPad
-
The first audio output pad or null if no audio streams.
GetCore()
Gets the core BaseElement wrapper. Returns null as the demux element is accessed directly without a wrapper.
public BaseElement GetCore()Returns
- BaseElement
-
Always returns null for this implementation.
GetElement()
Gets the underlying GStreamer element that performs the universal demuxing.
public Element GetElement()Returns
- Element
-
The GStreamer Element instance representing the universal demux.
GetMetadataOutput()
Gets the first metadata output pad if available. Convenience method for accessing the primary metadata stream.
public MediaBlockPad GetMetadataOutput()Returns
- MediaBlockPad
-
The first metadata output pad or null if no metadata streams.
GetSubtitleOutput()
Gets the first subtitle output pad if available. Convenience method for accessing the primary subtitle stream.
public MediaBlockPad GetSubtitleOutput()Returns
- MediaBlockPad
-
The first subtitle output pad or null if no subtitle streams.
GetVideoOutput()
Gets the first video output pad if available. Convenience method for accessing the primary video stream.
public MediaBlockPad GetVideoOutput()Returns
- MediaBlockPad
-
The first video output pad or null if no video streams.
IsAvailable(IUniversalDemuxSettings)
Determines whether this media block is available. Correct NuGet SDK redist should be included into your project. Checks for required demuxer plugins based on the specified settings.
public static bool IsAvailable(IUniversalDemuxSettings settings)Parameters
settingsIUniversalDemuxSettings-
The demuxer settings to check availability for.
Returns
- bool
-
trueif this media block is available; otherwise,false.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Associates this universal demux 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.