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  * $Revision: 20385 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-06-04 10:40:38 +0000 (Wed, 04 Jun 2008) $
00032  */
00033 
00034 #ifndef _PVFILEDEV
00035 #define _PVFILEDEV
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 #include <ptlib.h>
00042 
00043 #if P_VIDEO
00044 #if P_VIDFILE
00045 
00046 #include <ptlib.h>
00047 #include <ptlib/video.h>
00048 #include <ptlib/vconvert.h>
00049 #include <ptclib/pvidfile.h>
00050 #include <ptclib/delaychan.h>
00051 
00052 
00054 //
00055 // This class defines a video capture (input) device that reads video from a raw YUV file
00056 //
00057 
00058 class PVideoInputDevice_YUVFile : public PVideoInputDevice
00059 {
00060  PCLASSINFO(PVideoInputDevice_YUVFile, PVideoInputDevice);
00061  public:
00062    enum {
00063      Channel_PlayAndClose     = 0,
00064      Channel_PlayAndRepeat    = 1,
00065      Channel_PlayAndKeepLast  = 2,
00066      Channel_PlayAndShowBlack = 3,
00067      ChannelCount             = 4
00068    };
00069 
00072     PVideoInputDevice_YUVFile();
00073 
00076     ~PVideoInputDevice_YUVFile();
00077 
00078 
00081     PBoolean Open(
00082       const PString & deviceName,   
00083       PBoolean startImmediate = PTrue    
00084     );
00085 
00088     PBoolean IsOpen() ;
00089 
00092     PBoolean Close();
00093 
00096     PBoolean Start();
00097 
00100     PBoolean Stop();
00101 
00104     PBoolean IsCapturing();
00105 
00108     static PStringArray GetInputDeviceNames();
00109 
00110     virtual PStringArray GetDeviceNames() const
00111       { return GetInputDeviceNames(); }
00112 
00115     static bool GetDeviceCapabilities(
00116       const PString & /*deviceName*/, 
00117       Capabilities * /*caps*/         
00118     ) { return false; }
00119 
00125     virtual PINDEX GetMaxFrameBytes();
00126 
00131     virtual PBoolean GetFrameData(
00132       BYTE * buffer,                 
00133       PINDEX * bytesReturned = NULL  
00134     );
00135 
00140     virtual PBoolean GetFrameDataNoDelay(
00141       BYTE * buffer,                 
00142       PINDEX * bytesReturned = NULL  
00143     );
00144 
00145 
00148     void GrabBlankImage(BYTE *resFrame);
00149 
00155     virtual PBoolean SetVideoFormat(
00156       VideoFormat videoFormat   
00157     );
00158 
00163     virtual int GetNumChannels() ;
00164 
00174     virtual PBoolean SetChannel(
00175          int channelNumber  
00176     );
00177     
00183     virtual PBoolean SetColourFormat(
00184       const PString & colourFormat   // New colour format for device.
00185     );
00186     
00192     virtual PBoolean SetFrameRate(
00193       unsigned rate  
00194     );
00195          
00201     virtual PBoolean GetFrameSizeLimits(
00202       unsigned & minWidth,   
00203       unsigned & minHeight,  
00204       unsigned & maxWidth,   
00205       unsigned & maxHeight   
00206     ) ;
00207 
00213     virtual PBoolean SetFrameSize(
00214       unsigned width,   
00215       unsigned height   
00216     );
00217 
00218     void ClearMapping() { return ; }
00219 
00222     virtual PBoolean TestAllFormats()
00223       { return PTrue; }
00224 
00225     void FillRect(BYTE * frame,int xPos, int initialYPos,int rectWidth, int rectHeight,int r, int g,  int b);
00226    
00227  protected:
00228    unsigned       grabCount;
00229    PINDEX         videoFrameSize;
00230    PVideoFile   * file;
00231    PAdaptiveDelay pacing;
00232 };
00233 
00234 
00236 //
00237 // This class defines a video display (output) device that writes video to a raw YUV file
00238 //
00239 
00240 class PVideoOutputDevice_YUVFile : public PVideoOutputDevice
00241 {
00242   PCLASSINFO(PVideoOutputDevice_YUVFile, PVideoOutputDevice);
00243 
00244   public:
00247     PVideoOutputDevice_YUVFile();
00248 
00251     ~PVideoOutputDevice_YUVFile();
00252 
00255     static PStringArray GetOutputDeviceNames();
00256 
00257     virtual PStringArray GetDeviceNames() const
00258       { return GetOutputDeviceNames(); }
00259 
00262     virtual PBoolean Open(
00263       const PString & deviceName,   
00264       PBoolean startImmediate = PTrue    
00265     );
00266 
00269     PBoolean Start();
00270 
00273     PBoolean Stop();
00274 
00277     virtual PBoolean Close();
00278 
00281     virtual PBoolean IsOpen();
00282 
00288     virtual PBoolean SetColourFormat(
00289       const PString & colourFormat   // New colour format for device.
00290     );
00291     
00297     virtual PINDEX GetMaxFrameBytes();
00298 
00301     virtual PBoolean SetFrameData(
00302       unsigned x,
00303       unsigned y,
00304       unsigned width,
00305       unsigned height,
00306       const BYTE * data,
00307       PBoolean endFrame = PTrue
00308     );
00309 
00310   protected:  
00311    PVideoFile * file;
00312 };
00313 
00314 
00315 #endif // P_VIDFILE
00316 #endif
00317 
00318 #endif // _PVFILEDEV
00319 

Generated on Mon Feb 23 01:57:54 2009 for PTLib by  doxygen 1.5.1