Table of Contents

Class StreamSourceBlockWithDecoder

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

Composite media source block that combines stream reading with automatic decoding for complete media playback. This high-level block encapsulates the complexity of reading from .NET Stream objects, automatically detecting media formats, demuxing container formats, and decoding compressed streams into raw video and audio data. Provides a simplified API for applications that need to play media from memory without manual pipeline construction.

Key features:

  • Automatic format detection for all supported container formats
  • Integrated demuxing of multi-stream containers (MP4, MKV, AVI, etc.)
  • Hardware-accelerated decoding when available
  • Support for any .NET Stream implementation (MemoryStream, FileStream, NetworkStream)
  • Seamless handling of variable bitrate and adaptive streams
  • Automatic audio/video synchronization
  • Zero-copy streaming from memory buffers when possible

Common use cases:

  • Playing media from memory buffers or byte arrays
  • Streaming from encrypted or compressed archives
  • Processing media from network streams without temporary files
  • Embedding media playback in memory-constrained environments
  • Custom stream implementations for DRM or proprietary formats

The block internally manages a StreamSourceBlock for reading and a DecodeBinBlock for automatic format detection and decoding, presenting a simple interface with separate video and audio outputs ready for rendering or further processing. Implements the VisioForge.Core.MediaBlocks.Special.SuperMediaBlock

public class StreamSourceBlockWithDecoder : SuperMediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

StreamSourceBlockWithDecoder(Stream)

Initializes a new instance of the VisioForge.Core.MediaBlocks.Sources.StreamSourceBlockWithDecoder class with an existing stream. Creates a complete media playback pipeline from stream reading through decoding in a single block. The stream position should be at the beginning of valid media data for proper format detection.

public StreamSourceBlockWithDecoder(Stream stream)

Parameters

stream Stream

The .NET Stream object containing encoded media data to be read, demuxed, and decoded. The stream must be readable and seekable for most media formats.

Remarks

The stream is not disposed when this block is disposed - the caller retains ownership and responsibility for the stream's lifecycle. Ensure the stream remains valid for the duration of playback.

StreamSourceBlockWithDecoder(string)

Initializes a new instance of the VisioForge.Core.MediaBlocks.Sources.StreamSourceBlockWithDecoder class from a file path. Opens the file as a stream and creates a complete playback pipeline with automatic decoding. This constructor manages the file stream internally and will close it when disposed.

public StreamSourceBlockWithDecoder(string filename)

Parameters

filename string

The path to the media file to open, read, demux, and decode. Supports both absolute and relative paths.

Exceptions

FileNotFoundException

Thrown when the specified file does not exist.

UnauthorizedAccessException

Thrown when the file cannot be accessed due to permissions.

Properties

AudioOutput

Gets the audio output pad that provides decoded audio samples from the stream.

public MediaBlockPad AudioOutput { get; }

Property Value

MediaBlockPad

VideoOutput

Gets the video output pad that provides decoded video frames from the stream.

public MediaBlockPad VideoOutput { get; }

Property Value

MediaBlockPad

See Also