Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

VideoDevice.h

Go to the documentation of this file.
00001 /* CVideoDevice: video capture base class 00002 part of CamStream: a collection of GUI webcam tools 00003 Copyright (C) 2002 Nemosoft Unv. 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 For questions, remarks, patches, etc. for this program, the author can be 00020 reached at camstream@smcc.demon.nl. 00021 */ 00022 00023 #ifndef VIDEO_DEVICE_HPP 00024 #define VIDEO_DEVICE_HPP 00025 00026 #ifdef HAVE_CONFIG_H 00027 #include "config.h" 00028 #endif 00029 00030 #include <qglobal.h> 00031 00032 #if (QT_VERSION >= 0x030000) 00033 #include <qmutex.h> 00034 #endif 00035 00036 #include <qarray.h> 00037 #include <qcolor.h> 00038 #include <qdom.h> 00039 #include <qimage.h> 00040 #include <qlist.h> 00041 #include <qobject.h> 00042 #include <qsocketnotifier.h> 00043 #include <qtimer.h> 00044 #include <qthread.h> 00045 #include <qvector.h> 00046 00047 #include "VideoFrame.h" 00048 00049 #include "TVChannel.h" 00050 00051 class CChannelEditorDlg; 00052 00053 class CVideoDevice: public QObject, protected QThread 00054 { 00055 friend class CVideoCollector; 00056 Q_OBJECT 00057 public: 00058 enum Signals { 00059 frame_ready = 1, 00060 }; 00061 00062 private: 00063 enum Palettes { 00064 RGB, 00065 YUV, 00066 }; 00067 00068 QList<CVideoFrame> m_VideoFrames; 00069 QList<CVideoFrame> m_EmptyFrames, m_FullFrames; 00070 CVideoFrame *m_pFillFrame; 00071 QMutex m_BufMutex; 00072 00073 QWaitCondition m_WaitFromFrame; 00074 CChannelEditorDlg *m_pTunerDlg; 00075 00076 int m_CaptureCount; 00077 00078 void IncrementPalette(Palettes); 00079 void DecrementPalette(Palettes); 00080 00081 void ParseTVChannels(const QDomNode &); 00082 void GetTVChannels(QDomNode &) const; 00083 00084 private slots: 00085 virtual void NewFrequency(float) = 0; 00086 void NewCurrentChannel(); 00087 00088 protected: 00089 QList<TVChannel> m_TVChannels; 00090 00091 bool m_Validated; 00092 QString m_NodeName, m_IntfName, m_SerialNumber; 00093 bool m_HasDisplayDialog, m_HasFormatDialog, m_HasSourceDialog, m_HasTunerDialog; 00094 bool m_Mutable; 00095 00096 int m_OpenCount; 00097 00098 int m_PalRGB; 00099 int m_PalYUV; 00100 uint m_RequestedBuffers, m_Buffers; 00101 int m_FrameCount; 00102 int m_FrameDropped; 00103 00104 QSize m_ImageSize; 00105 QVector<QImage> m_RGB; 00106 QVector<QImage> m_Y, m_U, m_V; 00107 QImage *m_pNullImage; 00108 QRgb m_GrayScale[256]; 00109 00110 int GetCaptureCount() const; 00111 00112 virtual bool Init() = 0; 00113 virtual void Exit() = 0; 00114 00115 virtual void CreateImagesRGB() = 0; 00116 virtual void DeleteImagesRGB() = 0; 00117 virtual void CreateImagesYUV() = 0; 00118 virtual void DeleteImagesYUV() = 0; 00119 00120 void CreateVideoFrames(); 00121 void DeleteVideoFrames(); 00122 CVideoFrame *GetFillFrame(); 00123 void ReturnFillFrame(bool filled = true); 00124 00125 virtual bool StartCapture() = 0; 00126 virtual void StopCapture() = 0; 00127 00128 void SendSignal(Signals s); 00129 00130 public: 00131 enum ErrorCodes { 00132 NoError, 00133 SizeChangeFailed, 00134 }; 00135 00136 CVideoDevice(); 00137 virtual ~CVideoDevice(); 00138 00139 virtual bool event(QEvent *); 00140 00141 virtual void SetConfiguration(const QDomNode &); 00142 virtual void GetConfiguration(QDomNode &) const; 00143 00144 bool IsValid() const; 00145 bool Open(uint buffers = 0); 00146 void Close(); 00147 bool IsOpen() const; 00148 00149 virtual int GetNumberOfInputs() const = 0; 00150 00162 virtual void SetInput(int input) = 0; 00172 virtual int GetInput() const = 0; 00185 virtual int GetNumberOfTuners() const = 0; 00196 virtual void SetTuner(int tuner) = 0; 00197 virtual int GetTuner() const = 0; 00198 00199 unsigned int GetNumberOfTVChannels() const; 00200 TVChannel QueryTVChannel(unsigned int preset); 00201 TVChannel GetCurrentTVChannel() const; 00202 TVChannel SelectTVChannel(unsigned int preset); 00203 TVChannel SelectNextTVChannel(bool wrap = true); 00204 TVChannel SelectPrevTVChannel(bool wrap = true); 00205 00213 virtual long GetDescriptor() const = 0; 00214 00215 QString GetNodeName() const; 00216 QString GetIntfName() const; 00217 QString GetSerialNumber() const; 00218 00219 int GetBuffers() const; 00220 00221 CVideoFrame *GetLatestVideoFrame(int backlog = 0); 00222 00223 bool HasDisplayDialog() const; 00224 bool HasFormatDialog() const; 00225 bool HasSourceDialog() const; 00226 bool HasTunerDialog() const; 00227 00228 virtual QSize GetSize() const; 00229 00230 // Do we need these? 00231 bool IsMutable() const; 00232 virtual void Mute(bool on) const = 0; 00233 00234 public slots: 00235 virtual void ShowDisplayDialog() = 0; 00236 virtual void ShowFormatDialog() = 0; 00237 virtual void ShowSourceDialog() = 0; 00238 virtual void ShowTunerDialog(); 00239 00240 void EnableRGB(); 00241 void DisableRGB(); 00242 void EnableYUV(); 00243 void DisableYUV(); 00244 00245 signals: 00247 void Opened(); 00249 void Closed(); 00251 void SizeChanged(const QSize &); 00253 void FramerateChanged(int rate); 00255 void Error(int err_num); 00257 void FrameReady(); 00259 void TVChannelChanged(); 00260 }; 00261 00262 #endif

Generated on Wed Dec 13 23:38:46 2006 for CamStream by doxygen 1.3.7