pvfiledev.h

Go to the documentation of this file.
00001 /*
00002  * pvfiledev.cxx
00003  *
00004  * Video file declaration
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (C) 2004 Post Increment
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is
00023  * Craig Southeren <craigs@postincrement.com>
00024  *
00025  * All Rights Reserved.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: pvfiledev.h,v $
00030  * Revision 1.10  2007/04/20 06:47:02  csoutheren
00031  * Really disable video code when video is turned off
00032  *
00033  * Revision 1.9  2007/04/13 07:13:13  rjongbloed
00034  * Major update of video subsystem:
00035  *   Abstracted video frame info (width, height etc) into separate class.
00036  *   Changed devices, converter and video file to use above.
00037  *   Enhanced video file hint detection for frame rate and more
00038  *     flexible formats.
00039  *   Fixed issue if need to convert both colour format and size, had to do
00040  *     colour format first or it didn't convert size.
00041  *   Win32 video output device can be selected by "MSWIN" alone.
00042  *
00043  * Revision 1.8  2007/04/03 12:09:37  rjongbloed
00044  * Fixed various "file video device" issues:
00045  *   Remove filename from PVideoDevice::OpenArgs (use deviceName)
00046  *   Added driverName to PVideoDevice::OpenArgs (so can select YUVFile)
00047  *   Added new statics to create correct video input/output device object
00048  *     given a PVideoDevice::OpenArgs structure.
00049  *   Fixed begin able to write to YUVFile when YUV420P colour format
00050  *     is not actually selected.
00051  *   Fixed truncating output video file if overwriting.
00052  *
00053  * Revision 1.7  2006/06/21 03:28:41  csoutheren
00054  * Various cleanups thanks for Frederic Heem
00055  *
00056  * Revision 1.6  2006/04/19 04:09:04  csoutheren
00057  * Allow frame size conversions
00058  *
00059  * Revision 1.5  2006/03/17 06:54:49  csoutheren
00060  * Removed unused member variable
00061  *
00062  * Revision 1.4  2006/03/13 07:49:09  csoutheren
00063  * Added newline at end of file
00064  *
00065  * Revision 1.3  2006/03/06 06:04:13  csoutheren
00066  * Added YUVFile video output device
00067  *
00068  * Revision 1.2  2006/02/20 06:49:45  csoutheren
00069  * Added video file and video file input device code
00070  *
00071  * Revision 1.1  2006/02/20 06:17:28  csoutheren
00072  * Added ability to read video from a file
00073  *
00074  */
00075 
00076 #ifndef _PVFILEDEV
00077 #define _PVFILEDEV
00078 
00079 #ifdef P_USE_PRAGMA
00080 #pragma interface
00081 #endif
00082 
00083 #include <ptlib.h>
00084 
00085 #if P_VIDEO
00086 #if P_VIDFILE
00087 
00088 #include <ptlib.h>
00089 #include <ptlib/video.h>
00090 #include <ptlib/vconvert.h>
00091 #include <ptclib/pvidfile.h>
00092 #include <ptclib/delaychan.h>
00093 
00094 
00096 //
00097 // This class defines a video capture (input) device that reads video from a raw YUV file
00098 //
00099 
00100 class PVideoInputDevice_YUVFile : public PVideoInputDevice
00101 {
00102  PCLASSINFO(PVideoInputDevice_YUVFile, PVideoInputDevice);
00103  public:
00104    enum {
00105      Channel_PlayAndClose     = 0,
00106      Channel_PlayAndRepeat    = 1,
00107      Channel_PlayAndKeepLast  = 2,
00108      Channel_PlayAndShowBlack = 3,
00109      ChannelCount             = 4
00110    };
00111 
00114     PVideoInputDevice_YUVFile();
00115 
00118     ~PVideoInputDevice_YUVFile();
00119 
00120 
00123     BOOL Open(
00124       const PString & deviceName,   
00125       BOOL startImmediate = TRUE    
00126     );
00127 
00130     BOOL IsOpen() ;
00131 
00134     BOOL Close();
00135 
00138     BOOL Start();
00139 
00142     BOOL Stop();
00143 
00146     BOOL IsCapturing();
00147 
00150     static PStringList GetInputDeviceNames();
00151 
00152     virtual PStringList GetDeviceNames() const
00153       { return GetInputDeviceNames(); }
00154 
00160     virtual PINDEX GetMaxFrameBytes();
00161 
00166     virtual BOOL GetFrameData(
00167       BYTE * buffer,                 
00168       PINDEX * bytesReturned = NULL  
00169     );
00170 
00175     virtual BOOL GetFrameDataNoDelay(
00176       BYTE * buffer,                 
00177       PINDEX * bytesReturned = NULL  
00178     );
00179 
00180 
00183     void GrabBlankImage(BYTE *resFrame);
00184 
00190     virtual BOOL SetVideoFormat(
00191       VideoFormat videoFormat   
00192     );
00193 
00198     virtual int GetNumChannels() ;
00199 
00209     virtual BOOL SetChannel(
00210          int channelNumber  
00211     );
00212     
00218     virtual BOOL SetColourFormat(
00219       const PString & colourFormat   // New colour format for device.
00220     );
00221     
00227     virtual BOOL SetFrameRate(
00228       unsigned rate  
00229     );
00230          
00236     virtual BOOL GetFrameSizeLimits(
00237       unsigned & minWidth,   
00238       unsigned & minHeight,  
00239       unsigned & maxWidth,   
00240       unsigned & maxHeight   
00241     ) ;
00242 
00248     virtual BOOL SetFrameSize(
00249       unsigned width,   
00250       unsigned height   
00251     );
00252 
00253     void ClearMapping() { return ; }
00254 
00257     virtual BOOL TestAllFormats()
00258       { return TRUE; }
00259 
00260     void FillRect(BYTE * frame,int xPos, int initialYPos,int rectWidth, int rectHeight,int r, int g,  int b);
00261    
00262  protected:
00263    unsigned       grabCount;
00264    PINDEX         videoFrameSize;
00265    PVideoFile   * file;
00266    PAdaptiveDelay pacing;
00267 };
00268 
00269 
00271 //
00272 // This class defines a video display (output) device that writes video to a raw YUV file
00273 //
00274 
00275 class PVideoOutputDevice_YUVFile : public PVideoOutputDevice
00276 {
00277   PCLASSINFO(PVideoOutputDevice_YUVFile, PVideoOutputDevice);
00278 
00279   public:
00282     PVideoOutputDevice_YUVFile();
00283 
00286     ~PVideoOutputDevice_YUVFile();
00287 
00290     static PStringList GetOutputDeviceNames();
00291 
00292     virtual PStringList GetDeviceNames() const
00293       { return GetOutputDeviceNames(); }
00294 
00297     virtual BOOL Open(
00298       const PString & deviceName,   
00299       BOOL startImmediate = TRUE    
00300     );
00301 
00304     BOOL Start();
00305 
00308     BOOL Stop();
00309 
00312     virtual BOOL Close();
00313 
00316     virtual BOOL IsOpen();
00317 
00323     virtual BOOL SetColourFormat(
00324       const PString & colourFormat   // New colour format for device.
00325     );
00326     
00332     virtual PINDEX GetMaxFrameBytes();
00333 
00336     virtual BOOL SetFrameData(
00337       unsigned x,
00338       unsigned y,
00339       unsigned width,
00340       unsigned height,
00341       const BYTE * data,
00342       BOOL endFrame = TRUE
00343     );
00344 
00345   protected:  
00346    PVideoFile * file;
00347 };
00348 
00349 
00350 #endif // P_VIDFILE
00351 #endif
00352 
00353 #endif // _PVFILEDEV
00354 

Generated on Fri Mar 7 06:25:02 2008 for PTLib by  doxygen 1.5.1