duvc-ctl 2.0.0
USB Video Class Camera Control Library
Loading...
Searching...
No Matches
duvc Namespace Reference

Namespaces

namespace  detail
 Internal implementation details.
 
namespace  logitech
 

Classes

class  Camera
 RAII camera handle for simplified device management. More...
 
class  com_apartment
 
class  com_ptr
 
struct  Device
 Represents a camera device. More...
 
class  DeviceCapabilities
 Complete device capability snapshot. More...
 
class  DeviceConnection
 RAII wrapper for DirectShow device connections. More...
 
class  Error
 Error information with context. More...
 
class  IDeviceConnection
 Abstract interface for device-specific operations. More...
 
class  IPlatformInterface
 Abstract interface for platform-specific camera operations. More...
 
class  KsPropertySet
 RAII wrapper for IKsPropertySet interface. More...
 
struct  PropertyCapability
 Property capability information. More...
 
struct  PropRange
 Property range and default information. More...
 
struct  PropSetting
 Property setting with value and control mode. More...
 
class  Result
 Result type that can contain either a value or an error. More...
 
class  Result< void >
 Specialization for void results (operations that don't return values) More...
 
struct  VendorProperty
 Vendor-specific property data container. More...
 
class  WindowsPlatformInterface
 Windows DirectShow platform implementation. More...
 

Typedefs

using DeviceChangeCallback = std::function<void(bool device_added, const std::wstring& device_path)>
 Device change callback function type.
 
using LogCallback
 Log message callback type.
 

Enumerations

enum class  ErrorCode {
  Success = 0 , DeviceNotFound , DeviceBusy , PropertyNotSupported ,
  InvalidValue , PermissionDenied , SystemError , InvalidArgument ,
  NotImplemented
}
 Error codes for duvc operations. More...
 
enum class  CamProp {
  Pan , Tilt , Roll , Zoom ,
  Exposure , Iris , Focus , ScanMode ,
  Privacy , PanRelative , TiltRelative , RollRelative ,
  ZoomRelative , ExposureRelative , IrisRelative , FocusRelative ,
  PanTilt , PanTiltRelative , FocusSimple , DigitalZoom ,
  DigitalZoomRelative , BacklightCompensation , Lamp , Pan ,
  Tilt , Roll , Zoom , Exposure ,
  Iris , Focus , ScanMode , Privacy ,
  PanRelative , TiltRelative , RollRelative , ZoomRelative ,
  ExposureRelative , IrisRelative , FocusRelative , PanTilt ,
  PanTiltRelative , FocusSimple , DigitalZoom , DigitalZoomRelative ,
  BacklightCompensation , Lamp
}
 Camera control properties (IAMCameraControl interface) More...
 
enum class  VidProp {
  Brightness , Contrast , Hue , Saturation ,
  Sharpness , Gamma , ColorEnable , WhiteBalance ,
  BacklightCompensation , Gain , Brightness , Contrast ,
  Hue , Saturation , Sharpness , Gamma ,
  ColorEnable , WhiteBalance , BacklightCompensation , Gain
}
 Video processing properties (IAMVideoProcAmp interface) More...
 
enum class  CamMode { Auto , Manual , Auto , Manual }
 Property control mode. More...
 
enum class  CamProp {
  Pan , Tilt , Roll , Zoom ,
  Exposure , Iris , Focus , ScanMode ,
  Privacy , PanRelative , TiltRelative , RollRelative ,
  ZoomRelative , ExposureRelative , IrisRelative , FocusRelative ,
  PanTilt , PanTiltRelative , FocusSimple , DigitalZoom ,
  DigitalZoomRelative , BacklightCompensation , Lamp , Pan ,
  Tilt , Roll , Zoom , Exposure ,
  Iris , Focus , ScanMode , Privacy ,
  PanRelative , TiltRelative , RollRelative , ZoomRelative ,
  ExposureRelative , IrisRelative , FocusRelative , PanTilt ,
  PanTiltRelative , FocusSimple , DigitalZoom , DigitalZoomRelative ,
  BacklightCompensation , Lamp
}
 
enum class  VidProp {
  Brightness , Contrast , Hue , Saturation ,
  Sharpness , Gamma , ColorEnable , WhiteBalance ,
  BacklightCompensation , Gain , Brightness , Contrast ,
  Hue , Saturation , Sharpness , Gamma ,
  ColorEnable , WhiteBalance , BacklightCompensation , Gain
}
 
enum class  CamMode { Auto , Manual , Auto , Manual }
 
enum class  LogLevel {
  Debug = 0 , Info = 1 , Warning = 2 , Error = 3 ,
  Critical = 4
}
 Log levels. More...
 

Functions

std::vector< Devicelist_devices ()
 Enumerate all available video input devices.
 
bool get_range (const Device &dev, CamProp prop, PropRange &out)
 Get the valid range for a camera control property.
 
bool get (const Device &dev, CamProp prop, PropSetting &out)
 Get a camera control property value.
 
bool set (const Device &dev, CamProp prop, const PropSetting &in)
 Set a camera control property value.
 
bool get_range (const Device &dev, VidProp prop, PropRange &out)
 Get the valid range for a video processing property.
 
bool get (const Device &dev, VidProp prop, PropSetting &out)
 Get a video processing property value.
 
bool set (const Device &dev, VidProp prop, const PropSetting &in)
 Set a video processing property value.
 
const charto_string (CamProp prop)
 Convert camera property enum to string.
 
const charto_string (VidProp prop)
 Convert video property enum to string.
 
const charto_string (CamMode mode)
 Convert camera mode enum to string.
 
const wchar_tto_wstring (CamProp prop)
 Convert camera property enum to wide string.
 
const wchar_tto_wstring (VidProp prop)
 Convert video property enum to wide string.
 
const wchar_tto_wstring (CamMode mode)
 Convert camera mode enum to wide string.
 
void register_device_change_callback (DeviceChangeCallback callback)
 Register callback for device hotplug events.
 
void unregister_device_change_callback ()
 Unregister device change callback.
 
bool is_device_connected (const Device &dev)
 Check if a device is currently connected and accessible.
 
bool get_vendor_property (const Device &dev, const GUID &property_set, ULONG property_id, std::vector< uint8_t > &data)
 Get vendor-specific property data from device.
 
bool set_vendor_property (const Device &dev, const GUID &property_set, ULONG property_id, const std::vector< uint8_t > &data)
 Set vendor-specific property data on device.
 
bool query_vendor_property_support (const Device &dev, const GUID &property_set, ULONG property_id)
 Query whether device supports a vendor-specific property.
 
DeviceConnectionget_cached_connection (const Device &dev)
 
void release_cached_connection (const Device &dev)
 
void clear_connection_cache ()
 
Result< Cameraopen_camera (int device_index)
 Create camera from device index.
 
Result< Cameraopen_camera (const Device &device)
 Create camera from device.
 
Result< Cameraopen_camera (const std::wstring &device_path)
 Create camera from device path.
 
Result< DeviceCapabilitiesget_device_capabilities (const Device &device)
 Create device capability snapshot.
 
Result< DeviceCapabilitiesget_device_capabilities (int device_index)
 Create device capability snapshot by index.
 
Device find_device_by_path (const std::wstring &device_path)
 Find device by unique Windows device path.
 
const charto_string (ErrorCode code)
 Convert error code to string.
 
template<typename T >
Result< T > Ok (T value)
 Helper to create successful Result.
 
Result< voidOk ()
 Helper to create successful void Result.
 
template<typename T >
Result< T > Err (Error error)
 Helper to create error Result.
 
template<typename T >
Result< T > Err (ErrorCode code, std::string message="")
 Helper to create error Result from code.
 
std::unique_ptr< IPlatformInterfacecreate_platform_interface ()
 Get platform-specific interface implementation.
 
com_ptr< ICreateDevEnumcreate_dev_enum ()
 Create DirectShow device enumerator.
 
com_ptr< IEnumMonikerenum_video_devices (ICreateDevEnum *dev)
 Enumerate video input devices.
 
std::wstring read_friendly_name (IMoniker *mon)
 Read friendly name from device moniker.
 
std::wstring read_device_path (IMoniker *mon)
 Read device path from moniker.
 
bool is_same_device (const Device &d, const std::wstring &name, const std::wstring &path)
 Check if two device identifiers refer to same device.
 
com_ptr< IBaseFilteropen_device_filter (const Device &dev)
 Create DirectShow filter from device.
 
std::string decode_system_error (unsigned long error_code)
 Decode system error code to human-readable string.
 
std::string decode_hresult (HRESULT hr)
 Decode HRESULT to human-readable string.
 
std::string get_hresult_details (HRESULT hr)
 Get detailed HRESULT information.
 
bool is_device_error (HRESULT hr)
 Check if HRESULT indicates a device-related error.
 
bool is_permission_error (HRESULT hr)
 Check if HRESULT indicates permission/access error.
 
std::string get_diagnostic_info ()
 Get diagnostic information for troubleshooting.
 
const charto_string (LogLevel level)
 Convert log level to string.
 
void set_log_callback (LogCallback callback)
 Set global log callback.
 
void set_log_level (LogLevel level)
 Set minimum log level.
 
LogLevel get_log_level ()
 Get current minimum log level.
 
void log_message (LogLevel level, const std::string &message)
 Log a message.
 
void log_debug (const std::string &message)
 Log debug message.
 
void log_info (const std::string &message)
 Log info message.
 
void log_warning (const std::string &message)
 Log warning message.
 
void log_error (const std::string &message)
 Log error message.
 
void log_critical (const std::string &message)
 Log critical message.
 
std::string to_utf8 (const std::wstring &wstr)
 Converts a wide string (UTF-16 on Windows) to a UTF-8 string.
 
std::wstring to_wstring (const std::string &str)
 Converts a UTF-8 string to a wide string (UTF-16 on Windows)
 
static std::string wide_to_utf8 (const wchar_t *ws)
 
static void throw_hr (HRESULT hr, const char *where)
 
static LRESULT CALLBACK device_wndproc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static std::wstring read_prop_bstr (IPropertyBag *bag, const wchar_t *key)
 
static com_ptr< IBaseFilterbind_to_filter (IMoniker *mon)
 
static com_ptr< IAMCameraControlget_cam_ctrl (IBaseFilter *f)
 
static com_ptr< IAMVideoProcAmpget_vproc (IBaseFilter *f)
 
static com_ptr< IKsPropertySetget_property_set (IBaseFilter *f)
 
static long camprop_to_dshow (CamProp p)
 
static long vidprop_to_dshow (VidProp p)
 
static long to_flag (CamMode m, bool is_camera_control)
 
static CamMode from_flag (long flag, bool is_camera_control)
 
static std::wstring read_prop_bstr (IPropertyBag *bag, const wchar_t *key)
 
static com_ptr< IBaseFilterbind_to_filter (IMoniker *mon)
 
static com_ptr< IAMCameraControlget_cam_ctrl (IBaseFilter *f)
 
static com_ptr< IAMVideoProcAmpget_vproc (IBaseFilter *f)
 
static long camprop_to_dshow (CamProp p)
 
static long vidprop_to_dshow (VidProp p)
 
static long to_flag (CamMode m, bool is_camera_control)
 
static CamMode from_flag (long flag, bool is_camera_control)
 
static LRESULT CALLBACK device_notification_wndproc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 Window procedure for handling device change notifications.
 
static bool register_notification_window_class ()
 Register window class for device notifications.
 
static HWND create_notification_window ()
 Create invisible window for receiving device notifications.
 
static HDEVNOTIFY register_device_notifications (HWND hwnd)
 Register for device interface notifications.
 
static std::string get_timestamp ()
 Get current timestamp as string.
 
static void default_log_callback (LogLevel level, const std::string &message)
 Default logging callback that writes to stderr.
 
static com_ptr< IKsPropertySetget_property_set (IBaseFilter *f)
 

Variables

static DeviceChangeCallback g_device_callback = nullptr
 
static HWND g_notification_window = nullptr
 
static HDEVNOTIFY g_device_notify = nullptr
 
static std::mutex g_cache_mutex
 
static std::unordered_map< std::wstring, std::unique_ptr< DeviceConnection > > g_connection_cache
 
static std::mutex g_log_mutex
 
static LogCallback g_log_callback = nullptr
 
static LogLevel g_min_log_level = LogLevel::Info
 

Typedef Documentation

◆ DeviceChangeCallback

Device change callback function type.

Parameters
addedtrue if device was added, false if removed
device_pathPath of the device that changed

Definition at line 34 of file core.h.

◆ LogCallback

Initial value:
std::function<void(LogLevel level, const std::string &message)>

Log message callback type.

Parameters
levelLog level
messageLog message

Definition at line 36 of file logging.h.

Enumeration Type Documentation

◆ CamMode [1/2]

Property control mode.

Enumerator
Auto 

Automatic control by camera.

Manual 

Manual control by application.

Auto 
Manual 

Definition at line 66 of file types.h.

◆ CamMode [2/2]

Enumerator
Auto 

Automatic control by camera.

Manual 

Manual control by application.

Auto 
Manual 

Definition at line 23 of file defs.h.

◆ CamProp [1/2]

Camera control properties (IAMCameraControl interface)

These properties correspond to DirectShow's IAMCameraControl interface and control physical camera mechanisms.

Enumerator
Pan 

Horizontal camera rotation.

Tilt 

Vertical camera rotation.

Roll 

Camera roll rotation.

Zoom 

Optical zoom level.

Exposure 

Exposure time.

Iris 

Aperture/iris setting.

Focus 

Focus position.

ScanMode 

Scan mode (progressive/interlaced)

Privacy 

Privacy mode on/off.

PanRelative 

Relative pan movement.

TiltRelative 

Relative tilt movement.

RollRelative 

Relative roll movement.

ZoomRelative 

Relative zoom movement.

ExposureRelative 

Relative exposure adjustment.

IrisRelative 

Relative iris adjustment.

FocusRelative 

Relative focus adjustment.

PanTilt 

Combined pan/tilt control.

PanTiltRelative 

Relative pan/tilt movement.

FocusSimple 

Simple focus control.

DigitalZoom 

Digital zoom level.

DigitalZoomRelative 

Relative digital zoom.

BacklightCompensation 

Backlight compensation.

Lamp 

Camera lamp/flash control.

Pan 
Tilt 
Roll 
Zoom 
Exposure 
Iris 
Focus 
ScanMode 
Privacy 
PanRelative 
TiltRelative 
RollRelative 
ZoomRelative 
ExposureRelative 
IrisRelative 
FocusRelative 
PanTilt 
PanTiltRelative 
FocusSimple 
DigitalZoom 
DigitalZoomRelative 
BacklightCompensation 
Lamp 

Definition at line 18 of file types.h.

◆ CamProp [2/2]

Enumerator
Pan 

Horizontal camera rotation.

Tilt 

Vertical camera rotation.

Roll 

Camera roll rotation.

Zoom 

Optical zoom level.

Exposure 

Exposure time.

Iris 

Aperture/iris setting.

Focus 

Focus position.

ScanMode 

Scan mode (progressive/interlaced)

Privacy 

Privacy mode on/off.

PanRelative 

Relative pan movement.

TiltRelative 

Relative tilt movement.

RollRelative 

Relative roll movement.

ZoomRelative 

Relative zoom movement.

ExposureRelative 

Relative exposure adjustment.

IrisRelative 

Relative iris adjustment.

FocusRelative 

Relative focus adjustment.

PanTilt 

Combined pan/tilt control.

PanTiltRelative 

Relative pan/tilt movement.

FocusSimple 

Simple focus control.

DigitalZoom 

Digital zoom level.

DigitalZoomRelative 

Relative digital zoom.

BacklightCompensation 

Backlight compensation.

Lamp 

Camera lamp/flash control.

Pan 
Tilt 
Roll 
Zoom 
Exposure 
Iris 
Focus 
ScanMode 
Privacy 
PanRelative 
TiltRelative 
RollRelative 
ZoomRelative 
ExposureRelative 
IrisRelative 
FocusRelative 
PanTilt 
PanTiltRelative 
FocusSimple 
DigitalZoom 
DigitalZoomRelative 
BacklightCompensation 
Lamp 

Definition at line 7 of file defs.h.

◆ ErrorCode

Error codes for duvc operations.

Enumerator
Success 

Operation succeeded.

DeviceNotFound 

Device not found or disconnected.

DeviceBusy 

Device is busy or in use.

PropertyNotSupported 

Property not supported by device.

InvalidValue 

Property value out of range.

PermissionDenied 

Insufficient permissions.

SystemError 

System/platform error.

InvalidArgument 

Invalid function argument.

NotImplemented 

Feature not implemented on this platform.

Definition at line 19 of file result.h.

◆ LogLevel

Log levels.

Enumerator
Debug 

Debug information.

Info 

Informational messages.

Warning 

Warning messages.

Error 

Error messages.

Critical 

Critical errors.

Definition at line 16 of file logging.h.

◆ VidProp [1/2]

Video processing properties (IAMVideoProcAmp interface)

These properties correspond to DirectShow's IAMVideoProcAmp interface and control image processing parameters.

Enumerator
Brightness 

Image brightness level.

Contrast 

Image contrast level.

Hue 

Color hue adjustment.

Saturation 

Color saturation level.

Sharpness 

Image sharpness level.

Gamma 

Gamma correction value.

ColorEnable 

Color vs. monochrome mode.

WhiteBalance 

White balance adjustment.

BacklightCompensation 

Backlight compensation level.

Gain 

Sensor gain level.

Brightness 
Contrast 
Hue 
Saturation 
Sharpness 
Gamma 
ColorEnable 
WhiteBalance 
BacklightCompensation 
Gain 

Definition at line 50 of file types.h.

◆ VidProp [2/2]

Enumerator
Brightness 

Image brightness level.

Contrast 

Image contrast level.

Hue 

Color hue adjustment.

Saturation 

Color saturation level.

Sharpness 

Image sharpness level.

Gamma 

Gamma correction value.

ColorEnable 

Color vs. monochrome mode.

WhiteBalance 

White balance adjustment.

BacklightCompensation 

Backlight compensation level.

Gain 

Sensor gain level.

Brightness 
Contrast 
Hue 
Saturation 
Sharpness 
Gamma 
ColorEnable 
WhiteBalance 
BacklightCompensation 
Gain 

Definition at line 17 of file defs.h.

Function Documentation

◆ bind_to_filter() [1/2]

static com_ptr< IBaseFilter > duvc::bind_to_filter ( IMoniker * mon)
static

Definition at line 223 of file core.cpp.

References throw_hr().

Referenced by open_device_filter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bind_to_filter() [2/2]

static com_ptr< IBaseFilter > duvc::bind_to_filter ( IMoniker * mon)
static

Definition at line 81 of file connection_pool.cpp.

References throw_hr().

Here is the call graph for this function:

◆ camprop_to_dshow() [1/2]

◆ camprop_to_dshow() [2/2]

◆ clear_connection_cache()

void duvc::clear_connection_cache ( )

Definition at line 505 of file core.cpp.

References g_cache_mutex, and g_connection_cache.

Referenced by duvc_clear_cache().

Here is the caller graph for this function:

◆ create_dev_enum()

com_ptr< ICreateDevEnum > duvc::create_dev_enum ( )

Create DirectShow device enumerator.

Returns
COM pointer to ICreateDevEnum

Definition at line 173 of file core.cpp.

References CLSID_SystemDeviceEnum, IID_ICreateDevEnum, and throw_hr().

Referenced by is_device_connected(), list_devices(), and open_device_filter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_notification_window()

static HWND duvc::create_notification_window ( )
static

Create invisible window for receiving device notifications.

Returns
Window handle or nullptr if failed

Definition at line 95 of file device_monitor.cpp.

References DUVC_LOG_ERROR, and register_notification_window_class().

Here is the call graph for this function:

◆ create_platform_interface()

std::unique_ptr< IPlatformInterface > duvc::create_platform_interface ( )

Get platform-specific interface implementation.

Returns
Platform interface instance

Definition at line 60 of file factory.cpp.

◆ decode_hresult()

std::string duvc::decode_hresult ( HRESULT hr)

Decode HRESULT to human-readable string.

Parameters
hrHRESULT value
Returns
Human-readable error description

Definition at line 70 of file error_decoder.cpp.

References decode_system_error().

Referenced by get_diagnostic_info(), get_hresult_details(), duvc::KsPropertySet::get_property(), duvc::KsPropertySet::KsPropertySet(), duvc::KsPropertySet::query_support(), and duvc::KsPropertySet::set_property().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decode_system_error()

std::string duvc::decode_system_error ( unsigned long error_code)

Decode system error code to human-readable string.

Parameters
error_codeSystem error code
Returns
Human-readable error description

Definition at line 26 of file error_decoder.cpp.

Referenced by decode_hresult().

Here is the caller graph for this function:

◆ default_log_callback()

static void duvc::default_log_callback ( LogLevel level,
const std::string & message )
static

Default logging callback that writes to stderr.

Parameters
levelLog level
messageLog message

Definition at line 59 of file logging.cpp.

References Error, get_timestamp(), and to_string().

Referenced by log_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_notification_wndproc()

static LRESULT CALLBACK duvc::device_notification_wndproc ( HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam )
static

Window procedure for handling device change notifications.

Parameters
hwndWindow handle
msgMessage type
wParamMessage parameter
lParamMessage parameter
Returns
Message result

Definition at line 32 of file device_monitor.cpp.

References DUVC_LOG_DEBUG, DUVC_LOG_ERROR, DUVC_LOG_INFO, and g_device_callback.

Referenced by register_notification_window_class().

Here is the caller graph for this function:

◆ device_wndproc()

static LRESULT CALLBACK duvc::device_wndproc ( HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam )
static

Definition at line 156 of file core.cpp.

References g_device_callback.

Referenced by register_device_change_callback().

Here is the caller graph for this function:

◆ enum_video_devices()

com_ptr< IEnumMoniker > duvc::enum_video_devices ( ICreateDevEnum * dev)

Enumerate video input devices.

Parameters
devDevice enumerator
Returns
COM pointer to IEnumMoniker for video devices

Definition at line 181 of file core.cpp.

References CLSID_VideoInputDeviceCategory, and throw_hr().

Referenced by is_device_connected(), list_devices(), and open_device_filter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Err() [1/2]

template<typename T >
Result< T > duvc::Err ( Error error)

Helper to create error Result.

Template Parameters
TValue type
Parameters
errorError to wrap
Returns
Error Result

Definition at line 230 of file result.h.

◆ Err() [2/2]

template<typename T >
Result< T > duvc::Err ( ErrorCode code,
std::string message = "" )

Helper to create error Result from code.

Template Parameters
TValue type
Parameters
codeError code
messageOptional error message
Returns
Error Result

Definition at line 241 of file result.h.

◆ find_device_by_path()

Device duvc::find_device_by_path ( const std::wstring & device_path)

Find device by unique Windows device path.

Searches the current device enumeration for a device matching the specified Windows device instance path. This provides unambiguous identification when multiple cameras have identical names due to firmware variations.

Parameters
device_pathWide string containing the device path (case-insensitive)
Returns
Device object with matching path
Exceptions
std::runtime_errorif enumeration fails or device not found

The device path format is: USB\VID_XXXX&PID_XXXX&MI_XX#...#{GUID}

Note
Device paths can be obtained from Device::path member
See also
list_devices() to enumerate all devices with paths

Example:

try {
} catch (const std::runtime_error &e) {
// Handle device not found
}
RAII camera handle for simplified device management.
Definition camera.h:23
Result type that can contain either a value or an error.
Definition result.h:75
std::vector< Device > list_devices()
Enumerate all available video input devices.
Definition core.cpp:626
Device find_device_by_path(const std::wstring &device_path)
Find device by unique Windows device path.
Definition device.cpp:211

Definition at line 211 of file device.cpp.

References CLSID_SystemDeviceEnum, CLSID_VideoInputDeviceCategory, IID_ICreateDevEnum, read_device_path(), read_friendly_name(), and throw_hr().

Referenced by duvc::Camera::Camera(), duvc_find_device_by_path(), and open_camera().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ from_flag() [1/2]

static CamMode duvc::from_flag ( long flag,
bool is_camera_control )
static

Definition at line 332 of file core.cpp.

References Auto, CameraControl_Flags_Auto, Manual, and VideoProcAmp_Flags_Auto.

Referenced by duvc::DeviceConnection::get(), duvc::DeviceConnection::get(), duvc::DeviceConnection::get_range(), and duvc::DeviceConnection::get_range().

Here is the caller graph for this function:

◆ from_flag() [2/2]

static CamMode duvc::from_flag ( long flag,
bool is_camera_control )
static

Definition at line 222 of file connection_pool.cpp.

References Auto, CameraControl_Flags_Auto, Manual, and VideoProcAmp_Flags_Auto.

◆ get_cached_connection()

DeviceConnection * duvc::get_cached_connection ( const Device & dev)

Definition at line 480 of file core.cpp.

References g_cache_mutex, and g_connection_cache.

Referenced by is_device_connected().

Here is the caller graph for this function:

◆ get_cam_ctrl() [1/2]

static com_ptr< IAMCameraControl > duvc::get_cam_ctrl ( IBaseFilter * f)
static

Definition at line 230 of file core.cpp.

Referenced by duvc::DeviceConnection::DeviceConnection().

Here is the caller graph for this function:

◆ get_cam_ctrl() [2/2]

static com_ptr< IAMCameraControl > duvc::get_cam_ctrl ( IBaseFilter * f)
static

Definition at line 90 of file connection_pool.cpp.

◆ get_device_capabilities() [1/2]

Result< DeviceCapabilities > duvc::get_device_capabilities ( const Device & device)

Create device capability snapshot.

Parameters
deviceDevice to analyze
Returns
Result containing DeviceCapabilities or error

Definition at line 140 of file capability.cpp.

References DeviceNotFound, InvalidArgument, duvc::DeviceCapabilities::is_device_accessible(), duvc::Device::is_valid(), duvc::Device::name, Ok(), and duvc::Device::path.

Referenced by duvc_get_device_capabilities(), duvc_get_device_capabilities_by_index(), and get_device_capabilities().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_device_capabilities() [2/2]

Result< DeviceCapabilities > duvc::get_device_capabilities ( int device_index)

Create device capability snapshot by index.

Parameters
device_indexDevice index from list_devices()
Returns
Result containing DeviceCapabilities or error

Definition at line 188 of file capability.cpp.

References DeviceNotFound, get_device_capabilities(), and list_devices().

Here is the call graph for this function:

◆ get_diagnostic_info()

std::string duvc::get_diagnostic_info ( )

Get diagnostic information for troubleshooting.

Returns
Diagnostic information string

Definition at line 149 of file error_decoder.cpp.

References CLSID_SystemDeviceEnum, decode_hresult(), and IID_ICreateDevEnum.

Here is the call graph for this function:

◆ get_hresult_details()

std::string duvc::get_hresult_details ( HRESULT hr)

Get detailed HRESULT information.

Parameters
hrHRESULT value
Returns
Detailed error information including facility and code

Definition at line 94 of file error_decoder.cpp.

References decode_hresult().

Here is the call graph for this function:

◆ get_log_level()

LogLevel duvc::get_log_level ( )

Get current minimum log level.

Returns
Current minimum log level

Definition at line 83 of file logging.cpp.

References g_log_mutex, and g_min_log_level.

Referenced by duvc_get_log_level().

Here is the caller graph for this function:

◆ get_property_set() [1/2]

static com_ptr< IKsPropertySet > duvc::get_property_set ( IBaseFilter * f)
static

Definition at line 242 of file core.cpp.

Referenced by get_vendor_property(), query_vendor_property_support(), and set_vendor_property().

Here is the caller graph for this function:

◆ get_property_set() [2/2]

static com_ptr< IKsPropertySet > duvc::get_property_set ( IBaseFilter * f)
static

Definition at line 21 of file constants.cpp.

◆ get_timestamp()

static std::string duvc::get_timestamp ( )
static

Get current timestamp as string.

Returns
Formatted timestamp string

Definition at line 41 of file logging.cpp.

Referenced by default_log_callback().

Here is the caller graph for this function:

◆ get_vendor_property()

bool duvc::get_vendor_property ( const Device & dev,
const GUID & property_set,
ULONG property_id,
std::vector< uint8_t > & data )

Get vendor-specific property data from device.

Parameters
devTarget device to query
property_setProperty set GUID identifying the extension unit
property_idProperty ID within the extension unit
[out]dataOutput buffer to receive property data
Returns
true if property was read successfully, false on error

Definition at line 584 of file core.cpp.

References get_property_set(), and open_device_filter().

Here is the call graph for this function:

◆ get_vproc() [1/2]

static com_ptr< IAMVideoProcAmp > duvc::get_vproc ( IBaseFilter * f)
static

Definition at line 236 of file core.cpp.

Referenced by duvc::DeviceConnection::DeviceConnection().

Here is the caller graph for this function:

◆ get_vproc() [2/2]

static com_ptr< IAMVideoProcAmp > duvc::get_vproc ( IBaseFilter * f)
static

Definition at line 99 of file connection_pool.cpp.

◆ is_device_connected()

bool duvc::is_device_connected ( const Device & dev)

Check if a device is currently connected and accessible.

Parameters
devDevice to check
Returns
true if device is connected and can be opened

This performs a lightweight check to determine if the device still exists and can be accessed.

Definition at line 549 of file core.cpp.

References create_dev_enum(), enum_video_devices(), get_cached_connection(), is_same_device(), read_device_path(), and read_friendly_name().

Referenced by duvc::DeviceCapabilities::DeviceCapabilities(), duvc_is_device_connected(), duvc_is_device_connected(), duvc::Camera::is_valid(), open_camera(), open_camera(), and duvc::DeviceCapabilities::refresh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_device_error()

bool duvc::is_device_error ( HRESULT hr)

Check if HRESULT indicates a device-related error.

Parameters
hrHRESULT value
Returns
true if device-related error

Definition at line 121 of file error_decoder.cpp.

References VFW_E_DEVICE_IN_USE.

◆ is_permission_error()

bool duvc::is_permission_error ( HRESULT hr)

Check if HRESULT indicates permission/access error.

Parameters
hrHRESULT value
Returns
true if permission error

Definition at line 138 of file error_decoder.cpp.

◆ is_same_device()

bool duvc::is_same_device ( const Device & d,
const std::wstring & name,
const std::wstring & path )

Check if two device identifiers refer to same device.

Parameters
dDevice structure to compare
nameDevice name from enumeration
pathDevice path from enumeration
Returns
true if same device

Definition at line 250 of file core.cpp.

Referenced by is_device_connected(), and open_device_filter().

Here is the caller graph for this function:

◆ list_devices()

std::vector< Device > duvc::list_devices ( )

Enumerate all available video input devices.

Returns
Vector of detected devices
Exceptions
std::runtime_errorif device enumeration fails

Definition at line 626 of file core.cpp.

References create_dev_enum(), enum_video_devices(), read_device_path(), and read_friendly_name().

Referenced by duvc::Camera::Camera(), duvc_cam_get(), duvc_cam_get_range(), duvc_cam_set(), duvc_get_device_count(), duvc_get_device_name(), duvc_get_device_path(), duvc_is_device_connected(), duvc_list_devices(), duvc_refresh_devices(), duvc_vid_get(), duvc_vid_get_range(), duvc_vid_set(), get_device_capabilities(), and open_camera().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_critical()

void duvc::log_critical ( const std::string & message)

Log critical message.

Parameters
messageCritical message

Definition at line 126 of file logging.cpp.

References Critical, and log_message().

Here is the call graph for this function:

◆ log_debug()

void duvc::log_debug ( const std::string & message)

Log debug message.

Parameters
messageDebug message

Definition at line 110 of file logging.cpp.

References Debug, and log_message().

Here is the call graph for this function:

◆ log_error()

void duvc::log_error ( const std::string & message)

Log error message.

Parameters
messageError message

Definition at line 122 of file logging.cpp.

References Error, and log_message().

Here is the call graph for this function:

◆ log_info()

void duvc::log_info ( const std::string & message)

Log info message.

Parameters
messageInfo message

Definition at line 114 of file logging.cpp.

References Info, and log_message().

Referenced by duvc_initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_message()

void duvc::log_message ( LogLevel level,
const std::string & message )

Log a message.

Parameters
levelLog level
messageLog message

Definition at line 88 of file logging.cpp.

References default_log_callback(), Error, g_log_callback, g_log_mutex, and g_min_log_level.

Referenced by duvc_log_message(), log_critical(), log_debug(), log_error(), log_info(), and log_warning().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_warning()

void duvc::log_warning ( const std::string & message)

Log warning message.

Parameters
messageWarning message

Definition at line 118 of file logging.cpp.

References log_message(), and Warning.

Here is the call graph for this function:

◆ Ok() [1/2]

◆ Ok() [2/2]

template<typename T >
Result< T > duvc::Ok ( T value)

Helper to create successful Result.

Template Parameters
TValue type
Parameters
valueValue to wrap
Returns
Successful Result

Definition at line 214 of file result.h.

◆ open_camera() [1/3]

Result< Camera > duvc::open_camera ( const Device & device)

Create camera from device.

Parameters
deviceDevice to connect to
Returns
Result containing Camera or error

Definition at line 139 of file camera.cpp.

References DeviceNotFound, InvalidArgument, is_device_connected(), duvc::Device::is_valid(), and Ok().

Here is the call graph for this function:

◆ open_camera() [2/3]

Result< Camera > duvc::open_camera ( const std::wstring & device_path)

Create camera from device path.

Parameters
device_pathWindows device instance path
Returns
Result containing Camera or error

Most precise method for opening cameras when multiple devices share the same name or VID/PID due to firmware variations.

See also
find_device_by_path()

Definition at line 151 of file camera.cpp.

References DeviceNotFound, find_device_by_path(), InvalidArgument, is_device_connected(), duvc::Device::is_valid(), and Ok().

Here is the call graph for this function:

◆ open_camera() [3/3]

Result< Camera > duvc::open_camera ( int device_index)

Create camera from device index.

Parameters
device_indexIndex from list_devices()
Returns
Result containing Camera or error

Definition at line 130 of file camera.cpp.

References DeviceNotFound, list_devices(), and open_camera().

Referenced by duvc_open_camera(), duvc_open_camera_by_index(), duvc_quick_get_camera_property(), duvc_quick_get_camera_property_range(), duvc_quick_get_video_property(), duvc_quick_get_video_property_range(), duvc_quick_set_camera_property(), duvc_quick_set_video_property(), and open_camera().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open_device_filter()

com_ptr< IBaseFilter > duvc::open_device_filter ( const Device & dev)

Create DirectShow filter from device.

Parameters
devDevice to open
Returns
COM pointer to IBaseFilter

Definition at line 260 of file core.cpp.

References bind_to_filter(), create_dev_enum(), enum_video_devices(), is_same_device(), read_device_path(), and read_friendly_name().

Referenced by duvc::DeviceConnection::DeviceConnection(), get_vendor_property(), query_vendor_property_support(), and set_vendor_property().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ query_vendor_property_support()

bool duvc::query_vendor_property_support ( const Device & dev,
const GUID & property_set,
ULONG property_id )

Query whether device supports a vendor-specific property.

Parameters
devTarget device to check
property_setProperty set GUID to query
property_idProperty ID within set to query
Returns
true if property is supported for get/set operations, false otherwise

Definition at line 614 of file core.cpp.

References get_property_set(), KSPROPERTY_SUPPORT_GET, KSPROPERTY_SUPPORT_SET, and open_device_filter().

Here is the call graph for this function:

◆ read_device_path()

std::wstring duvc::read_device_path ( IMoniker * mon)

Read device path from moniker.

Parameters
monDevice moniker
Returns
Device path

Definition at line 207 of file core.cpp.

References IID_IPropertyBag, and read_prop_bstr().

Referenced by find_device_by_path(), is_device_connected(), list_devices(), and open_device_filter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_friendly_name()

std::wstring duvc::read_friendly_name ( IMoniker * mon)

Read friendly name from device moniker.

Parameters
monDevice moniker
Returns
Device friendly name

Definition at line 199 of file core.cpp.

References IID_IPropertyBag, and read_prop_bstr().

Referenced by find_device_by_path(), is_device_connected(), list_devices(), and open_device_filter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_prop_bstr() [1/2]

static std::wstring duvc::read_prop_bstr ( IPropertyBag * bag,
const wchar_t * key )
static

Definition at line 189 of file core.cpp.

Referenced by read_device_path(), and read_friendly_name().

Here is the caller graph for this function:

◆ read_prop_bstr() [2/2]

static std::wstring duvc::read_prop_bstr ( IPropertyBag * bag,
const wchar_t * key )
static

Definition at line 54 of file device.cpp.

◆ register_device_change_callback()

void duvc::register_device_change_callback ( DeviceChangeCallback callback)

Register callback for device hotplug events.

Parameters
callbackFunction to call when devices are added/removed

Only one callback can be registered at a time. Calling this multiple times will replace the previous callback.

Definition at line 511 of file core.cpp.

References CLSID_VideoInputDeviceCategory, device_wndproc(), g_device_callback, g_device_notify, and g_notification_window.

Referenced by duvc_register_device_change_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_device_notifications()

static HDEVNOTIFY duvc::register_device_notifications ( HWND hwnd)
static

Register for device interface notifications.

Parameters
hwndWindow to receive notifications
Returns
Device notification handle or nullptr if failed

Definition at line 123 of file device_monitor.cpp.

References CLSID_VideoInputDeviceCategory, DUVC_LOG_ERROR, and DUVC_LOG_INFO.

◆ register_notification_window_class()

static bool duvc::register_notification_window_class ( )
static

Register window class for device notifications.

Returns
true if successful

Definition at line 72 of file device_monitor.cpp.

References device_notification_wndproc(), and DUVC_LOG_ERROR.

Referenced by create_notification_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ release_cached_connection()

void duvc::release_cached_connection ( const Device & dev)

Definition at line 499 of file core.cpp.

References g_cache_mutex, and g_connection_cache.

◆ set_log_callback()

void duvc::set_log_callback ( LogCallback callback)

Set global log callback.

Parameters
callbackCallback function (nullptr to disable logging)

Definition at line 73 of file logging.cpp.

References g_log_callback, and g_log_mutex.

Referenced by duvc_set_log_callback().

Here is the caller graph for this function:

◆ set_log_level()

void duvc::set_log_level ( LogLevel level)

Set minimum log level.

Parameters
levelMinimum level to log

Definition at line 78 of file logging.cpp.

References g_log_mutex, and g_min_log_level.

Referenced by duvc_initialize(), and duvc_set_log_level().

Here is the caller graph for this function:

◆ set_vendor_property()

bool duvc::set_vendor_property ( const Device & dev,
const GUID & property_set,
ULONG property_id,
const std::vector< uint8_t > & data )

Set vendor-specific property data on device.

Parameters
devTarget device to modify
property_setProperty set GUID identifying the extension unit
property_idProperty ID within the extension unit
dataProperty data to write (vendor-specific binary format)
Returns
true if property was written successfully, false on error

Definition at line 602 of file core.cpp.

References get_property_set(), and open_device_filter().

Here is the call graph for this function:

◆ throw_hr()

static void duvc::throw_hr ( HRESULT hr,
const char * where )
static

Definition at line 115 of file core.cpp.

References wide_to_utf8().

Referenced by bind_to_filter(), duvc::com_apartment::com_apartment(), duvc::DeviceConnection::com_apartment::com_apartment(), create_dev_enum(), enum_video_devices(), and find_device_by_path().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_flag() [1/2]

static long duvc::to_flag ( CamMode m,
bool is_camera_control )
static

Definition at line 324 of file core.cpp.

References Auto, CameraControl_Flags_Auto, CameraControl_Flags_Manual, VideoProcAmp_Flags_Auto, and VideoProcAmp_Flags_Manual.

Referenced by duvc::DeviceConnection::set(), and duvc::DeviceConnection::set().

Here is the caller graph for this function:

◆ to_flag() [2/2]

static long duvc::to_flag ( CamMode m,
bool is_camera_control )
static

◆ to_string() [1/5]

const char * duvc::to_string ( CamMode mode)

Convert camera mode enum to string.

Parameters
modeCamera mode to convert
Returns
Mode name as C string ("AUTO" or "MANUAL")

Definition at line 768 of file core.cpp.

References Auto.

◆ to_string() [2/5]

const char * duvc::to_string ( CamProp prop)

Convert camera property enum to string.

Parameters
propCamera property to convert
Returns
Property name as C string

Definition at line 678 of file core.cpp.

References BacklightCompensation, DigitalZoom, DigitalZoomRelative, Exposure, ExposureRelative, Focus, FocusRelative, FocusSimple, Iris, IrisRelative, Lamp, Pan, PanRelative, PanTilt, PanTiltRelative, Privacy, Roll, RollRelative, ScanMode, Tilt, TiltRelative, Zoom, and ZoomRelative.

Referenced by default_log_callback(), duvc::Error::description(), duvc_cam_mode_to_string(), duvc_cam_prop_to_string(), and duvc_vid_prop_to_string().

Here is the caller graph for this function:

◆ to_string() [3/5]

const char * duvc::to_string ( ErrorCode code)

Convert error code to string.

Parameters
codeError code
Returns
Human-readable error description

Definition at line 10 of file result.cpp.

References DeviceBusy, DeviceNotFound, InvalidArgument, InvalidValue, NotImplemented, PermissionDenied, PropertyNotSupported, Success, and SystemError.

◆ to_string() [4/5]

const char * duvc::to_string ( LogLevel level)

Convert log level to string.

Parameters
levelLog level
Returns
Log level name

Definition at line 20 of file logging.cpp.

References Critical, Debug, Error, Info, and Warning.

◆ to_string() [5/5]

const char * duvc::to_string ( VidProp prop)

Convert video property enum to string.

Parameters
propVideo property to convert
Returns
Property name as C string

Definition at line 736 of file core.cpp.

References BacklightCompensation, Brightness, ColorEnable, Contrast, Gain, Gamma, Hue, Saturation, Sharpness, and WhiteBalance.

◆ to_utf8()

std::string duvc::to_utf8 ( const std::wstring & wstr)

Converts a wide string (UTF-16 on Windows) to a UTF-8 string.

Parameters
wstrWide string to convert (UTF-16 encoded on Windows)
Returns
UTF-8 encoded string

Definition at line 181 of file string_conversion.cpp.

Referenced by duvc_register_device_change_callback().

Here is the caller graph for this function:

◆ to_wstring() [1/4]

const wchar_t * duvc::to_wstring ( CamMode mode)

Convert camera mode enum to wide string.

Parameters
modeCamera mode to convert
Returns
Mode name as wide C string (L"AUTO" or L"MANUAL")

Definition at line 772 of file core.cpp.

References Auto.

◆ to_wstring() [2/4]

const wchar_t * duvc::to_wstring ( CamProp prop)

Convert camera property enum to wide string.

Parameters
propCamera property to convert
Returns
Property name as wide C string

Definition at line 707 of file core.cpp.

References BacklightCompensation, DigitalZoom, DigitalZoomRelative, Exposure, ExposureRelative, Focus, FocusRelative, FocusSimple, Iris, IrisRelative, Lamp, Pan, PanRelative, PanTilt, PanTiltRelative, Privacy, Roll, RollRelative, ScanMode, Tilt, TiltRelative, Zoom, and ZoomRelative.

Referenced by duvc_find_device_by_path().

Here is the caller graph for this function:

◆ to_wstring() [3/4]

std::wstring duvc::to_wstring ( const std::string & str)

Converts a UTF-8 string to a wide string (UTF-16 on Windows)

Parameters
strUTF-8 encoded string to convert
Returns
Wide string (UTF-16 encoded on Windows)

Definition at line 196 of file string_conversion.cpp.

◆ to_wstring() [4/4]

const wchar_t * duvc::to_wstring ( VidProp prop)

Convert video property enum to wide string.

Parameters
propVideo property to convert
Returns
Property name as wide C string

Definition at line 752 of file core.cpp.

References BacklightCompensation, Brightness, ColorEnable, Contrast, Gain, Gamma, Hue, Saturation, Sharpness, and WhiteBalance.

◆ unregister_device_change_callback()

void duvc::unregister_device_change_callback ( )

Unregister device change callback.

Stops monitoring device changes and cleans up resources.

Definition at line 537 of file core.cpp.

References g_device_callback, g_device_notify, and g_notification_window.

Referenced by duvc_unregister_device_change_callback().

Here is the caller graph for this function:

◆ vidprop_to_dshow() [1/2]

◆ vidprop_to_dshow() [2/2]

◆ wide_to_utf8()

static std::string duvc::wide_to_utf8 ( const wchar_t * ws)
static

Definition at line 107 of file core.cpp.

Referenced by throw_hr().

Here is the caller graph for this function:

Variable Documentation

◆ g_cache_mutex

std::mutex duvc::g_cache_mutex
static

◆ g_connection_cache

std::unordered_map<std::wstring, std::unique_ptr<DeviceConnection> > duvc::g_connection_cache
static

◆ g_device_callback

◆ g_device_notify

HDEVNOTIFY duvc::g_device_notify = nullptr
static

Definition at line 149 of file core.cpp.

Referenced by register_device_change_callback(), and unregister_device_change_callback().

◆ g_log_callback

LogCallback duvc::g_log_callback = nullptr
static

Definition at line 17 of file logging.cpp.

Referenced by log_message(), and set_log_callback().

◆ g_log_mutex

std::mutex duvc::g_log_mutex
static

Definition at line 16 of file logging.cpp.

Referenced by get_log_level(), log_message(), set_log_callback(), and set_log_level().

◆ g_min_log_level

LogLevel duvc::g_min_log_level = LogLevel::Info
static

Definition at line 18 of file logging.cpp.

Referenced by get_log_level(), log_message(), and set_log_level().

◆ g_notification_window

HWND duvc::g_notification_window = nullptr
static

Definition at line 148 of file core.cpp.

Referenced by register_device_change_callback(), and unregister_device_change_callback().