#include <icy/av/devicemanager.h>Enumerates and manages system audio and video devices.
| Return | Name | Description |
|---|---|---|
NullSignal | DevicesChanged | Signals when a system device is connected or removed. Emitted by the platform-specific [DeviceWatcher](icy-av-DeviceWatcher.html#devicewatcher). |
NullSignal DevicesChangedSignals when a system device is connected or removed. Emitted by the platform-specific [DeviceWatcher](icy-av-DeviceWatcher.html#devicewatcher).
NOTE: This signal may be emitted from a background thread (e.g. inotify thread on Linux, COM callback on Windows, CoreAudio listener on macOS). Handlers must be thread-safe and should NOT call back into DeviceManager to enumerate. Instead, post to the main thread or set a flag.
| Return | Name | Description |
|---|---|---|
DeviceManager | ||
bool | getCameras const | Populate devices with all connected video input (camera) devices. |
bool | getMicrophones const | Populate devices with all connected audio input (microphone) devices. |
bool | getSpeakers const | Populate devices with all connected audio output (speaker) devices. |
bool | getDefaultCamera const | Return the default (or first available) camera. |
bool | getDefaultMicrophone const | Return the default (or first available) microphone. |
bool | getDefaultSpeaker const | Return the default (or first available) speaker. |
bool | findCamera const | Find a camera by display name or device id. |
bool | findMicrophone const | Find a microphone by display name or device id. |
bool | findSpeaker const | Find a speaker by display name or device id. |
bool | getDeviceList const | Populate devices from the platform-specific backend for the given type. |
int | getCapabilities const | #### Returns |
void | setWatcher | Replace the active device watcher. Takes ownership. |
DeviceWatcher * | watcher const | #### Returns |
void | print const | Print all devices to the output stream. |
std::vector< HardwareCodec > | getHardwareCodecs const | Detect available hardware-accelerated codecs via FFmpeg. |
std::optional< std::pair< Device, Device::VideoCapability > > | negotiateVideoCapture const | Resolve the best video capture parameters for a device. |
std::optional< std::pair< Device, Device::AudioCapability > > | negotiateAudioCapture const | Resolve the best audio capture parameters for a device. Returns std::nullopt if no microphone is available. |
const AVInputFormat * | findVideoInputFormat const | Find base FFmpeg formats. |
const AVInputFormat * | findAudioInputFormat const |
DeviceManager()const
bool getCameras(std::vector< Device > & devices) constPopulate devices with all connected video input (camera) devices.
devices Output vector to fill.True if enumeration succeeded (even if the list is empty).
const
bool getMicrophones(std::vector< Device > & devices) constPopulate devices with all connected audio input (microphone) devices.
devices Output vector to fill.True if enumeration succeeded.
const
bool getSpeakers(std::vector< Device > & devices) constPopulate devices with all connected audio output (speaker) devices.
devices Output vector to fill.True if enumeration succeeded.
const
bool getDefaultCamera(Device & device) constReturn the default (or first available) camera.
device Output Device to fill.True if a camera was found.
const
bool getDefaultMicrophone(Device & device) constReturn the default (or first available) microphone.
device Output Device to fill.True if a microphone was found.
const
bool getDefaultSpeaker(Device & device) constReturn the default (or first available) speaker.
device Output Device to fill.True if a speaker was found.
const
bool findCamera(std::string_view name, Device & device) constFind a camera by display name or device id.
name The name or id to search for.
device Output Device to fill if found.
True if a matching device was found.
const
bool findMicrophone(std::string_view name, Device & device) constFind a microphone by display name or device id.
name The name or id to search for.
device Output Device to fill if found.
True if a matching device was found.
const
bool findSpeaker(std::string_view name, Device & device) constFind a speaker by display name or device id.
name The name or id to search for.
device Output Device to fill if found.
True if a matching device was found.
const
bool getDeviceList(Device::Type type, std::vector< av::Device > & devices) constPopulate devices from the platform-specific backend for the given type.
type The device type to enumerate.
devices Output vector to fill.
True if enumeration succeeded.
const
int getCapabilities() constA bitmask of MediaCapabilities flags indicating which capture/render types are available.
void setWatcher(DeviceWatcher * watcher)Replace the active device watcher. Takes ownership.
watcher The new DeviceWatcher, or nullptr to disable watching.const
DeviceWatcher * watcher() constThe currently active DeviceWatcher, or nullptr if none has been set.
const
void print(std::ostream & ost) constPrint all devices to the output stream.
const
std::vector< HardwareCodec > getHardwareCodecs() constDetect available hardware-accelerated codecs via FFmpeg.
const
std::optional< std::pair< Device, Device::VideoCapability > > negotiateVideoCapture(std::string_view deviceName, int width, int height, double fps) constResolve the best video capture parameters for a device.
Looks up the device by name/id (or default camera if empty), queries its capabilities, and returns the closest match. Returns std::nullopt if no camera is available.
Usage: if (auto result = devman.negotiateVideoCapture("", 1280, 720, 30)) { auto& [dev, cap] = *result; capture.openVideo(dev.id, cap.width, cap.height, cap.maxFps, cap.pixelFormat); }
const
std::optional< std::pair< Device, Device::AudioCapability > > negotiateAudioCapture(std::string_view deviceName, int sampleRate, int channels) constResolve the best audio capture parameters for a device. Returns std::nullopt if no microphone is available.
const
const AVInputFormat * findVideoInputFormat() constFind base FFmpeg formats.
const
const AVInputFormat * findAudioInputFormat() const| Return | Name | Description |
|---|---|---|
DeviceManager & | instance static | Returns the default [DeviceManager](#devicemanager) singleton. |
void | shutdown static | Shuts down the MediaFactory and deletes the singleton instance. |
static
static DeviceManager & instance()Returns the default [DeviceManager](#devicemanager) singleton.
static
static void shutdown()Shuts down the MediaFactory and deletes the singleton instance.
| Return | Name | Description |
|---|---|---|
std::unique_ptr< DeviceWatcher > | _watcher |
std::unique_ptr< DeviceWatcher > _watcher