PTLib  Version 2.12.9
 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  * $Revision: 30072 $
30  * $Author: rjongbloed $
31  * $Date: 2013-06-28 16:51:52 +1000 (Fri, 28 Jun 2013) $
32  */
33 
34 #ifndef PTLIB_PVIDFILE_H
35 #define PTLIB_PVIDFILE_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #include <ptlib.h>
42 
43 #if P_VIDEO
44 #if P_VIDFILE
45 
46 #include <ptlib/videoio.h>
47 
48 
52 class PVideoFile : public PVideoFrameInfo
53 {
54  PCLASSINFO(PVideoFile, PVideoFrameInfo);
55  protected:
56  PVideoFile();
57 
58  public:
59  virtual PBoolean Open(
60  const PFilePath & name, // Name of file to open.
61  PFile::OpenMode mode = PFile::ReadWrite, // Mode in which to open the file.
62  PFile::OpenOptions opts = PFile::ModeDefault // <code>OpenOptions</code> enum# for open operation.
63  );
64 
65  virtual PBoolean IsOpen() const { return m_file.IsOpen(); }
66  virtual PBoolean Close() { return m_file.Close(); }
67 
68  virtual PBoolean WriteFrame(const void * frame);
69  virtual PBoolean ReadFrame(void * frame);
70 
71  virtual off_t GetLength() const;
72  virtual PBoolean SetLength(
73  off_t len // New length of file in frames.
74  );
75 
76  virtual off_t GetPosition() const;
77  virtual PBoolean SetPosition(
78  off_t pos,
80  );
81 
82  virtual PBoolean SetFrameSize(
83  unsigned width,
84  unsigned height
85  );
86  virtual PBoolean SetFrameRate(
87  unsigned rate
88  );
89 
90  const PFilePath & GetFilePath() const { return m_file.GetFilePath(); }
91  PChannel::Errors GetErrorCode(PChannel::ErrorGroup group = PChannel::NumErrorGroups) const { return m_file.GetErrorCode(group); }
92  int GetErrorNumber(PChannel::ErrorGroup group = PChannel::NumErrorGroups) const { return m_file.GetErrorNumber(group); }
93  PString GetErrorText(PChannel::ErrorGroup group = PChannel::NumErrorGroups) const { return m_file.GetErrorText(group); }
94  PINDEX GetFrameBytes() const { return m_frameBytes; }
95 
96 
97  protected:
98  bool m_fixedFrameSize;
99  bool m_fixedFrameRate;
100  PINDEX m_frameBytes;
101  off_t m_headerOffset;
102  off_t m_frameHeaderLen;
103  PFile m_file;
104 };
105 
111 class PYUVFile : public PVideoFile
112 {
113  PCLASSINFO(PYUVFile, PVideoFile);
114  public:
115  PYUVFile();
116 
117  virtual PBoolean Open(
118  const PFilePath & name, // Name of file to open.
119  PFile::OpenMode mode = PFile::ReadWrite, // Mode in which to open the file.
120  PFile::OpenOptions opts = PFile::ModeDefault // <code>OpenOptions</code> enum# for open operation.
121  );
122 
123  virtual PBoolean WriteFrame(const void * frame);
124  virtual PBoolean ReadFrame(void * frame);
125 
126  protected:
127  bool m_y4mMode;
128 };
129 
130 PFACTORY_LOAD(PYUVFile);
131 
132 #endif
133 #endif
134 
135 #endif // PTLIB_PVIDFILE_H
136 
137 
138 // End Of File ///////////////////////////////////////////////////////////////