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 #ifdef HAVE_CONFIG_H
00005 #include <config.h>
00006 #endif
00007 
00008 #include <sys/types.h>
00009 #include <linux/videodev.h>
00010 
00011 #include <qarray.h>
00012 #include <qcolor.h>
00013 #include <qimage.h>
00014 #include <qobject.h>
00015 #include <qsocketnotifier.h>
00016 #include <qtimer.h>
00017 #include <qvector.h>
00018 
00019 #include "VideoDeviceInput.h"
00020 #include "VideoAudioInput.h"
00021 
00022 class CVideoDevice: public QObject
00023 {
00024 friend class CVideoDeviceInput;
00025 friend class CVideoDeviceTuner;
00026 friend class CVideoAudioInput;
00027    Q_OBJECT
00028 private:
00029    bool validated;
00030    QString NodeName, IntfName;
00031    int CamFD, Opened;
00032    bool UseSelect, HasFramerate;
00033    int Capturing;
00034    int Palette, FrameRate;
00035    int PalRGB, PalYUV;
00036    struct video_picture VPic;
00037    struct video_mbuf VMBuf;
00038    int Buffers, CurBuffer;
00039 
00040    QVector <CVideoDeviceInput>VideoInputs;
00041    int CurrentVideoInput;
00042    QVector <CVideoAudioInput>AudioInputs;
00043    int CurrentAudioInput;
00044 
00045    QVector<QImage> RGB;
00046    QVector<QImage> Y, U, V;
00047    QImage *pNullImage;
00048    QRgb GrayScale[256];
00049 
00050    int image_w, image_h;
00051    int max_w, max_h;
00052    int min_w, min_h;
00053    uchar *vid_io_buffer;                // The buffer used for I/O; this can be mmap()ed or malloc()ed
00054    uchar *rgb_vid_buffer;               // The buffer for rgb images; may point to vid_io_buffer
00055    uchar *yuv_vid_buffer;               // The buffer for yuv images; may point to vid_io_buffer
00056    QArray<int> vid_io_offsets, rgb_vid_offsets, yuv_vid_offsets;
00057    int vid_io_buffer_size, vid_io_image_size;
00058 
00059    QSocketNotifier *pImageSocket;
00060    QTimer *pImageTimer;
00061 
00062    void Init();
00063    void CleanUp();
00064 
00065    bool TryPalette(int pal, int depth);
00066    void SetPalette();
00067    void CalcVidIoSize();
00068    
00069    int MCapture(int buf);
00070    int MSync();
00071 
00072    void CreateImagesRGB();
00073    void ResetImagesRGB();
00074    void CreateImagesYUV();
00075    void ResetImagesYUV();
00076    
00077    void StartCapture();
00078    void StopCapture();
00079 
00080 private slots:
00081    void LoadImage();
00082 
00083 public:
00084    CVideoDevice(const QString &node_name);
00085    ~CVideoDevice();
00086 
00087    bool IsValid();
00088 
00089    int Open(int buffers = 1);
00090    void Close();
00091    int GetDescriptor() const;
00092    
00093    void EnableRGB(bool isOn);
00094    void EnableYUV(bool isOn);
00095 
00096    QString GetNodeName() const;
00097    QString GetIntfName() const;
00098    
00099    QSize GetMinSize() const;
00100    QSize GetSize();
00101    QSize GetMaxSize() const;
00102    bool  SetSize(int width, int height);
00103    bool  SetSize(const QSize &new_size);
00104    int   GetFramerate() const;
00105    bool  SetFramerate(int fps);
00106    int   GetMBuffers() const;
00107    int   GetBuffers() const;
00108 
00109    int   GetVideoInputs() const;
00110    int   GetCurrentVideoInput() const;
00111    CVideoDeviceInput *GetVideoInput(int number = -1) const;
00112    bool  SelectVideoInput(int number);
00113    
00114    int   GetAudioInputs() const;
00115    CVideoAudioInput *GetAudioInput(int number = -1) const;
00116    bool  SelectAudioInput(int number);
00117    
00118    int GetBrightness() const;
00119    bool SetBrightness(int val);
00120    int GetContrast() const;
00121    bool SetContrast(int val);
00122    int GetHue() const;
00123    bool SetHue(int val);
00124    int GetColour() const;
00125    bool SetColour(int val);
00126    int GetWhiteness() const;
00127    bool SetWhiteness(int val);
00128    
00129    int ReadImage();
00130 
00131    QImage *GetRGB(int offset = 0) const;
00132    QImage *GetY(int offset = 0) const;
00133    QImage *GetU(int offset = 0) const;
00134    QImage *GetV(int offset = 0) const;
00135 
00136 signals:   
00138    void Notify();
00140    void Closed();
00142    void Resized(const QSize &new_size);
00144    void FramerateChanged(int);
00146    void ChangedVideoInput(int input);
00148    void ChangedTunerNorm(int tuner, int norm);
00150    void Error(int err_num);
00151 };
00152 
00153 #endif

Generated at Sat May 18 02:56:55 2002 for Camstream by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001