Class LiveSourceSwitchBlockDynamic
- Namespace
- VisioForge.Core.LiveSourceSwitch
- Assembly
- VisioForge.Core.dll
Dynamic Live Source Switch block with proper support for runtime input add/remove. Unlike LiveSourceSwitchBlock, this version uses slot-based management where each slot has a fixed bridge name. When an input is removed, the slot becomes empty but the bridge remains ready for a new input.
public class LiveSourceSwitchBlockDynamic : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Implements
Inherited Members
Extension Methods
Constructors
LiveSourceSwitchBlockDynamic(MediaBlocksPipeline, LiveSourceSwitchSettings)
Initializes a new instance of the VisioForge.Core.LiveSourceSwitch.LiveSourceSwitchBlockDynamic class.
public LiveSourceSwitchBlockDynamic(MediaBlocksPipeline pipeline, LiveSourceSwitchSettings settings)Parameters
pipelineMediaBlocksPipeline-
The parent MediaBlocks pipeline that will host this switch block.
settingsLiveSourceSwitchSettings-
The configuration settings including video/audio parameters and input limits.
Remarks
This constructor creates fixed bridge sources for each slot with predetermined names. When inputs are removed and re-added, they reuse the same bridge names to avoid conflicts.
Properties
AudioOutput
Gets the audio output pad.
public MediaBlockPad AudioOutput { get; }Property Value
CurrentAudioIndex
Gets the currently active audio slot index.
public int CurrentAudioIndex { get; }Property Value
CurrentVideoIndex
Gets the currently active video slot index.
public int CurrentVideoIndex { get; }Property Value
Input
Gets the input (not used - inputs are managed via slots).
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets the inputs array (empty - inputs are managed via slots).
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the primary output (video).
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets all outputs.
public override MediaBlockPad[] Outputs { get; }Property Value
Settings
Gets the settings.
public LiveSourceSwitchSettings Settings { get; }Property Value
Type
Gets the block type.
public override MediaBlockType Type { get; }Property Value
VideoOutput
Gets the video output pad.
public MediaBlockPad VideoOutput { get; }Property Value
Methods
Build()
Builds the internal pipeline structure by connecting bridge sources to switch inputs.
public override bool Build()Returns
- bool
-
trueif the build was successful or was already built;falseotherwise.
Remarks
This method connects all video and audio bridge sources to their respective switch inputs. Bridge sources remain connected even when slots are empty, outputting silence/black until an input is added.
CleanUp()
Cleans up resources.
public void CleanUp()Dispose(bool)
Disposes resources.
protected override void Dispose(bool disposing)Parameters
disposingbool
DurationAsync()
Gets the current playback duration/position of the main pipeline.
public Task<TimeSpan> DurationAsync()Returns
- Task<TimeSpan>
-
A Task<TResult> representing the current playback position.
GetContext()
Gets the execution context for this switch block.
public ContextX GetContext()Returns
- ContextX
-
The VisioForge.Core.GStreamer.ContextX instance used for logging and error handling.
GetCore()
Gets the core element (not applicable for composite blocks).
public BaseElement GetCore()Returns
- BaseElement
GetElement()
Gets the element (not applicable for composite blocks).
public Element GetElement()Returns
- Element
GetPipeline()
Gets the parent pipeline that hosts this switch block.
public MediaBlocksPipeline GetPipeline()Returns
- MediaBlocksPipeline
-
The VisioForge.Core.MediaBlocks.MediaBlocksPipeline instance managing this block.
Input_AddToSlotAsync(LVCVideoInput, int)
Adds a video-only input to a specific slot.
public Task<bool> Input_AddToSlotAsync(LVCVideoInput input, int slotIndex)Parameters
inputLVCVideoInput-
The video input configuration to add.
slotIndexint-
The zero-based slot index (0 to MaxVideoInputsCount-1).
Returns
- Task<bool>
-
A Task<TResult> that completes with
trueif the input was added successfully; otherwise,false.
Remarks
Each slot has a fixed bridge name. When an input is added to a slot, it connects to that bridge. The slot must be empty before adding a new input - use VisioForge.Core.LiveSourceSwitch.LiveSourceSwitchBlockDynamic.Input_RemoveFromSlotAsync(System.Int32) first if needed.
Input_AddToSlotAsync(LVCVideoAudioInput, int)
Adds a combined video and audio input to a specific slot.
public Task<bool> Input_AddToSlotAsync(LVCVideoAudioInput input, int slotIndex)Parameters
inputLVCVideoAudioInput-
The video/audio input configuration to add.
slotIndexint-
The zero-based slot index.
Returns
- Task<bool>
-
A Task<TResult> that completes with
trueif the input was added successfully; otherwise,false.
Remarks
Both video and audio streams are connected to their respective bridges for the same slot index. The slot must be empty before adding a new input.
Input_GetFromSlot(int)
Gets the input at a specific slot.
public LVCInput Input_GetFromSlot(int slotIndex)Parameters
slotIndexint-
The zero-based slot index.
Returns
- LVCInput
-
The VisioForge.Core.LiveVideoCompositor.LVCInput at the specified slot, or
nullif the slot is empty or the index is invalid.
Input_RemoveFromSlotAsync(int)
Removes an input from a specific slot.
public Task<bool> Input_RemoveFromSlotAsync(int slotIndex)Parameters
slotIndexint-
The zero-based slot index to clear.
Returns
- Task<bool>
-
A Task<TResult> that completes with
trueif the slot was cleared successfully; otherwise,false.
Remarks
The bridge source remains active after removal, outputting silence/black until a new input is added.
The new input must use the same bridge name for this slot, which is handled automatically by VisioForge.Core.LiveSourceSwitch.LiveSourceSwitchBlockDynamic.Input_AddToSlotAsync(VisioForge.Core.LiveVideoCompositor.LVCVideoInput,System.Int32).
Returns true if the slot is already empty.
StartAsync()
Starts the switch block and all configured input sources asynchronously.
public Task<bool> StartAsync()Returns
- Task<bool>
-
A Task<TResult> that completes with
trueif startup was successful; otherwise,false.
Remarks
This method builds the pipeline if not already built, preloads all inputs in occupied slots, then starts all input pipelines and the main pipeline in synchronized fashion.
StopAsync()
Stops the switch block and all active input sources asynchronously.
public Task StopAsync()Returns
Remarks
This method stops all input pipelines in occupied slots, then stops the main pipeline. Empty slots are skipped during the stop process.
Switch(int)
Switches both video and audio to the specified slot.
public void Switch(int slotIndex)Parameters
slotIndexint-
The zero-based slot index to switch to.
Remarks
This method synchronously switches both video and audio streams to the same slot. Use VisioForge.Core.LiveSourceSwitch.LiveSourceSwitchBlockDynamic.SwitchVideo(System.Int32) and VisioForge.Core.LiveSourceSwitch.LiveSourceSwitchBlockDynamic.SwitchAudio(System.Int32) for independent control.
SwitchAudio(int)
Switches only audio to the specified slot, keeping video on its current slot.
public void SwitchAudio(int slotIndex)Parameters
slotIndexint-
The zero-based slot index to switch audio to.
SwitchVideo(int)
Switches only video to the specified slot, keeping audio on its current slot.
public void SwitchVideo(int slotIndex)Parameters
slotIndexint-
The zero-based slot index to switch video to.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Associates this MediaBlock with a pipeline and initializes its internal context. This method is called automatically when the block is added to a pipeline, providing access to shared resources and pipeline-wide configuration.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The MediaBlocksPipeline instance that will manage this block.