Class SourceMediaBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sources
- Assembly
- VisioForge.Core.dll
Abstract base class for all media source blocks in the MediaBlocks pipeline framework. This foundational class provides the essential infrastructure for blocks that originate media data from various sources including file systems, capture devices, network streams, and synthetic generators. Source blocks represent the entry points of media processing pipelines, responsible for acquiring raw or encoded media data and making it available to downstream processing blocks.
Key responsibilities:
- Defining the common interface for all media source implementations
- Providing base functionality for source lifecycle management
- Establishing contracts for subtitle availability and source control
- Serving as the starting point for media processing chains
Common derived implementations:
- File sources (MP4, AVI, MKV, WebM, etc.)
- Device sources (cameras, microphones, capture cards)
- Network sources (RTSP, RTMP, HTTP streams)
- Synthetic sources (test patterns, tone generators)
- Screen capture sources (desktop, window, region)
- Industrial camera sources (GenICam, machine vision)
Source blocks typically have no input pads and one or more output pads depending on the media streams they provide (video, audio, subtitles). They are responsible for format detection, stream initialization, and maintaining synchronization between multiple output streams. Implements the VisioForge.Core.MediaBlocks.MediaBlock.
public class SourceMediaBlock : MediaBlock, IMediaBlock, IDisposableInheritance
Derived
Implements
Inherited Members
Extension Methods
Methods
IsSubtitlesAvailable()
Determines whether subtitle streams are available from this media source. This method allows downstream blocks to query the availability of text-based subtitle tracks that may be embedded in media files or provided as separate streams. Subtitle support includes various formats such as SRT, SSA/ASS, WebVTT, TTML, and embedded formats like DVD/Blu-ray subtitles.
public virtual bool IsSubtitlesAvailable()Returns
- bool
-
trueif one or more subtitle streams are available and can be extracted;falseif no subtitles are present or the source doesn't support subtitle extraction.
Remarks
Override this method in derived classes that implement subtitle extraction capabilities. The base implementation returns false, indicating no subtitle support by default. Sources that support subtitles should also implement the corresponding subtitle output pad.
Stop()
Stops the media source from generating or reading data and releases associated resources. This method provides a controlled shutdown mechanism for source blocks, ensuring proper cleanup of system resources, device handles, network connections, and file descriptors.
public virtual bool Stop()Returns
- bool
-
trueif the source was successfully stopped and all resources were released;falseif an error occurred during shutdown.
Remarks
Override this method in derived classes to implement source-specific stopping logic:
- File sources: Close file handles and release memory buffers
- Device sources: Stop hardware devices and release exclusive access
- Network sources: Close connections and cleanup network resources
- Thread sources: Signal and wait for worker threads to terminate
The base implementation returns true, allowing simple sources to use default behavior. Complex sources should ensure all resources are properly released to prevent leaks. This method may be called multiple times and should be idempotent.