PTLib  Version 2.10.4
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: 25197 $
00030  * $Author: rjongbloed $
00031  * $Date: 2011-02-24 21:03:12 -0600 (Thu, 24 Feb 2011) $
00032  */
00033 
00034 #ifndef PTLIB_PVIDFILE_H
00035 #define PTLIB_PVIDFILE_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/videoio.h>
00047 
00048 
00052 class PVideoFile : public PVideoFrameInfo
00053 {
00054   PCLASSINFO(PVideoFile, PVideoFrameInfo);
00055   protected:
00056     PVideoFile();
00057 
00058   public:
00059     virtual PBoolean Open(
00060       const PFilePath & name,    // Name of file to open.
00061       PFile::OpenMode mode = PFile::ReadWrite, // Mode in which to open the file.
00062       int opts = PFile::ModeDefault     // <code>OpenOptions</code> enum# for open operation.
00063     );
00064 
00065     virtual PBoolean IsOpen() const { return m_file.IsOpen(); }
00066     virtual PBoolean Close() { return m_file.Close(); }
00067 
00068     virtual PBoolean WriteFrame(const void * frame);
00069     virtual PBoolean ReadFrame(void * frame);
00070 
00071     virtual off_t GetLength() const;
00072     virtual PBoolean SetLength(
00073       off_t len   // New length of file in frames.
00074     );
00075 
00076     virtual off_t GetPosition() const;
00077     virtual PBoolean SetPosition(
00078       off_t pos,                                       
00079       PFile::FilePositionOrigin origin = PFile::Start  
00080     );
00081 
00082     virtual PBoolean SetFrameSize(
00083       unsigned width,   
00084       unsigned height   
00085     );
00086     virtual PBoolean SetFrameRate(
00087       unsigned rate  
00088     );
00089 
00090     const PFilePath & GetFilePath() const { return m_file.GetFilePath(); }
00091     PINDEX GetFrameBytes() const { return m_frameBytes; }
00092 
00093 
00094   protected:
00095     bool   m_fixedFrameSize;
00096     bool   m_fixedFrameRate;
00097     PINDEX m_frameBytes;
00098     off_t  m_headerOffset;
00099     PFile  m_file;
00100 };
00101 
00107 class PYUVFile : public PVideoFile
00108 {
00109   PCLASSINFO(PYUVFile, PVideoFile);
00110   public:
00111     PYUVFile();
00112 
00113     virtual PBoolean Open(
00114       const PFilePath & name,    // Name of file to open.
00115       PFile::OpenMode mode = PFile::ReadWrite, // Mode in which to open the file.
00116       int opts = PFile::ModeDefault     // <code>OpenOptions</code> enum# for open operation.
00117     );
00118 
00119     virtual PBoolean WriteFrame(const void * frame);
00120     virtual PBoolean ReadFrame(void * frame);
00121 
00122   protected:
00123     bool m_y4mMode;
00124 };
00125 
00126 PFACTORY_LOAD(PYUVFile);
00127 
00128 #endif
00129 #endif
00130 
00131 #endif // PTLIB_PVIDFILE_H
00132 
00133 
00134 // End Of File ///////////////////////////////////////////////////////////////
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines