PTLib  Version 2.10.11
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: 27357 $
30  * $Author: rjongbloed $
31  * $Date: 2012-03-28 19:39:08 -0500 (Wed, 28 Mar 2012) $
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  bool m_opened;
220 };
221 
222 
224 //
225 // This class defines a video display (output) device that writes video to a raw YUV file
226 //
227 
228 class PVideoOutputDevice_YUVFile : public PVideoOutputDevice
229 {
230  PCLASSINFO(PVideoOutputDevice_YUVFile, PVideoOutputDevice);
231 
232  public:
235  PVideoOutputDevice_YUVFile();
236 
239  virtual ~PVideoOutputDevice_YUVFile();
240 
243  static PStringArray GetOutputDeviceNames();
244 
245  virtual PStringArray GetDeviceNames() const
246  { return GetOutputDeviceNames(); }
247 
250  virtual PBoolean Open(
251  const PString & deviceName,
252  PBoolean startImmediate = true
253  );
254 
257  PBoolean Start();
258 
261  PBoolean Stop();
262 
265  virtual PBoolean Close();
266 
269  virtual PBoolean IsOpen();
270 
276  virtual PBoolean SetColourFormat(
277  const PString & colourFormat // New colour format for device.
278  );
279 
285  virtual PINDEX GetMaxFrameBytes();
286 
289  virtual PBoolean SetFrameData(
290  unsigned x,
291  unsigned y,
292  unsigned width,
293  unsigned height,
294  const BYTE * data,
295  PBoolean endFrame = true
296  );
297 
298  protected:
299  PVideoFile * m_file;
300  bool m_opened;
301 };
302 
303 
304 #endif // P_VIDFILE
305 #endif
306 
307 #endif // PTLIB_PVFILEDEV_H
308 
309 
310 // End Of File ///////////////////////////////////////////////////////////////
virtual PBoolean GetFrameData(BYTE *buffer, PINDEX *bytesReturned, unsigned int &flags)
Grab a frame, after a delay as specified by the frame rate.
virtual PBoolean GetFrameDataNoDelay(BYTE *buffer, PINDEX *bytesReturned, unsigned int &flags)
Grab a frame.
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
virtual PBoolean SetFrameRate(unsigned rate)
Set the video frame rate to be used on the device.
virtual PINDEX GetMaxFrameBytes()=0
Get the maximum frame size in bytes.
This is an array collection class of PString objects.
Definition: pstring.h:2024
virtual PBoolean Stop()=0
Stop the video device I/O capture.
BOOL PBoolean
Definition: object.h:102
virtual bool GetDeviceCapabilities(Capabilities *capabilities) const
Retrieve a list of Device Capabilities.
Definition: videoio.h:1052
virtual PBoolean Close()
Close the device.
Definition: videoio.h:1085
virtual PBoolean IsOpen()=0
Determine if the device is currently open.
virtual int GetNumChannels()
Get the number of video channels available on the device.
virtual PBoolean Start()=0
Start the video device I/O capture.
The character string class.
Definition: pstring.h:108
virtual PStringArray GetDeviceNames() const =0
Get a list of all of the drivers available.
Class for implementing an "adaptive" delay.
Definition: delaychan.h:52
virtual PBoolean IsCapturing()=0
Determine if the video device I/O capture is in progress.
This class defines a video input device.
Definition: videoio.h:975
virtual PBoolean SetFrameSize(unsigned width, unsigned height)
Set the frame size to be used.
virtual PBoolean SetColourFormat(const PString &colourFormat)
Set the colour format to be used.
This class defines a video output device.
Definition: videoio.h:716
virtual PBoolean SetChannel(int channelNumber)
Set the video channel to be used on the device.
virtual PBoolean GetFrameSizeLimits(unsigned &minWidth, unsigned &minHeight, unsigned &maxWidth, unsigned &maxHeight)
Get the minimum & maximum size of a frame on the device.
virtual PBoolean SetVideoFormat(VideoFormat videoFormat)
Set the video format to be used.
virtual PBoolean Open(const PString &deviceName, PBoolean startImmediate=true)=0
Open the device given the device name.