Table of Contents

Class DeviceEnumerator

Namespace
VisioForge.Core
Assembly
VisioForge.Core.dll

Provides specialized enumeration for Allied Vision industrial cameras using the Vimba X SDK integration.

public class DeviceEnumerator : IDisposable

Inheritance

Implements

Inherited Members

Remarks

This class provides unified access to a wide variety of media devices:

  • Standard webcams and video capture devices
  • Microphones and audio capture sources
  • Audio output devices (speakers, headphones, etc.)
  • IP cameras via ONVIF protocol
  • NDI (Network Device Interface) sources for IP video streaming
  • Blackmagic Design DeckLink professional video hardware
  • Industrial cameras supporting GenICam/GigE Vision standards
  • Allied Vision, Basler, and FLIR/Teledyne machine vision cameras

The class supports both synchronous and asynchronous device discovery methods with platform-specific optimizations for Windows, macOS, Linux, iOS, and Android. Real-time device change notifications are provided through events when devices are added or removed from the system.

Use the VisioForge.Core.DeviceEnumerator.Shared singleton instance for most scenarios to avoid resource duplication and ensure consistent device state across your application.

Constructors

DeviceEnumerator(ContextX)

Initializes a new instance of the VisioForge.Core.DeviceEnumerator class with an optional GStreamer context. If no context is provided, a new default context will be created for device operations.

protected DeviceEnumerator(ContextX context = null)

Parameters

context ContextX

The GStreamer context to use for device operations, or null to create a default context.

Fields

_shared

The shared singleton DeviceEnumerator instance for application-wide device management.

protected static DeviceEnumerator _shared

Field Value

DeviceEnumerator

_videoSourcesLock

The video sources lock.

protected object _videoSourcesLock

Field Value

object

_videoSourcesX

Represents a list of video capture device information objects.

protected List<VideoCaptureDeviceInfo> _videoSourcesX

Field Value

List<VideoCaptureDeviceInfo>

Properties

Shared

Gets the shared singleton VisioForge.Core.DeviceEnumerator instance that provides application-wide device enumeration.

public static DeviceEnumerator Shared { get; }

Property Value

DeviceEnumerator

Remarks

This property provides a singleton instance that is automatically created on first access and disposed when the application exits via the ProcessExit event.

Using the shared instance is recommended for most scenarios to:

  • Avoid resource duplication from multiple enumerator instances
  • Maintain consistent device state across your application
  • Reduce memory overhead from redundant device monitoring

Methods

AlliedVisionSourcesAsync()

Asynchronously gets an array of available Allied Vision machine vision cameras.

public Task<AlliedVisionCameraInfo[]> AlliedVisionSourcesAsync()

Returns

Task<AlliedVisionCameraInfo[]>

A task that represents the asynchronous operation. The task result contains an array of VisioForge.Core.Types.X.Sources.AlliedVisionCameraInfo objects representing available Allied Vision cameras.

Remarks

This method discovers Allied Vision cameras using the Vimba X SDK, supporting GigE Vision, USB3 Vision, and Camera Link interfaces. The enumeration is performed on a background thread.

Requires the Allied Vision Vimba X SDK to be installed on the system.

AudioOutputsAsync(AudioOutputDeviceAPI?)

Asynchronously gets an array of available audio output devices (speakers, headphones, etc.).

public Task<AudioOutputDeviceInfo[]> AudioOutputsAsync(AudioOutputDeviceAPI? api = null)

Parameters

api AudioOutputDeviceAPI?

Optional filter to return only devices from a specific audio API. If null, returns devices from all available APIs.

Returns

Task<AudioOutputDeviceInfo[]>

A task that represents the asynchronous operation. The task result contains an array of VisioForge.Core.Types.X.Output.AudioOutputDeviceInfo objects representing available audio output devices.

Remarks

This method runs device enumeration on a background thread to avoid blocking the calling thread.

AudioSources(AudioCaptureDeviceAPI?)

Gets an array of available audio capture devices (microphones and audio inputs).

public AudioCaptureDeviceInfo[] AudioSources(AudioCaptureDeviceAPI? api = null)

Parameters

api AudioCaptureDeviceAPI?

Optional filter to return only devices from a specific audio API. If null, returns devices from all available APIs. On Linux, defaults to PulseAudio.

Returns

AudioCaptureDeviceInfo[]

An array of VisioForge.Core.Types.X.Sources.AudioCaptureDeviceInfo objects representing available audio input devices.

Remarks

This method automatically performs device enumeration on first call if the internal cache is empty. Subsequent calls return cached results unless VisioForge.Core.DeviceEnumerator.Clear is called.

Supported APIs vary by platform:

  • Windows: DirectSound, WASAPI
  • Linux: PulseAudio, ALSA, PipeWire
  • macOS: Core Audio
  • iOS/Android: Platform default (single device)

AudioSourcesAsync(AudioCaptureDeviceAPI?)

Asynchronously gets an array of available audio capture devices (microphones and audio inputs).

public Task<AudioCaptureDeviceInfo[]> AudioSourcesAsync(AudioCaptureDeviceAPI? api = null)

Parameters

api AudioCaptureDeviceAPI?

Optional filter to return only devices from a specific audio API. If null, returns devices from all available APIs.

Returns

Task<AudioCaptureDeviceInfo[]>

A task that represents the asynchronous operation. The task result contains an array of VisioForge.Core.Types.X.Sources.AudioCaptureDeviceInfo objects representing available audio input devices.

Remarks

On Apple platforms (macOS, iOS), this method automatically requests microphone access permission before performing enumeration. The method runs device enumeration on a background thread.

BaslerSourcesAsync()

Asynchronously gets an array of available Basler machine vision cameras.

public Task<BaslerCameraInfo[]> BaslerSourcesAsync()

Returns

Task<BaslerCameraInfo[]>

A task that represents the asynchronous operation. The task result contains an array of VisioForge.Core.Types.X.Sources.BaslerCameraInfo objects representing available Basler cameras.

Remarks

This method discovers Basler cameras using the Pylon SDK, supporting GigE Vision, USB3 Vision, and Camera Link interfaces. The enumeration provides detailed camera information including device IDs, model names, and connection details.

Requires the Basler Pylon SDK to be installed on the system. The method runs enumeration on a background thread to avoid blocking the calling thread.

Clear()

Clears all cached device lists, forcing a fresh enumeration on the next device query.

public void Clear()

Remarks

This method clears all internal device caches including:

  • Video capture sources
  • Audio capture sources
  • Audio output devices (sinks)
  • DeckLink video and audio sources/sinks
  • NDI sources
  • GenICam cameras

Call this method when you need to force a complete re-enumeration of all devices, for example, after system configuration changes or when troubleshooting device detection issues.

DecklinkAudioSinksAsync()

Asynchronously gets an array of available DeckLink audio output sinks.

public Task<DecklinkAudioSinkInfo[]> DecklinkAudioSinksAsync()

Returns

Task<DecklinkAudioSinkInfo[]>

A task that represents the asynchronous operation. The task result contains an array of VisioForge.Core.Types.X.Decklink.DecklinkAudioSinkInfo objects representing available DeckLink audio outputs.

Remarks

This method enumerates all DeckLink audio output connections including embedded audio channels. The enumeration is performed on a background thread.

DecklinkAudioSourcesAsync()

Asynchronously gets an array of available DeckLink audio capture sources.

public Task<DecklinkAudioSourceInfo[]> DecklinkAudioSourcesAsync()

Returns

Task<DecklinkAudioSourceInfo[]>

A task that represents the asynchronous operation. The task result contains an array of VisioForge.Core.Types.X.Decklink.DecklinkAudioSourceInfo objects representing available DeckLink audio inputs.

Remarks

This method enumerates all DeckLink audio capture inputs including embedded audio channels. The enumeration is performed on a background thread.

DecklinkVideoSinksAsync()

Asynchronously gets an array of available DeckLink video output sinks.

public Task<DecklinkVideoSinkInfo[]> DecklinkVideoSinksAsync()

Returns

Task<DecklinkVideoSinkInfo[]>

A task that represents the asynchronous operation. The task result contains an array of VisioForge.Core.Types.X.Decklink.DecklinkVideoSinkInfo objects representing available DeckLink video outputs.

Remarks

This method enumerates all DeckLink video output connections including SDI and HDMI outputs. The enumeration is performed on a background thread.

DecklinkVideoSourcesAsync()

Asynchronously gets an array of available DeckLink video capture sources.

public Task<DecklinkVideoSourceInfo[]> DecklinkVideoSourcesAsync()

Returns

Task<DecklinkVideoSourceInfo[]>

A task that represents the asynchronous operation. The task result contains an array of VisioForge.Core.Types.X.Decklink.DecklinkVideoSourceInfo objects representing available DeckLink video inputs.

Remarks

This method enumerates all DeckLink video capture inputs including SDI, HDMI, and component connections. The enumeration is performed on a background thread.

Dispose()

Releases all resources used by the VisioForge.Core.DeviceEnumerator instance.

public void Dispose()

Remarks

This method stops all active device monitors, releases GStreamer resources, and unregisters any platform-specific device notification handlers. On Windows, this also stops the WMI event watcher used for USB device change notifications.

After calling this method, the device enumerator cannot be reused. If using the VisioForge.Core.DeviceEnumerator.Shared instance, a new instance will be created automatically on the next access.

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

~DeviceEnumerator()

protected ~DeviceEnumerator()

GenICamSourcesAsync()

Asynchronously gets an array of available GenICam-compliant cameras.

public Task<GenICamCamera[]> GenICamSourcesAsync()

Returns

Task<GenICamCamera[]>

A task that represents the asynchronous operation. The task result contains an array of VisioForge.Core.GenICam.GenICamCamera objects representing available GenICam cameras.

Remarks

This method discovers industrial and scientific cameras that comply with the GenICam standard, including GigE Vision and USB3 Vision devices. The enumeration provides detailed camera information including device IDs, model names, and available pixel formats.

The method includes fallback mechanisms to ensure robust camera discovery even when detailed enumeration fails.

NDISourcesAsync()

Asynchronously gets an array of available NDI video/audio sources on the network.

public Task<NDISourceInfo[]> NDISourcesAsync()

Returns

Task<NDISourceInfo[]>

A task that represents the asynchronous operation. The task result contains an array of VisioForge.Core.Types.X.Sources.NDISourceInfo objects representing available NDI sources.

Remarks

This method discovers NDI sources available on the local network. NDI (Network Device Interface) is a royalty-free protocol for live video streaming over IP networks, commonly used in professional broadcast and video production environments.

The enumeration includes a retry mechanism with delays to ensure all network sources are discovered, as NDI source discovery may take time depending on network conditions.

ONVIF_ListSourcesAsync(TimeSpan?, CancellationTokenSource?)

Asynchronously discovers ONVIF-compliant devices on the local network.

public Task<Uri[]> ONVIF_ListSourcesAsync(TimeSpan? timeout, CancellationTokenSource? cts)

Parameters

timeout TimeSpan?

The maximum time to wait for device responses. If null, defaults to 2 seconds. Increase this value for larger networks or slow-responding devices.

cts CancellationTokenSource?

Optional cancellation token source to abort the discovery operation. If null, a new cancellation token source is created internally.

Returns

Task<Uri[]>

A task that represents the asynchronous operation. The task result contains an array of Uri objects representing the service URLs of discovered ONVIF devices.

Remarks

This method uses WS-Discovery to find ONVIF devices on the network. Each returned URI represents the device service endpoint that can be used to establish a connection for camera control and streaming.

For connecting to discovered devices, use the ONVIFClientX class from VisioForge.Core.ONVIFX namespace for full device management capabilities including PTZ control, event handling, and profile management.

StartAudioSinkMonitor()

Starts monitoring for audio output device changes on the current thread.

public void StartAudioSinkMonitor()

Remarks

Once started, the monitor will raise VisioForge.Core.DeviceEnumerator.OnAudioSinkAdded and VisioForge.Core.DeviceEnumerator.OnAudioSinkRemoved events when audio output devices are connected or disconnected.

On Linux, this method performs a one-time enumeration instead of continuous monitoring.

StartAudioSinkMonitorAsync()

Asynchronously starts monitoring for audio output device changes.

public Task StartAudioSinkMonitorAsync()

Returns

Task

A task that represents the asynchronous operation.

Remarks

Once started, the monitor will raise VisioForge.Core.DeviceEnumerator.OnAudioSinkAdded and VisioForge.Core.DeviceEnumerator.OnAudioSinkRemoved events when audio output devices are connected or disconnected.

On Apple platforms (macOS, iOS), this method automatically requests audio access permission.

StartAudioSourceMonitor()

Starts monitoring for audio capture device changes on the current thread.

public void StartAudioSourceMonitor()

Remarks

Once started, the monitor will raise VisioForge.Core.DeviceEnumerator.OnAudioSourceAdded and VisioForge.Core.DeviceEnumerator.OnAudioSourceRemoved events when audio input devices are connected or disconnected.

On Linux, this method performs a one-time enumeration instead of continuous monitoring.

StartAudioSourceMonitorAsync()

Asynchronously starts monitoring for audio capture device changes.

public Task StartAudioSourceMonitorAsync()

Returns

Task

A task that represents the asynchronous operation.

Remarks

Once started, the monitor will raise VisioForge.Core.DeviceEnumerator.OnAudioSourceAdded and VisioForge.Core.DeviceEnumerator.OnAudioSourceRemoved events when audio input devices are connected or disconnected.

On Apple platforms (macOS, iOS), this method automatically requests microphone access permission.

StartVideoSourceMonitor()

Starts monitoring for video capture device changes on the current thread.

public void StartVideoSourceMonitor()

Remarks

Once started, the monitor will raise VisioForge.Core.DeviceEnumerator.OnVideoSourceAdded and VisioForge.Core.DeviceEnumerator.OnVideoSourceRemoved events when video capture devices are connected or disconnected.

On Linux, this method performs a one-time enumeration instead of continuous monitoring.

StartVideoSourceMonitorAsync()

Asynchronously starts monitoring for video capture device changes.

public Task StartVideoSourceMonitorAsync()

Returns

Task

A task that represents the asynchronous operation.

Remarks

Once started, the monitor will raise VisioForge.Core.DeviceEnumerator.OnVideoSourceAdded and VisioForge.Core.DeviceEnumerator.OnVideoSourceRemoved events when video capture devices are connected or disconnected.

On Apple platforms (macOS), this method automatically requests camera access permission.

VideoSources()

Gets an array of available video capture devices (cameras, webcams, and capture cards).

public VideoCaptureDeviceInfo[] VideoSources()

Returns

VideoCaptureDeviceInfo[]

An array of VisioForge.Core.Types.X.Sources.VideoCaptureDeviceInfo objects representing available video capture devices.

Remarks

This method automatically performs device enumeration on first call if the internal cache is empty. Subsequent calls return cached results unless VisioForge.Core.DeviceEnumerator.Clear is called.

Supported video sources vary by platform:

  • Windows: DirectShow, Media Foundation, UVC cameras
  • Linux: V4L2, libcamera, UVC cameras
  • macOS: AVFoundation cameras
  • iOS: Built-in cameras via AVFoundation
  • Android: Camera API devices

VideoSourcesAsync()

Asynchronously gets an array of available video capture devices (cameras, webcams, and capture cards).

public Task<VideoCaptureDeviceInfo[]> VideoSourcesAsync()

Returns

Task<VideoCaptureDeviceInfo[]>

A task that represents the asynchronous operation. The task result contains an array of VisioForge.Core.Types.X.Sources.VideoCaptureDeviceInfo objects representing available video capture devices.

Remarks

On Apple platforms (macOS), this method automatically requests camera access permission before performing enumeration. The method runs device enumeration on a background thread.

OnAudioSinkAdded

Occurs when a new audio output device (speaker/headphones) is added to the system.

public event EventHandler<AudioOutputDeviceInfo> OnAudioSinkAdded

Event Type

EventHandler<AudioOutputDeviceInfo>

Remarks

This event is triggered when the device monitor detects a newly connected audio output device. The event argument contains detailed information about the added device.

OnAudioSinkRemoved

Occurs when an audio output device (speaker/headphones) is removed from the system.

public event EventHandler<AudioOutputDeviceInfo> OnAudioSinkRemoved

Event Type

EventHandler<AudioOutputDeviceInfo>

Remarks

This event is triggered when the device monitor detects that an audio output device has been disconnected. The event argument contains information about the removed device.

OnAudioSourceAdded

Occurs when a new audio capture device (microphone) is added to the system.

public event EventHandler<AudioCaptureDeviceInfo> OnAudioSourceAdded

Event Type

EventHandler<AudioCaptureDeviceInfo>

Remarks

This event is triggered when the device monitor detects a newly connected audio input device. The event argument contains detailed information about the added device including its name, API type, and internal identifier.

OnAudioSourceRemoved

Occurs when an audio capture device (microphone) is removed from the system.

public event EventHandler<AudioCaptureDeviceInfo> OnAudioSourceRemoved

Event Type

EventHandler<AudioCaptureDeviceInfo>

Remarks

This event is triggered when the device monitor detects that an audio input device has been disconnected. The event argument contains information about the removed device.

OnDecklinkSignalLost

Occurs when the DeckLink device loses input signal.

public event EventHandler<EventArgs> OnDecklinkSignalLost

Event Type

EventHandler<EventArgs>

Remarks

This event is triggered when the DeckLink hardware detects a loss of video/audio input signal. This commonly occurs when an SDI or HDMI cable is disconnected or the source device is powered off. Applications should handle this event to notify users or switch to alternative sources.

OnVideoSourceAdded

Occurs when a new video capture device (camera/webcam) is added to the system.

public event EventHandler<VideoCaptureDeviceInfo> OnVideoSourceAdded

Event Type

EventHandler<VideoCaptureDeviceInfo>

Remarks

This event is triggered when the device monitor detects a newly connected video capture device. The event argument contains detailed information about the added device including its name, supported formats, resolutions, and API type.

OnVideoSourceRemoved

Occurs when a video capture device (camera/webcam) is removed from the system.

public event EventHandler<VideoCaptureDeviceInfo> OnVideoSourceRemoved

Event Type

EventHandler<VideoCaptureDeviceInfo>

Remarks

This event is triggered when the device monitor detects that a video capture device has been disconnected. The event argument contains information about the removed device.