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

kstars

v4ldriver.h

Go to the documentation of this file.
00001 #if 0
00002     V4L INDI Driver
00003     INDI Interface for V4L devices
00004     Copyright (C) 2003-2005 Jasem Mutlaq (mutlaqja@ikarustech.com)
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Lesser General Public
00008     License as published by the Free Software Foundation; either
00009     version 2.1 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Lesser General Public License for more details.
00015 
00016     You should have received a copy of the GNU Lesser General Public
00017     License along with this library; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 #endif
00021 
00022 #ifndef V4L_DRIVER_H
00023 #define V4L_DRIVER_H
00024 
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <string.h>
00028 #include <stdarg.h>
00029 #include <math.h>
00030 #include <unistd.h>
00031 #include <time.h>
00032 #include <fcntl.h>
00033 #include <signal.h>
00034 #include <errno.h>
00035 #include <sys/stat.h>
00036 #include <sys/time.h>
00037 #include <sys/types.h>
00038 #include <sys/socket.h>
00039 #include <netinet/in.h>
00040 #include <netdb.h>
00041 #include <zlib.h>
00042 #include <asm/types.h>
00043 
00044 #include "indidevapi.h"
00045 #include "indicom.h"
00046 #include "fitsrw.h"
00047 #include "eventloop.h"
00048 
00049 #ifdef HAVE_CONFIG_H
00050 #include <config.h>
00051 #endif
00052 
00053 #ifdef HAVE_LINUX_VIDEODEV2_H
00054 #include "webcam/v4l2_base.h"
00055 #else
00056 #include "webcam/v4l1_base.h"
00057 #endif 
00058 
00059 #define COMM_GROUP  "Main Control"
00060 #define IMAGE_CONTROL   "Image Control"
00061 #define IMAGE_GROUP "Image Settings"
00062 
00063 #define MAX_PIXELS  4096        /* Max number of pixels in one dimension */
00064 #define ERRMSGSIZ   1024
00065 
00066 
00067 class V4L_Driver
00068 {
00069   public:
00070     V4L_Driver();
00071     virtual ~V4L_Driver();
00072 
00073     /* INDI Functions that must be called from indidrivermain */
00074     virtual void ISGetProperties (const char *dev);
00075     virtual void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
00076     virtual void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n);
00077     virtual void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
00078 
00079     virtual void initCamBase();
00080     virtual void initProperties(const char *dev);
00081 
00082     static void newFrame(void *p);
00083     void updateFrame();
00084 
00085    protected:
00086 
00087    /* Structs */
00088    typedef struct {
00089     int  width;
00090     int  height;
00091     int  expose;
00092     unsigned char  *Y;
00093     unsigned char  *U;
00094     unsigned char  *V;
00095     unsigned char  *colorBuffer;
00096     unsigned char  *compressedFrame;
00097     } img_t;
00098 
00099 
00100    /* Switches */
00101     ISwitch PowerS[2];
00102     ISwitch StreamS[2];
00103     ISwitch CompressS[2];
00104     ISwitch ImageTypeS[2];
00105     
00106     /* Texts */
00107     IText PortT[1];
00108     IText camNameT[1];
00109 
00110     /* Numbers */
00111     INumber ExposeTimeN[1];
00112     INumber FrameRateN[1];
00113     INumber FrameN[4];
00114     #ifndef HAVE_LINUX_VIDEODEV2_H
00115     INumber ImageAdjustN[5];
00116     #endif
00117     
00118     /* BLOBs */
00119     IBLOB imageB;
00120     
00121     /* Switch vectors */
00122     ISwitchVectorProperty PowerSP;              /* Connection switch */
00123     ISwitchVectorProperty StreamSP;             /* Stream switch */
00124     ISwitchVectorProperty CompressSP;               /* Compress stream switch */
00125     ISwitchVectorProperty ImageTypeSP;              /* Color or grey switch */
00126 
00127     /* Number vectors */
00128     INumberVectorProperty ExposeTimeNP;             /* Exposure */
00129     INumberVectorProperty FrameRateNP;              /* Frame rate */
00130     INumberVectorProperty FrameNP;              /* Stream dimenstion */
00131     INumberVectorProperty ImageAdjustNP;            /* Image controls */
00132 
00133     /* Text vectors */
00134     ITextVectorProperty PortTP;
00135     ITextVectorProperty camNameTP;
00136     
00137     /* BLOB vectors */
00138     IBLOBVectorProperty imageBP;                /* Data stream */
00139 
00140    /* Initilization functions */
00141    virtual void connectCamera(void);
00142    virtual void getBasicData(void);
00143 
00144    /* Stream/FITS functions */
00145    void updateStream();
00146    void uploadFile(const char * filename);
00147    int  writeFITS(const char *filename, char errmsg[]);
00148    int  grabImage(void);
00149    FITS_HDU_LIST * create_fits_header (FITS_FILE *ofp, uint width, uint height, uint bpp);
00150 
00151    /* Helper functions */
00152    int  checkPowerN(INumberVectorProperty *np);
00153    int  checkPowerS(ISwitchVectorProperty *sp);
00154    int  checkPowerT(ITextVectorProperty *tp);
00155 
00156    #ifndef HAVE_LINUX_VIDEODEV2_H
00157    virtual void updateV4L1Controls();
00158    V4L1_Base *v4l_base;
00159    #else
00160    virtual void updateV4L2Controls();
00161    V4L2_Base *v4l_base;
00162    #endif
00163 
00164    char device_name[MAXINDIDEVICE];
00165    int frameCount;          /* For debugging */
00166    double divider;          /* For limits */
00167    img_t * V4LFrame;            /* Video frame */
00168 
00169 };
00170    
00171 #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