Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

VideoDevice.h

Go to the documentation of this file.
00001 #ifndef VIDEO_DEVICE_HPP
00002 #define VIDEO_DEVICE_HPP
00003 
00004 #include <sys/ioctl.h>
00005 #include <sys/types.h>
00006 #include <linux/videodev.h>
00007 
00008 #include <qimage.h>
00009 #include <qobject.h>
00010 #include <qsocketnotifier.h>
00011 #include <qtimer.h>
00012 #include <qvector.h>
00013 
00014 #include "VideoDeviceInput.h"
00015 
00016 class CVideoDevice: public QObject
00017 {
00018 friend class CVideoDeviceInput;
00019 friend class CVideoDeviceTuner;
00020    Q_OBJECT
00021 private:
00022    bool validated;
00023    QString NodeName, IntfName;
00024    int CamFD, Opened;
00025    bool UseSelect, HasFramerate;
00026    int Palette, FrameRate;
00027    int PalRGB, PalYUV;
00028    struct video_picture VPic;
00029    struct video_mbuf VMBuf;
00030    int Buffers, CurBuffer;
00031 
00032    QVector <CVideoDeviceInput>Inputs;
00033    int CurrentInput;
00034 
00035    QImage *RGB, *Y, *U, *V;
00036    int image_w, image_h;
00037    int max_w, max_h;
00038    int min_w, min_h;
00039    uchar *vid_buffer;
00040    int vid_buffer_size, image_buffer_size;
00041 
00042    QSocketNotifier *pImageSocket;
00043    QTimer *pImageTimer;
00044 
00045    void Init(bool First = FALSE);
00046    void CleanUp();
00047    bool TryPalette(int pal, int depth);
00048    void SetPalette();
00049    
00050    int MCapture(int buf);
00051    int MSync();
00052 
00053    void CreateImagesRGB();
00054    void ResetImagesRGB();
00055    void CreateImagesYUV();
00056    void ResetImagesYUV();
00057 
00058 private slots:
00059    void LoadImage();
00060 
00061 public:
00062    CVideoDevice(const QString &node_name);
00063    ~CVideoDevice();
00064 
00065    bool IsValid();
00066 
00067    int Open(int buffers = 1);
00068    void Close();
00069    int GetDescriptor() const;
00070    
00071    void EnableRGB(bool isOn);
00072    void EnableYUV(bool isOn);
00073 
00074    QString GetNodeName() const;
00075    QString GetIntfName() const;
00076    
00077    QSize GetMinSize() const;
00078    QSize GetSize();
00079    QSize GetMaxSize() const;
00080    bool  SetSize(int width, int height);
00081    bool  SetSize(const QSize &new_size);
00082    int   GetFramerate() const;
00083    bool  SetFramerate(int fps, bool snap = FALSE);
00084    int   GetMBuffers() const;
00085 
00086    int   GetInputs() const;
00087    int   GetCurrentInput() const;
00088    CVideoDeviceInput *GetInput(int number) const;
00089    bool SelectInput(int number);
00090    
00091    int GetBrightness() const;
00092    bool SetBrightness(int val);
00093    int GetContrast() const;
00094    bool SetContrast(int val);
00095    int GetHue() const;
00096    bool SetHue(int val);
00097    int GetColour() const;
00098    bool SetColour(int val);
00099    int GetWhiteness() const;
00100    bool SetWhiteness(int val);
00101    
00102    int ReadImage();
00103 
00104    QImage *GetRGB(int offset = 0) const;
00105    QImage *GetY(int offset = 0) const;
00106    QImage *GetU(int offset = 0) const;
00107    QImage *GetV(int offset = 0) const;
00108 
00109 signals:   
00111    void Notify();
00113    void Resized(const QSize &new_size);
00115    void ChangedInput(int input);
00117    void ChangedTunerNorm(int tuner, int norm);
00119    void Error(int err_num);
00120 };
00121 
00122 #endif

Generated at Wed Jun 20 02:51:23 2001 for Camstream by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001