PTLib  Version 2.10.4
 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: 25197 $
30  * $Author: rjongbloed $
31  * $Date: 2011-02-24 21:03:12 -0600 (Thu, 24 Feb 2011) $
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 #include <ptlib.h>
42 
43 #if P_VIDEO
44 #if P_VIDFILE
45 
46 #include <ptlib.h>
47 #include <ptlib/video.h>
48 #include <ptlib/vconvert.h>
49 #include <ptclib/pvidfile.h>
50 #include <ptclib/delaychan.h>
51 
52 
54 //
55 // This class defines a video capture (input) device that reads video from a raw YUV file
56 //
57 
58 class PVideoInputDevice_YUVFile : public PVideoInputDevice
59 {
60  PCLASSINFO(PVideoInputDevice_YUVFile, PVideoInputDevice);
61  public:
62  enum {
63  Channel_PlayAndClose = 0,
64  Channel_PlayAndRepeat = 1,
65  Channel_PlayAndKeepLast = 2,
66  Channel_PlayAndShowBlack = 3,
67  ChannelCount = 4
68  };
69 
72  PVideoInputDevice_YUVFile();
73 
76  virtual ~PVideoInputDevice_YUVFile();
77 
78 
81  PBoolean Open(
82  const PString & deviceName,
83  PBoolean startImmediate = true
84  );
85 
88  PBoolean IsOpen() ;
89 
92  PBoolean Close();
93 
96  PBoolean Start();
97 
100  PBoolean Stop();
101 
105 
108  static PStringArray GetInputDeviceNames();
109 
110  virtual PStringArray GetDeviceNames() const
111  { return GetInputDeviceNames(); }
112 
115  static bool GetDeviceCapabilities(
116  const PString & /*deviceName*/,
117  Capabilities * /*caps*/
118  ) { return false; }
119 
125  virtual PINDEX GetMaxFrameBytes();
126 
131  virtual PBoolean GetFrameData(
132  BYTE * buffer,
133  PINDEX * bytesReturned = NULL
134  );
135 
141  BYTE * buffer,
142  PINDEX * bytesReturned = NULL
143  );
144 
145 
151  virtual PBoolean SetVideoFormat(
152  VideoFormat videoFormat
153  );
154 
159  virtual int GetNumChannels() ;
160 
170  virtual PBoolean SetChannel(
171  int channelNumber
172  );
173 
179  virtual PBoolean SetColourFormat(
180  const PString & colourFormat // New colour format for device.
181  );
182 
188  virtual PBoolean SetFrameRate(
189  unsigned rate
190  );
191 
198  unsigned & minWidth,
199  unsigned & minHeight,
200  unsigned & maxWidth,
201  unsigned & maxHeight
202  ) ;
203 
209  virtual PBoolean SetFrameSize(
210  unsigned width,
211  unsigned height
212  );
213 
214 
215  protected:
216  PVideoFile * m_file;
217  PAdaptiveDelay m_pacing;
218  unsigned m_frameRateAdjust;
219 };
220 
221 
223 //
224 // This class defines a video display (output) device that writes video to a raw YUV file
225 //
226 
227 class PVideoOutputDevice_YUVFile : public PVideoOutputDevice
228 {
229  PCLASSINFO(PVideoOutputDevice_YUVFile, PVideoOutputDevice);
230 
231  public:
234  PVideoOutputDevice_YUVFile();
235 
238  virtual ~PVideoOutputDevice_YUVFile();
239 
242  static PStringArray GetOutputDeviceNames();
243 
244  virtual PStringArray GetDeviceNames() const
245  { return GetOutputDeviceNames(); }
246 
249  virtual PBoolean Open(
250  const PString & deviceName,
251  PBoolean startImmediate = true
252  );
253 
256  PBoolean Start();
257 
260  PBoolean Stop();
261 
264  virtual PBoolean Close();
265 
268  virtual PBoolean IsOpen();
269 
275  virtual PBoolean SetColourFormat(
276  const PString & colourFormat // New colour format for device.
277  );
278 
284  virtual PINDEX GetMaxFrameBytes();
285 
288  virtual PBoolean SetFrameData(
289  unsigned x,
290  unsigned y,
291  unsigned width,
292  unsigned height,
293  const BYTE * data,
294  PBoolean endFrame = true
295  );
296 
297  protected:
298  PVideoFile * m_file;
299 };
300 
301 
302 #endif // P_VIDFILE
303 #endif
304 
305 #endif // PTLIB_PVFILEDEV_H
306 
307 
308 // End Of File ///////////////////////////////////////////////////////////////