PTLib  Version 2.10.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pffvdev.h
Go to the documentation of this file.
1 /*
2  * pffvdev.cxx
3  *
4  * Video device for ffmpeg
5  *
6  * Portable Windows Library
7  *
8  * Copyright (C) 2008 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: 24867 $
30  * $Author: rjongbloed $
31  * $Date: 2010-11-10 01:29:17 -0600 (Wed, 10 Nov 2010) $
32  */
33 
34 #ifndef PTLIB_PFFVDEV_H
35 #define PTLIB_PFFVDEV_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_FFVDEV
45 
46 #include <ptlib/pipechan.h>
47 #include <ptclib/delaychan.h>
48 
50 //
51 // This class defines a video capture (input) device that reads video from an FFMpeg command
52 //
53 
54 
55 class PVideoInputDevice_FFMPEG : public PVideoInputDevice
56 {
57  PCLASSINFO(PVideoInputDevice_FFMPEG, PVideoInputDevice);
58  public:
61  PVideoInputDevice_FFMPEG();
62 
65  ~PVideoInputDevice_FFMPEG();
66 
67 
70  PBoolean Open(
71  const PString & deviceName,
72  PBoolean startImmediate = true
73  );
74 
77  PBoolean IsOpen() ;
78 
81  PBoolean Close();
82 
85  PBoolean Start();
86 
89  PBoolean Stop();
90 
94 
97  static PStringArray GetInputDeviceNames();
98 
99  virtual PStringArray GetDeviceNames() const
100  { return GetInputDeviceNames(); }
101 
104  static bool GetDeviceCapabilities(
105  const PString & /*deviceName*/,
106  Capabilities * /*caps*/
107  ) { return false; }
108 
114  virtual PINDEX GetMaxFrameBytes();
115 
120  virtual PBoolean GetFrameData(
121  BYTE * buffer,
122  PINDEX * bytesReturned = NULL
123  );
124 
130  BYTE * buffer,
131  PINDEX * bytesReturned = NULL
132  );
133 
134 
140  virtual PBoolean SetVideoFormat(
141  VideoFormat videoFormat
142  );
143 
148  virtual int GetNumChannels() ;
149 
152  virtual PBoolean SetChannel(
153  int channelNumber
154  );
155 
161  virtual PBoolean SetColourFormat(
162  const PString & colourFormat // New colour format for device.
163  );
164 
170  virtual PBoolean SetFrameRate(
171  unsigned rate
172  );
173 
180  unsigned & minWidth,
181  unsigned & minHeight,
182  unsigned & maxWidth,
183  unsigned & maxHeight
184  ) ;
185 
191  virtual PBoolean SetFrameSize(
192  unsigned width,
193  unsigned height
194  );
195 
196  void ClearMapping() { return ; }
197 
198 
199  protected:
200  unsigned m_ffmpegFrameWidth;
201  unsigned m_ffmpegFrameHeight;
202  unsigned m_ffmpegFrameRate;
203  unsigned m_ffmpegFrameSize;
204  PPipeChannel m_command;
205  PINDEX m_videoFrameSize;
206  unsigned grabCount;
207  PAdaptiveDelay pacing;
208 };
209 
210 
211 #endif // P_FFVDEV
212 #endif
213 
214 #endif // PTLIB_PVFILEDEV_H
215 
216 
217 // 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
Definition: pipechan.h:73
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:1039
virtual PBoolean Close()
Close the device.
Definition: videoio.h:1072
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:962
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.
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.