PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pvfiledev.h
Go to the documentation of this file.
1 /*
2  * pvfiledev.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: 30765 $
30  * $Author: rjongbloed $
31  * $Date: 2013-10-21 12:26:29 +1100 (Mon, 21 Oct 2013) $
32  */
33 
34 #ifndef PTLIB_PVFILEDEV_H
35 #define PTLIB_PVFILEDEV_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #if P_VIDEO
42 #if P_VIDFILE
43 
44 #include <ptlib/video.h>
45 #include <ptlib/vconvert.h>
46 #include <ptclib/pvidfile.h>
47 #include <ptclib/delaychan.h>
48 
49 
51 //
52 // This class defines a video capture (input) device that reads video from a raw YUV file
53 //
54 
55 class PVideoInputDevice_VideoFile : public PVideoInputDevice
56 {
57  PCLASSINFO(PVideoInputDevice_VideoFile, PVideoInputDevice);
58  public:
59  enum {
60  Channel_PlayAndClose = 0,
61  Channel_PlayAndRepeat = 1,
62  Channel_PlayAndKeepLast = 2,
63  Channel_PlayAndShowBlack = 3,
64  ChannelCount = 4
65  };
66 
69  PVideoInputDevice_VideoFile();
70 
73  virtual ~PVideoInputDevice_VideoFile();
74 
75 
78  PBoolean Open(
79  const PString & deviceName,
80  PBoolean startImmediate = true
81  );
82 
85  PBoolean IsOpen() ;
86 
89  PBoolean Close();
90 
93  PBoolean Start();
94 
97  PBoolean Stop();
98 
102 
105  static PStringArray GetInputDeviceNames();
106 
107  virtual PStringArray GetDeviceNames() const
108  { return GetInputDeviceNames(); }
109 
112  static bool GetDeviceCapabilities(
113  const PString & /*deviceName*/,
114  Capabilities * /*caps*/
115  ) { return false; }
116 
122  virtual PINDEX GetMaxFrameBytes();
123 
128  virtual PBoolean GetFrameData(
129  BYTE * buffer,
130  PINDEX * bytesReturned = NULL
131  );
132 
138  BYTE * buffer,
139  PINDEX * bytesReturned = NULL
140  );
141 
142 
148  virtual PBoolean SetVideoFormat(
149  VideoFormat videoFormat
150  );
151 
160  virtual int GetNumChannels();
161 
164  virtual PStringArray GetChannelNames();
165 
171  virtual PBoolean SetColourFormat(
172  const PString & colourFormat // New colour format for device.
173  );
174 
180  virtual PBoolean SetFrameRate(
181  unsigned rate
182  );
183 
190  unsigned & minWidth,
191  unsigned & minHeight,
192  unsigned & maxWidth,
193  unsigned & maxHeight
194  ) ;
195 
201  virtual PBoolean SetFrameSize(
202  unsigned width,
203  unsigned height
204  );
205 
206 
207  protected:
208  PVideoFile * m_file;
209  PAdaptiveDelay m_pacing;
210  unsigned m_frameRateAdjust;
211  bool m_opened;
212 };
213 
214 
216 //
217 // This class defines a video display (output) device that writes video to a raw YUV file
218 //
219 
220 class PVideoOutputDevice_VideoFile : public PVideoOutputDevice
221 {
222  PCLASSINFO(PVideoOutputDevice_VideoFile, PVideoOutputDevice);
223 
224  public:
227  PVideoOutputDevice_VideoFile();
228 
231  virtual ~PVideoOutputDevice_VideoFile();
232 
235  static PStringArray GetOutputDeviceNames();
236 
237  virtual PStringArray GetDeviceNames() const
238  { return GetOutputDeviceNames(); }
239 
242  virtual PBoolean Open(
243  const PString & deviceName,
244  PBoolean startImmediate = true
245  );
246 
249  PBoolean Start();
250 
253  PBoolean Stop();
254 
257  virtual PBoolean Close();
258 
261  virtual PBoolean IsOpen();
262 
268  virtual PBoolean SetColourFormat(
269  const PString & colourFormat // New colour format for device.
270  );
271 
277  virtual PINDEX GetMaxFrameBytes();
278 
281  virtual PBoolean SetFrameData(
282  unsigned x,
283  unsigned y,
284  unsigned width,
285  unsigned height,
286  const BYTE * data,
287  PBoolean endFrame = true
288  );
289 
290  protected:
291  PVideoFile * m_file;
292  bool m_opened;
293 };
294 
295 
296 #endif // P_VIDFILE
297 #endif
298 
299 #endif // PTLIB_PVFILEDEV_H
300 
301 
302 // End Of File ///////////////////////////////////////////////////////////////