Table of Contents

Class CustomMixerSourceBlock

Namespace
VisioForge.Core.MediaBlocks.Sources
Assembly
VisioForge.Core.dll

Custom mixer source block that accepts pushed video and audio frames via API. Has no input pads. Outputs fixed-caps video and audio streams. Input data must match the configured output caps exactly; mismatched data is rejected. Uses do-timestamp=true on both AppSrc elements so the pipeline clock generates live timestamps for A/V synchronization.

public class CustomMixerSourceBlock : SourceMediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

CustomMixerSourceBlock(CustomMixerSourceSettings)

Initializes a new instance of the VisioForge.Core.MediaBlocks.Sources.CustomMixerSourceBlock class.

public CustomMixerSourceBlock(CustomMixerSourceSettings settings)

Parameters

settings CustomMixerSourceSettings

The output caps configuration.

Properties

AudioDroppedTotal

Gets the total number of dropped audio buffers from managed queues.

public long AudioDroppedTotal { get; }

Property Value

long

AudioManagedQueueBytes

Gets the current queued audio bytes in the managed queue.

public long AudioManagedQueueBytes { get; }

Property Value

long

AudioManagedQueueCount

Gets the current number of queued audio buffers in the managed queue.

public int AudioManagedQueueCount { get; }

Property Value

int

AudioOutput

Gets the audio output pad.

public MediaBlockPad AudioOutput { get; }

Property Value

MediaBlockPad

Input

Gets the input pad (none - data is pushed via API).

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets the input pads (none).

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the primary output pad (video).

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets all output pads.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets the settings.

public CustomMixerSourceSettings Settings { get; }

Property Value

CustomMixerSourceSettings

Type

Gets the block type.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

VideoDroppedTotal

Gets the total number of dropped video buffers from managed queues.

public long VideoDroppedTotal { get; }

Property Value

long

VideoManagedQueueBytes

Gets the current queued video bytes in the managed queue.

public long VideoManagedQueueBytes { get; }

Property Value

long

VideoManagedQueueCount

Gets the current number of queued video buffers in the managed queue.

public int VideoManagedQueueCount { get; }

Property Value

int

VideoOutput

Gets the video output pad.

public MediaBlockPad VideoOutput { get; }

Property Value

MediaBlockPad

Methods

Build()

Builds the internal GStreamer pipeline: two AppSrc elements with queues.

public override bool Build()

Returns

bool

CleanUp()

Cleans up all GStreamer resources.

public void CleanUp()

Remarks

Tear-down order per element is the canonical GStreamer sequence:

  1. SetState(NULL) — stop dataflow gracefully so any in-flight push returns and the streaming task exits.
  2. pipeline.Remove(element) — detach from the parent bin so the bin no longer holds a ref. Without this, Dispose only drops the managed wrapper while the unmanaged GstElement stays alive (parented by the bin) and shows up as a leak when the pipeline itself is reused or disposed later. Wrapped in try/catch — Remove is a no-op + warning if the element is not actually parented (defensive against partial Build()s).
  3. Dispose() — release the managed wrapper and the final unmanaged ref.
QueueElement.Dispose handles SetState internally; we only need explicit Remove on the queue's underlying Element before disposing the wrapper.

Dispose(bool)

Releases resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

GetCore()

Gets the core BaseElement wrapper (not applicable).

public BaseElement GetCore()

Returns

BaseElement

GetDiagnosticsSummary()

Gets a multi-line diagnostics summary for the managed and internal GStreamer queues.

public string GetDiagnosticsSummary()

Returns

string

GetElement()

Gets the GStreamer element (not applicable for composite blocks).

public Element GetElement()

Returns

Element

IsAvailable()

Determines whether AppSrc is available on this system.

public static bool IsAvailable()

Returns

bool

PushAudioFrame(byte[], int)

Pushes raw audio data into the pipeline. The data must be in the configured audio format.

public bool PushAudioFrame(byte[] data, int dataSize)

Parameters

data byte[]

Raw audio sample bytes.

dataSize int

Number of valid bytes in the array.

Returns

bool

True if the audio data was pushed successfully.

PushAudioFrame(AudioFrame)

Pushes an audio frame into the pipeline. The frame data must be in the configured audio format.

public bool PushAudioFrame(AudioFrame frame)

Parameters

frame AudioFrame

The audio frame to push.

Returns

bool

True if the audio frame was pushed successfully.

PushAudioSample(Sample)

Pushes a GStreamer audio sample into the pipeline without copying raw PCM bytes into a fresh managed buffer. The sample caps must match the configured audio format, sample rate, and channel count.

public bool PushAudioSample(Sample sample)

Parameters

sample Sample

The audio sample to push.

Returns

bool

True if the sample was accepted.

PushVideoFrame(VideoFrameX)

Pushes a video frame into the pipeline. The frame must match the configured video format, width, and height exactly.

public bool PushVideoFrame(VideoFrameX frame)

Parameters

frame VideoFrameX

The video frame to push.

Returns

bool

True if the frame was pushed successfully.

PushVideoSample(Sample)

Pushes a GStreamer video sample into the pipeline without copying the frame pixels. The sample caps must match the configured output format, width, height, and frame rate.

public bool PushVideoSample(Sample sample)

Parameters

sample Sample

The video sample to push.

Returns

bool

True if the sample was accepted.

SendEOS()

Signals end of stream on both video and audio.

public void SendEOS()

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the pipeline context.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

QueueDropped

Occurs when managed queues drop buffers.

public event EventHandler<CustomMixerQueueDropEventArgs> QueueDropped

Event Type

EventHandler<CustomMixerQueueDropEventArgs>