Main Page | Class List | File List

kvdr.h

00001 /***************************************************************************
00002                           kvdr.h  -  description
00003                              -------------------
00004     begin                : Sat Aug  5 13:32:09 MEST 2000
00005     copyright            : (C) 2000 by Guido
00006     email                : gfiala@s.netic.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef KVDR_H
00019 #define KVDR_H                                               -----
00020 
00021 #define QT_CLEAN_NAMESPACE
00022 #include <config.h>
00023 
00024 #include <qwidget.h>
00025 #include <qstring.h>
00026 #include <qtimer.h>
00027 #include <qfile.h>
00028 #include <qcursor.h>
00029 
00030 #include <kapp.h>
00031 #include <kaccel.h>
00032 #include <kprocess.h>
00033 #include <kcmdlineargs.h>
00034 
00035 #include "svdrpc.h"
00036 #include "ckvdrcfg.h"
00037 
00038 #define _STRUCT_TIMESPEC
00039 #undef __need_timeval
00040 #undef __USE_POSIX199309
00041 #define _LINUX_TIME_H
00042 #include <linux/videodev.h>
00043 
00044 #include <sys/stat.h>
00045 #include <sys/ioctl.h>
00046 #include <sys/fcntl.h>
00047 #include <sys/mman.h>
00048 #include <unistd.h>
00049 
00050 #define HAVE_SYS_SOUNDCARD_H 1
00051 #ifdef HAVE_SOUNDCARD_H
00052 # include <soundcard.h>
00053 #endif
00054 #ifdef HAVE_SYS_SOUNDCARD_H
00055 # include <sys/soundcard.h>
00056 #endif
00057 
00058 // includes needed for X stuff
00059 #include <X11/X.h>
00060 #include <X11/Xmd.h>
00061 
00062 #define DEFAULT_VIDEO_DEV "/dev/video"
00063 
00064 #define HAVE_LIBXV//will not work without so far, ToDo: put it into configure-scripts
00065 
00066 #ifdef HAVE_LIBXV
00067 class XvDisplayer;
00068 #endif
00069 
00070 #define USE_DPMS 1 //uncomment this line if wished and add "-lDPMS" in linking options
00071 //#define USE_VFAT_FS 1 //uncomment if you store your images at VFAT filesystems
00072                         //that avoids using the colon ":" in the name...
00073 
00074 #define MAXCLIPRECTS 100
00075 
00076 typedef struct CRect
00077 {
00078   signed short x,y,width,height;
00079 };
00080 
00081 class Kvdr : public QWidget
00082 {
00083   Q_OBJECT
00084   public:
00085     Kvdr(QWidget* parent=0, const char *name=0);
00086     ~Kvdr();
00087     bool isPAL,ismute,isXv,tinySticky;
00088     int XvDi;
00089     float video_aspect_ratio, aspect_ratio;
00090     QString basename;//set by dialog & .kdvrrc
00091     int brightness, colour, hue, contrast, VidDev;//set by dialog & .kdvrrc
00092     int i_size_x, i_size_y, i_g_size_x, i_g_size_y, i_jpg_qual;//set by dialog & .kdvrrc
00093     unsigned int vdr_port, Volume, FrontRear, MixerChannel;//set by dialog & .kdvrrc
00094     int display_width,display_height;
00095     QStrList mixerdevlist;
00096     QString StrMixerChannel;
00097     cSVDRPC *svdrpc;
00098     QTimer AdjustSizeTimer;//used to correct geometry after resize-Events...
00099     void SetVolume(int Volume, QString MGroup, int FrontRearBalance);
00100     void save_kvdrrc();
00101     QTimer CheckClippingTimer;//used to check Clipping on a regular basis - workaround!
00102     int bpp, palette;
00103     void *base;
00104     void doClipping(bool doit=1);
00105     QFile video_fd;
00106     QFile multivideo_fd[4];
00107   private:
00108     bool vdr_mb_shown,kde_sc_was_running;
00109     QTimer RefreshDisplayTimer;//used to refresh Display out of doClipping()
00110     KAccel *userKeys;
00111     ckvdrcfg *cnfdlg;
00112     QRect prevSize,saveGeom,savePos;
00113     QCursor orgCursor;
00114     QPoint orgpos;
00115     bool isfullscreen, stayontop, ovlstat, store, dirty_position;
00116     bool res_was_switched, RefreshEntireScreen;
00117     bool ismultivideo, use_dvb_mixer;
00118     int lp_x,lp_y,pip_pos,pip_dev,o_cursor;
00119     int didRefresh,num_of_consecutive_expose_events;
00120     int old_vol;
00121     Display *disp;
00122     int ss_timeout,ss_interval,ss_prefer_blanking,ss_allow_exposures;
00123     int vdr_timeout;
00124 #ifdef USE_DPMS
00125     CARD16 dpms_state;
00126 #endif
00127 #ifdef HAVE_LIBXV
00128     char *xv_mem[4];
00129     struct video_mmap *xv_vm[4];
00130           struct video_mbuf *xv_mb[4];
00131     bool stopXv;
00132                 XvDisplayer *Xvdsp;
00133 #endif
00134     int (*oldXErrorHandler)();
00135     Window root;
00136     int screen;
00137     int newVisibility;
00138     int vm_count;
00139     BOOL dpms_on;
00140     int f_size_x, f_size_y, f_x, f_y;
00141     void GetNextFilename(QString& fn, const char* basename, const char* ext);
00142     void moveEvent(QMoveEvent*);
00143     void resizeEvent(QResizeEvent*);
00144                 void hideEvent(QHideEvent*);
00145                 void showEvent(QShowEvent*);
00146     void refreshDisplay(const QRect& rect);
00147     KCmdLineArgs *args;
00148     CRect cr[MAXCLIPRECTS];
00149     CRect cr1[MAXCLIPRECTS];
00150     void addCRect(int &cc, int x, int y, int w, int h);
00151     void load_kvdrrc();
00152     //overlay capabilities
00153     bool OvlG(int SizeX, int SizeY, int PosX, int PosY);
00154     bool OvlC(int ClipCount, CRect *cr);
00155     bool OvlO(bool Value);
00156     bool GImg(const char *FileName, bool Jpeg, int Quality, int SizeX, int SizeY);
00157     bool ovlFbSet, ovlGeoSet, ovlStat;
00158     int  ovlFbSizeX,ovlFbSizeY,ovlBpp,ovlPalette;
00159     int  ovlBrightness,ovlColour,ovlHue,ovlContrast,ovlClipCount;
00160     int  ovlSizeX, ovlSizeY, ovlPosX, ovlPosY;
00161                 int  rem_hdisplay,rem_vdisplay;
00162     struct video_clip ovlClipRects[MAXCLIPRECTS][4];
00163     //some functions and variables for the mixer:
00164     /* The following mixer device would be set to record mode and
00165        controls the rear speaker volume: */
00166     #define REAR "IGain"
00167     QFile mix;  // "/dev/mixer" File handle
00168     int         dev;  // Mixer Volume Device
00169     int   rdev; // Mixer Rear-Volume Device
00170     char  mixer_devices[128];
00171 
00172                 char* InitMixer(void);
00173     void SetMixer(const char *device, int FrontVolume, int RearVolume);
00174     void ExitMixer(void);
00175 public: //for the configuration dialog only:
00176     bool OvlF(int SizeX, int SizeY, int FbAddr, int Bpp, int Palette);
00177     bool OvlP(int Brightness, int Colour, int Hue, int Contrast);
00178 protected:
00179     bool x11Event( XEvent *event );
00180     void mouseMoveEvent( QMouseEvent *event );
00181     int crs_hide_cnt;
00182 #define CSR_HIDE_TIME 20
00183 protected slots:
00184     void QuitSLOT();
00185     void HelpSLOT();
00186     void MuteSLOT();
00187     void VolumeUpSLOT();
00188     void VolumeDownSLOT();
00189     void RearVolumeUpSLOT();
00190     void RearVolumeDownSLOT();
00191     void FullscreenSLOT();
00192     void GrabJpgSLOT();
00193     void GrabPnmSLOT();
00194     void ConfigurationSLOT();
00195     void AdjustAspectRatioSlot();
00196     void RefreshDisplaySlot();
00197     void CheckClippingTimerSlot();
00198     void ZapVideoDevSlot();
00199     void MultiVideoDevSlot();
00200     void PiPposSlot();
00201     void PiPzapSlot();
00202     void PipexchangeSlot();
00203     void OvlCursorSlot();
00204     void TinyStickySlot();
00205 #ifdef HAVE_LIBXV
00206                 void XvDeinterlaceSLOT();
00207                 void XvSLOT();
00208 #else
00209                 void XvDeinterlaceSLOT(){};
00210                 void XvSLOT(){};
00211 #endif
00212     //just all the keys vdr knows about:
00213     void KeyMenuSLOT(){svdrpc->CmdTKey("Menu");}
00214     void KeyOkSLOT(){svdrpc->CmdTKey("Ok");}
00215     void KeyLeftSLOT(){svdrpc->CmdTKey("Left");}
00216     void KeyRightSLOT(){svdrpc->CmdTKey("Right");}
00217     void KeyUpSLOT(){svdrpc->CmdTKey("Up");}
00218     void KeyDownSLOT(){svdrpc->CmdTKey("Down");}
00219     void KeyBackSLOT(){svdrpc->CmdTKey("Back");}
00220     void KeyRedSLOT(){svdrpc->CmdTKey("Red");}
00221     void KeyGreenSLOT(){svdrpc->CmdTKey("Green");}
00222     void KeyYellowSLOT(){svdrpc->CmdTKey("Yellow");}
00223     void KeyBlueSLOT(){svdrpc->CmdTKey("Blue");}
00224     void Key0SLOT(){svdrpc->CmdTKey("0");}
00225     void Key1SLOT(){svdrpc->CmdTKey("1");}
00226     void Key2SLOT(){svdrpc->CmdTKey("2");}
00227     void Key3SLOT(){svdrpc->CmdTKey("3");}
00228     void Key4SLOT(){svdrpc->CmdTKey("4");}
00229     void Key5SLOT(){svdrpc->CmdTKey("5");}
00230     void Key6SLOT(){svdrpc->CmdTKey("6");}
00231     void Key7SLOT(){svdrpc->CmdTKey("7");}
00232     void Key8SLOT(){svdrpc->CmdTKey("8");}
00233     void Key9SLOT(){svdrpc->CmdTKey("9");}
00234     void RecordSLOT(){svdrpc->CmdTKey("Record");}
00235 #define Num_OSD_Lines 14
00236     void PgUpSLOT(){for(int i=0;i<Num_OSD_Lines;i++,svdrpc->CmdTKey("Up"));}
00237     void PgDownSLOT(){for(int i=0;i<Num_OSD_Lines;i++,svdrpc->CmdTKey("Down"),usleep(10000));}
00238 public slots:
00239     void OverlayOnOffSLOT(int state=0);
00240 };
00241 
00242 #endif

Generated on Tue Jan 17 18:19:44 2006 for kvdr.kdevelop by doxygen 1.3.5