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  * $Revision: 20385 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-06-04 10:40:38 +0000 (Wed, 04 Jun 2008) $
00032  */
00033 
00034 #ifndef _PVIDFILE
00035 #define _PVIDFILE
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/videoio.h>
00047 
00048 
00052 class PVideoFile : public PVideoFrameInfo
00053 {
00054   PCLASSINFO(PVideoFile, PVideoFrameInfo);
00055   protected:
00056     PVideoFile();
00057 
00058   public:
00059     virtual PBoolean SetFrameSize(
00060       unsigned width,   
00061       unsigned height   
00062     );
00063 
00064     virtual PBoolean Open(
00065       const PFilePath & name,    // Name of file to open.
00066       PFile::OpenMode mode = PFile::ReadWrite, // Mode in which to open the file.
00067       int opts = PFile::ModeDefault     // #OpenOptions enum# for open operation.
00068     );
00069 
00070     virtual PBoolean IsOpen() const { return file.IsOpen(); }
00071     virtual PBoolean Close() { return file.Close(); }
00072 
00073     virtual PBoolean WriteFrame(const void * frame);
00074     virtual PBoolean ReadFrame(void * frame);
00075 
00076     virtual off_t GetLength() const;
00077     virtual PBoolean SetLength(
00078       off_t len   // New length of file in frames.
00079     );
00080 
00081     virtual off_t GetPosition() const;
00082     virtual PBoolean SetPosition(
00083       off_t pos,                                       
00084       PFile::FilePositionOrigin origin = PFile::Start  
00085     );
00086 
00087     const PFilePath & GetFilePath() const { return file.GetFilePath(); }
00088     bool IsUnknownFrameSize() const { return unknownFrameSize; }
00089     PINDEX GetFrameBytes() const { return frameBytes; }
00090 
00091     static PBoolean ExtractHints(const PFilePath & fn, PVideoFrameInfo & info);
00092 
00093   protected:
00094     bool   unknownFrameSize;
00095     PINDEX frameBytes;
00096     off_t  headerOffset;
00097     PFile  file;
00098 };
00099 
00105 class PYUVFile : public PVideoFile
00106 {
00107   PCLASSINFO(PYUVFile, PVideoFile);
00108   public:
00109     PYUVFile();
00110 
00111     virtual PBoolean Open(
00112       const PFilePath & name,    // Name of file to open.
00113       PFile::OpenMode mode = PFile::ReadWrite, // Mode in which to open the file.
00114       int opts = PFile::ModeDefault     // #OpenOptions enum# for open operation.
00115     );
00116 
00117     virtual PBoolean WriteFrame(const void * frame);
00118     virtual PBoolean ReadFrame(void * frame);
00119 
00120   protected:
00121     PBoolean y4mMode;
00122 };
00123 
00124 #endif
00125 #endif
00126 
00127 #endif // P_VIDFILE

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