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