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