Table of Contents

Class DecklinkDeviceInfo

Namespace
VisioForge.Core.Types.Decklink
Assembly
VisioForge.Core.dll

Provides comprehensive information about a Decklink capture device and manages device enumeration.

public class DecklinkDeviceInfo : IDisposable

Inheritance

Implements

Inherited Members

Remarks

This class encapsulates all the information and functionality needed to work with a Decklink capture device, including video format enumeration, audio capabilities detection, and device configuration. It implements VisioForge.Libs.Decklink.SDK.IDeckLinkInputCallback to receive notifications about format changes and input events during enumeration.

Constructors

Initializes a new instance of the VisioForge.Core.Types.Decklink.DecklinkDeviceInfo class.

public DecklinkDeviceInfo(string name, DecklinkDeviceMode deviceMode, IDeckLink decklink)

Parameters

name string

The display name of the Decklink device.

deviceMode DecklinkDeviceMode

The operating mode (WDM or VisioForge wrapper).

decklink IDeckLink

The native Decklink COM interface.

Remarks

Creates a new device information object and queries the device for its capabilities, including whether it supports automatic format detection. The device is not fully enumerated at this point - call VisioForge.Core.Types.Decklink.DecklinkDeviceInfo.GetVideoFormatsAsync to enumerate formats.

Properties

Gets the list of supported audio formats for the device.

public List<string> AudioFormats { get; }

Property Value

List<string>

Remarks

Contains a list of audio format descriptions if the device supports audio capture. The list will be empty if the device doesn't support audio or if audio formats haven't been enumerated yet.

Gets a value indicating whether the device has audio capture capabilities.

public bool AudioOutput { get; }

Property Value

bool

Remarks

When true, the device can capture audio along with video. This is detected during format enumeration by checking if audio packets are received from the device. Most professional Decklink cards support embedded audio capture.

SDK logging context. Set by the consuming SDK code (e.g. MediaDevices) so internal failures route through the SDK's Serilog sink. When null, falls back to Trace.

public BaseContext Context { get; set; }

Property Value

BaseContext

Gets the Decklink input interface for configuring and controlling capture operations.

public IDeckLinkInput DecklinkInputIntf { get; }

Property Value

IDeckLinkInput

Remarks

This interface (IDeckLinkInput) is used to manage video and audio input from the Decklink device. It provides methods for:

  • Enabling and disabling video/audio input streams
  • Starting and stopping capture
  • Setting callback delegates for input events
  • Querying input capabilities and status

Gets the underlying Decklink COM interface used for low-level device communication.

public IDeckLink DecklinkIntf { get; }

Property Value

IDeckLink

Remarks

This property provides direct access to the native Decklink SDK interface (IDeckLink). It allows for advanced configuration and control that may not be exposed through the high-level API. Use with caution as improper use of the raw interface can affect device stability or interfere with other operations.

Gets the operating mode of the Decklink device.

public DecklinkDeviceMode DeviceMode { get; }

Property Value

DecklinkDeviceMode

Remarks

Indicates whether the device is accessed through the WDM driver (for DirectShow compatibility) or through the VisioForge wrapper using the native Decklink SDK. The mode affects available features and performance characteristics.

Gets a value indicating whether the device information has been successfully initialized.

public bool Initiated { get; }

Property Value

bool

Remarks

This property indicates whether the device has been properly initialized and is ready for use. Check this property before attempting to access device capabilities or perform operations.

Gets or sets the display name of the Decklink device.

public string Name { get; set; }

Property Value

string

Remarks

This is the human-readable name of the device, such as "DeckLink Mini Recorder 4K" or "DeckLink Studio 4K". This name is retrieved from the device driver.

Gets a value indicating whether the device supports automatic input format detection.

public bool SupportsFormatDetection { get; }

Property Value

bool

Remarks

When format detection is supported, the device can automatically detect and adapt to changes in the input video format (resolution, frame rate, etc.) without manual configuration. This is particularly useful in live production environments where input sources may change unpredictably.

Methods

Releases unmanaged and - optionally - managed resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

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

Remarks

Properly releases COM interfaces to prevent resource leaks. This is critical for Decklink devices as they have limited resources and improper cleanup can prevent the device from being used by other applications.

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Remarks

Call this method when you're finished using the device information object to ensure all COM interfaces are properly released and the device is available for other applications.

Populates the device information with pre-enumerated data.

public void Fill(DecklinkDeviceMode deviceMode, bool audioOutput, List<DecklinkVideoFormat> videoFormats, List<string> audioFormats)

Parameters

deviceMode DecklinkDeviceMode

The operating mode of the device (WDM or VisioForge wrapper).

audioOutput bool

Indicates whether audio capture is available on this device.

videoFormats List<DecklinkVideoFormat>

List of supported video formats including resolution, frame rate, and pixel format.

audioFormats List<string>

List of supported audio format descriptions.

Remarks

This method is used to manually inject device capabilities when they have been retrieved from an external source or a previous session. This avoids the overhead of querying the hardware again, which can be time-consuming and may interrupt valid signals. It effectively sets the device state to "enumerated" without performing the actual enumeration.

Finalizes an instance of the VisioForge.Core.Types.Decklink.DecklinkDeviceInfo class.

protected ~DecklinkDeviceInfo()

Remarks

Ensures COM interfaces are released even if Dispose() is not called explicitly. However, it's strongly recommended to call Dispose() explicitly or use a using statement.

Asynchronously enumerates all supported video formats for the device.

public Task<List<DecklinkVideoFormat>> GetVideoFormatsAsync()

Returns

Task<List<DecklinkVideoFormat>>

A task that returns a list of supported video formats.

Remarks

This method performs format enumeration by briefly starting capture with format detection enabled. The device will report all detected formats through callbacks. This process may take up to 1 second to complete. The enumeration is non-blocking and runs on a background thread.

Asynchronously enumerates all supported video formats for the device, with cancellation support.

public Task<List<DecklinkVideoFormat>> GetVideoFormatsAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Token to abort the enumeration; the underlying 1-second wait will return early if cancellation is requested.

Returns

Task<List<DecklinkVideoFormat>>

A task that returns a list of supported video formats.

Remarks

New cancellation-aware overload. The blocking 1-second wait inside VisioForge.Core.Types.Decklink.DecklinkDeviceInfo.GetVideoFormats previously gave callers no way to abort enumeration if the parent operation was cancelled (e.g. user switched away from the device list dialog). The wait now polls the token and exits early on cancellation, returning whatever formats were detected before cancellation. The Decklink SDK's StartStreams / StopStreams are themselves synchronous and can't be cancelled, so the Task.Run offload is preserved to keep the calling thread free; the finally block in GetVideoFormats still tears down streams cleanly.

Callback method invoked when the input video format changes during format detection.

public void VideoInputFormatChanged(_BMDVideoInputFormatChangedEvents notificationEvents, IDeckLinkDisplayMode newMode, _BMDDetectedVideoInputFormatFlags detectedSignalFlags)

Parameters

notificationEvents _BMDVideoInputFormatChangedEvents

Flags indicating what aspects of the format have changed.

newMode IDeckLinkDisplayMode

The newly detected display mode containing format information.

detectedSignalFlags _BMDDetectedVideoInputFormatFlags

Flags indicating the detected signal characteristics (color space, etc.).

Remarks

This callback is part of the IDeckLinkInputCallback interface and is called by the Decklink SDK when it detects a video format during enumeration. The method extracts format details and adds them to the internal format list.

Callback method invoked when a video frame and/or audio packet arrives from the input.

public void VideoInputFrameArrived(IDeckLinkVideoInputFrame videoFrame, IDeckLinkAudioInputPacket audioPacket)

Parameters

videoFrame IDeckLinkVideoInputFrame

The captured video frame (may be null if only audio is captured).

audioPacket IDeckLinkAudioInputPacket

The captured audio packet (may be null if only video is captured).

Remarks

This callback is used during format enumeration to detect whether the device supports audio capture. If an audio packet is received, the device is marked as having audio capabilities. The actual frame/packet data is not processed during enumeration.