Class MediaBlock
- Namespace
- VisioForge.Core.MediaBlocks
- Assembly
- VisioForge.Core.dll
Base implementation of a media processing block in the VisioForge MediaBlocks pipeline system. This abstract base class provides core functionality for all media blocks including pipeline management, context handling, and basic lifecycle operations. Media blocks are the fundamental building blocks that can be connected together to create complex media processing pipelines. Implements the VisioForge.Core.MediaBlocks.IMediaBlock interface.
public class MediaBlock : IMediaBlock, IDisposableInheritance
Derived
Implements
Inherited Members
Extension Methods
Fields
Context
Gets or sets the GStreamer context that provides access to the underlying pipeline and bus components. This context is essential for low-level GStreamer operations and pipeline management.
public ContextX ContextField Value
- ContextX
_isBuilt
Flag indicating whether this media block has been successfully built and is ready for use in the pipeline.
protected bool _isBuiltField Value
_pipelineCtx
The pipeline context containing shared resources, settings, and state information for the entire pipeline.
protected BlockPipelineContext _pipelineCtxField Value
Properties
HasInputs
Gets a value indicating whether this media block has any input pads.
public virtual bool HasInputs { get; }Property Value
HasOutputs
Gets a value indicating whether this media block has any output pads.
public virtual bool HasOutputs { get; }Property Value
ID
Gets or sets the unique identifier for this media block instance. This ID is automatically generated when the block is created and should not be modified.
public Guid ID { get; set; }Property Value
Input
Gets the primary input pad for this media block.
public virtual MediaBlockPad Input { get; }Property Value
Inputs
Gets the collection of input pads for this media block.
public virtual MediaBlockPad[] Inputs { get; }Property Value
IsBuilt
Gets a value indicating whether this block is built.
public bool IsBuilt { get; }Property Value
Name
Gets or sets the unique name identifier for this media block within the pipeline. This name is used to reference the block when building connections and for debugging purposes.
public string Name { get; set; }Property Value
Output
Gets the primary output pad for this media block.
public virtual MediaBlockPad Output { get; }Property Value
Outputs
Gets the collection of output pads for this media block.
public virtual MediaBlockPad[] Outputs { get; }Property Value
Owner
Gets or sets the parent SuperMediaBlock that contains this block as a child. SuperMediaBlocks can contain multiple child blocks to create complex composite functionality.
public SuperMediaBlock Owner { get; set; }Property Value
Type
Gets or sets the functional type of this media block (source, sink, effect, encoder, etc.). This property must be overridden in derived classes to specify the block's role in the pipeline.
public virtual MediaBlockType Type { get; set; }Property Value
Exceptions
- NotImplementedException
-
Thrown when the derived class has not implemented this property.
- NotImplementedException
-
Thrown when the derived class has not implemented the setter.
_pipeline
Gets the pipeline that owns this block, or null if the pipeline has been collected. Protected property for derived classes to safely access the pipeline.
protected MediaBlocksPipeline _pipeline { get; }Property Value
Methods
AddElementsToPipeline()
Adds the GStreamer elements owned by this block to the pipeline. Override this method in derived classes that manage GStreamer elements. This method is called automatically when the block is added to a pipeline.
public virtual void AddElementsToPipeline()Build()
Builds and initializes this media block, creating any necessary GStreamer elements and configuring them. This method must be overridden in derived classes to implement block-specific initialization logic.
public virtual bool Build()Returns
- bool
-
trueif the block was successfully built; otherwise,false.
ClearPads()
Clears all input and output pad references for this media block. This method is typically called during cleanup or disposal to ensure proper resource release.
public void ClearPads()CreateElements()
Creates the internal GStreamer elements used by this media block. Override this method in derived classes that need to create GStreamer elements. This method is typically called from the Build() method.
public virtual bool CreateElements()Returns
- bool
-
trueif elements were successfully created; otherwise,false.
DeepCopy(string)
Creates and returns a deep copy of this media block with a new unique name. The clone will have the same configuration but will be a separate instance. Override this method in derived classes to implement block-specific cloning logic.
public virtual IMediaBlock DeepCopy(string newName = null)Parameters
newNamestring-
The name to assign to the cloned block. If null or empty, a name will be auto-generated.
Returns
- IMediaBlock
-
A new instance of the media block with the same configuration as the original.
Exceptions
- NotImplementedException
-
Thrown when the derived class has not implemented cloning.
Dispose(bool)
Releases unmanaged and - optionally - managed resources. Override this method in derived classes to implement block-specific cleanup logic.
protected virtual void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()~MediaBlock()
Finalizes an instance of the VisioForge.Core.MediaBlocks.MediaBlock class.
protected ~MediaBlock()GetPipelineContext()
Gets the pipeline context that contains shared resources and configuration for the entire MediaBlocks pipeline. This context provides access to GStreamer objects, logging, licensing information, and other pipeline-wide resources.
public BlockPipelineContext GetPipelineContext()Returns
- BlockPipelineContext
-
The BlockPipelineContext instance associated with this block's pipeline.
RemoveElementsFromPipeline()
Removes the GStreamer elements owned by this block from the pipeline. Override this method in derived classes that manage GStreamer elements. This method is called automatically when the block is removed from a pipeline.
public virtual void RemoveElementsFromPipeline()Reset()
Resets this media block to its initial state, clearing any accumulated data or state. Override this method in derived classes that maintain internal state that needs to be reset.
public virtual void Reset()SetPipeline(MediaBlocksPipeline)
Associates this media block with a specific MediaBlocks pipeline and initializes the pipeline context. This method is typically called automatically when the block is added to a pipeline.
public void SetPipeline(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The MediaBlocksPipeline instance that will own this block.
SetPipelineContext(BlockPipelineContext)
Sets the pipeline context that contains shared resources and configuration for the entire MediaBlocks pipeline. This context provides access to GStreamer objects, logging, licensing information, and other pipeline-wide resources.
public void SetPipelineContext(BlockPipelineContext context)Parameters
contextBlockPipelineContext-
The BlockPipelineContext instance to associate with this block.
ToYAMLBlock()
Converts this media block to a YAML block representation.
public virtual YAMLBlock ToYAMLBlock()Returns
- YAMLBlock
-
A YAMLBlock containing the YAML representation of this block.