pvidfile.h

Go to the documentation of this file.
00001 /*
00002  * pvidfile.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: pvidfile.h,v $
00030  * Revision 1.6  2007/04/20 06:47:02  csoutheren
00031  * Really disable video code when video is turned off
00032  *
00033  * Revision 1.5  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.4  2006/10/31 04:10:40  csoutheren
00044  * Make sure PVidFileDev class is loaded, and make it work with OPAL
00045  *
00046  * Revision 1.3  2006/02/24 04:51:26  csoutheren
00047  * Fixed problem with using CIF from video files
00048  * Added support for video files in y4m format
00049  *
00050  * Revision 1.2  2006/02/20 06:49:45  csoutheren
00051  * Added video file and video file input device code
00052  *
00053  * Revision 1.1  2006/02/20 06:17:28  csoutheren
00054  * Added ability to read video from a file
00055  *
00056  */
00057 
00058 #ifndef _PVIDFILE
00059 #define _PVIDFILE
00060 
00061 #ifdef P_USE_PRAGMA
00062 #pragma interface
00063 #endif
00064 
00065 #include <ptlib.h>
00066 
00067 #if P_VIDEO
00068 #if P_VIDFILE
00069 
00070 #include <ptlib/videoio.h>
00071 
00072 
00076 class PVideoFile : public PVideoFrameInfo
00077 {
00078   PCLASSINFO(PVideoFile, PVideoFrameInfo);
00079   protected:
00080     PVideoFile();
00081 
00082   public:
00083     virtual BOOL SetFrameSize(
00084       unsigned width,   
00085       unsigned height   
00086     );
00087 
00088     virtual BOOL Open(
00089       const PFilePath & name,    // Name of file to open.
00090       PFile::OpenMode mode = PFile::ReadWrite, // Mode in which to open the file.
00091       int opts = PFile::ModeDefault     // #OpenOptions enum# for open operation.
00092     );
00093 
00094     virtual BOOL IsOpen() const { return file.IsOpen(); }
00095     virtual BOOL Close() { return file.Close(); }
00096 
00097     virtual BOOL WriteFrame(const void * frame);
00098     virtual BOOL ReadFrame(void * frame);
00099 
00100     virtual off_t GetLength() const;
00101     virtual BOOL SetLength(
00102       off_t len   // New length of file in frames.
00103     );
00104 
00105     virtual off_t GetPosition() const;
00106     virtual BOOL SetPosition(
00107       off_t pos,                                       
00108       PFile::FilePositionOrigin origin = PFile::Start  
00109     );
00110 
00111     const PFilePath & GetFilePath() const { return file.GetFilePath(); }
00112     bool IsUnknownFrameSize() const { return unknownFrameSize; }
00113     PINDEX GetFrameBytes() const { return frameBytes; }
00114 
00115     static BOOL ExtractHints(const PFilePath & fn, PVideoFrameInfo & info);
00116 
00117   protected:
00118     bool   unknownFrameSize;
00119     PINDEX frameBytes;
00120     off_t  headerOffset;
00121     PFile  file;
00122 };
00123 
00129 class PYUVFile : public PVideoFile
00130 {
00131   PCLASSINFO(PYUVFile, PVideoFile);
00132   public:
00133     PYUVFile();
00134 
00135     virtual BOOL Open(
00136       const PFilePath & name,    // Name of file to open.
00137       PFile::OpenMode mode = PFile::ReadWrite, // Mode in which to open the file.
00138       int opts = PFile::ModeDefault     // #OpenOptions enum# for open operation.
00139     );
00140 
00141     virtual BOOL WriteFrame(const void * frame);
00142     virtual BOOL ReadFrame(void * frame);
00143 
00144   protected:
00145     BOOL y4mMode;
00146 };
00147 
00148 #endif
00149 #endif
00150 
00151 #endif // P_VIDFILE

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