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

Complete C ABI implementation for duvc-ctl library. More...

#include "duvc-ctl/c/api.h"
#include "duvc-ctl/core/camera.h"
#include "duvc-ctl/core/capability.h"
#include "duvc-ctl/core/device.h"
#include "duvc-ctl/core/result.h"
#include "duvc-ctl/core/types.h"
#include "duvc-ctl/utils/error_decoder.h"
#include "duvc-ctl/utils/logging.h"
#include "duvc-ctl/utils/string_conversion.h"
#include "duvc-ctl/platform/windows/connection_pool.h"
#include <algorithm>
#include <atomic>
#include <cstring>
#include <memory>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
Include dependency graph for api.cpp:

Go to the source code of this file.

Macros

#define DUVC_ABI_VERSION_STRING   "1.0.0"
 

Functions

uint32_t duvc_get_version (void)
 Get library version.
 
const char * duvc_get_version_string (void)
 Get library version string.
 
int duvc_check_abi_compatibility (uint32_t compiled_version)
 Check ABI compatibility.
 
duvc_result_t duvc_initialize (void)
 Initialize library.
 
void duvc_shutdown (void)
 Shutdown library.
 
int duvc_is_initialized (void)
 Check if library is initialized.
 
const char * duvc_error_code_to_string (duvc_result_t code)
 Convert error code to string.
 
const char * duvc_cam_prop_to_string (duvc_cam_prop_t prop)
 Convert camera property to string.
 
const char * duvc_vid_prop_to_string (duvc_vid_prop_t prop)
 Convert video property to string.
 
const char * duvc_cam_mode_to_string (duvc_cam_mode_t mode)
 Convert camera mode to string.
 
const char * duvc_log_level_to_string (duvc_log_level_t level)
 Convert log level to string.
 
duvc_result_t duvc_set_log_callback (duvc_log_callback callback, void *user_data)
 Set log callback.
 
duvc_result_t duvc_set_log_level (duvc_log_level_t level)
 Set minimum log level.
 
duvc_result_t duvc_get_log_level (duvc_log_level_t *level)
 Get current log level.
 
duvc_result_t duvc_log_message (duvc_log_level_t level, const char *message)
 Log message at specific level.
 
duvc_result_t duvc_log_debug (const char *message)
 Log debug message.
 
duvc_result_t duvc_log_info (const char *message)
 Log info message.
 
duvc_result_t duvc_log_warning (const char *message)
 Log warning message.
 
duvc_result_t duvc_log_error (const char *message)
 Log error message.
 
duvc_result_t duvc_log_critical (const char *message)
 Log critical message.
 
duvc_result_t duvc_list_devices (duvc_device_t ***devices, size_t *count)
 List all connected devices.
 
duvc_result_t duvc_find_device_by_path (const char *device_path_utf8, duvc_device_t **device)
 Find device by unique Windows device path.
 
void duvc_free_device_list (duvc_device_t **devices, size_t count)
 Free device list.
 
duvc_result_t duvc_is_device_connected (const duvc_device_t *device, int *connected)
 Check if device is connected.
 
duvc_result_t duvc_get_device_name (const duvc_device_t *device, char *buffer, size_t buffer_size, size_t *required)
 Get device name.
 
duvc_result_t duvc_get_device_path (const duvc_device_t *device, char *buffer, size_t buffer_size, size_t *required)
 Get device path.
 
duvc_result_t duvc_get_device_id (const duvc_device_t *device, char *buffer, size_t buffer_size, size_t *required)
 Get device ID.
 
duvc_result_t duvc_device_is_valid (const duvc_device_t *device, int *valid)
 Check if device is valid.
 
duvc_result_t duvc_register_device_change_callback (duvc_device_change_callback callback, void *user_data)
 Register device change callback.
 
void duvc_unregister_device_change_callback (void)
 Unregister device change callback.
 
duvc_result_t duvc_open_camera_by_index (int device_index, duvc_connection_t **conn)
 Open camera by device index.
 
duvc_result_t duvc_open_camera (const duvc_device_t *device, duvc_connection_t **conn)
 Open camera by device handle.
 
void duvc_close_camera (duvc_connection_t *conn)
 Close camera connection.
 
int duvc_camera_is_valid (const duvc_connection_t *conn)
 Check if camera connection is valid.
 
duvc_result_t duvc_get_camera_property (duvc_connection_t *conn, duvc_cam_prop_t prop, duvc_prop_setting_t *setting)
 Get camera property value.
 
duvc_result_t duvc_set_camera_property (duvc_connection_t *conn, duvc_cam_prop_t prop, const duvc_prop_setting_t *setting)
 Set camera property value.
 
duvc_result_t duvc_get_camera_property_range (duvc_connection_t *conn, duvc_cam_prop_t prop, duvc_prop_range_t *range)
 Get camera property range.
 
duvc_result_t duvc_get_video_property (duvc_connection_t *conn, duvc_vid_prop_t prop, duvc_prop_setting_t *setting)
 Get video property value.
 
duvc_result_t duvc_set_video_property (duvc_connection_t *conn, duvc_vid_prop_t prop, const duvc_prop_setting_t *setting)
 Set video property value.
 
duvc_result_t duvc_get_video_property_range (duvc_connection_t *conn, duvc_vid_prop_t prop, duvc_prop_range_t *range)
 Get video property range.
 
duvc_result_t duvc_get_multiple_camera_properties (duvc_connection_t *conn, const duvc_cam_prop_t *props, duvc_prop_setting_t *settings, size_t count)
 Get multiple camera properties.
 
duvc_result_t duvc_set_multiple_camera_properties (duvc_connection_t *conn, const duvc_cam_prop_t *props, const duvc_prop_setting_t *settings, size_t count)
 Set multiple camera properties.
 
duvc_result_t duvc_get_multiple_video_properties (duvc_connection_t *conn, const duvc_vid_prop_t *props, duvc_prop_setting_t *settings, size_t count)
 Get multiple video properties.
 
duvc_result_t duvc_set_multiple_video_properties (duvc_connection_t *conn, const duvc_vid_prop_t *props, const duvc_prop_setting_t *settings, size_t count)
 Set multiple video properties.
 
duvc_result_t duvc_quick_get_camera_property (const duvc_device_t *device, duvc_cam_prop_t prop, duvc_prop_setting_t *setting)
 Quick get camera property (creates temporary connection)
 
duvc_result_t duvc_quick_set_camera_property (const duvc_device_t *device, duvc_cam_prop_t prop, const duvc_prop_setting_t *setting)
 Quick set camera property (creates temporary connection)
 
duvc_result_t duvc_quick_get_camera_property_range (const duvc_device_t *device, duvc_cam_prop_t prop, duvc_prop_range_t *range)
 Quick get camera property range.
 
duvc_result_t duvc_quick_get_video_property (const duvc_device_t *device, duvc_vid_prop_t prop, duvc_prop_setting_t *setting)
 Quick get video property.
 
duvc_result_t duvc_quick_set_video_property (const duvc_device_t *device, duvc_vid_prop_t prop, const duvc_prop_setting_t *setting)
 Quick set video property.
 
duvc_result_t duvc_quick_get_video_property_range (const duvc_device_t *device, duvc_vid_prop_t prop, duvc_prop_range_t *range)
 Quick get video property range.
 
duvc_result_t duvc_get_device_capabilities (const duvc_device_t *device, duvc_device_capabilities_t **caps)
 Get device capabilities snapshot.
 
duvc_result_t duvc_get_device_capabilities_by_index (int device_index, duvc_device_capabilities_t **caps)
 Get device capabilities by index.
 
void duvc_free_device_capabilities (duvc_device_capabilities_t *caps)
 Free device capabilities.
 
duvc_result_t duvc_refresh_device_capabilities (duvc_device_capabilities_t *caps)
 Refresh capabilities snapshot.
 
duvc_result_t duvc_get_camera_capability (const duvc_device_capabilities_t *caps, duvc_cam_prop_t prop, duvc_prop_range_t *range, duvc_prop_setting_t *current)
 Get camera property capability.
 
duvc_result_t duvc_get_video_capability (const duvc_device_capabilities_t *caps, duvc_vid_prop_t prop, duvc_prop_range_t *range, duvc_prop_setting_t *current)
 Get video property capability.
 
duvc_result_t duvc_supports_camera_property (const duvc_device_capabilities_t *caps, duvc_cam_prop_t prop, int *supported)
 Check if camera property is supported.
 
duvc_result_t duvc_supports_video_property (const duvc_device_capabilities_t *caps, duvc_vid_prop_t prop, int *supported)
 Check if video property is supported.
 
duvc_result_t duvc_get_supported_camera_properties (const duvc_device_capabilities_t *caps, duvc_cam_prop_t *props, size_t max_count, size_t *actual_count)
 Get list of supported camera properties.
 
duvc_result_t duvc_get_supported_video_properties (const duvc_device_capabilities_t *caps, duvc_vid_prop_t *props, size_t max_count, size_t *actual_count)
 Get list of supported video properties.
 
duvc_result_t duvc_capabilities_is_device_accessible (const duvc_device_capabilities_t *caps, int *accessible)
 Check if device is accessible.
 
duvc_result_t duvc_prop_range_is_valid (const duvc_prop_range_t *range, int32_t value, int *valid)
 Check if value is valid for range.
 
duvc_result_t duvc_prop_range_clamp (const duvc_prop_range_t *range, int32_t value, int32_t *clamped_value)
 Clamp value to valid range.
 
duvc_result_t duvc_prop_capability_supports_auto (const duvc_prop_range_t *range, int *supports_auto)
 Check if property supports auto mode.
 
duvc_result_t duvc_get_last_error_details (char *buffer, size_t buffer_size, size_t *required_size)
 Get last error details.
 
void duvc_clear_last_error (void)
 Clear last error information.
 

Detailed Description

Complete C ABI implementation for duvc-ctl library.

This file implements the comprehensive C ABI interface, providing a stable C-compatible API that bridges to the underlying C++ implementation. All C++ exceptions are caught and converted to appropriate C error codes. Memory management is handled appropriately for C consumers.

Definition in file api.cpp.

Macro Definition Documentation

◆ DUVC_ABI_VERSION_STRING

#define DUVC_ABI_VERSION_STRING   "1.0.0"

Definition at line 41 of file api.cpp.

Referenced by duvc_get_version_string().

Function Documentation

◆ duvc_cam_mode_to_string()

const char * duvc_cam_mode_to_string ( duvc_cam_mode_t mode)

Convert camera mode to string.

Parameters
modeCamera mode to convert
Returns
Null-terminated mode name string (statically allocated)

Definition at line 381 of file api.cpp.

References duvc::to_string().

Here is the call graph for this function:

◆ duvc_cam_prop_to_string()

const char * duvc_cam_prop_to_string ( duvc_cam_prop_t prop)

Convert camera property to string.

Parameters
propCamera property to convert
Returns
Null-terminated property name string (statically allocated)

Definition at line 372 of file api.cpp.

References duvc::to_string().

Here is the call graph for this function:

◆ duvc_camera_is_valid()

int duvc_camera_is_valid ( const duvc_connection_t * conn)

Check if camera connection is valid.

Parameters
connConnection to check
Returns
1 if valid, 0 if not

Definition at line 854 of file api.cpp.

◆ duvc_capabilities_is_device_accessible()

duvc_result_t duvc_capabilities_is_device_accessible ( const duvc_device_capabilities_t * caps,
int * accessible )

Check if device is accessible.

Parameters
capsDevice capabilities handle
[out]accessible1 if accessible, 0 if not
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1718 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::DeviceCapabilities::is_device_accessible().

Here is the call graph for this function:

◆ duvc_check_abi_compatibility()

int duvc_check_abi_compatibility ( uint32_t compiled_version)

Check ABI compatibility.

Parameters
compiled_versionVersion the application was compiled with (use DUVC_ABI_VERSION)
Returns
1 if compatible, 0 if incompatible

Definition at line 238 of file api.cpp.

References duvc_get_version().

Here is the call graph for this function:

◆ duvc_clear_last_error()

void duvc_clear_last_error ( void )

Clear last error information.

Note
Clears any stored error details from previous operations

Definition at line 1845 of file api.cpp.

◆ duvc_close_camera()

void duvc_close_camera ( duvc_connection_t * conn)

Close camera connection.

Parameters
connConnection to close

Definition at line 838 of file api.cpp.

◆ duvc_device_is_valid()

duvc_result_t duvc_device_is_valid ( const duvc_device_t * device,
int * valid )

Check if device is valid.

Parameters
deviceDevice to check
[out]valid1 if valid, 0 if not
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 690 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::Device::is_valid().

Here is the call graph for this function:

◆ duvc_error_code_to_string()

const char * duvc_error_code_to_string ( duvc_result_t code)

Convert error code to string.

Parameters
codeError code to convert
Returns
Null-terminated error description string (statically allocated)

Definition at line 341 of file api.cpp.

References DUVC_ERROR_BUFFER_TOO_SMALL, DUVC_ERROR_CONNECTION_FAILED, DUVC_ERROR_DEVICE_BUSY, DUVC_ERROR_DEVICE_NOT_FOUND, DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_INVALID_VALUE, DUVC_ERROR_NOT_IMPLEMENTED, DUVC_ERROR_PERMISSION_DENIED, DUVC_ERROR_PROPERTY_NOT_SUPPORTED, DUVC_ERROR_SYSTEM_ERROR, DUVC_ERROR_TIMEOUT, and DUVC_SUCCESS.

Referenced by duvc_get_error_statistics(), and duvc_suggest_error_resolution().

Here is the caller graph for this function:

◆ duvc_find_device_by_path()

duvc_result_t duvc_find_device_by_path ( const char * device_path_utf8,
duvc_device_t ** device )

Find device by unique Windows device path.

Parameters
device_path_utf8UTF-8 encoded Windows device path
[out]devicePointer to receive found device handle
Returns
DUVC_SUCCESS on success, DUVC_ERROR_DEVICE_NOT_FOUND if not found

Provides precise device selection when multiple cameras share names/VID/PID. The device path format is: USB\VID_XXXX&PID_XXXX&MI_XX#...#{GUID}

Note
Device is managed by library - do not free manually
See also
duvc_list_devices() to obtain device paths
duvc_get_device_path() to extract path from device

Definition at line 556 of file api.cpp.

References DUVC_ERROR_DEVICE_NOT_FOUND, DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, duvc::find_device_by_path(), and duvc::to_wstring().

Here is the call graph for this function:

◆ duvc_free_device_capabilities()

void duvc_free_device_capabilities ( duvc_device_capabilities_t * caps)

Free device capabilities.

Parameters
capsCapabilities handle to free

Definition at line 1477 of file api.cpp.

◆ duvc_free_device_list()

void duvc_free_device_list ( duvc_device_t ** devices,
size_t count )

Free device list.

Parameters
devicesDevice array to free
countNumber of devices in array

Definition at line 590 of file api.cpp.

◆ duvc_get_camera_capability()

duvc_result_t duvc_get_camera_capability ( const duvc_device_capabilities_t * caps,
duvc_cam_prop_t prop,
duvc_prop_range_t * range,
duvc_prop_setting_t * current )

Get camera property capability.

Parameters
capsDevice capabilities handle
propCamera property to query
[out]rangeProperty range (can be NULL if not needed)
[out]currentCurrent property value (can be NULL if not needed)
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1525 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_PROPERTY_NOT_SUPPORTED, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::DeviceCapabilities::get_camera_capability().

Here is the call graph for this function:

◆ duvc_get_camera_property()

duvc_result_t duvc_get_camera_property ( duvc_connection_t * conn,
duvc_cam_prop_t prop,
duvc_prop_setting_t * setting )

Get camera property value.

Parameters
connCamera connection
propCamera property to query
[out]settingProperty setting (value and mode)
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 875 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, and DUVC_SUCCESS.

◆ duvc_get_camera_property_range()

duvc_result_t duvc_get_camera_property_range ( duvc_connection_t * conn,
duvc_cam_prop_t prop,
duvc_prop_range_t * range )

Get camera property range.

Parameters
connCamera connection
propCamera property to query
[out]rangeProperty range information
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 935 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, and DUVC_SUCCESS.

◆ duvc_get_device_capabilities()

duvc_result_t duvc_get_device_capabilities ( const duvc_device_t * device,
duvc_device_capabilities_t ** caps )

Get device capabilities snapshot.

Parameters
deviceDevice to analyze
[out]capsPointer to receive capabilities handle
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1412 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::get_device_capabilities().

Here is the call graph for this function:

◆ duvc_get_device_capabilities_by_index()

duvc_result_t duvc_get_device_capabilities_by_index ( int device_index,
duvc_device_capabilities_t ** caps )

Get device capabilities by index.

Parameters
device_indexDevice index from duvc_list_devices()
[out]capsPointer to receive capabilities handle
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1446 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::get_device_capabilities().

Here is the call graph for this function:

◆ duvc_get_device_id()

duvc_result_t duvc_get_device_id ( const duvc_device_t * device,
char * buffer,
size_t buffer_size,
size_t * required )

Get device ID.

Parameters
deviceDevice to query
[out]bufferBuffer to receive ID
buffer_sizeSize of buffer in bytes
[out]requiredRequired buffer size (including null terminator)
Returns
DUVC_SUCCESS on success, DUVC_ERROR_BUFFER_TOO_SMALL if buffer too small

Definition at line 668 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, duvc::Device::name, and duvc::Device::path.

◆ duvc_get_device_name()

duvc_result_t duvc_get_device_name ( const duvc_device_t * device,
char * buffer,
size_t buffer_size,
size_t * required )

Get device name.

Parameters
deviceDevice to query
[out]bufferBuffer to receive name
buffer_sizeSize of buffer in bytes
[out]requiredRequired buffer size (including null terminator)
Returns
DUVC_SUCCESS on success, DUVC_ERROR_BUFFER_TOO_SMALL if buffer too small

Definition at line 626 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, and duvc::Device::name.

◆ duvc_get_device_path()

duvc_result_t duvc_get_device_path ( const duvc_device_t * device,
char * buffer,
size_t buffer_size,
size_t * required )

Get device path.

Parameters
deviceDevice to query
[out]bufferBuffer to receive path
buffer_sizeSize of buffer in bytes
[out]requiredRequired buffer size (including null terminator)
Returns
DUVC_SUCCESS on success, DUVC_ERROR_BUFFER_TOO_SMALL if buffer too small

Definition at line 647 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, and duvc::Device::path.

◆ duvc_get_last_error_details()

duvc_result_t duvc_get_last_error_details ( char * buffer,
size_t buffer_size,
size_t * required_size )

Get last error details.

Parameters
[out]bufferBuffer to receive error details
buffer_sizeSize of buffer in bytes
[out]required_sizeRequired buffer size (including null terminator)
Returns
DUVC_SUCCESS on success, DUVC_ERROR_BUFFER_TOO_SMALL if buffer too small

Definition at line 1839 of file api.cpp.

◆ duvc_get_log_level()

duvc_result_t duvc_get_log_level ( duvc_log_level_t * level)

Get current log level.

Parameters
[out]levelCurrent minimum log level
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 449 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::get_log_level().

Here is the call graph for this function:

◆ duvc_get_multiple_camera_properties()

duvc_result_t duvc_get_multiple_camera_properties ( duvc_connection_t * conn,
const duvc_cam_prop_t * props,
duvc_prop_setting_t * settings,
size_t count )

Get multiple camera properties.

Parameters
connCamera connection
propsArray of camera properties to query
[out]settingsArray to receive property settings
countNumber of properties in arrays
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1063 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::Camera::get().

Here is the call graph for this function:

◆ duvc_get_multiple_video_properties()

duvc_result_t duvc_get_multiple_video_properties ( duvc_connection_t * conn,
const duvc_vid_prop_t * props,
duvc_prop_setting_t * settings,
size_t count )

Get multiple video properties.

Parameters
connCamera connection
propsArray of video properties to query
[out]settingsArray to receive property settings
countNumber of properties in arrays
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1138 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::Camera::get().

Here is the call graph for this function:

◆ duvc_get_supported_camera_properties()

duvc_result_t duvc_get_supported_camera_properties ( const duvc_device_capabilities_t * caps,
duvc_cam_prop_t * props,
size_t max_count,
size_t * actual_count )

Get list of supported camera properties.

Parameters
capsDevice capabilities handle
[out]propsArray to receive supported properties
max_countMaximum number of properties that can be stored
[out]actual_countActual number of supported properties
Returns
DUVC_SUCCESS on success, DUVC_ERROR_BUFFER_TOO_SMALL if array too small

Definition at line 1648 of file api.cpp.

References DUVC_ERROR_BUFFER_TOO_SMALL, DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::DeviceCapabilities::supported_camera_properties().

Here is the call graph for this function:

◆ duvc_get_supported_video_properties()

duvc_result_t duvc_get_supported_video_properties ( const duvc_device_capabilities_t * caps,
duvc_vid_prop_t * props,
size_t max_count,
size_t * actual_count )

Get list of supported video properties.

Parameters
capsDevice capabilities handle
[out]propsArray to receive supported properties
max_countMaximum number of properties that can be stored
[out]actual_countActual number of supported properties
Returns
DUVC_SUCCESS on success, DUVC_ERROR_BUFFER_TOO_SMALL if array too small

Definition at line 1683 of file api.cpp.

References DUVC_ERROR_BUFFER_TOO_SMALL, DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::DeviceCapabilities::supported_video_properties().

Here is the call graph for this function:

◆ duvc_get_version()

uint32_t duvc_get_version ( void )

Get library version.

Get runtime library version.

Returns
Combined version number as returned by DUVC_ABI_VERSION macro

Definition at line 234 of file api.cpp.

References DUVC_ABI_VERSION.

Referenced by duvc_check_abi_compatibility().

Here is the caller graph for this function:

◆ duvc_get_version_string()

const char * duvc_get_version_string ( void )

Get library version string.

Get runtime library version string.

Returns
Null-terminated version string (e.g., "1.0.0")
Note
Returned string is statically allocated and should not be freed

Definition at line 236 of file api.cpp.

References DUVC_ABI_VERSION_STRING.

◆ duvc_get_video_capability()

duvc_result_t duvc_get_video_capability ( const duvc_device_capabilities_t * caps,
duvc_vid_prop_t prop,
duvc_prop_range_t * range,
duvc_prop_setting_t * current )

Get video property capability.

Parameters
capsDevice capabilities handle
propVideo property to query
[out]rangeProperty range (can be NULL if not needed)
[out]currentCurrent property value (can be NULL if not needed)
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1563 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_PROPERTY_NOT_SUPPORTED, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::DeviceCapabilities::get_video_capability().

Here is the call graph for this function:

◆ duvc_get_video_property()

duvc_result_t duvc_get_video_property ( duvc_connection_t * conn,
duvc_vid_prop_t prop,
duvc_prop_setting_t * setting )

Get video property value.

Parameters
connCamera connection
propVideo property to query
[out]settingProperty setting (value and mode)
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 967 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, and DUVC_SUCCESS.

◆ duvc_get_video_property_range()

duvc_result_t duvc_get_video_property_range ( duvc_connection_t * conn,
duvc_vid_prop_t prop,
duvc_prop_range_t * range )

Get video property range.

Parameters
connCamera connection
propVideo property to query
[out]rangeProperty range information
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1027 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, and DUVC_SUCCESS.

◆ duvc_initialize()

duvc_result_t duvc_initialize ( void )

Initialize library.

Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 261 of file api.cpp.

References DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, duvc::Info, duvc::log_info(), and duvc::set_log_level().

Here is the call graph for this function:

◆ duvc_is_device_connected()

duvc_result_t duvc_is_device_connected ( const duvc_device_t * device,
int * connected )

Check if device is connected.

Parameters
deviceDevice to check
[out]connected1 if connected, 0 if not
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 600 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::is_device_connected().

Here is the call graph for this function:

◆ duvc_is_initialized()

int duvc_is_initialized ( void )

Check if library is initialized.

Returns
1 if initialized, 0 if not

Definition at line 335 of file api.cpp.

◆ duvc_list_devices()

duvc_result_t duvc_list_devices ( duvc_device_t *** devices,
size_t * count )

List all connected devices.

Parameters
[out]devicesPointer to receive device array
[out]countNumber of devices found
Returns
DUVC_SUCCESS on success, error code on failure
Note
Caller must free with duvc_free_device_list()

Definition at line 510 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::list_devices().

Here is the call graph for this function:

◆ duvc_log_critical()

duvc_result_t duvc_log_critical ( const char * message)

Log critical message.

Parameters
messageCritical message to log
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 502 of file api.cpp.

References DUVC_LOG_CRITICAL, and duvc_log_message().

Here is the call graph for this function:

◆ duvc_log_debug()

duvc_result_t duvc_log_debug ( const char * message)

Log debug message.

Parameters
messageDebug message to log
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 486 of file api.cpp.

References DUVC_LOG_DEBUG, and duvc_log_message().

Here is the call graph for this function:

◆ duvc_log_error()

duvc_result_t duvc_log_error ( const char * message)

Log error message.

Parameters
messageError message to log
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 498 of file api.cpp.

References DUVC_LOG_ERROR, and duvc_log_message().

Here is the call graph for this function:

◆ duvc_log_info()

duvc_result_t duvc_log_info ( const char * message)

Log info message.

Parameters
messageInfo message to log
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 490 of file api.cpp.

References DUVC_LOG_INFO, and duvc_log_message().

Here is the call graph for this function:

◆ duvc_log_level_to_string()

const char * duvc_log_level_to_string ( duvc_log_level_t level)

Convert log level to string.

Parameters
levelLog level to convert
Returns
Null-terminated log level name string (statically allocated)

Definition at line 385 of file api.cpp.

References DUVC_LOG_CRITICAL, DUVC_LOG_DEBUG, DUVC_LOG_ERROR, DUVC_LOG_INFO, and DUVC_LOG_WARNING.

◆ duvc_log_message()

duvc_result_t duvc_log_message ( duvc_log_level_t level,
const char * message )

Log message at specific level.

Parameters
levelLog level
messageMessage to log
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 467 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::log_message().

Referenced by duvc_log_critical(), duvc_log_debug(), duvc_log_error(), duvc_log_info(), and duvc_log_warning().

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

◆ duvc_log_warning()

duvc_result_t duvc_log_warning ( const char * message)

Log warning message.

Parameters
messageWarning message to log
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 494 of file api.cpp.

References duvc_log_message(), and DUVC_LOG_WARNING.

Here is the call graph for this function:

◆ duvc_open_camera()

duvc_result_t duvc_open_camera ( const duvc_device_t * device,
duvc_connection_t ** conn )

Open camera by device handle.

Parameters
deviceDevice to connect to
[out]connPointer to receive connection handle
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 806 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::open_camera().

Here is the call graph for this function:

◆ duvc_open_camera_by_index()

duvc_result_t duvc_open_camera_by_index ( int device_index,
duvc_connection_t ** conn )

Open camera by device index.

Parameters
device_indexIndex from duvc_list_devices()
[out]connPointer to receive connection handle
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 775 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::open_camera().

Here is the call graph for this function:

◆ duvc_prop_capability_supports_auto()

duvc_result_t duvc_prop_capability_supports_auto ( const duvc_prop_range_t * range,
int * supports_auto )

Check if property supports auto mode.

Parameters
rangeProperty range to check
[out]supports_auto1 if auto mode supported, 0 if not
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1818 of file api.cpp.

References duvc_prop_range_t::default_mode, DUVC_CAM_MODE_AUTO, DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, and DUVC_SUCCESS.

◆ duvc_prop_range_clamp()

duvc_result_t duvc_prop_range_clamp ( const duvc_prop_range_t * range,
int32_t value,
int32_t * clamped_value )

Clamp value to valid range.

Parameters
rangeProperty range to clamp to
valueValue to clamp
[out]clamped_valueClamped value within range
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1774 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, duvc_prop_range_t::max, duvc_prop_range_t::min, and duvc_prop_range_t::step.

◆ duvc_prop_range_is_valid()

duvc_result_t duvc_prop_range_is_valid ( const duvc_prop_range_t * range,
int32_t value,
int * valid )

Check if value is valid for range.

Parameters
rangeProperty range to check against
valueValue to validate
[out]valid1 if valid, 0 if not
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1743 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, duvc_prop_range_t::max, duvc_prop_range_t::min, and duvc_prop_range_t::step.

◆ duvc_quick_get_camera_property()

duvc_result_t duvc_quick_get_camera_property ( const duvc_device_t * device,
duvc_cam_prop_t prop,
duvc_prop_setting_t * setting )

Quick get camera property (creates temporary connection)

Parameters
deviceDevice to query
propCamera property to get
[out]settingProperty setting (value and mode)
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1217 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::open_camera().

Here is the call graph for this function:

◆ duvc_quick_get_camera_property_range()

duvc_result_t duvc_quick_get_camera_property_range ( const duvc_device_t * device,
duvc_cam_prop_t prop,
duvc_prop_range_t * range )

Quick get camera property range.

Parameters
deviceDevice to query
propCamera property to query
[out]rangeProperty range information
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1280 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::open_camera().

Here is the call graph for this function:

◆ duvc_quick_get_video_property()

duvc_result_t duvc_quick_get_video_property ( const duvc_device_t * device,
duvc_vid_prop_t prop,
duvc_prop_setting_t * setting )

Quick get video property.

Parameters
deviceDevice to query
propVideo property to get
[out]settingProperty setting (value and mode)
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1313 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::open_camera().

Here is the call graph for this function:

◆ duvc_quick_get_video_property_range()

duvc_result_t duvc_quick_get_video_property_range ( const duvc_device_t * device,
duvc_vid_prop_t prop,
duvc_prop_range_t * range )

Quick get video property range.

Parameters
deviceDevice to query
propVideo property to query
[out]rangeProperty range information
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1375 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::open_camera().

Here is the call graph for this function:

◆ duvc_quick_set_camera_property()

duvc_result_t duvc_quick_set_camera_property ( const duvc_device_t * device,
duvc_cam_prop_t prop,
const duvc_prop_setting_t * setting )

Quick set camera property (creates temporary connection)

Parameters
deviceDevice to modify
propCamera property to set
settingProperty setting to apply
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1251 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, and duvc::open_camera().

Here is the call graph for this function:

◆ duvc_quick_set_video_property()

duvc_result_t duvc_quick_set_video_property ( const duvc_device_t * device,
duvc_vid_prop_t prop,
const duvc_prop_setting_t * setting )

Quick set video property.

Parameters
deviceDevice to modify
propVideo property to set
settingProperty setting to apply
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1347 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, and duvc::open_camera().

Here is the call graph for this function:

◆ duvc_refresh_device_capabilities()

duvc_result_t duvc_refresh_device_capabilities ( duvc_device_capabilities_t * caps)

Refresh capabilities snapshot.

Parameters
capsCapabilities handle to refresh
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1500 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, and duvc::DeviceCapabilities::refresh().

Here is the call graph for this function:

◆ duvc_register_device_change_callback()

duvc_result_t duvc_register_device_change_callback ( duvc_device_change_callback callback,
void * user_data )

Register device change callback.

Parameters
callbackCallback function to register
user_dataUser data to pass to callback
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 715 of file api.cpp.

References DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, duvc::register_device_change_callback(), and duvc::to_utf8().

Here is the call graph for this function:

◆ duvc_set_camera_property()

duvc_result_t duvc_set_camera_property ( duvc_connection_t * conn,
duvc_cam_prop_t prop,
const duvc_prop_setting_t * setting )

Set camera property value.

Parameters
connCamera connection
propCamera property to set
settingProperty setting to apply
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 907 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, and DUVC_ERROR_SYSTEM_ERROR.

◆ duvc_set_log_callback()

duvc_result_t duvc_set_log_callback ( duvc_log_callback callback,
void * user_data )

Set log callback.

Parameters
callbackLog callback function (NULL to disable logging)
user_dataUser data passed to callback
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 406 of file api.cpp.

References DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::set_log_callback().

Here is the call graph for this function:

◆ duvc_set_log_level()

duvc_result_t duvc_set_log_level ( duvc_log_level_t level)

Set minimum log level.

Parameters
levelMinimum level to log
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 432 of file api.cpp.

References DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::set_log_level().

Here is the call graph for this function:

◆ duvc_set_multiple_camera_properties()

duvc_result_t duvc_set_multiple_camera_properties ( duvc_connection_t * conn,
const duvc_cam_prop_t * props,
const duvc_prop_setting_t * settings,
size_t count )

Set multiple camera properties.

Parameters
connCamera connection
propsArray of camera properties to set
settingsArray of property settings to apply
countNumber of properties in arrays
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1101 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, duvc::Camera::get(), and duvc::Camera::set().

Here is the call graph for this function:

◆ duvc_set_multiple_video_properties()

duvc_result_t duvc_set_multiple_video_properties ( duvc_connection_t * conn,
const duvc_vid_prop_t * props,
const duvc_prop_setting_t * settings,
size_t count )

Set multiple video properties.

Parameters
connCamera connection
propsArray of video properties to set
settingsArray of property settings to apply
countNumber of properties in arrays
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1176 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, duvc::Camera::get(), and duvc::Camera::set().

Here is the call graph for this function:

◆ duvc_set_video_property()

duvc_result_t duvc_set_video_property ( duvc_connection_t * conn,
duvc_vid_prop_t prop,
const duvc_prop_setting_t * setting )

Set video property value.

Parameters
connCamera connection
propVideo property to set
settingProperty setting to apply
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 999 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, and DUVC_ERROR_SYSTEM_ERROR.

◆ duvc_shutdown()

void duvc_shutdown ( void )

Shutdown library.

Note
Cleans up all resources and connections

Definition at line 293 of file api.cpp.

References duvc_unregister_device_change_callback().

Here is the call graph for this function:

◆ duvc_supports_camera_property()

duvc_result_t duvc_supports_camera_property ( const duvc_device_capabilities_t * caps,
duvc_cam_prop_t prop,
int * supported )

Check if camera property is supported.

Parameters
capsDevice capabilities handle
propCamera property to check
[out]supported1 if supported, 0 if not
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1602 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::DeviceCapabilities::supports_camera_property().

Here is the call graph for this function:

◆ duvc_supports_video_property()

duvc_result_t duvc_supports_video_property ( const duvc_device_capabilities_t * caps,
duvc_vid_prop_t prop,
int * supported )

Check if video property is supported.

Parameters
capsDevice capabilities handle
propVideo property to check
[out]supported1 if supported, 0 if not
Returns
DUVC_SUCCESS on success, error code on failure

Definition at line 1625 of file api.cpp.

References DUVC_ERROR_INVALID_ARGUMENT, DUVC_ERROR_SYSTEM_ERROR, DUVC_SUCCESS, and duvc::DeviceCapabilities::supports_video_property().

Here is the call graph for this function:

◆ duvc_unregister_device_change_callback()

void duvc_unregister_device_change_callback ( void )

Unregister device change callback.

Note
Stops monitoring device changes and cleans up resources

Definition at line 752 of file api.cpp.

References duvc::unregister_device_change_callback().

Referenced by duvc_shutdown().

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

◆ duvc_vid_prop_to_string()

const char * duvc_vid_prop_to_string ( duvc_vid_prop_t prop)

Convert video property to string.

Parameters
propVideo property to convert
Returns
Null-terminated property name string (statically allocated)

Definition at line 377 of file api.cpp.

References duvc::to_string().

Here is the call graph for this function: