PTLib  Version 2.10.10
video.h
Go to the documentation of this file.
1 /*
2  * video.h
3  *
4  * Video interface class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
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 Equivalence Pty. Ltd.
23  *
24  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25  * All Rights Reserved.
26  *
27  * Contributor(s): Derek Smithies (derek@indranet.co.nz)
28  *
29  * $Revision: 24459 $
30  * $Author: shorne $
31  * $Date: 2010-06-06 08:59:59 -0500 (Sun, 06 Jun 2010) $
32  */
33 
34 #ifndef PTLIB_VIDEO_H
35 #define PTLIB_VIDEO_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #include <ptbuildopts.h>
42 
43 #if P_VIDEO
44 
45 #include <ptlib/videoio.h>
46 
53 class PVideoChannel : public PChannel
54 {
55  PCLASSINFO(PVideoChannel, PChannel);
56 
57  public:
60  enum Directions {
63  };
64 
66  PVideoChannel();
67 
72  const PString & device,
73  Directions dir
74  );
75  //
76 
78  // Destroy and close the video driver
80 
89  PBoolean Open(
90  const PString & device,
91  Directions dir
92  );
93 
98  PBoolean IsOpen() const;
99 
109  Directions dir
110  ) ;
111 
120  static PString GetDefaultDevice(
121  Directions dir // Video I/O direction
122  );
124 
125 
128  virtual PINDEX GetGrabWidth();
129 
132  virtual PINDEX GetGrabHeight();
133 
134  virtual PBoolean Read(void * buf, PINDEX len);
135  // Low level read from the video channel. This function will block until the
136  // requested number of characters were read.
137 
138 
142  PBoolean Write(const void * buf, //Pointer to the image data to be rendered
143  PINDEX len);
144 
147  virtual PBoolean Write(
148  const void * buf,
149  PINDEX len,
150  void * mark
151  );
152 
156  virtual PBoolean Redraw(const void * frame);
157 
160  PINDEX GetRenderWidth();
161 
164  PINDEX GetRenderHeight();
165 
169  virtual void SetRenderFrameSize(int width, int height);
170 
174  virtual void SetRenderFrameSize(int width, int height,int sarwidth, int sarheight);
175 
179  virtual void SetGrabberFrameSize(int width, int height);
180 
189  virtual void AttachVideoPlayer(PVideoOutputDevice * device, PBoolean keepCurrent = true);
190 
199  virtual void AttachVideoReader(PVideoInputDevice * device, PBoolean keepCurrent = true);
200 
204 
208 
211  virtual PBoolean IsGrabberOpen();
212 
215  virtual PBoolean IsRenderOpen();
216 
222  virtual PBoolean DisableDecode();
223 
227  PBoolean DisplayRawData(void *videoBuffer);
228 
231  virtual void CloseVideoReader();
232 
235  virtual void CloseVideoPlayer();
236 
239  void RestrictAccess();
240 
243  void EnableAccess();
244 
248 
252  virtual bool FlowControl(const void * flowData);
253 
254  protected:
255 
257 
261 
262  PMutex accessMutex; // Ensure that only task is accesing
263  // members in this video channel.
264  private:
265  void Construct();
266 
267 
268 // Include platform dependent part of class
269 #ifdef _WIN32
270 #include "msos/ptlib/video.h"
271 #else
272 #include "unix/ptlib/video.h"
273 #endif
274 };
275 
276 #endif // P_VIDEO
277 
278 #endif // PTLIB_VIDEO_H
279 
280 
281 // End Of File ///////////////////////////////////////////////////////////////
virtual void CloseVideoReader()
Destroy the attached grabber class.
virtual PBoolean IsRenderOpen()
See if the rendering device is open.
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the channel.
virtual void CloseVideoPlayer()
Destroy the attached video display class.
A class representing a video channel.
Definition: video.h:53
PVideoChannel()
Create a video channel.
PBoolean Open(const PString &device, Directions dir)
Open the specified device for playing or recording.
virtual void SetRenderFrameSize(int width, int height)
Specify the width and height of the video stream, which is to be rendered onto the previously specifi...
virtual void AttachVideoPlayer(PVideoOutputDevice *device, PBoolean keepCurrent=true)
Attach a user specific class for rendering video.
virtual PBoolean DisableDecode()
Allow the outputdevice decide whether the decoder should ignore decode hence not render any output...
virtual bool FlowControl(const void *flowData)
Flow Control information Pass data to the channel for flowControl determination.
Definition: video.h:61
virtual void SetGrabberFrameSize(int width, int height)
Specifiy the width and height of the video stream, which is to be extracted from the previously speci...
PBoolean IsOpen() const
return True if one (or both) of the video device class pointers is non NULL.
This is an array collection class of PString objects.
Definition: pstring.h:2024
PINDEX GetRenderHeight()
Return the previously specified height.
static PStringArray GetDeviceNames(Directions dir)
Get all of the names for video devices/drivers that are available on this platform.
Directions direction
Definition: video.h:256
PMutex accessMutex
For displaying video on the screen.
Definition: video.h:262
BOOL PBoolean
Definition: object.h:102
PVideoInputDevice * mpInput
Specified video device name, eg /dev/video0.
Definition: video.h:259
virtual void AttachVideoReader(PVideoInputDevice *device, PBoolean keepCurrent=true)
Attach a user specific class for acquiring video.
virtual PBoolean IsGrabberOpen()
See if the grabber is open.
virtual PVideoOutputDevice * GetVideoPlayer()
Return a pointer to the class for displaying video.
PBoolean ToggleVFlipInput()
Toggle the vertical flip state of the video grabber.
Abstract class defining I/O channel semantics.
Definition: channel.h:107
The character string class.
Definition: pstring.h:108
virtual PINDEX GetGrabHeight()
Return the height of the currently selected grabbing device.
Directions
Definition: video.h:60
PINDEX GetRenderWidth()
Return the previously specified width.
PBoolean DisplayRawData(void *videoBuffer)
Get data from the attached inputDevice, and display on the attached ouptutDevice. ...
virtual PINDEX GetGrabWidth()
Return the width of the currently selected grabbing device.
PBoolean Write(const void *buf, PINDEX len)
Low level write to the channel, which is data to be rendered to the local video display device...
This class defines a video input device.
Definition: videoio.h:962
virtual PVideoInputDevice * GetVideoReader()
Return a pointer to the class for acquiring video.
Definition: video.h:62
virtual PBoolean Redraw(const void *frame)
Cause the referenced data to be drawn to the previously defined media.
PString deviceName
Definition: video.h:258
static PString GetDefaultDevice(Directions dir)
Get the name for the default video devices/driver that is on this platform.
void RestrictAccess()
Restrict others from using this video channel.
This class defines a video output device.
Definition: videoio.h:703
Synonym for PTimedMutex.
PVideoOutputDevice * mpOutput
For grabbing video from the camera.
Definition: video.h:260
void EnableAccess()
Allow free access to this video channel.