PTLib  Version 2.10.4
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: 25197 $
00030  * $Author: rjongbloed $
00031  * $Date: 2011-02-24 21:03:12 -0600 (Thu, 24 Feb 2011) $
00032  */
00033 
00034 #ifndef PTLIB_PVFILEDEV_H
00035 #define PTLIB_PVFILEDEV_H
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     virtual ~PVideoInputDevice_YUVFile();
00077 
00078 
00081     PBoolean Open(
00082       const PString & deviceName,   
00083       PBoolean startImmediate = true    
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 
00151     virtual PBoolean SetVideoFormat(
00152       VideoFormat videoFormat   
00153     );
00154 
00159     virtual int GetNumChannels() ;
00160 
00170     virtual PBoolean SetChannel(
00171          int channelNumber  
00172     );
00173     
00179     virtual PBoolean SetColourFormat(
00180       const PString & colourFormat   // New colour format for device.
00181     );
00182     
00188     virtual PBoolean SetFrameRate(
00189       unsigned rate  
00190     );
00191          
00197     virtual PBoolean GetFrameSizeLimits(
00198       unsigned & minWidth,   
00199       unsigned & minHeight,  
00200       unsigned & maxWidth,   
00201       unsigned & maxHeight   
00202     ) ;
00203 
00209     virtual PBoolean SetFrameSize(
00210       unsigned width,   
00211       unsigned height   
00212     );
00213 
00214    
00215  protected:
00216    PVideoFile   * m_file;
00217    PAdaptiveDelay m_pacing;
00218    unsigned       m_frameRateAdjust;
00219 };
00220 
00221 
00223 //
00224 // This class defines a video display (output) device that writes video to a raw YUV file
00225 //
00226 
00227 class PVideoOutputDevice_YUVFile : public PVideoOutputDevice
00228 {
00229   PCLASSINFO(PVideoOutputDevice_YUVFile, PVideoOutputDevice);
00230 
00231   public:
00234     PVideoOutputDevice_YUVFile();
00235 
00238     virtual ~PVideoOutputDevice_YUVFile();
00239 
00242     static PStringArray GetOutputDeviceNames();
00243 
00244     virtual PStringArray GetDeviceNames() const
00245       { return GetOutputDeviceNames(); }
00246 
00249     virtual PBoolean Open(
00250       const PString & deviceName,   
00251       PBoolean startImmediate = true    
00252     );
00253 
00256     PBoolean Start();
00257 
00260     PBoolean Stop();
00261 
00264     virtual PBoolean Close();
00265 
00268     virtual PBoolean IsOpen();
00269 
00275     virtual PBoolean SetColourFormat(
00276       const PString & colourFormat   // New colour format for device.
00277     );
00278     
00284     virtual PINDEX GetMaxFrameBytes();
00285 
00288     virtual PBoolean SetFrameData(
00289       unsigned x,
00290       unsigned y,
00291       unsigned width,
00292       unsigned height,
00293       const BYTE * data,
00294       PBoolean endFrame = true
00295     );
00296 
00297   protected:  
00298    PVideoFile * m_file;
00299 };
00300 
00301 
00302 #endif // P_VIDFILE
00303 #endif
00304 
00305 #endif // PTLIB_PVFILEDEV_H
00306 
00307 
00308 // End Of File ///////////////////////////////////////////////////////////////
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines