1 #ifndef LIBUVC_H 2 #define LIBUVC_H 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 #include <stdio.h> // FILE 9 #include <stdint.h> 10 #include <sys/time.h> 11 #include <libuvc/libuvc_config.h> 12 13 struct libusb_context; 14 struct libusb_device_handle; 15 16 /** UVC error types, based on libusb errors 17 * @ingroup diag 18 */ 19 typedef enum uvc_error { 20 /** Success (no error) */ 21 UVC_SUCCESS = 0, 22 /** Input/output error */ 23 UVC_ERROR_IO = -1, 24 /** Invalid parameter */ 25 UVC_ERROR_INVALID_PARAM = -2, 26 /** Access denied */ 27 UVC_ERROR_ACCESS = -3, 28 /** No such device */ 29 UVC_ERROR_NO_DEVICE = -4, 30 /** Entity not found */ 31 UVC_ERROR_NOT_FOUND = -5, 32 /** Resource busy */ 33 UVC_ERROR_BUSY = -6, 34 /** Operation timed out */ 35 UVC_ERROR_TIMEOUT = -7, 36 /** Overflow */ 37 UVC_ERROR_OVERFLOW = -8, 38 /** Pipe error */ 39 UVC_ERROR_PIPE = -9, 40 /** System call interrupted */ 41 UVC_ERROR_INTERRUPTED = -10, 42 /** Insufficient memory */ 43 UVC_ERROR_NO_MEM = -11, 44 /** Operation not supported */ 45 UVC_ERROR_NOT_SUPPORTED = -12, 46 /** Device is not UVC-compliant */ 47 UVC_ERROR_INVALID_DEVICE = -50, 48 /** Mode not supported */ 49 UVC_ERROR_INVALID_MODE = -51, 50 /** Resource has a callback (can't use polling and async) */ 51 UVC_ERROR_CALLBACK_EXISTS = -52, 52 /** Undefined error */ 53 UVC_ERROR_OTHER = -99 54 } uvc_error_t; 55 56 /** Color coding of stream, transport-independent 57 * @ingroup streaming 58 */ 59 enum uvc_frame_format { 60 UVC_FRAME_FORMAT_UNKNOWN = 0, 61 /** Any supported format */ 62 UVC_FRAME_FORMAT_ANY = 0, 63 UVC_FRAME_FORMAT_UNCOMPRESSED, 64 UVC_FRAME_FORMAT_COMPRESSED, 65 /** YUYV/YUV2/YUV422: YUV encoding with one luminance value per pixel and 66 * one UV (chrominance) pair for every two pixels. 67 */ 68 UVC_FRAME_FORMAT_YUYV, 69 UVC_FRAME_FORMAT_UYVY, 70 /** 24-bit RGB */ 71 UVC_FRAME_FORMAT_RGB, 72 UVC_FRAME_FORMAT_BGR, 73 /** Motion-JPEG (or JPEG) encoded images */ 74 UVC_FRAME_FORMAT_MJPEG, 75 UVC_FRAME_FORMAT_H264, 76 /** Greyscale images */ 77 UVC_FRAME_FORMAT_GRAY8, 78 UVC_FRAME_FORMAT_GRAY16, 79 /* Raw colour mosaic images */ 80 UVC_FRAME_FORMAT_BY8, 81 UVC_FRAME_FORMAT_BA81, 82 UVC_FRAME_FORMAT_SGRBG8, 83 UVC_FRAME_FORMAT_SGBRG8, 84 UVC_FRAME_FORMAT_SRGGB8, 85 UVC_FRAME_FORMAT_SBGGR8, 86 /** YUV420: NV12 */ 87 UVC_FRAME_FORMAT_NV12, 88 /** Number of formats understood */ 89 UVC_FRAME_FORMAT_COUNT, 90 }; 91 92 /* UVC_COLOR_FORMAT_* have been replaced with UVC_FRAME_FORMAT_*. Please use 93 * UVC_FRAME_FORMAT_* instead of using these. */ 94 #define UVC_COLOR_FORMAT_UNKNOWN UVC_FRAME_FORMAT_UNKNOWN 95 #define UVC_COLOR_FORMAT_UNCOMPRESSED UVC_FRAME_FORMAT_UNCOMPRESSED 96 #define UVC_COLOR_FORMAT_COMPRESSED UVC_FRAME_FORMAT_COMPRESSED 97 #define UVC_COLOR_FORMAT_YUYV UVC_FRAME_FORMAT_YUYV 98 #define UVC_COLOR_FORMAT_UYVY UVC_FRAME_FORMAT_UYVY 99 #define UVC_COLOR_FORMAT_RGB UVC_FRAME_FORMAT_RGB 100 #define UVC_COLOR_FORMAT_BGR UVC_FRAME_FORMAT_BGR 101 #define UVC_COLOR_FORMAT_MJPEG UVC_FRAME_FORMAT_MJPEG 102 #define UVC_COLOR_FORMAT_GRAY8 UVC_FRAME_FORMAT_GRAY8 103 #define UVC_COLOR_FORMAT_GRAY16 UVC_FRAME_FORMAT_GRAY16 104 #define UVC_COLOR_FORMAT_NV12 UVC_FRAME_FORMAT_NV12 105 106 /** VideoStreaming interface descriptor subtype (A.6) */ 107 enum uvc_vs_desc_subtype { 108 UVC_VS_UNDEFINED = 0x00, 109 UVC_VS_INPUT_HEADER = 0x01, 110 UVC_VS_OUTPUT_HEADER = 0x02, 111 UVC_VS_STILL_IMAGE_FRAME = 0x03, 112 UVC_VS_FORMAT_UNCOMPRESSED = 0x04, 113 UVC_VS_FRAME_UNCOMPRESSED = 0x05, 114 UVC_VS_FORMAT_MJPEG = 0x06, 115 UVC_VS_FRAME_MJPEG = 0x07, 116 UVC_VS_FORMAT_MPEG2TS = 0x0a, 117 UVC_VS_FORMAT_DV = 0x0c, 118 UVC_VS_COLORFORMAT = 0x0d, 119 UVC_VS_FORMAT_FRAME_BASED = 0x10, 120 UVC_VS_FRAME_FRAME_BASED = 0x11, 121 UVC_VS_FORMAT_STREAM_BASED = 0x12 122 }; 123 124 struct uvc_format_desc; 125 struct uvc_frame_desc; 126 127 typedef struct uvc_still_frame_res { 128 struct uvc_still_frame_res *prev, *next; 129 uint8_t bResolutionIndex; 130 /** Image width */ 131 uint16_t wWidth; 132 /** Image height */ 133 uint16_t wHeight; 134 } uvc_still_frame_res_t; 135 136 typedef struct uvc_still_frame_desc { 137 struct uvc_format_desc *parent; 138 struct uvc_still_frame_desc *prev, *next; 139 /** Type of frame, such as JPEG frame or uncompressed frme */ 140 enum uvc_vs_desc_subtype bDescriptorSubtype; 141 /** Index of the frame within the list of specs available for this format */ 142 uint8_t bEndPointAddress; 143 uvc_still_frame_res_t* imageSizePatterns; 144 uint8_t bNumCompressionPattern; 145 /* indication of compression level, the higher, the more compression is applied to image */ 146 uint8_t* bCompression; 147 } uvc_still_frame_desc_t; 148 149 /** Frame descriptor 150 * 151 * A "frame" is a configuration of a streaming format 152 * for a particular image size at one of possibly several 153 * available frame rates. 154 */ 155 typedef struct uvc_frame_desc { 156 struct uvc_format_desc *parent; 157 struct uvc_frame_desc *prev, *next; 158 /** Type of frame, such as JPEG frame or uncompressed frme */ 159 enum uvc_vs_desc_subtype bDescriptorSubtype; 160 /** Index of the frame within the list of specs available for this format */ 161 uint8_t bFrameIndex; 162 uint8_t bmCapabilities; 163 /** Image width */ 164 uint16_t wWidth; 165 /** Image height */ 166 uint16_t wHeight; 167 /** Bitrate of corresponding stream at minimal frame rate */ 168 uint32_t dwMinBitRate; 169 /** Bitrate of corresponding stream at maximal frame rate */ 170 uint32_t dwMaxBitRate; 171 /** Maximum number of bytes for a video frame */ 172 uint32_t dwMaxVideoFrameBufferSize; 173 /** Default frame interval (in 100ns units) */ 174 uint32_t dwDefaultFrameInterval; 175 /** Minimum frame interval for continuous mode (100ns units) */ 176 uint32_t dwMinFrameInterval; 177 /** Maximum frame interval for continuous mode (100ns units) */ 178 uint32_t dwMaxFrameInterval; 179 /** Granularity of frame interval range for continuous mode (100ns) */ 180 uint32_t dwFrameIntervalStep; 181 /** Frame intervals */ 182 uint8_t bFrameIntervalType; 183 /** number of bytes per line */ 184 uint32_t dwBytesPerLine; 185 /** Available frame rates, zero-terminated (in 100ns units) */ 186 uint32_t *intervals; 187 } uvc_frame_desc_t; 188 189 /** Format descriptor 190 * 191 * A "format" determines a stream's image type (e.g., raw YUYV or JPEG) 192 * and includes many "frame" configurations. 193 */ 194 typedef struct uvc_format_desc { 195 struct uvc_streaming_interface *parent; 196 struct uvc_format_desc *prev, *next; 197 /** Type of image stream, such as JPEG or uncompressed. */ 198 enum uvc_vs_desc_subtype bDescriptorSubtype; 199 /** Identifier of this format within the VS interface's format list */ 200 uint8_t bFormatIndex; 201 uint8_t bNumFrameDescriptors; 202 /** Format specifier */ 203 union { 204 uint8_t guidFormat[16]; 205 uint8_t fourccFormat[4]; 206 }; 207 /** Format-specific data */ 208 union { 209 /** BPP for uncompressed stream */ 210 uint8_t bBitsPerPixel; 211 /** Flags for JPEG stream */ 212 uint8_t bmFlags; 213 }; 214 /** Default {uvc_frame_desc} to choose given this format */ 215 uint8_t bDefaultFrameIndex; 216 uint8_t bAspectRatioX; 217 uint8_t bAspectRatioY; 218 uint8_t bmInterlaceFlags; 219 uint8_t bCopyProtect; 220 uint8_t bVariableSize; 221 /** Available frame specifications for this format */ 222 struct uvc_frame_desc *frame_descs; 223 struct uvc_still_frame_desc *still_frame_desc; 224 } uvc_format_desc_t; 225 226 /** UVC request code (A.8) */ 227 enum uvc_req_code { 228 UVC_RC_UNDEFINED = 0x00, 229 UVC_SET_CUR = 0x01, 230 UVC_GET_CUR = 0x81, 231 UVC_GET_MIN = 0x82, 232 UVC_GET_MAX = 0x83, 233 UVC_GET_RES = 0x84, 234 UVC_GET_LEN = 0x85, 235 UVC_GET_INFO = 0x86, 236 UVC_GET_DEF = 0x87 237 }; 238 239 enum uvc_device_power_mode { 240 UVC_VC_VIDEO_POWER_MODE_FULL = 0x000b, 241 UVC_VC_VIDEO_POWER_MODE_DEVICE_DEPENDENT = 0x001b, 242 }; 243 244 /** Camera terminal control selector (A.9.4) */ 245 enum uvc_ct_ctrl_selector { 246 UVC_CT_CONTROL_UNDEFINED = 0x00, 247 UVC_CT_SCANNING_MODE_CONTROL = 0x01, 248 UVC_CT_AE_MODE_CONTROL = 0x02, 249 UVC_CT_AE_PRIORITY_CONTROL = 0x03, 250 UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL = 0x04, 251 UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL = 0x05, 252 UVC_CT_FOCUS_ABSOLUTE_CONTROL = 0x06, 253 UVC_CT_FOCUS_RELATIVE_CONTROL = 0x07, 254 UVC_CT_FOCUS_AUTO_CONTROL = 0x08, 255 UVC_CT_IRIS_ABSOLUTE_CONTROL = 0x09, 256 UVC_CT_IRIS_RELATIVE_CONTROL = 0x0a, 257 UVC_CT_ZOOM_ABSOLUTE_CONTROL = 0x0b, 258 UVC_CT_ZOOM_RELATIVE_CONTROL = 0x0c, 259 UVC_CT_PANTILT_ABSOLUTE_CONTROL = 0x0d, 260 UVC_CT_PANTILT_RELATIVE_CONTROL = 0x0e, 261 UVC_CT_ROLL_ABSOLUTE_CONTROL = 0x0f, 262 UVC_CT_ROLL_RELATIVE_CONTROL = 0x10, 263 UVC_CT_PRIVACY_CONTROL = 0x11, 264 UVC_CT_FOCUS_SIMPLE_CONTROL = 0x12, 265 UVC_CT_DIGITAL_WINDOW_CONTROL = 0x13, 266 UVC_CT_REGION_OF_INTEREST_CONTROL = 0x14 267 }; 268 269 /** Processing unit control selector (A.9.5) */ 270 enum uvc_pu_ctrl_selector { 271 UVC_PU_CONTROL_UNDEFINED = 0x00, 272 UVC_PU_BACKLIGHT_COMPENSATION_CONTROL = 0x01, 273 UVC_PU_BRIGHTNESS_CONTROL = 0x02, 274 UVC_PU_CONTRAST_CONTROL = 0x03, 275 UVC_PU_GAIN_CONTROL = 0x04, 276 UVC_PU_POWER_LINE_FREQUENCY_CONTROL = 0x05, 277 UVC_PU_HUE_CONTROL = 0x06, 278 UVC_PU_SATURATION_CONTROL = 0x07, 279 UVC_PU_SHARPNESS_CONTROL = 0x08, 280 UVC_PU_GAMMA_CONTROL = 0x09, 281 UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL = 0x0a, 282 UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL = 0x0b, 283 UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL = 0x0c, 284 UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL = 0x0d, 285 UVC_PU_DIGITAL_MULTIPLIER_CONTROL = 0x0e, 286 UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL = 0x0f, 287 UVC_PU_HUE_AUTO_CONTROL = 0x10, 288 UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL = 0x11, 289 UVC_PU_ANALOG_LOCK_STATUS_CONTROL = 0x12, 290 UVC_PU_CONTRAST_AUTO_CONTROL = 0x13 291 }; 292 293 /** USB terminal type (B.1) */ 294 enum uvc_term_type { 295 UVC_TT_VENDOR_SPECIFIC = 0x0100, 296 UVC_TT_STREAMING = 0x0101 297 }; 298 299 /** Input terminal type (B.2) */ 300 enum uvc_it_type { 301 UVC_ITT_VENDOR_SPECIFIC = 0x0200, 302 UVC_ITT_CAMERA = 0x0201, 303 UVC_ITT_MEDIA_TRANSPORT_INPUT = 0x0202 304 }; 305 306 /** Output terminal type (B.3) */ 307 enum uvc_ot_type { 308 UVC_OTT_VENDOR_SPECIFIC = 0x0300, 309 UVC_OTT_DISPLAY = 0x0301, 310 UVC_OTT_MEDIA_TRANSPORT_OUTPUT = 0x0302 311 }; 312 313 /** External terminal type (B.4) */ 314 enum uvc_et_type { 315 UVC_EXTERNAL_VENDOR_SPECIFIC = 0x0400, 316 UVC_COMPOSITE_CONNECTOR = 0x0401, 317 UVC_SVIDEO_CONNECTOR = 0x0402, 318 UVC_COMPONENT_CONNECTOR = 0x0403 319 }; 320 321 /** Context, equivalent to libusb's contexts. 322 * 323 * May either own a libusb context or use one that's already made. 324 * 325 * Always create these with uvc_get_context. 326 */ 327 struct uvc_context; 328 typedef struct uvc_context uvc_context_t; 329 330 /** UVC device. 331 * 332 * Get this from uvc_get_device_list() or uvc_find_device(). 333 */ 334 struct uvc_device; 335 typedef struct uvc_device uvc_device_t; 336 337 /** Handle on an open UVC device. 338 * 339 * Get one of these from uvc_open(). Once you uvc_close() 340 * it, it's no longer valid. 341 */ 342 struct uvc_device_handle; 343 typedef struct uvc_device_handle uvc_device_handle_t; 344 345 /** Handle on an open UVC stream. 346 * 347 * Get one of these from uvc_stream_open*(). 348 * Once you uvc_stream_close() it, it will no longer be valid. 349 */ 350 struct uvc_stream_handle; 351 typedef struct uvc_stream_handle uvc_stream_handle_t; 352 353 /** Representation of the interface that brings data into the UVC device */ 354 typedef struct uvc_input_terminal { 355 struct uvc_input_terminal *prev, *next; 356 /** Index of the terminal within the device */ 357 uint8_t bTerminalID; 358 /** Type of terminal (e.g., camera) */ 359 enum uvc_it_type wTerminalType; 360 uint16_t wObjectiveFocalLengthMin; 361 uint16_t wObjectiveFocalLengthMax; 362 uint16_t wOcularFocalLength; 363 /** Camera controls (meaning of bits given in {uvc_ct_ctrl_selector}) */ 364 uint64_t bmControls; 365 } uvc_input_terminal_t; 366 367 typedef struct uvc_output_terminal { 368 struct uvc_output_terminal *prev, *next; 369 /** @todo */ 370 } uvc_output_terminal_t; 371 372 /** Represents post-capture processing functions */ 373 typedef struct uvc_processing_unit { 374 struct uvc_processing_unit *prev, *next; 375 /** Index of the processing unit within the device */ 376 uint8_t bUnitID; 377 /** Index of the terminal from which the device accepts images */ 378 uint8_t bSourceID; 379 /** Processing controls (meaning of bits given in {uvc_pu_ctrl_selector}) */ 380 uint64_t bmControls; 381 } uvc_processing_unit_t; 382 383 /** Represents selector unit to connect other units */ 384 typedef struct uvc_selector_unit { 385 struct uvc_selector_unit *prev, *next; 386 /** Index of the selector unit within the device */ 387 uint8_t bUnitID; 388 } uvc_selector_unit_t; 389 390 /** Custom processing or camera-control functions */ 391 typedef struct uvc_extension_unit { 392 struct uvc_extension_unit *prev, *next; 393 /** Index of the extension unit within the device */ 394 uint8_t bUnitID; 395 /** GUID identifying the extension unit */ 396 uint8_t guidExtensionCode[16]; 397 /** Bitmap of available controls (manufacturer-dependent) */ 398 uint64_t bmControls; 399 } uvc_extension_unit_t; 400 401 enum uvc_status_class { 402 UVC_STATUS_CLASS_CONTROL = 0x10, 403 UVC_STATUS_CLASS_CONTROL_CAMERA = 0x11, 404 UVC_STATUS_CLASS_CONTROL_PROCESSING = 0x12, 405 }; 406 407 enum uvc_status_attribute { 408 UVC_STATUS_ATTRIBUTE_VALUE_CHANGE = 0x00, 409 UVC_STATUS_ATTRIBUTE_INFO_CHANGE = 0x01, 410 UVC_STATUS_ATTRIBUTE_FAILURE_CHANGE = 0x02, 411 UVC_STATUS_ATTRIBUTE_UNKNOWN = 0xff 412 }; 413 414 /** A callback function to accept status updates 415 * @ingroup device 416 */ 417 typedef void(uvc_status_callback_t)(enum uvc_status_class status_class, 418 int event, 419 int selector, 420 enum uvc_status_attribute status_attribute, 421 void *data, size_t data_len, 422 void *user_ptr); 423 424 /** A callback function to accept button events 425 * @ingroup device 426 */ 427 typedef void(uvc_button_callback_t)(int button, 428 int state, 429 void *user_ptr); 430 431 /** Structure representing a UVC device descriptor. 432 * 433 * (This isn't a standard structure.) 434 */ 435 typedef struct uvc_device_descriptor { 436 /** Vendor ID */ 437 uint16_t idVendor; 438 /** Product ID */ 439 uint16_t idProduct; 440 /** UVC compliance level, e.g. 0x0100 (1.0), 0x0110 */ 441 uint16_t bcdUVC; 442 /** Serial number (null if unavailable) */ 443 const char *serialNumber; 444 /** Device-reported manufacturer name (or null) */ 445 const char *manufacturer; 446 /** Device-reporter product name (or null) */ 447 const char *product; 448 } uvc_device_descriptor_t; 449 450 /** An image frame received from the UVC device 451 * @ingroup streaming 452 */ 453 typedef struct uvc_frame { 454 /** Image data for this frame */ 455 void *data; 456 /** Size of image data buffer */ 457 size_t data_bytes; 458 /** Width of image in pixels */ 459 uint32_t width; 460 /** Height of image in pixels */ 461 uint32_t height; 462 /** Pixel data format */ 463 enum uvc_frame_format frame_format; 464 /** Number of bytes per horizontal line (undefined for compressed format) */ 465 size_t step; 466 /** Frame number (may skip, but is strictly monotonically increasing) */ 467 uint32_t sequence; 468 /** Estimate of system time when the device started capturing the image */ 469 struct timeval capture_time; 470 /** Estimate of system time when the device finished receiving the image */ 471 struct timespec capture_time_finished; 472 /** Handle on the device that produced the image. 473 * @warning You must not call any uvc_* functions during a callback. */ 474 uvc_device_handle_t *source; 475 /** Is the data buffer owned by the library? 476 * If 1, the data buffer can be arbitrarily reallocated by frame conversion 477 * functions. 478 * If 0, the data buffer will not be reallocated or freed by the library. 479 * Set this field to zero if you are supplying the buffer. 480 */ 481 uint8_t library_owns_data; 482 /** Metadata for this frame if available */ 483 void *metadata; 484 /** Size of metadata buffer */ 485 size_t metadata_bytes; 486 } uvc_frame_t; 487 488 /** A callback function to handle incoming assembled UVC frames 489 * @ingroup streaming 490 */ 491 typedef void(uvc_frame_callback_t)(struct uvc_frame *frame, void *user_ptr); 492 493 /** Streaming mode, includes all information needed to select stream 494 * @ingroup streaming 495 */ 496 typedef struct uvc_stream_ctrl { 497 uint16_t bmHint; 498 uint8_t bFormatIndex; 499 uint8_t bFrameIndex; 500 uint32_t dwFrameInterval; 501 uint16_t wKeyFrameRate; 502 uint16_t wPFrameRate; 503 uint16_t wCompQuality; 504 uint16_t wCompWindowSize; 505 uint16_t wDelay; 506 uint32_t dwMaxVideoFrameSize; 507 uint32_t dwMaxPayloadTransferSize; 508 uint32_t dwClockFrequency; 509 uint8_t bmFramingInfo; 510 uint8_t bPreferredVersion; 511 uint8_t bMinVersion; 512 uint8_t bMaxVersion; 513 uint8_t bInterfaceNumber; 514 } uvc_stream_ctrl_t; 515 516 typedef struct uvc_still_ctrl { 517 /* Video format index from a format descriptor */ 518 uint8_t bFormatIndex; 519 /* Video frame index from a frame descriptor */ 520 uint8_t bFrameIndex; 521 /* Compression index from a frame descriptor */ 522 uint8_t bCompressionIndex; 523 /* Maximum still image size in bytes. */ 524 uint32_t dwMaxVideoFrameSize; 525 /* Maximum number of byte per payload*/ 526 uint32_t dwMaxPayloadTransferSize; 527 uint8_t bInterfaceNumber; 528 } uvc_still_ctrl_t; 529 530 uvc_error_t uvc_init(uvc_context_t **ctx, struct libusb_context *usb_ctx); 531 void uvc_exit(uvc_context_t *ctx); 532 533 uvc_error_t uvc_get_device_list( 534 uvc_context_t *ctx, 535 uvc_device_t ***list); 536 void uvc_free_device_list(uvc_device_t **list, uint8_t unref_devices); 537 538 uvc_error_t uvc_get_device_descriptor( 539 uvc_device_t *dev, 540 uvc_device_descriptor_t **desc); 541 void uvc_free_device_descriptor( 542 uvc_device_descriptor_t *desc); 543 544 uint8_t uvc_get_bus_number(uvc_device_t *dev); 545 uint8_t uvc_get_device_address(uvc_device_t *dev); 546 547 uvc_error_t uvc_find_device( 548 uvc_context_t *ctx, 549 uvc_device_t **dev, 550 int vid, int pid, const char *sn); 551 552 uvc_error_t uvc_find_devices( 553 uvc_context_t *ctx, 554 uvc_device_t ***devs, 555 int vid, int pid, const char *sn); 556 557 #if LIBUSB_API_VERSION >= 0x01000107 558 uvc_error_t uvc_wrap( 559 int sys_dev, 560 uvc_context_t *context, 561 uvc_device_handle_t **devh); 562 #endif 563 564 uvc_error_t uvc_open( 565 uvc_device_t *dev, 566 uvc_device_handle_t **devh); 567 void uvc_close(uvc_device_handle_t *devh); 568 569 uvc_device_t *uvc_get_device(uvc_device_handle_t *devh); 570 struct libusb_device_handle *uvc_get_libusb_handle(uvc_device_handle_t *devh); 571 572 void uvc_ref_device(uvc_device_t *dev); 573 void uvc_unref_device(uvc_device_t *dev); 574 575 void uvc_set_status_callback(uvc_device_handle_t *devh, 576 uvc_status_callback_t cb, 577 void *user_ptr); 578 579 void uvc_set_button_callback(uvc_device_handle_t *devh, 580 uvc_button_callback_t cb, 581 void *user_ptr); 582 583 const uvc_input_terminal_t *uvc_get_camera_terminal(uvc_device_handle_t *devh); 584 const uvc_input_terminal_t *uvc_get_input_terminals(uvc_device_handle_t *devh); 585 const uvc_output_terminal_t *uvc_get_output_terminals(uvc_device_handle_t *devh); 586 const uvc_selector_unit_t *uvc_get_selector_units(uvc_device_handle_t *devh); 587 const uvc_processing_unit_t *uvc_get_processing_units(uvc_device_handle_t *devh); 588 const uvc_extension_unit_t *uvc_get_extension_units(uvc_device_handle_t *devh); 589 590 uvc_error_t uvc_get_stream_ctrl_format_size( 591 uvc_device_handle_t *devh, 592 uvc_stream_ctrl_t *ctrl, 593 enum uvc_frame_format format, 594 int width, int height, 595 int fps 596 ); 597 598 uvc_error_t uvc_get_still_ctrl_format_size( 599 uvc_device_handle_t *devh, 600 uvc_stream_ctrl_t *ctrl, 601 uvc_still_ctrl_t *still_ctrl, 602 int width, int height); 603 604 uvc_error_t uvc_trigger_still( 605 uvc_device_handle_t *devh, 606 uvc_still_ctrl_t *still_ctrl); 607 608 const uvc_format_desc_t *uvc_get_format_descs(uvc_device_handle_t* ); 609 610 uvc_error_t uvc_probe_stream_ctrl( 611 uvc_device_handle_t *devh, 612 uvc_stream_ctrl_t *ctrl); 613 614 uvc_error_t uvc_probe_still_ctrl( 615 uvc_device_handle_t *devh, 616 uvc_still_ctrl_t *still_ctrl); 617 618 uvc_error_t uvc_start_streaming( 619 uvc_device_handle_t *devh, 620 uvc_stream_ctrl_t *ctrl, 621 uvc_frame_callback_t *cb, 622 void *user_ptr, 623 uint8_t flags); 624 625 uvc_error_t uvc_start_iso_streaming( 626 uvc_device_handle_t *devh, 627 uvc_stream_ctrl_t *ctrl, 628 uvc_frame_callback_t *cb, 629 void *user_ptr); 630 631 void uvc_stop_streaming(uvc_device_handle_t *devh); 632 633 uvc_error_t uvc_stream_open_ctrl(uvc_device_handle_t *devh, uvc_stream_handle_t **strmh, uvc_stream_ctrl_t *ctrl); 634 uvc_error_t uvc_stream_ctrl(uvc_stream_handle_t *strmh, uvc_stream_ctrl_t *ctrl); 635 uvc_error_t uvc_stream_start(uvc_stream_handle_t *strmh, 636 uvc_frame_callback_t *cb, 637 void *user_ptr, 638 uint8_t flags); 639 uvc_error_t uvc_stream_start_iso(uvc_stream_handle_t *strmh, 640 uvc_frame_callback_t *cb, 641 void *user_ptr); 642 uvc_error_t uvc_stream_get_frame( 643 uvc_stream_handle_t *strmh, 644 uvc_frame_t **frame, 645 int32_t timeout_us 646 ); 647 uvc_error_t uvc_stream_stop(uvc_stream_handle_t *strmh); 648 void uvc_stream_close(uvc_stream_handle_t *strmh); 649 650 int uvc_get_ctrl_len(uvc_device_handle_t *devh, uint8_t unit, uint8_t ctrl); 651 int uvc_get_ctrl(uvc_device_handle_t *devh, uint8_t unit, uint8_t ctrl, void *data, int len, enum uvc_req_code req_code); 652 int uvc_set_ctrl(uvc_device_handle_t *devh, uint8_t unit, uint8_t ctrl, void *data, int len); 653 654 uvc_error_t uvc_get_power_mode(uvc_device_handle_t *devh, enum uvc_device_power_mode *mode, enum uvc_req_code req_code); 655 uvc_error_t uvc_set_power_mode(uvc_device_handle_t *devh, enum uvc_device_power_mode mode); 656 657 /* AUTO-GENERATED control accessors! Update them with the output of `ctrl-gen.py decl`. */ 658 uvc_error_t uvc_get_scanning_mode(uvc_device_handle_t *devh, uint8_t* mode, enum uvc_req_code req_code); 659 uvc_error_t uvc_set_scanning_mode(uvc_device_handle_t *devh, uint8_t mode); 660 661 uvc_error_t uvc_get_ae_mode(uvc_device_handle_t *devh, uint8_t* mode, enum uvc_req_code req_code); 662 uvc_error_t uvc_set_ae_mode(uvc_device_handle_t *devh, uint8_t mode); 663 664 uvc_error_t uvc_get_ae_priority(uvc_device_handle_t *devh, uint8_t* priority, enum uvc_req_code req_code); 665 uvc_error_t uvc_set_ae_priority(uvc_device_handle_t *devh, uint8_t priority); 666 667 uvc_error_t uvc_get_exposure_abs(uvc_device_handle_t *devh, uint32_t* time, enum uvc_req_code req_code); 668 uvc_error_t uvc_set_exposure_abs(uvc_device_handle_t *devh, uint32_t time); 669 670 uvc_error_t uvc_get_exposure_rel(uvc_device_handle_t *devh, int8_t* step, enum uvc_req_code req_code); 671 uvc_error_t uvc_set_exposure_rel(uvc_device_handle_t *devh, int8_t step); 672 673 uvc_error_t uvc_get_focus_abs(uvc_device_handle_t *devh, uint16_t* focus, enum uvc_req_code req_code); 674 uvc_error_t uvc_set_focus_abs(uvc_device_handle_t *devh, uint16_t focus); 675 676 uvc_error_t uvc_get_focus_rel(uvc_device_handle_t *devh, int8_t* focus_rel, uint8_t* speed, enum uvc_req_code req_code); 677 uvc_error_t uvc_set_focus_rel(uvc_device_handle_t *devh, int8_t focus_rel, uint8_t speed); 678 679 uvc_error_t uvc_get_focus_simple_range(uvc_device_handle_t *devh, uint8_t* focus, enum uvc_req_code req_code); 680 uvc_error_t uvc_set_focus_simple_range(uvc_device_handle_t *devh, uint8_t focus); 681 682 uvc_error_t uvc_get_focus_auto(uvc_device_handle_t *devh, uint8_t* state, enum uvc_req_code req_code); 683 uvc_error_t uvc_set_focus_auto(uvc_device_handle_t *devh, uint8_t state); 684 685 uvc_error_t uvc_get_iris_abs(uvc_device_handle_t *devh, uint16_t* iris, enum uvc_req_code req_code); 686 uvc_error_t uvc_set_iris_abs(uvc_device_handle_t *devh, uint16_t iris); 687 688 uvc_error_t uvc_get_iris_rel(uvc_device_handle_t *devh, uint8_t* iris_rel, enum uvc_req_code req_code); 689 uvc_error_t uvc_set_iris_rel(uvc_device_handle_t *devh, uint8_t iris_rel); 690 691 uvc_error_t uvc_get_zoom_abs(uvc_device_handle_t *devh, uint16_t* focal_length, enum uvc_req_code req_code); 692 uvc_error_t uvc_set_zoom_abs(uvc_device_handle_t *devh, uint16_t focal_length); 693 694 uvc_error_t uvc_get_zoom_rel(uvc_device_handle_t *devh, int8_t* zoom_rel, uint8_t* digital_zoom, uint8_t* speed, enum uvc_req_code req_code); 695 uvc_error_t uvc_set_zoom_rel(uvc_device_handle_t *devh, int8_t zoom_rel, uint8_t digital_zoom, uint8_t speed); 696 697 uvc_error_t uvc_get_pantilt_abs(uvc_device_handle_t *devh, int32_t* pan, int32_t* tilt, enum uvc_req_code req_code); 698 uvc_error_t uvc_set_pantilt_abs(uvc_device_handle_t *devh, int32_t pan, int32_t tilt); 699 700 uvc_error_t uvc_get_pantilt_rel(uvc_device_handle_t *devh, int8_t* pan_rel, uint8_t* pan_speed, int8_t* tilt_rel, uint8_t* tilt_speed, enum uvc_req_code req_code); 701 uvc_error_t uvc_set_pantilt_rel(uvc_device_handle_t *devh, int8_t pan_rel, uint8_t pan_speed, int8_t tilt_rel, uint8_t tilt_speed); 702 703 uvc_error_t uvc_get_roll_abs(uvc_device_handle_t *devh, int16_t* roll, enum uvc_req_code req_code); 704 uvc_error_t uvc_set_roll_abs(uvc_device_handle_t *devh, int16_t roll); 705 706 uvc_error_t uvc_get_roll_rel(uvc_device_handle_t *devh, int8_t* roll_rel, uint8_t* speed, enum uvc_req_code req_code); 707 uvc_error_t uvc_set_roll_rel(uvc_device_handle_t *devh, int8_t roll_rel, uint8_t speed); 708 709 uvc_error_t uvc_get_privacy(uvc_device_handle_t *devh, uint8_t* privacy, enum uvc_req_code req_code); 710 uvc_error_t uvc_set_privacy(uvc_device_handle_t *devh, uint8_t privacy); 711 712 uvc_error_t uvc_get_digital_window(uvc_device_handle_t *devh, uint16_t* window_top, uint16_t* window_left, uint16_t* window_bottom, uint16_t* window_right, uint16_t* num_steps, uint16_t* num_steps_units, enum uvc_req_code req_code); 713 uvc_error_t uvc_set_digital_window(uvc_device_handle_t *devh, uint16_t window_top, uint16_t window_left, uint16_t window_bottom, uint16_t window_right, uint16_t num_steps, uint16_t num_steps_units); 714 715 uvc_error_t uvc_get_digital_roi(uvc_device_handle_t *devh, uint16_t* roi_top, uint16_t* roi_left, uint16_t* roi_bottom, uint16_t* roi_right, uint16_t* auto_controls, enum uvc_req_code req_code); 716 uvc_error_t uvc_set_digital_roi(uvc_device_handle_t *devh, uint16_t roi_top, uint16_t roi_left, uint16_t roi_bottom, uint16_t roi_right, uint16_t auto_controls); 717 718 uvc_error_t uvc_get_backlight_compensation(uvc_device_handle_t *devh, uint16_t* backlight_compensation, enum uvc_req_code req_code); 719 uvc_error_t uvc_set_backlight_compensation(uvc_device_handle_t *devh, uint16_t backlight_compensation); 720 721 uvc_error_t uvc_get_brightness(uvc_device_handle_t *devh, int16_t* brightness, enum uvc_req_code req_code); 722 uvc_error_t uvc_set_brightness(uvc_device_handle_t *devh, int16_t brightness); 723 724 uvc_error_t uvc_get_contrast(uvc_device_handle_t *devh, uint16_t* contrast, enum uvc_req_code req_code); 725 uvc_error_t uvc_set_contrast(uvc_device_handle_t *devh, uint16_t contrast); 726 727 uvc_error_t uvc_get_contrast_auto(uvc_device_handle_t *devh, uint8_t* contrast_auto, enum uvc_req_code req_code); 728 uvc_error_t uvc_set_contrast_auto(uvc_device_handle_t *devh, uint8_t contrast_auto); 729 730 uvc_error_t uvc_get_gain(uvc_device_handle_t *devh, uint16_t* gain, enum uvc_req_code req_code); 731 uvc_error_t uvc_set_gain(uvc_device_handle_t *devh, uint16_t gain); 732 733 uvc_error_t uvc_get_power_line_frequency(uvc_device_handle_t *devh, uint8_t* power_line_frequency, enum uvc_req_code req_code); 734 uvc_error_t uvc_set_power_line_frequency(uvc_device_handle_t *devh, uint8_t power_line_frequency); 735 736 uvc_error_t uvc_get_hue(uvc_device_handle_t *devh, int16_t* hue, enum uvc_req_code req_code); 737 uvc_error_t uvc_set_hue(uvc_device_handle_t *devh, int16_t hue); 738 739 uvc_error_t uvc_get_hue_auto(uvc_device_handle_t *devh, uint8_t* hue_auto, enum uvc_req_code req_code); 740 uvc_error_t uvc_set_hue_auto(uvc_device_handle_t *devh, uint8_t hue_auto); 741 742 uvc_error_t uvc_get_saturation(uvc_device_handle_t *devh, uint16_t* saturation, enum uvc_req_code req_code); 743 uvc_error_t uvc_set_saturation(uvc_device_handle_t *devh, uint16_t saturation); 744 745 uvc_error_t uvc_get_sharpness(uvc_device_handle_t *devh, uint16_t* sharpness, enum uvc_req_code req_code); 746 uvc_error_t uvc_set_sharpness(uvc_device_handle_t *devh, uint16_t sharpness); 747 748 uvc_error_t uvc_get_gamma(uvc_device_handle_t *devh, uint16_t* gamma, enum uvc_req_code req_code); 749 uvc_error_t uvc_set_gamma(uvc_device_handle_t *devh, uint16_t gamma); 750 751 uvc_error_t uvc_get_white_balance_temperature(uvc_device_handle_t *devh, uint16_t* temperature, enum uvc_req_code req_code); 752 uvc_error_t uvc_set_white_balance_temperature(uvc_device_handle_t *devh, uint16_t temperature); 753 754 uvc_error_t uvc_get_white_balance_temperature_auto(uvc_device_handle_t *devh, uint8_t* temperature_auto, enum uvc_req_code req_code); 755 uvc_error_t uvc_set_white_balance_temperature_auto(uvc_device_handle_t *devh, uint8_t temperature_auto); 756 757 uvc_error_t uvc_get_white_balance_component(uvc_device_handle_t *devh, uint16_t* blue, uint16_t* red, enum uvc_req_code req_code); 758 uvc_error_t uvc_set_white_balance_component(uvc_device_handle_t *devh, uint16_t blue, uint16_t red); 759 760 uvc_error_t uvc_get_white_balance_component_auto(uvc_device_handle_t *devh, uint8_t* white_balance_component_auto, enum uvc_req_code req_code); 761 uvc_error_t uvc_set_white_balance_component_auto(uvc_device_handle_t *devh, uint8_t white_balance_component_auto); 762 763 uvc_error_t uvc_get_digital_multiplier(uvc_device_handle_t *devh, uint16_t* multiplier_step, enum uvc_req_code req_code); 764 uvc_error_t uvc_set_digital_multiplier(uvc_device_handle_t *devh, uint16_t multiplier_step); 765 766 uvc_error_t uvc_get_digital_multiplier_limit(uvc_device_handle_t *devh, uint16_t* multiplier_step, enum uvc_req_code req_code); 767 uvc_error_t uvc_set_digital_multiplier_limit(uvc_device_handle_t *devh, uint16_t multiplier_step); 768 769 uvc_error_t uvc_get_analog_video_standard(uvc_device_handle_t *devh, uint8_t* video_standard, enum uvc_req_code req_code); 770 uvc_error_t uvc_set_analog_video_standard(uvc_device_handle_t *devh, uint8_t video_standard); 771 772 uvc_error_t uvc_get_analog_video_lock_status(uvc_device_handle_t *devh, uint8_t* status, enum uvc_req_code req_code); 773 uvc_error_t uvc_set_analog_video_lock_status(uvc_device_handle_t *devh, uint8_t status); 774 775 uvc_error_t uvc_get_input_select(uvc_device_handle_t *devh, uint8_t* selector, enum uvc_req_code req_code); 776 uvc_error_t uvc_set_input_select(uvc_device_handle_t *devh, uint8_t selector); 777 /* end AUTO-GENERATED control accessors */ 778 779 void uvc_perror(uvc_error_t err, const char *msg); 780 const char* uvc_strerror(uvc_error_t err); 781 void uvc_print_diag(uvc_device_handle_t *devh, FILE *stream); 782 void uvc_print_stream_ctrl(uvc_stream_ctrl_t *ctrl, FILE *stream); 783 784 uvc_frame_t *uvc_allocate_frame(size_t data_bytes); 785 void uvc_free_frame(uvc_frame_t *frame); 786 787 uvc_error_t uvc_duplicate_frame(uvc_frame_t *in, uvc_frame_t *out); 788 789 uvc_error_t uvc_yuyv2rgb(uvc_frame_t *in, uvc_frame_t *out); 790 uvc_error_t uvc_uyvy2rgb(uvc_frame_t *in, uvc_frame_t *out); 791 uvc_error_t uvc_any2rgb(uvc_frame_t *in, uvc_frame_t *out); 792 793 uvc_error_t uvc_yuyv2bgr(uvc_frame_t *in, uvc_frame_t *out); 794 uvc_error_t uvc_uyvy2bgr(uvc_frame_t *in, uvc_frame_t *out); 795 uvc_error_t uvc_any2bgr(uvc_frame_t *in, uvc_frame_t *out); 796 797 uvc_error_t uvc_yuyv2y(uvc_frame_t *in, uvc_frame_t *out); 798 uvc_error_t uvc_yuyv2uv(uvc_frame_t *in, uvc_frame_t *out); 799 800 #ifdef LIBUVC_HAS_JPEG 801 uvc_error_t uvc_mjpeg2rgb(uvc_frame_t *in, uvc_frame_t *out); 802 uvc_error_t uvc_mjpeg2gray(uvc_frame_t *in, uvc_frame_t *out); 803 #endif 804 805 #ifdef __cplusplus 806 } 807 #endif 808 809 #endif // !def(LIBUVC_H) 810 811