PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | List of all members
PVideoInputDevice Class Referenceabstract

This class defines a video input device. More...

`#include <videoio.h>`

Inheritance diagram for PVideoInputDevice:
[legend]
Collaboration diagram for PVideoInputDevice:
[legend]

## Classes
struct | Capabilities

## Public Member Functions
| ~PVideoInputDevice ()
| Create a new video input device. More...
virtual bool | GetDeviceCapabilities (Capabilities *capabilities) const
| Retrieve a list of Device Capabilities. More...
virtual PVideoInputControl * | GetVideoInputControls ()
| Get the devices video Input controls By Default return NULL;. More...
virtual PBoolean | Open (const PString &deviceName, PBoolean startImmediate=true)=0
| Open the device given the device name. More...
virtual PBoolean | Close ()
| Close the device. More...
virtual PBoolean | CanCaptureVideo () const
| Is the device a camera, and obtain video. More...
virtual PBoolean | IsCapturing ()=0
| Determine if the video device I/O capture is in progress. More...
virtual PBoolean | SetNearestFrameSize (unsigned width, unsigned height)
| Set the nearest available frame size to be used. More...
virtual PBoolean | GetFrame (PBYTEArray &frame)
| Grab a frame. More...
virtual PBoolean | GetFrameData (BYTE *buffer, PINDEX *bytesReturned, bool &keyFrame)
| Grab a frame, after a delay as specified by the frame rate. More...
virtual PBoolean | GetFrameData (BYTE *buffer, PINDEX *bytesReturned=NULL)=0
virtual PBoolean | GetFrameDataNoDelay (BYTE *buffer, PINDEX *bytesReturned, bool &keyFrame)
| Grab a frame. More...
virtual PBoolean | GetFrameDataNoDelay (BYTE *buffer, PINDEX *bytesReturned=NULL)=0
virtual bool | FlowControl (const void *flowData)
| Pass data to the inputdevice for flowControl determination. More...
virtual bool | SetCaptureMode (unsigned mode)
| Set the capture modes for implementations that support them. More...
virtual int | GetCaptureMode () const
| Returns the current capture mode. More...
| P_REMOVE_VIRTUAL (PBoolean, GetFrameData(BYTE *, PINDEX *, unsigned &), false)
| P_REMOVE_VIRTUAL (PBoolean, GetFrameDataNoDelay(BYTE *, PINDEX *, unsigned &), false)
Public Member Functions inherited from PVideoDevice
virtual | ~PVideoDevice ()
| Delete structures created by PVideoDevice();. More...
const PString & | GetDeviceName () const
| Get the device name of the open device. More...
virtual PStringArray | GetDeviceNames () const =0
| Get a list of all of the drivers available. More...
virtual PBoolean | OpenFull (const OpenArgs &args, PBoolean startImmediate=true)
| Open the device given the device name. More...
virtual PBoolean | IsOpen ()=0
| Determine if the device is currently open. More...
virtual PBoolean | Start ()=0
| Start the video device I/O capture. More...
virtual PBoolean | Stop ()=0
| Stop the video device I/O capture. More...
virtual PBoolean | SetVideoFormat (VideoFormat videoFormat)
| Set the video format to be used. More...
virtual VideoFormat | GetVideoFormat () const
| Get the video format being used. More...
virtual int | GetNumChannels ()
| Get the number of video channels available on the device. More...
virtual PStringArray | GetChannelNames ()
| Get the names of video channels available on the device. More...
virtual PBoolean | SetChannel (int channelNumber)
| Set the video channel to be used on the device. More...
virtual int | GetChannel () const
| Get the video channel to be used on the device. More...
virtual bool | SetFrameInfoConverter (const PVideoFrameInfo &info)
| Set the frame info to be used, trying converters if available. More...
virtual PBoolean | SetColourFormatConverter (const PString &colourFormat)
| Set the colour format to be used, trying converters if available. More...
virtual PBoolean | GetVFlipState ()
| Get the video conversion vertical flip state. More...
virtual PBoolean | SetVFlipState (PBoolean newVFlipState)
| Set the video conversion vertical flip state. More...
virtual PBoolean | GetFrameSizeLimits (unsigned &minWidth, unsigned &minHeight, unsigned &maxWidth, unsigned &maxHeight)
| Get the minimum & maximum size of a frame on the device. More...
virtual PBoolean | SetFrameSizeConverter (unsigned width, unsigned height, ResizeMode resizeMode=eMaxResizeMode)
| Set the frame size to be used, trying converters if available. More...
virtual PBoolean | SetFrameSizeConverter (unsigned width, unsigned height, PBoolean)
| Set the frame size to be used, trying converters if available. More...
virtual PBoolean | SetFrameSize (unsigned width, unsigned height)
| Set the frame size to be used. More...
virtual PBoolean | GetFrameSize (unsigned &width, unsigned &height) const
| Get the frame size being used. More...
virtual const PString & | GetColourFormat () const
| Get the colour format being used. More...
virtual PINDEX | GetMaxFrameBytes ()=0
| Get the maximum frame size in bytes. More...
int | GetLastError () const
| Get the last error code. More...
virtual bool | GetAttributes (Attributes &attributes)
| Get video attributes. More...
virtual bool | SetAttributes (const Attributes &attributes)
| Set video attributes. More...
virtual PBoolean | SetVideoChannelFormat (int channelNumber, VideoFormat videoFormat)
| Set VideoFormat and VideoChannel in one ioctl. More...
void | SetPreferredColourFormat (const PString &colourFmt)
| Set preferred native colour format from video capture device. More...
const PString & | GetPreferredColourFormat ()
| Get preferred native colour format from video capture device. More...
Public Member Functions inherited from PVideoFrameInfo
| P_DECLARE_ENUM_EX (ResizeMode, eMaxResizeMode, eScale, 0, eCropCentre, eCropTopLeft)
| PVideoFrameInfo ()
| Construct video frame information. More...
| PVideoFrameInfo (unsigned frameWidth, unsigned frameHeight, const PString &colourFormat="YUV420P", unsigned frameRate=15, ResizeMode resizeMode=eScale)
virtual Comparison | Compare (const PObject &obj) const
| Compare the two PVideoFrameInfo and return their relative rank. More...
virtual void | PrintOn (ostream &strm) const
| Output the contents of the object to the stream. More...
virtual unsigned | GetFrameWidth () const
| Get the width of the frame being used. More...
virtual unsigned | GetFrameHeight () const
| Get the height of the frame being used. More...
virtual PBoolean | SetFrameSar (unsigned width, unsigned height)
| Set the Storage Aspect Ratio size to be used. More...
virtual PBoolean | GetSarSize (unsigned &width, unsigned &height) const
| Get the Storage Aspect Ratio size being used. More...
virtual unsigned | GetSarWidth () const
| Get the width of the Storage Aspect Ratio being used. More...
virtual unsigned | GetSarHeight () const
| Get the height of the Storage Aspect Ratio being used. More...
virtual PBoolean | SetFrameRate (unsigned rate)
| Set the video frame rate to be used on the device. More...
virtual unsigned | GetFrameRate () const
| Get the video frame rate used on the device. More...
virtual PBoolean | SetColourFormat (const PString &colourFormat)
| Set the colour format to be used. More...
void | SetResizeMode (ResizeMode mode)
| Set the resize mode to be used. More...
ResizeMode | GetResizeMode () const
| Get the resize mode to be used. More...
PINDEX | CalculateFrameBytes () const
| Get the number of bytes of an image, given a particular width, height and colour format. More...
bool | Parse (const PString &str)
| Parse a descriptor string for the video format. More...
Public Member Functions inherited from PObject
unsigned | GetTraceContextIdentifier () const
| Get PTRACE context identifier. More...
void | SetTraceContextIdentifier (unsigned id)
void | GetTraceContextIdentifier (PObject &obj)
void | GetTraceContextIdentifier (PObject *obj)
void | SetTraceContextIdentifier (const PObject &obj)
void | SetTraceContextIdentifier (const PObject *obj)
virtual | ~PObject ()
virtual PObject * | Clone () const
| Create a copy of the class on the heap. More...
template<class CLS >
CLS * | CloneAs () const
| As for Clone() but converts to specified type. More...
virtual PINDEX | HashFunction () const
| This function yields a hash value required by the `PDictionary` class. More...
virtual const char * | GetClass (unsigned ancestor=0) const
| Get the current dynamic type of the object instance. More...
PBoolean | IsClass (const char *cls) const
virtual PBoolean | InternalIsDescendant (const char *clsName) const
| Determine if the dynamic type of the current instance is a descendent of the specified class. More...
__inline const PObject * | PTraceObjectInstance () const
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const
| Determine the byte wise comparison of two objects. More...
bool | operator== (const PObject &obj) const
| Compare the two objects. More...
bool | operator!= (const PObject &obj) const
| Compare the two objects. More...
bool | operator< (const PObject &obj) const
| Compare the two objects. More...
bool | operator> (const PObject &obj) const
| Compare the two objects. More...
bool | operator<= (const PObject &obj) const
| Compare the two objects. More...
bool | operator>= (const PObject &obj) const
| Compare the two objects. More...
virtual void | PrintOn (ostream &strm) const
| Output the contents of the object to the stream. More...
virtual void | ReadFrom (istream &strm)
| Input the contents of the object from the stream. More...

## Static Public Member Functions
static PStringArray | GetDriverNames (PPluginManager *pluginMgr=NULL)
| Get the list of available video input drivers (plug-ins) More...
static PStringArray | GetDriversDeviceNames (const PString &driverName, PPluginManager *pluginMgr=NULL)
| Get video input devices that correspond to the specified driver name. More...
static PVideoInputDevice * | CreateDevice (const PString &driverName, PPluginManager *pluginMgr=NULL)
| Create the video input device that corresponds to the specified driver name. More...
static PVideoInputDevice * | CreateDeviceByName (const PString &deviceName, const PString &driverName=PString::Empty(), PPluginManager *pluginMgr=NULL)
static PVideoInputDevice * | CreateOpenedDevice (const PString &driverName, const PString &deviceName, PBoolean startImmediate=true, PPluginManager *pluginMgr=NULL)
| Create an opened video input device that corresponds to the specified names. More...
static PVideoInputDevice * | CreateOpenedDevice (const OpenArgs &args, PBoolean startImmediate=true)
| Create an opened video output device that corresponds to the specified arguments. More...
static PBoolean | GetDeviceCapabilities (const PString &deviceName, Capabilities *capabilities, PPluginManager *pluginMgr=NULL)
| Retrieve a list of Device Capabilities for particular device. More...
static PBoolean | GetDeviceCapabilities (const PString &deviceName, const PString &driverName, Capabilities *caps, PPluginManager *pluginMgr=NULL)
| Retrieve a list of Device Capabilities for a particular driver. More...

## Additional Inherited Members
Public Types inherited from PVideoDevice
enum | VideoFormat { PAL, NTSC, SECAM, Auto, NumVideoFormats }
Protected Member Functions inherited from PVideoDevice
| PVideoDevice ()
| Create a new video device (input or output). More...
PINDEX | GetMaxFrameBytesConverted (PINDEX rawFrameBytes) const
Protected Attributes inherited from PVideoDevice
PCaselessString | deviceName
int | lastError
VideoFormat | videoFormat
int | channelNumber
PString | preferredColourFormat
PBoolean | nativeVerticalFlip
PColourConverter * | converter
PBYTEArray | frameStore
Friends inherited from PObject

## Detailed Description

This class defines a video input device.

## Constructor & Destructor Documentation

PVideoInputDevice::~PVideoInputDevice | ( |  | ) |
| inline

Create a new video input device.

Close the video input device on destruction.

References Close().

## Member Function Documentation

virtual PBoolean PVideoInputDevice::CanCaptureVideo | ( |  | ) | const
| virtual

Is the device a camera, and obtain video.

Implements PVideoDevice.

virtual PBoolean PVideoInputDevice::Close | ( |  | ) |
| inline virtual

Close the device.

Implements PVideoDevice.

Reimplemented in PVideoInput1394DcDevice.

Referenced by ~PVideoInputDevice().

static PVideoInputDevice* PVideoInputDevice::CreateDevice | ( | const PString & | driverName,
|  | PPluginManager * | pluginMgr = `NULL`
| ) |  |
| static

Create the video input device that corresponds to the specified driver name.

Parameters

  driverName | Name of driver
  pluginMgr | Plug in manager, use default if NULL

static PVideoInputDevice* PVideoInputDevice::CreateDeviceByName | ( | const PString & | deviceName,
|  | const PString & | driverName = `PString::Empty()`,
|  | PPluginManager * | pluginMgr = `NULL`
| ) |  |
| static

Parameters

  deviceName | Name of device
  driverName | Name of driver (if any)
  pluginMgr | Plug in manager, use default if NULL

static PVideoInputDevice* PVideoInputDevice::CreateOpenedDevice | ( | const PString & | driverName,
|  | const PString & | deviceName,
|  | PBoolean | startImmediate = `true`,
|  | PPluginManager * | pluginMgr = `NULL`
| ) |  |
| static

Create an opened video input device that corresponds to the specified names.

If the driverName parameter is an empty string or "*" then CreateDeviceByName is used with the deviceName parameter which is assumed to be a value returned from GetDriversDeviceNames().

Parameters

  driverName | Name of driver
  deviceName | Name of device
  startImmediate | Immediately start grabbing
  pluginMgr | Plug in manager, use default if NULL

static PVideoInputDevice* PVideoInputDevice::CreateOpenedDevice | ( | const OpenArgs & | args,
|  | PBoolean | startImmediate = `true`
| ) |  |
| static

Create an opened video output device that corresponds to the specified arguments.

Parameters

  args | Parameters to set on opened device
  startImmediate | Immediately start display

virtual bool PVideoInputDevice::FlowControl | ( | const void * | flowData | ) |
| virtual

Pass data to the inputdevice for flowControl determination.

virtual int PVideoInputDevice::GetCaptureMode | ( |  | ) | const
| virtual

Returns the current capture mode.

See SetCaptureMode() for more details. A return value of -1 indicates an error or the mode is not supported.

virtual bool PVideoInputDevice::GetDeviceCapabilities | ( | Capabilities * | capabilities | ) | const
| inline virtual

Retrieve a list of Device Capabilities.

Parameters

  capabilities | List of supported capabilities

References GetDeviceCapabilities(), and PVideoDevice::GetDeviceName().

Referenced by GetDeviceCapabilities().

static PBoolean PVideoInputDevice::GetDeviceCapabilities | ( | const PString & | deviceName,
|  | Capabilities * | capabilities,
|  | PPluginManager * | pluginMgr = `NULL`
| ) |  |
| static

Retrieve a list of Device Capabilities for particular device.

Parameters

  deviceName | Name of device
  capabilities | List of supported capabilities
  pluginMgr | Plug in manager, use default if NULL

static PBoolean PVideoInputDevice::GetDeviceCapabilities | ( | const PString & | deviceName,
|  | const PString & | driverName,
|  | Capabilities * | caps,
|  | PPluginManager * | pluginMgr = `NULL`
| ) |  |
| static

Retrieve a list of Device Capabilities for a particular driver.

Parameters

  deviceName | Name of device
  driverName | Device Driver
  caps | List of supported capabilities
  pluginMgr | Plug in manager, use default if NULL

static PStringArray PVideoInputDevice::GetDriverNames | ( | PPluginManager * | pluginMgr = `NULL` | ) |
| static

Get the list of available video input drivers (plug-ins)

Parameters

  pluginMgr | Plug in manager, use default if NULL

static PStringArray PVideoInputDevice::GetDriversDeviceNames | ( | const PString & | driverName,
|  | PPluginManager * | pluginMgr = `NULL`
| ) |  |
| static

Get video input devices that correspond to the specified driver name.

If driverName is an empty string or the value "*" then this will return a list of unique device names across all of the available drivers. If two drivers have identical names for devices, then the string returned will be of the form driver+'\t'+device.

Parameters

  driverName | Name of driver
  pluginMgr | Plug in manager, use default if NULL

virtual PBoolean PVideoInputDevice::GetFrame | ( | PBYTEArray & | frame | ) |
| virtual

Grab a frame.

virtual PBoolean PVideoInputDevice::GetFrameData | ( | BYTE * | buffer,
|  | PINDEX * | bytesReturned,
|  | bool & | keyFrame
| ) |  |
| virtual

Grab a frame, after a delay as specified by the frame rate.

Parameters

  buffer | Buffer to receive frame
  bytesReturned | Optional bytes returned.
  keyFrame | On input, forces generation of key frame, On return indicates key frame generated

virtual PBoolean PVideoInputDevice::GetFrameData | ( | BYTE * | buffer,
|  | PINDEX * | bytesReturned = `NULL`
| ) |  |
| pure virtual

Parameters

  buffer | Buffer to receive frame
  bytesReturned | Optional bytes returned.

Implemented in PVideoInput1394DcDevice.

virtual PBoolean PVideoInputDevice::GetFrameDataNoDelay | ( | BYTE * | buffer,
|  | PINDEX * | bytesReturned,
|  | bool & | keyFrame
| ) |  |
| virtual

Grab a frame.

Do not delay according to the current frame rate parameter.

Parameters

  buffer | Buffer to receive frame
  bytesReturned | Optional bytes returned.
  keyFrame | On input, forces generation of key frame, On return indicates key frame generated

virtual PBoolean PVideoInputDevice::GetFrameDataNoDelay | ( | BYTE * | buffer,
|  | PINDEX * | bytesReturned = `NULL`
| ) |  |
| pure virtual

Parameters

  buffer | Buffer to receive frame
  bytesReturned | Optional bytes returned.

Implemented in PVideoInput1394DcDevice.

virtual PVideoInputControl* PVideoInputDevice::GetVideoInputControls | ( |  | ) |
| virtual

Get the devices video Input controls By Default return NULL;.

virtual PBoolean PVideoInputDevice::IsCapturing | ( |  | ) |
| pure virtual

Determine if the video device I/O capture is in progress.

Implemented in PVideoInput1394DcDevice.

virtual PBoolean PVideoInputDevice::Open | ( | const PString & | deviceName,
|  | PBoolean | startImmediate = `true`
| ) |  |
| pure virtual

Open the device given the device name.

Parameters

  deviceName | Device name to open
  startImmediate | Immediately start device

Implements PVideoDevice.

Implemented in PVideoInput1394DcDevice.

PVideoInputDevice::P_REMOVE_VIRTUAL | ( | PBoolean | ,
|  | GetFrameData(BYTE *, PINDEX *, unsigned &) | ,
|  | false |
| ) |  |

PVideoInputDevice::P_REMOVE_VIRTUAL | ( | PBoolean | ,
|  | GetFrameDataNoDelay(BYTE *, PINDEX *, unsigned &) | ,
|  | false |
| ) |  |

virtual bool PVideoInputDevice::SetCaptureMode | ( | unsigned | mode | ) |
| virtual

Set the capture modes for implementations that support them.

For example with Video For Windows, this is used to select picture (0) or video (1) modes.

In picture-mode the implementation requests a single frame from the connected camera device. The camera device then does nothing until the frame has been processed and the next is requested.

In video-mode the camera continuously sends new frames.

The default implementation does nothing but returns false.

virtual PBoolean PVideoInputDevice::SetNearestFrameSize | ( | unsigned | width,
|  | unsigned | height
| ) |  |
| virtual

Set the nearest available frame size to be used.

Note that devices may not be able to produce the requested size, so this function picks the nearest available size.

Default behaviour simply calls SetFrameSize().

Parameters

  width | New width of frame
  height | New height of frame

Reimplemented from PVideoDevice.

The documentation for this class was generated from the following file:

- videoio.h