Table of Contents

Class LiveSourceSwitchBlock

Namespace
VisioForge.Core.LiveSourceSwitch
Assembly
VisioForge.Core.dll

Live Source Switch. Allows to switch between multiple video and audio sources. Implements the IDisposable. Implements the IAsyncDisposable.

public class LiveSourceSwitchBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

LiveSourceSwitchBlock(MediaBlocksPipeline, LiveSourceSwitchSettings)

Initializes a new instance of the VisioForge.Core.LiveSourceSwitch.LiveSourceSwitchBlock class.

public LiveSourceSwitchBlock(MediaBlocksPipeline pipeline, LiveSourceSwitchSettings settings)

Parameters

pipeline MediaBlocksPipeline

The parent MediaBlocks pipeline that will host this switch block.

settings LiveSourceSwitchSettings

The configuration settings including video/audio parameters and input limits.

Remarks

This constructor sets up the internal switch infrastructure including bridge sources, video/audio switches, and multi-queue synchronization based on the provided settings.

Properties

AudioOutput

Gets the audio output pad providing access to the currently selected audio stream.

public MediaBlockPad AudioOutput { get; }

Property Value

MediaBlockPad

Input

Gets the primary input pad for this block.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets the collection of input pads for this block.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the primary output pad (video output).

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets all output pads for this block.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets the configuration settings for the live source switch.

public LiveSourceSwitchSettings Settings { get; }

Property Value

LiveSourceSwitchSettings

Type

Gets the type of this media block.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

VideoOutput

Gets the video output pad providing access to the currently selected video stream.

public MediaBlockPad VideoOutput { get; }

Property Value

MediaBlockPad

Methods

Build()

Builds the internal pipeline structure by connecting bridge sources to switch inputs.

public override bool Build()

Returns

bool

true if the build was successful or was already built; false otherwise.

Remarks

This method connects all video and audio bridge sources to their respective switch inputs. It is called automatically by VisioForge.Core.LiveSourceSwitch.LiveSourceSwitchBlock.StartAsync and only executes once.

CleanUp()

Performs cleanup operations and resets the built state.

public void CleanUp()

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

DurationAsync()

Gets the current playback duration/position of the switch block.

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 GStreamer base element.

public BaseElement GetCore()

Returns

BaseElement

Always returns null as this is a composite block without a single core element.

GetElement()

Gets the underlying GStreamer element.

public Element GetElement()

Returns

Element

Always returns null as this is a composite block without a single underlying 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_AddAsync(LVCVideoInput)

Adds a video-only input source to the switch.

public Task<bool> Input_AddAsync(LVCVideoInput input)

Parameters

input LVCVideoInput

The video input configuration including source block and positioning information.

Returns

Task<bool>

A Task<TResult> that completes with true if the input was added successfully; otherwise, false.

Remarks

The input is assigned a unique bridge name and automatically started if the main pipeline is already running. Returns false if the maximum video input count has been reached.

Input_AddAsync(LVCAudioInput)

Adds an audio-only input source to the switch.

public Task<bool> Input_AddAsync(LVCAudioInput input)

Parameters

input LVCAudioInput

The audio input configuration including source block and audio format information.

Returns

Task<bool>

A Task<TResult> that completes with true if the input was added successfully; otherwise, false.

Remarks

The audio format is automatically configured to match the switch settings. The input is started automatically if AutoStart is true and the main pipeline is running.

Input_AddAsync(LVCVideoAudioInput, bool)

Adds a combined video and audio input source to the switch.

public Task<bool> Input_AddAsync(LVCVideoAudioInput input, bool start = false)

Parameters

input LVCVideoAudioInput

The video/audio input configuration including source block and media information.

start bool

If true, starts the input immediately after adding; otherwise, waits for AutoStart or manual start.

Returns

Task<bool>

A Task<TResult> that completes with true if the input was added successfully; otherwise, false.

Input_AddAsync(LVCFileVideoAudioInput, bool)

Adds a file-based video and audio input source to the switch.

public Task<bool> Input_AddAsync(LVCFileVideoAudioInput input, bool start = false)

Parameters

input LVCFileVideoAudioInput

The file video/audio input configuration including source block and media information.

start bool

If true, starts the input immediately after adding; otherwise, waits for AutoStart or manual start.

Returns

Task<bool>

A Task<TResult> that completes with true if the input was added successfully; otherwise, false.

Remarks

This method uses buffered bridge sources for file inputs to ensure smooth playback.

Input_FileVideoAudio_Get(int)

Gets a file-based video/audio input by its index position.

public LVCFileVideoAudioInput Input_FileVideoAudio_Get(int index)

Parameters

index int

The zero-based index of the input to retrieve.

Returns

LVCFileVideoAudioInput

The VisioForge.Core.LiveVideoCompositor.LVCFileVideoAudioInput at the specified index, or null if the index is invalid or the input is not a file video/audio type.

Input_Get(int)

Gets any input by its index position.

public LVCInput Input_Get(int index)

Parameters

index int

The zero-based index of the input to retrieve.

Returns

LVCInput

The VisioForge.Core.LiveVideoCompositor.LVCInput at the specified index, or null if the index is out of range.

Input_RemoveAtAsync(int)

Removes an input at the specified index position.

public Task<bool> Input_RemoveAtAsync(int index)

Parameters

index int

The zero-based index of the input to remove.

Returns

Task<bool>

A Task<TResult> that completes with true if the input was removed successfully; otherwise, false.

Remarks

The input pipeline is stopped and disposed before removal. Returns false if the index is out of range.

Input_VideoAudio_Get(int)

Gets a video/audio input by its index position.

public LVCVideoAudioInput Input_VideoAudio_Get(int index)

Parameters

index int

The zero-based index of the input to retrieve.

Returns

LVCVideoAudioInput

The VisioForge.Core.LiveVideoCompositor.LVCVideoAudioInput at the specified index, or null if the index is invalid or the input is not a video/audio type.

StartAsync()

Starts the switch block and all configured input sources asynchronously.

public Task<bool> StartAsync()

Returns

Task<bool>

A Task<TResult> that completes with true if startup was successful; otherwise, false.

Remarks

This method builds the pipeline if not already built, preloads all inputs, 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

Task

A Task representing the asynchronous stop operation.

Remarks

This method stops all input pipelines first, then stops the main pipeline. Any errors during stopping are logged but do not prevent other inputs from being stopped.

Switch(int)

Switches both video and audio inputs to the specified source index.

public void Switch(int index)

Parameters

index int

The zero-based index of the input source to switch to.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the execution context for this block from the specified pipeline.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The pipeline to retrieve context from.

See Also