Webcam Library Reference Documentation  Logitech logo

Common/include/webcam.h

Go to the documentation of this file.
00001 
00008 /*
00009  * Copyright (c) 2006-2007 Logitech.
00010  *
00011  * This file is part of libwebcam.
00012  * 
00013  * libwebcam is free software: you can redistribute it and/or modify
00014  * it under the terms of the GNU Lesser General Public License as published
00015  * by the Free Software Foundation, either version 3 of the License, or
00016  * (at your option) any later version.
00017  * 
00018  * libwebcam is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU Lesser General Public License for more details.
00022  * 
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with libwebcam.  If not, see <http://www.gnu.org/licenses/>.
00025  */
00026 
00027 #ifndef C_WEBCAM_H
00028 #define C_WEBCAM_H
00029 
00030 
00031 /*
00032  * Basic type definitions
00033  */
00034 
00036 typedef unsigned int CHandle;
00038 typedef unsigned int CResult;
00039 
00040 
00041 
00042 /*
00043  * Enums
00044  */
00045 
00049 enum _CResults {
00050     C_SUCCESS               = 0,    
00051     C_NOT_IMPLEMENTED,      
00052     C_INIT_ERROR,           
00053     C_INVALID_ARG,          
00054     C_INVALID_HANDLE,       
00055     C_INVALID_DEVICE,       
00056     C_NOT_EXIST,            
00057     C_NOT_FOUND,            
00058     C_BUFFER_TOO_SMALL,     
00059     C_SYNC_ERROR,           
00060     C_NO_MEMORY,            
00061     C_NO_HANDLES,           
00062     C_V4L2_ERROR,           
00063     C_SYSFS_ERROR,          
00064     C_PARSE_ERROR,          
00065     C_CANNOT_WRITE,         
00066     C_CANNOT_READ,          
00067 };
00068 
00069 
00075 typedef enum _CControlId {
00076     // UVC: Basic image control
00077     CC_BRIGHTNESS       = 1,            
00078     CC_CONTRAST,                        
00079     CC_GAIN,                            
00080     CC_SATURATION,                      
00081     CC_HUE,                             
00082     CC_GAMMA,                           
00083     CC_SHARPNESS,                       
00084 
00085     // UVC: Advanced image control
00087     CC_WHITE_BALANCE_TEMPERATURE,
00089     CC_AUTO_WHITE_BALANCE_TEMPERATURE,
00091     CC_WHITE_BALANCE_COMPONENT,
00093     CC_AUTO_WHITE_BALANCE_COMPONENT,
00095     CC_BACKLIGHT_COMPENSATION,
00097     CC_POWER_LINE_FREQUENCY,
00099     CC_AUTO_HUE,
00101     CC_AUTO_EXPOSURE_MODE,
00103     CC_AUTO_EXPOSURE_PRIORITY,
00105     CC_EXPOSURE_TIME_ABSOLUTE,
00107     CC_EXPOSURE_TIME_RELATIVE,
00108 
00109     // UVC: Optics control
00111     CC_AUTO_FOCUS,
00113     CC_FOCUS_ABSOLUTE,
00115     CC_FOCUS_RELATIVE,
00117     CC_IRIS_ABSOLUTE,
00119     CC_IRIS_RELATIVE,
00121     CC_ZOOM_ABSOLUTE,
00123     CC_ZOOM_RELATIVE,
00125     CC_DIGITAL_ZOOM,
00126 
00127     // UVC: Motion control
00129     CC_PAN_ABSOLUTE,
00131     CC_PAN_RELATIVE,
00133     CC_TILT_ABSOLUTE,
00135     CC_TILT_RELATIVE,
00137     CC_ROLL_ABSOLUTE,
00139     CC_ROLL_RELATIVE,
00140 
00141     // UVC: Misc
00143     CC_PRIVACY,
00144 
00145     // V4L2: Motion control (new since 2.6.26)
00147     CC_PAN_RESET,
00149     CC_TILT_RESET,
00150 
00151     // V4L2: Unknown controls
00153     CC_V4L2_BASE                = 0x1000,
00155     CC_V4L2_CUSTOM_BASE         = 0x2000,
00157     CC_V4L2_MPEG_BASE           = 0x3000,
00159     CC_V4L2_CAMERA_CLASS_BASE   = 0x4000,
00160 
00161     // Logitech (USB vendor ID: 0x046d)
00162     CC_LOGITECH_BASE = 0x046d0000,
00166     CC_LOGITECH_PANTILT_RELATIVE,
00170     CC_LOGITECH_PANTILT_RESET,
00171     // Illumination mode of the first LED.
00172     CC_LOGITECH_LED1_MODE,
00173     // Blinking frequency of the first LED.
00174     CC_LOGITECH_LED1_FREQUENCY,
00175     // Disable video processing (enable raw mode)
00176     CC_LOGITECH_DISABLE_PROCESSING,
00177     // Bits per pixel for raw (Bayer) mode
00178     CC_LOGITECH_RAW_BITS_PER_PIXEL,
00179 
00180 
00181 } CControlId;
00182 
00183 
00187 typedef enum _CControlFlags {
00190     CC_CAN_READ             = 1 << 0,
00194     CC_CAN_WRITE            = 1 << 1,
00196     CC_CAN_NOTIFY           = 1 << 2,
00197 
00198     // The control is a custom vendor control and not standardized in V4L2 or UVC.
00199     CC_IS_CUSTOM            = 1 << 8,
00200     // Set values are interpreted as being relative to the current value.
00201     CC_IS_RELATIVE          = 1 << 9,
00202     // The control triggers an action.
00203     CC_IS_ACTION            = 1 << 10,
00204 
00205 } CControlFlags;
00206 
00207 
00214 typedef enum _CControlType {
00218     CC_TYPE_RAW             = 1,
00221     CC_TYPE_BOOLEAN,
00224     CC_TYPE_CHOICE,
00226     CC_TYPE_BYTE,
00228     CC_TYPE_WORD,
00230     CC_TYPE_DWORD,
00231 
00232 } CControlType;
00233 
00234 
00238 typedef enum _CEventId {
00239     CE_CONTROL_INVALID      = 0,
00240 
00241 } CEventId;
00242 
00243 
00247 typedef enum _CEventFlags {
00248     CE_INVALID              = 0,
00249 
00250 } CEventFlags;
00251 
00252 
00256 typedef enum _CFrameSizeTypes {
00258     CF_SIZE_DISCRETE        = 1,
00260     CF_SIZE_CONTINUOUS,
00262     CF_SIZE_STEPWISE,
00263 
00264 } CFrameSizeTypes;
00265 
00266 
00270 typedef enum _CFrameIntervalTypes {
00272     CF_INTERVAL_DISCRETE        = 1,
00274     CF_INTERVAL_CONTINUOUS,
00276     CF_INTERVAL_STEPWISE,
00277 
00278 } CFrameIntervalTypes;
00279 
00280 
00284 typedef enum _CDynctrlFlags {
00286     CD_DONT_VALIDATE        = 1 << 0,
00288     CD_REPORT_ERRORS        = 1 << 1,
00290     CD_RETRIEVE_META_INFO   = 1 << 2,
00291 
00292 } CDynctrlFlags;
00293 
00294 
00298 typedef enum _CDynctrlMessageSeverity {
00299     CD_SEVERITY_ERROR       = 2,        
00300     CD_SEVERITY_WARNING     = 3,        
00301     CD_SEVERITY_INFO        = 4,        
00302 
00303 } CDynctrlMessageSeverity;
00304 
00305 
00306 
00307 /*
00308  * Structs
00309  */
00310 
00314 typedef struct _CUSBInfo {
00316     unsigned short  vendor;
00318     unsigned short  product;
00320     unsigned short  release;
00321 
00322 } CUSBInfo;
00323 
00324 
00328 typedef struct _CDevice {
00333     char            * shortName;
00334     
00337     char            * name;
00338 
00341     char            * driver;
00342 
00347     char            * location;
00348 
00350     CUSBInfo        usb;
00351 
00352 } CDevice;
00353 
00354 
00358 typedef struct _CControlRawValue {
00360     void            * data;
00362     unsigned int    size;
00363 
00364 } CControlRawValue;
00365 
00366 
00370 typedef struct _CControlValue {
00374     CControlType    type;
00375 
00376     union {
00381         int             value;
00382 
00385         CControlRawValue    raw;
00386     };
00387 
00388 } CControlValue;
00389 
00390 
00395 typedef struct _CControlChoice {
00399     int             index;
00400 
00403     char            * name;
00404 
00405 } CControlChoice;
00406 
00407 
00411 typedef struct _CControl {
00413     CControlId      id;
00415     char            * name;
00417     CControlType    type;
00419     CControlFlags   flags;
00420 
00422     CControlValue   value;
00424     CControlValue   def;
00425 
00426     union {
00430         struct {
00432             CControlValue   min;
00434             CControlValue   max;
00436             CControlValue   step;
00437         };
00438 
00441         struct {
00443             unsigned int    count;
00445             CControlChoice  * list;
00446             
00451             char            * names;
00452 
00453         } choices;
00454     };
00455 
00456 } CControl;
00457 
00458 
00462 typedef struct _CPixelFormat {
00467     char            fourcc[5];
00468 
00470     char            * name;
00471 
00474     char            * mimeType;
00475 
00476 } CPixelFormat;
00477 
00478 
00482 typedef struct _CFrameSize {
00484     CFrameSizeTypes type;
00485     
00486     union {
00489         struct {
00491             unsigned int    width;
00493             unsigned int    height;
00494         };
00495 
00499         struct {
00501             unsigned int    min_width;
00503             unsigned int    max_width;
00505             unsigned int    step_width;
00507             unsigned int    min_height;
00509             unsigned int    max_height;
00511             unsigned int    step_height;
00512         };
00513     };
00514 
00515 } CFrameSize;
00516 
00517 
00522 typedef struct _CFrameInterval {
00524     CFrameIntervalTypes type;
00525 
00526     union {
00529         struct {
00531             unsigned int    n;
00533             unsigned int    d;
00534         };
00535 
00539         struct {
00541             unsigned int    min_n;
00543             unsigned int    min_d;
00545             unsigned int    max_n;
00547             unsigned int    max_d;
00549             unsigned int    step_n;
00551             unsigned int    step_d;
00552         };
00553     };
00554 
00555 } CFrameInterval;
00556 
00557 
00561 typedef struct _CEvent {
00563     CEventId        id;
00564 
00566     char            * name;
00567 
00569     CEventFlags     flags;
00570 
00571 } CEvent;
00572 
00573 
00577 typedef struct _CDynctrlMessage {
00579     int             line;
00580 
00582     int             col;
00583 
00585     CDynctrlMessageSeverity severity;
00586 
00588     char            * text;
00589 
00590 } CDynctrlMessage;
00591 
00592 
00596 typedef struct _CVersionNumber {
00598     unsigned int    major;
00599 
00601     unsigned int    minor;
00602 
00603 } CVersionNumber;
00604 
00605 
00609 typedef struct _CDynctrlInfoListStats {
00611     unsigned int    successful;
00612 
00614     unsigned int    failed;
00615 
00616 } CDynctrlInfoListStats;
00617 
00618 
00622 typedef struct _CDynctrlInfo {
00624     CDynctrlFlags   flags;
00625 
00627     struct {
00629         CDynctrlInfoListStats   constants;
00630 
00632         CDynctrlInfoListStats   controls;
00633 
00635         CDynctrlInfoListStats   mappings;
00636 
00637     }               stats;
00638 
00640     struct {
00642         CVersionNumber  version;
00643 
00645         char            * author;
00646 
00648         char            * contact;
00649 
00651         char            * copyright;
00652 
00654         CVersionNumber  revision;
00655 
00656     }               meta;
00657 
00659     unsigned int    message_count;
00660 
00662     CDynctrlMessage * messages;
00663 
00664 } CDynctrlInfo;
00665 
00666 
00667 
00668 /*
00669  * Type definitions
00670  */
00671 
00675 typedef void (*CEventHandler)(CHandle hDevice, CEventId event_id, void *context);
00676 
00677 
00678 
00679 /*
00680  * Functions
00681  */
00682 
00683 #ifdef __cplusplus
00684 extern "C" {
00685 #endif
00686 
00687 extern CResult      c_init (void);
00688 extern void         c_cleanup (void);
00689 
00690 extern CHandle      c_open_device (const char *device_name);
00691 extern void         c_close_device (CHandle hDevice);
00692 
00693 extern CResult      c_enum_devices (CDevice *devices, unsigned int *size, unsigned int *count);
00694 extern CResult      c_get_device_info (CHandle hDevice, const char *device_name, CDevice *info, unsigned int *size);
00695 
00696 extern CResult      c_enum_pixel_formats (CHandle hDevice, CPixelFormat *formats, unsigned int *size, unsigned int *count);
00697 extern CResult      c_enum_frame_sizes (CHandle hDevice, const CPixelFormat *pixelformat, CFrameSize *sizes, unsigned int *size, unsigned int *count);
00698 extern CResult      c_enum_frame_intervals (CHandle hDevice, const CPixelFormat *pixelformat, const CFrameSize *framesize, CFrameInterval *intervals, unsigned int *size, unsigned int *count);
00699 
00700 extern CResult      c_enum_controls (CHandle hDevice, CControl *controls, unsigned int *size, unsigned int *count);
00701 extern CResult      c_set_control (CHandle hDevice, CControlId control_id, const CControlValue *value);
00702 extern CResult      c_get_control (CHandle hDevice, CControlId control_id, CControlValue *value);
00703 
00704 extern CResult      c_enum_events (CHandle hDevice, CEvent *events, unsigned int *size, unsigned int *count);
00705 extern CResult      c_subscribe_event (CHandle hDevice, CEventId event_id, CEventHandler handler, void *context);
00706 extern CResult      c_unsubscribe_event (CHandle hDevice, CEventId event_id);
00707 
00708 #ifndef DISABLE_UVCVIDEO_DYNCTRL
00709 extern CResult      c_add_control_mappings_from_file (const char *file_name, CDynctrlInfo *info);
00710 #endif
00711 
00712 extern char         *c_get_error_text (CResult error);
00713 extern char         *c_get_handle_error_text (CHandle hDevice, CResult error);
00714 
00715 #ifdef __cplusplus
00716 }
00717 #endif
00718 
00719 
00720 #endif /* C_WEBCAM_H */

Generated on Tue Nov 8 08:41:15 2011 for Webcam Library by Doxygen 1.4.6
Copyright © 2006-2008 Logitech.