PTLib  Version 2.10.10
 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: 25197 $
30  * $Author: rjongbloed $
31  * $Date: 2011-02-24 21:03:12 -0600 (Thu, 24 Feb 2011) $
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  int 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  PINDEX GetFrameBytes() const { return m_frameBytes; }
92 
93 
94  protected:
95  bool m_fixedFrameSize;
96  bool m_fixedFrameRate;
97  PINDEX m_frameBytes;
98  off_t m_headerOffset;
99  PFile m_file;
100 };
101 
107 class PYUVFile : public PVideoFile
108 {
109  PCLASSINFO(PYUVFile, PVideoFile);
110  public:
111  PYUVFile();
112 
113  virtual PBoolean Open(
114  const PFilePath & name, // Name of file to open.
115  PFile::OpenMode mode = PFile::ReadWrite, // Mode in which to open the file.
116  int opts = PFile::ModeDefault // <code>OpenOptions</code> enum# for open operation.
117  );
118 
119  virtual PBoolean WriteFrame(const void * frame);
120  virtual PBoolean ReadFrame(void * frame);
121 
122  protected:
123  bool m_y4mMode;
124 };
125 
126 PFACTORY_LOAD(PYUVFile);
127 
128 #endif
129 #endif
130 
131 #endif // PTLIB_PVIDFILE_H
132 
133 
134 // End Of File ///////////////////////////////////////////////////////////////