Table of Contents

Class NDISourceXBlock

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

NDI (Network Device Interface) source block that receives through the NDI SDK directly.

public class NDISourceXBlock : SourceMediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockInternals2, IMediaBlockAsyncPrepare

Inheritance

Implements

Inherited Members

Extension Methods

Remarks

Windows only. VisioForge.Core.MediaBlocks.Sources.NDISourceBlock drives the GStreamer ndisrc element and is the cross-platform path; this block runs the NDI SDK receiver itself and feeds the frames into an internal live VisioForge.Core.MediaBlocks.Sources.CustomMixerSourceBlock.

Teardown contract. Pushes are gated by a flag that VisioForge.Core.MediaBlocks.Sources.NDISourceXBlock.Stop and VisioForge.Core.MediaBlocks.Sources.NDISourceXBlock.CleanUp clear, followed by a handshake on the push barrier - after that handshake no push can be in flight, so the mixer is safe to dispose even if the NDI capture thread refuses to exit. The receiver is disconnected before the mixer goes away. A live NDI capture thread at process exit is what left the host alive after Stop-Process -Force, wedged in libndi's DllMain(DLL_PROCESS_DETACH) under the loader lock (issue #1490), so nothing here may return while that thread is still running by choice.

BlockOnPush stays false on the mixer. Flipping it to true would let a push block on downstream while holding the push barrier, and the disconnect below would then wait on a thread that is waiting on us.

The audio output exists only when the sender has audio, and a caller that wants video alone simply leaves it unconnected - hence IParksUnconnectedOutputs. Without it the audio appsrc pushes into an unlinked queue and the pipeline dies with "Internal data stream error" before it reaches PLAYING.

Constructors

NDISourceXBlock(NDISourceSettings)

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

public NDISourceXBlock(NDISourceSettings settings)

Parameters

settings NDISourceSettings

The NDI source settings.

Properties

AudioOutput

Gets the audio output pad. It carries data only when the sender advertises an audio stream.

public MediaBlockPad AudioOutput { get; }

Property Value

MediaBlockPad

Input

Gets the input pad. Always null, this is a source.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets the input pads. Always empty, this is a source.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the default output pad, which is the video one.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets the output pads: video always, audio only when the sender has an audio stream.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets or sets the source settings.

public NDISourceSettings Settings { get; set; }

Property Value

NDISourceSettings

Type

Gets the media block type.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

VideoOutput

Gets the video output pad.

public MediaBlockPad VideoOutput { get; }

Property Value

MediaBlockPad

Methods

Build()

Builds the block: connects the receiver, learns the real caps from the first frame, and wires the mixer that carries them into the pipeline.

public override bool Build()

Returns

bool

true if the block was built.

CleanUp()

Tears the block down: stop pushing, drain, disconnect the receiver, then dispose the mixer. The order is the contract described in the class remarks and must not be rearranged.

public void CleanUp()

Dispose(bool)

Releases the block's resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true when called from Dispose.

GetCore()

Gets the core element. Not applicable to this block.

public BaseElement GetCore()

Returns

BaseElement

Always null.

GetElement()

Gets the underlying GStreamer element. This block is composite - it owns a receiver and a mixer, not one element - so this is always null, exactly as VisioForge.Core.MediaBlocks.Sources.CustomMixerSourceBlock reports for itself.

public Element GetElement()

Returns

Element

Always null.

IsAvailable()

Checks whether the NDI runtime this block needs is installed.

public static bool IsAvailable()

Returns

bool

true if the NDI runtime is available.

PostConnect()

Opens the gate the frame handlers push through. Called after every pad is connected and before the state change, so the mixer's queue absorbs whatever arrives before PLAYING.

public bool PostConnect()

Returns

bool

Always true.

Stop()

Stops pushing and sends EOS. The receiver stays connected so a later start does not have to probe the sender again.

public override bool Stop()

Returns

bool

The base result.

IMediaBlockAsyncPrepare.PrepareAsync(ContextX, CancellationToken)

Reads the source media information before the pipeline is built, off the build thread.

Task<bool> IMediaBlockAsyncPrepare.PrepareAsync(ContextX context, CancellationToken cancellationToken)

Parameters

context ContextX

The context.

cancellationToken CancellationToken

Cancels the probe.

Returns

Task<bool>

true when the media information is available.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the pipeline context.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The pipeline.

See Also