• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

v4l2_base.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005 by Jasem Mutlaq
00003 
00004     Based on V4L 2 Example
00005     http://v4l2spec.bytesex.org/spec-single/v4l2.html#CAPTURE-EXAMPLE
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 */
00022 
00023 #ifndef V4L2_BASE_H
00024 #define V4L2_BASE_H
00025 
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include "videodev2.h"
00029 #include "../eventloop.h"
00030 #include "../indidevapi.h"
00031 
00032 #define VIDEO_COMPRESSION_LEVEL     4
00033 
00034 class V4L2_Base
00035 {
00036   public:
00037    V4L2_Base();
00038    virtual ~V4L2_Base();
00039 
00040    typedef enum { IO_METHOD_READ, IO_METHOD_MMAP, IO_METHOD_USERPTR } io_method;
00041 
00042    struct buffer
00043    {
00044         void *                  start;
00045         size_t                  length;
00046    };
00047 
00048   /* Connection */
00049   virtual int connectCam(const char * devpath, char *errmsg, int pixelFormat = V4L2_PIX_FMT_YUYV , int width = 160, int height = 120);
00050   virtual void disconnectCam();
00051   char * getDeviceName();
00052 
00053   /* Image settings */
00054   int  getBrightness();
00055   int  getContrast();
00056   int  getColor();
00057   int  getHue();
00058   int  getWhiteness();
00059   void setContrast(int val);
00060   void setBrightness(int val);
00061   void setColor(int val);
00062   void setHue(int val);
00063   void setWhiteness(int val);
00064 
00065   /* Updates */
00066   void callFrame(void *p);
00067   void setPictureSettings();
00068   void getPictureSettings();
00069 
00070   /* Image Size */
00071   int getWidth();
00072   int getHeight();
00073   virtual int setSize(int x, int y);
00074   virtual void getMaxMinSize(int & x_max, int & y_max, int & x_min, int & y_min);
00075 
00076   /* Frame rate */
00077   void setFPS(int fps);
00078   int  getFPS();
00079 
00080   void allocBuffers();
00081   unsigned char * getY();
00082   unsigned char * getU();
00083   unsigned char * getV();
00084   unsigned char * getColorBuffer();
00085 
00086   void registerCallback(WPF *fp, void *ud);
00087 
00088   int start_capturing(char *errmsg);
00089   int stop_capturing(char *errmsg);
00090   static void newFrame(int fd, void *p);
00091   
00092   void enumerate_ctrl (void);
00093   void enumerate_menu (void);
00094   int  queryINTControls(INumberVectorProperty *nvp);
00095   int  setINTControl(unsigned int ctrl_id, double new_value, char *errmsg);
00096 
00097   int  query_ctrl(unsigned int ctrl_id, double & ctrl_min, double & ctrl_max, double & ctrl_step, double & ctrl_value, char *errmsg);
00098 
00099   protected:
00100 
00101   int xioctl(int fd, int request, void *arg);
00102   int read_frame(char *errsg);
00103   int uninit_device(char *errmsg);
00104   int open_device(const char *devpath, char *errmsg);
00105   int init_device(char *errmsg, int pixelFormat , int width, int height); 
00106   int init_mmap(char *errmsg);
00107   int errno_exit(const char *s, char *errmsg);
00108   
00109   void close_device(void);
00110   void init_userp(unsigned int buffer_size);
00111   void init_read(unsigned int buffer_size);
00112 
00113   void findMinMax();
00114   
00115   struct v4l2_capability cap;
00116   struct v4l2_cropcap cropcap;
00117   struct v4l2_crop crop;
00118   struct v4l2_format fmt;
00119 
00120   struct v4l2_queryctrl queryctrl;
00121   struct v4l2_querymenu querymenu;
00122 
00123   WPF *callback;
00124   void *uptr;
00125   char          dev_name[64];
00126   io_method io;
00127   int           fd;
00128   struct buffer *buffers;
00129   unsigned int  n_buffers;
00130 
00131   bool      dropFrame;
00132 
00133   
00134   int frameRate;
00135   int  xmax, xmin, ymax, ymin;
00136   int  selectCallBackID;
00137   unsigned char * YBuf,*UBuf,*VBuf, *colorBuffer, *rgb24_buffer;
00138 
00139 };
00140    
00141 #endif

kstars

Skip menu "kstars"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal