PTLib  Version 2.14.3
 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: 30765 $
30  * $Author: rjongbloed $
31  * $Date: 2013-10-21 12:26:29 +1100 (Mon, 21 Oct 2013) $
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 
149  virtual PBoolean SetColourFormat(
150  const PString & colourFormat // New colour format for device.
151  );
152 
158  virtual PBoolean SetFrameRate(
159  unsigned rate
160  );
161 
168  unsigned & minWidth,
169  unsigned & minHeight,
170  unsigned & maxWidth,
171  unsigned & maxHeight
172  ) ;
173 
179  virtual PBoolean SetFrameSize(
180  unsigned width,
181  unsigned height
182  );
183 
184  void ClearMapping() { return ; }
185 
186 
187  protected:
188  unsigned m_ffmpegFrameWidth;
189  unsigned m_ffmpegFrameHeight;
190  unsigned m_ffmpegFrameRate;
191  unsigned m_ffmpegFrameSize;
192  PPipeChannel m_command;
193  PINDEX m_videoFrameSize;
194  unsigned grabCount;
195  PAdaptiveDelay pacing;
196 };
197 
198 
199 #endif // P_FFVDEV
200 #endif
201 
202 #endif // PTLIB_PVFILEDEV_H
203 
204 
205 // End Of File ///////////////////////////////////////////////////////////////