00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
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 SetFrameSize(
00060 unsigned width,
00061 unsigned height
00062 );
00063
00064 virtual PBoolean Open(
00065 const PFilePath & name,
00066 PFile::OpenMode mode = PFile::ReadWrite,
00067 int opts = PFile::ModeDefault
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
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,
00113 PFile::OpenMode mode = PFile::ReadWrite,
00114 int opts = PFile::ModeDefault
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 // PTLIB_PVIDFILE_H
00128
00129
00130