Class SuperMediaBlock
- Namespace
- VisioForge.Core.MediaBlocks.Special
- Assembly
- VisioForge.Core.dll
Provides a container for combining multiple media blocks into a single reusable unit.
public class SuperMediaBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Derived
Implements
Inherited Members
Extension Methods
Examples
// Example 1: Create a reusable video enhancement chain
public class VideoEnhancementBlock : SuperMediaBlock
{
public VideoEnhancementBlock() : base(autoConnectBlocks: true)
{
// Add blocks in processing order
Blocks.Add(new DeinterlaceBlock());
Blocks.Add(new ColorCorrectionBlock());
Blocks.Add(new SharpenBlock());
Blocks.Add(new NoiseReductionBlock());
}
}
// Use it like any other block
var enhancer = new VideoEnhancementBlock();
enhancer.Configure(pipeline);
pipeline.Connect(source.Output, enhancer.Input);
pipeline.Connect(enhancer.Output, renderer.Input);
// Example 2: Manual connection for complex routing
var superBlock = new SuperMediaBlock(autoConnectBlocks: false);
var tee = new TeeBlock(2, MediaBlockPadMediaType.Video);
var effect1 = new BlurEffectBlock();
var effect2 = new EdgeDetectionBlock();
var mixer = new VideoMixerBlock();
superBlock.Blocks.AddRange(new[] { tee, effect1, effect2, mixer });
// Configure before connecting
superBlock.Configure(pipeline);
// Manual internal connections
pipeline.Connect(tee.Outputs[0], effect1.Input);
pipeline.Connect(tee.Outputs[1], effect2.Input);
pipeline.Connect(effect1.Output, mixer.Inputs[0]);
pipeline.Connect(effect2.Output, mixer.Inputs[1]);
Remarks
The VisioForge.Core.MediaBlocks.Special.SuperMediaBlock acts as a composite pattern implementation, allowing you to group multiple media blocks together and treat them as a single block. This is particularly useful for creating reusable processing chains or complex media processing units.
Key features and benefits:
- Encapsulates complex processing chains into a single reusable component
- Simplifies pipeline construction by hiding internal complexity
- Enables modular design and code reuse
- Maintains the same interface as regular media blocks
- Supports both manual and automatic block connection
The super block exposes:
- Input pads from the first block in the chain
- Output pads from the last block in the chain
- Transparent pass-through of data between contained blocks
Auto-connect Mode: When enabled (default), blocks are automatically connected in the order they are added. When disabled, you must manually connect the internal blocks before calling VisioForge.Core.MediaBlocks.Special.SuperMediaBlock.Configure(VisioForge.Core.MediaBlocks.MediaBlocksPipeline).
Constructors
SuperMediaBlock(bool)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Special.SuperMediaBlock class.
public SuperMediaBlock(bool autoConnectBlocks = true)Parameters
autoConnectBlocksbool-
trueto automatically connect blocks in sequence during configuration;falseif blocks will be manually connected. Default istrue.
Remarks
When autoConnectBlocks is true:
- Blocks are connected in the order they appear in the VisioForge.Core.MediaBlocks.Special.SuperMediaBlock.Blocks collection
- Each block's primary output is connected to the next block's primary input
- Suitable for simple linear processing chains
When autoConnectBlocks is false:
- You must manually connect blocks using the pipeline's Connect method
- Allows for complex routing patterns (branching, merging, etc.)
- Connections must be established after calling VisioForge.Core.MediaBlocks.Special.SuperMediaBlock.Configure(VisioForge.Core.MediaBlocks.MediaBlocksPipeline)
Properties
Blocks
Gets the collection of media blocks contained within this super block.
public List<MediaBlock> Blocks { get; }Property Value
Remarks
Add blocks to this collection in the order they should be connected (when using auto-connect mode). The first block's inputs become the super block's inputs, and the last block's outputs become the super block's outputs.
Blocks should be added before calling VisioForge.Core.MediaBlocks.Special.SuperMediaBlock.Configure(VisioForge.Core.MediaBlocks.MediaBlocksPipeline). Adding blocks after configuration may lead to undefined behavior.
Input
Gets the input.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets the inputs.
public override MediaBlockPad[] Inputs { 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
Type
Gets the type.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds the super block, marking it as ready for use.
public override bool Build()Returns
- bool
-
Always returns
trueas super blocks have no build operations.
Remarks
Unlike regular media blocks, super blocks don't create GStreamer elements. This method simply sets the build flag. The actual building of contained blocks is handled by the pipeline when they are connected.
The method is idempotent - multiple calls have no effect after the first.
CleanUp()
Performs cleanup of all contained blocks and resources.
public void CleanUp()Remarks
This method disposes of all blocks in the VisioForge.Core.MediaBlocks.Special.SuperMediaBlock.Blocks collection and clears the collection. Disposal happens in the order blocks were added, which may be important for blocks with interdependencies.
After cleanup, the super block cannot be used again. A new instance must be created if the same functionality is needed.
This method is called automatically during disposal and should not be called directly by user code.
Configure(MediaBlocksPipeline)
Configures the super block by setting up the pipeline context and optionally connecting internal blocks.
public void Configure(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The media pipeline that will contain this super block.
Remarks
This method must be called before using the super block in a pipeline. It performs the following operations:
- Sets the pipeline context for the super block
- If auto-connect is enabled, connects blocks in sequence
- Prepares the super block for building
When auto-connect is enabled, blocks are connected using their primary Output and Input pads. For complex routing, disable auto-connect and manually establish connections after calling this method.
Important: Add all blocks to the VisioForge.Core.MediaBlocks.Special.SuperMediaBlock.Blocks collection before calling this method.
Exceptions
- ArgumentNullException
-
Thrown when
pipelineisnull.
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.
GetCore()
Gets the core wrapper element.
public BaseElement GetCore()Returns
- BaseElement
-
Always returns
nullas super blocks don't have a single core element.
Remarks
Super blocks are containers for other blocks and don't have their own GStreamer element. To access specific elements, query the contained blocks.
GetElement()
Gets the underlying GStreamer element.
public Element GetElement()Returns
- Element
-
Always returns
nullas super blocks don't have a single GStreamer element.
Remarks
Super blocks are logical containers only. To access GStreamer elements, query the individual blocks within the VisioForge.Core.MediaBlocks.Special.SuperMediaBlock.Blocks collection.
IsAvailable()
Determines whether the super block functionality is available.
public static bool IsAvailable()Returns
- bool
-
Always returns
trueas super blocks have no specific dependencies.
Remarks
Super blocks are a framework-level feature and don't depend on specific GStreamer plugins or external components. However, the availability of the contained blocks should be checked separately.
When using super blocks, ensure all contained blocks are available by
calling their respective IsAvailable methods.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The pipeline.