Main Page   Class Hierarchy   Compound List   File List   Compound Members  

kxv.h

00001 /* 
00002     KDE Xv interface
00003 
00004     Copyright (C) 2001 George Staikos (staikos@kde.org)
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program 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
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 
00022 #ifndef __KXV_H
00023 #define __KXV_H
00024 
00025 #include <X11/X.h>
00026 #include <X11/Xlib.h>
00027 #include <qstring.h>
00028 #include <qstringlist.h>
00029 #include <qlist.h>
00030 #include <qpixmap.h>
00031 
00032 class QWidget;
00033 
00034 class KXvPrivate;
00035 class KXvDevice;
00036 class KXvDevicePrivate;
00037 
00038 typedef QList<KXvDevice> KXvDeviceList;
00039 
00040 
00041 class KXv {
00042 public:
00043   ~KXv();
00044 
00045   /*
00046    *   To get access to the Xv extension, you call this method.  It will return
00047    *   a KXv* object on success, or NULL if it can't connect.
00048    *
00049    *   d is typically the Window ID
00050    */
00051   static KXv *connect(Drawable d);
00052 
00053   /*
00054    *   True if we can connect to the Xv extension.
00055    */
00056   static bool haveXv();
00057 
00058   /*
00059    *   Return the list of Xv devices
00060    */
00061   KXvDeviceList& devices();
00062 
00063 protected:
00064   KXv();
00065   bool init(Drawable d);
00066 
00067   /***   XV info   ***/
00068   unsigned int xv_version, xv_release, xv_request, xv_event, xv_error;
00069   unsigned int xv_adaptors;
00070   void *xv_adaptor_info;
00071 
00072 
00073   KXvDeviceList _devs;
00074 
00075 
00076 private:
00077   KXvPrivate *d;
00078 };
00079 
00080 
00081 
00082 class KXvDeviceAttribute {
00083 public:
00084   QString name;
00085   int min;
00086   int max;
00087   int flags;
00088 
00089   Atom atom();
00090 };
00091 
00092 typedef QList<KXvDeviceAttribute> KXvDeviceAttributes;
00093 
00094 
00095 
00096 class KXvDevice {
00097 friend class KXv;
00098 public:
00099 
00100   KXvDevice();
00101   ~KXvDevice();
00102 
00103   /*
00104    *   return the list of known attributes
00105    */
00106   const KXvDeviceAttributes& attributes();
00107 
00108   /*
00109    *   return the range for a given attribute
00110    */
00111   bool getAttributeRange(QString attribute, int *min, int *max);
00112 
00113   /*
00114    *   get the current value of a given attribute
00115    */
00116   bool getAttribute(QString attribute, int *val);
00117 
00118   /*
00119    *   set the current value of a given attribute
00120    */
00121   bool setAttribute(QString attribute, int val);
00122 
00123   bool grabStill(QPixmap *pix, int dw, int dh);
00124 
00125   /*
00126    *   True if this device can operate on the given widget
00127    */
00128   bool supportsWidget(QWidget *w);
00129 
00130   /*
00131    *   Display the given image with Xv.
00132    */
00133   int displayImage(QWidget *widget, const unsigned char *const data, int w, int h, int dw, int dh);
00134   int displayImage(Window win, const unsigned char *const data, int w, int h, int dw, int dh);
00135 
00136   /*
00137    *   Start a video stream in widget w, width dw, height dh
00138    */
00139   bool startVideo(QWidget *w, int dw, int dh);
00140   bool startVideo(Window w, int dw, int dh);
00141 
00142   /*
00143    *   Is the video playing
00144    */
00145   bool videoPlaying() const;
00146 
00147   /*
00148    *   Stop video stream
00149    */
00150   bool stopVideo();
00151 
00152   /*
00153    *   True if this is an image output backend (video card)
00154    */
00155   bool isImageBackend();
00156 
00157   /*
00158    *   True if this is a video source
00159    */
00160   bool isVideoSource();
00161 
00162   /*
00163    *   Name of the device
00164    */
00165   const QString& name() const;
00166 
00167   /*
00168    *   The Xv port for this device
00169    */
00170   int port() const;
00171 
00172   /*
00173    *   The list of encodings/norms available
00174    */
00175   const QStringList& encodings() const;
00176 
00177   /*
00178    *   Set the encoding to the given one.  This should be taken from the list.
00179    */
00180   bool setEncoding(const QString& e);
00181 
00182   /*
00183    *   Set the image format. (ex YUV)
00184    */
00185   int setImageFormat(int format);
00186 
00187   /*
00188    *   Get the current image format
00189    */
00190   int imageFormat() const;
00191 
00192   /*
00193    *   Use SHM for PutImage if available
00194    */
00195   bool useShm(bool on);
00196 
00197   /*
00198    *   Is SHM being used?
00199    */
00200   bool usingShm() const;
00201 
00202 protected:
00203 
00204   bool init();
00205 
00206   bool _shm;
00207   KXvDeviceAttributes _attrs;
00208 
00209   int xv_type, xv_adaptor;
00210   QString xv_name;
00211   int xv_port;
00212   unsigned int xv_encodings;
00213   int xv_encoding;
00214   void *xv_encoding_info;
00215   int xv_encoding_attributes;
00216   void *xv_attr;
00217   GC xv_gc;
00218   Window xv_last_win;
00219 
00220   QStringList _encodingList;
00221 
00222   int xv_formats;
00223   void *xv_formatvalues;
00224 
00225   int xv_nvisualformats;
00226   void *xv_visualformats;  // XvFormat*
00227 
00228   bool videoStarted;
00229   Window videoWindow;
00230 
00231   long xv_imageformat;
00232 
00233   void *xv_shminfo;
00234   void *xv_image;
00235   int xv_image_w;
00236   int xv_image_h;
00237   bool _haveShm;
00238 
00239 private:
00240 
00241   KXvDevicePrivate *d;
00242 
00243   void rebuildImage(int w, int h, bool shm);
00244   void destroyImage();
00245 };
00246 
00247 
00248 #endif
00249 

Generated at Thu Jan 30 02:56:02 2003 for QtVision by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001