PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pvidfile.h
Go to the documentation of this file.
1 /*
2  * pvidfile.cxx
3  *
4  * Video file declaration
5  *
6  * Portable Windows Library
7  *
8  * Copyright (C) 2004 Post Increment
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is
23  * Craig Southeren <craigs@postincrement.com>
24  *
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  */
29 
30 #ifndef PTLIB_PVIDFILE_H
31 #define PTLIB_PVIDFILE_H
32 
33 #ifdef P_USE_PRAGMA
34 #pragma interface
35 #endif
36 
37 #include <ptlib.h>
38 
39 #if P_VIDEO
40 #if P_VIDFILE
41 
42 #include <ptlib/videoio.h>
43 
44 
47 class PVideoFile : public PFile
48 {
49  PCLASSINFO(PVideoFile, PFile);
50  protected:
51  PVideoFile();
52 
53  public:
54  virtual off_t GetLength() const;
55  virtual PBoolean SetLength(
56  off_t len // New length of file in frames.
57  );
58 
59  virtual off_t GetPosition() const;
60  virtual PBoolean SetPosition(
61  off_t pos,
63  );
64 
65  virtual PBoolean WriteFrame(const void * frame);
66  virtual PBoolean ReadFrame(void * frame);
67 
68  virtual PBoolean SetFrameSize(
69  unsigned width,
70  unsigned height
71  );
72  virtual PBoolean SetFrameRate(
73  unsigned rate
74  );
75 
76  PINDEX GetFrameBytes() const { return m_frameBytes; }
77 
78  bool SetFrameSizeFromFilename(const PString & fn);
79  bool SetFPSFromFilename(const PString & fn);
80 
81  operator const PVideoFrameInfo &() const { return m_videoInfo; }
82  bool IsFixedFrameSize() const { return m_fixedFrameSize; }
83  bool GetFrameSize(unsigned & w, unsigned & h) const { return m_videoInfo.GetFrameSize(w, h); }
84  unsigned GetFrameWidth() const { return m_videoInfo.GetFrameWidth(); }
85  unsigned GetFrameHeight() const { return m_videoInfo.GetFrameHeight(); }
86  bool IsFixedFrameRate() const { return m_fixedFrameRate; }
87  unsigned GetFrameRate() const { return m_videoInfo.GetFrameRate(); }
88  PString GetColourFormat() const { return m_videoInfo.GetColourFormat(); }
89 
90  protected:
91  bool m_fixedFrameSize;
92  bool m_fixedFrameRate;
93  PINDEX m_frameBytes;
94  off_t m_headerOffset;
95  off_t m_frameHeaderLen;
96  PVideoFrameInfo m_videoInfo;
97 };
98 
99 typedef PFactory<PVideoFile, PFilePathString> PVideoFileFactory;
100 
101 
105 class PYUVFile : public PVideoFile
106 {
107  PCLASSINFO(PYUVFile, PVideoFile);
108  public:
109  PYUVFile();
110 
111  virtual PBoolean WriteFrame(const void * frame);
112  virtual PBoolean ReadFrame(void * frame);
113 
114  protected:
115  virtual bool InternalOpen(OpenMode mode, OpenOptions opts, PFileInfo::Permissions permissions);
116 
117  bool m_y4mMode;
118 };
119 
120 PFACTORY_LOAD(PYUVFile);
121 
122 #endif // P_VIDFILE
123 
124 #endif // P_VIDEO
125 
126 #endif // PTLIB_PVIDFILE_H
127 
128 
129 // End Of File ///////////////////////////////////////////////////////////////
This class represents a disk file.
Definition: file.h:57
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
virtual off_t GetLength() const
Get the current size of the file.
virtual PBoolean SetPosition(off_t pos, FilePositionOrigin origin=Start)
Set the current active position in the file for the next read or write operation. ...
virtual PBoolean GetFrameSize(unsigned &width, unsigned &height) const
Get the frame size being used.
Definition: videoio.h:49
#define PFACTORY_LOAD(ConcreteType)
Definition: pfactory.h:557
FilePositionOrigin
Options for the origin in setting the file position.
Definition: file.h:500
virtual off_t GetPosition() const
Get the current active position in the file for the next read or write operation. ...
bool PBoolean
Definition: object.h:174
The character string class.
Definition: pstring.h:108
Class for a factory to create concrete class instances without parameters during construction.
Definition: pfactory.h:396
Set position relative to start of file.
Definition: file.h:501
virtual PBoolean SetLength(off_t len)
Set the size of the file, padding with 0 bytes if it would require expanding the file, or truncating it if being made shorter.