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.7  2006/06/21 03:28:41  csoutheren
00031  * Various cleanups thanks for Frederic Heem
00032  *
00033  * Revision 1.6  2006/04/19 04:09:04  csoutheren
00034  * Allow frame size conversions
00035  *
00036  * Revision 1.5  2006/03/17 06:54:49  csoutheren
00037  * Removed unused member variable
00038  *
00039  * Revision 1.4  2006/03/13 07:49:09  csoutheren
00040  * Added newline at end of file
00041  *
00042  * Revision 1.3  2006/03/06 06:04:13  csoutheren
00043  * Added YUVFile video output device
00044  *
00045  * Revision 1.2  2006/02/20 06:49:45  csoutheren
00046  * Added video file and video file input device code
00047  *
00048  * Revision 1.1  2006/02/20 06:17:28  csoutheren
00049  * Added ability to read video from a file
00050  *
00051  */
00052 
00053 #ifndef _PVFILEDEV
00054 #define _PVFILEDEV
00055 
00056 #ifdef P_USE_PRAGMA
00057 #pragma interface
00058 #endif
00059 
00060 #include <ptlib.h>
00061 
00062 #if P_VIDFILE
00063 
00064 
00065 #include <ptlib.h>
00066 #include <ptlib/video.h>
00067 #include <ptlib/vconvert.h>
00068 #include <ptclib/pvidfile.h>
00069 
00071 //
00072 // This class defines a video capture (input) device that reads video from a raw YUV file
00073 //
00074 
00075 class PVideoInputDevice_YUVFile : public PVideoInputDevice
00076 {
00077  PCLASSINFO(PVideoInputDevice_YUVFile, PVideoInputDevice);
00078  public:
00079    enum {
00080      Channel_PlayAndClose     = 0,
00081      Channel_PlayAndRepeat    = 1,
00082      Channel_PlayAndKeepLast  = 2,
00083      Channel_PlayAndShowBlack = 3,
00084      ChannelCount             = 4
00085    };
00086 
00089     PVideoInputDevice_YUVFile();
00090 
00091 
00094     BOOL Open(
00095       const PString & deviceName,   
00096       BOOL startImmediate = TRUE    
00097     );
00098 
00101     BOOL IsOpen() ;
00102 
00105     BOOL Close();
00106 
00109     BOOL Start();
00110 
00113     BOOL Stop();
00114 
00117     BOOL IsCapturing();
00118 
00121     static PStringList GetInputDeviceNames();
00122 
00123     virtual PStringList GetDeviceNames() const
00124       { return GetInputDeviceNames(); }
00125 
00131     virtual PINDEX GetMaxFrameBytes();
00132 
00137     virtual BOOL GetFrameData(
00138       BYTE * buffer,                 
00139       PINDEX * bytesReturned = NULL  
00140     );
00141 
00146     virtual BOOL GetFrameDataNoDelay(
00147       BYTE * buffer,                 
00148       PINDEX * bytesReturned = NULL  
00149     );
00150 
00151 
00154     void GrabBlankImage(BYTE *resFrame);
00155 
00161     virtual BOOL SetVideoFormat(
00162       VideoFormat videoFormat   
00163     );
00164 
00169     virtual int GetNumChannels() ;
00170 
00180     virtual BOOL SetChannel(
00181          int channelNumber  
00182     );
00183     
00189     virtual BOOL SetColourFormat(
00190       const PString & colourFormat   // New colour format for device.
00191     );
00192     
00198     virtual BOOL SetFrameRate(
00199       unsigned rate  
00200     );
00201          
00207     virtual BOOL GetFrameSizeLimits(
00208       unsigned & minWidth,   
00209       unsigned & minHeight,  
00210       unsigned & maxWidth,   
00211       unsigned & maxHeight   
00212     ) ;
00213 
00219     virtual BOOL SetFrameSize(
00220       unsigned width,   
00221       unsigned height   
00222     );
00223 
00224     BOOL SetFrameSizeConverter(
00225       unsigned width,        
00226       unsigned height,       
00227       BOOL     bScaleNotCrop 
00228     );
00229          
00230     void ClearMapping() { return ; }
00231 
00234     virtual BOOL TestAllFormats()
00235       { return TRUE; }
00236 
00237     void FillRect(BYTE * frame,int xPos, int initialYPos,int rectWidth, int rectHeight,int r, int g,  int b);
00238    
00239  protected:
00240    unsigned grabCount;
00241    PINDEX   videoFrameSize;
00242    PINDEX   scanLineWidth;
00243    PYUVFile file;
00244    PBYTEArray frameStore;
00245 };
00246 
00247 PLOAD_FACTORY_DECLARE(PVideoInputDevice,YUVFile)
00248 
00249 
00250 //
00251 // This class defines a video display (output) device that writes video to a raw YUV file
00252 //
00253 
00254 class PVideoOutputDevice_YUVFile : public PVideoOutputDevice
00255 {
00256   PCLASSINFO(PVideoOutputDevice_YUVFile, PVideoOutputDevice);
00257 
00258   public:
00261     PVideoOutputDevice_YUVFile();
00262 
00265     static PStringList GetOutputDeviceNames();
00266 
00267     virtual PStringList GetDeviceNames() const
00268       { return GetOutputDeviceNames(); }
00269 
00272     virtual BOOL Open(
00273       const PString & deviceName,   
00274       BOOL startImmediate = TRUE    
00275     );
00276 
00279     BOOL Start();
00280 
00283     BOOL Stop();
00284 
00287     virtual BOOL Close();
00288 
00291     virtual BOOL IsOpen();
00292 
00298     virtual PINDEX GetMaxFrameBytes();
00299 
00302     virtual BOOL SetFrameData(
00303       unsigned x,
00304       unsigned y,
00305       unsigned width,
00306       unsigned height,
00307       const BYTE * data,
00308       BOOL endFrame = TRUE
00309     );
00310 
00313     virtual BOOL EndFrame();
00314 
00315   protected:  
00316     PYUVFile file;
00317 };
00318 
00319 PLOAD_FACTORY_DECLARE(PVideoOutputDevice,YUVFile)
00320 
00321 #endif // P_VIDFILE
00322 
00323 #endif // _PVFILEDEV
00324 

Generated on Fri Feb 29 13:37:10 2008 for PWLib by  doxygen 1.5.5