# PVideoChannel Class Reference

A class representing a video channel. More...

`#include <video.h>`

Inheritance diagram for PVideoChannel:

List of all members.

## Construction

enum | Directions { Recorder, Player }
| PVideoChannel ()
| Create a video channel.
| PVideoChannel (const PString &device, Directions dir)
| Create a video channel.
| ~PVideoChannel ()

## Open functions

PBoolean | Open (const PString &device, Directions dir)
| Open the specified device for playing or recording.
PBoolean | IsOpen () const
| return True if one (or both) of the video device class pointers is non NULL.
static PStringArray | GetDeviceNames (Directions dir)
| Get all of the names for video devices/drivers that are available on this platform.
static PString | GetDefaultDevice (Directions dir)
| Get the name for the default video devices/driver that is on this platform.

## Public Member Functions

virtual PINDEX | GetGrabWidth ()
| Return the width of the currently selected grabbing device.
virtual PINDEX | GetGrabHeight ()
| Return the height of the currently selected grabbing device.
virtual PBoolean | Read (void *buf, PINDEX len)
| Low level read from the channel.
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.
virtual PBoolean | Write (const void *buf, PINDEX len, void *mark)
| Low level write to the video channel with marker.
virtual PBoolean | Redraw (const void *frame)
| Cause the referenced data to be drawn to the previously defined media.
PINDEX | GetRenderWidth ()
| Return the previously specified width.
PINDEX | GetRenderHeight ()
| Return the previously specified height.
virtual void | SetRenderFrameSize (int width, int height)
| Specify the width and height of the video stream, which is to be rendered onto the previously specified device.
virtual void | SetRenderFrameSize (int width, int height, int sarwidth, int sarheight)
| Specify the width and height of the video stream, which is to be rendered onto the previously specified device including sample aspect ratio.
virtual void | SetGrabberFrameSize (int width, int height)
| Specifiy the width and height of the video stream, which is to be extracted from the previously specified device.
virtual void | AttachVideoPlayer (PVideoOutputDevice *device, PBoolean keepCurrent=true)
| Attach a user specific class for rendering video.
virtual void | AttachVideoReader (PVideoInputDevice *device, PBoolean keepCurrent=true)
| Attach a user specific class for acquiring video.
virtual PVideoInputDevice * | GetVideoReader ()
| Return a pointer to the class for acquiring video.
virtual PVideoOutputDevice * | GetVideoPlayer ()
| Return a pointer to the class for displaying video.
virtual PBoolean | IsGrabberOpen ()
| See if the grabber is open.
virtual PBoolean | IsRenderOpen ()
| See if the rendering device is open.
virtual PBoolean | DisableDecode ()
| Allow the outputdevice decide whether the decoder should ignore decode hence not render any output.
PBoolean | DisplayRawData (void *videoBuffer)
| Get data from the attached inputDevice, and display on the attached ouptutDevice.
virtual void | CloseVideoReader ()
| Destroy the attached grabber class.
virtual void | CloseVideoPlayer ()
| Destroy the attached video display class.
void | RestrictAccess ()
| Restrict others from using this video channel.
void | EnableAccess ()
| Allow free access to this video channel.
PBoolean | ToggleVFlipInput ()
| Toggle the vertical flip state of the video grabber.
virtual bool | FlowControl (const void *flowData)
| Flow Control information Pass data to the channel for flowControl determination.
virtual PBoolean | Close ()
| Close the channel, shutting down the link to the data source.
virtual PString | GetName () const
| Get the platform and I/O channel type name of the channel.
PString | GetErrorText () const

## Protected Attributes

Directions | direction
PString | deviceName
PVideoInputDevice * | mpInput
| Specified video device name, eg /dev/video0.
PVideoOutputDevice * | mpOutput
| For grabbing video from the camera.
PMutex | accessMutex
| For displaying video on the screen.

## Static Protected Attributes

static PMutex | dictMutex

## Detailed Description

A class representing a video channel.

This class is provided mainly for the playback or recording of video on the system.

Note that this video channel is implicitly a series of frames in YUV411P format. No conversion is performed on data to/from the channel.

## Member Enumeration Documentation

enum PVideoChannel::Directions

Enumerator:

  Recorder |
  Player |

## Constructor & Destructor Documentation

PVideoChannel::PVideoChannel | ( |  | ) |

Create a video channel.

PVideoChannel::PVideoChannel | ( | const PString & | device,
|  | Directions | dir |
| ) |  |  |

Create a video channel.

Create a reference to the video drivers for the platform.

Parameters:

  device | Name of video driver/device
  dir | Video I/O direction

PVideoChannel::~PVideoChannel | ( |  | ) |

## Member Function Documentation

virtual void PVideoChannel::AttachVideoPlayer | ( | PVideoOutputDevice * | device,
|  | PBoolean | keepCurrent = `true` |
| ) |  |  | `[virtual]`

Attach a user specific class for rendering video.

If keepCurrent is true, an abort is caused when the program attempts to attach a new player when there is already a video player attached.

If keepCurrent is false, the existing video player is deleted before attaching the new player.

virtual void PVideoChannel::AttachVideoReader | ( | PVideoInputDevice * | device,
|  | PBoolean | keepCurrent = `true` |
| ) |  |  | `[virtual]`

Attach a user specific class for acquiring video.

If keepCurrent is true, an abort is caused when the program attempts to attach a new reader when there is already a video reader attached.

If keepCurrent is false, the existing video reader is deleted before attaching the new reader.

virtual PBoolean PVideoChannel::Close | ( |  | ) | `[virtual]`

Close the channel, shutting down the link to the data source.

Returns:
  true if the channel successfully closed.

Reimplemented from PChannel.

virtual void PVideoChannel::CloseVideoPlayer | ( |  | ) | `[virtual]`

Destroy the attached video display class.

virtual void PVideoChannel::CloseVideoReader | ( |  | ) | `[virtual]`

Destroy the attached grabber class.

virtual PBoolean PVideoChannel::DisableDecode | ( |  | ) | `[virtual]`

Allow the outputdevice decide whether the decoder should ignore decode hence not render any output.

This does not mean the video channel is closed just to not decode and render any frames.

PBoolean PVideoChannel::DisplayRawData | ( | void * | videoBuffer | ) |

Get data from the attached inputDevice, and display on the attached ouptutDevice.

void PVideoChannel::EnableAccess | ( |  | ) |

Allow free access to this video channel.

virtual bool PVideoChannel::FlowControl | ( | const void * | flowData | ) | `[virtual]`

Flow Control information Pass data to the channel for flowControl determination.

Reimplemented from PChannel.

static PString PVideoChannel::GetDefaultDevice | ( | Directions | dir | ) | `[static]`

Get the name for the default video devices/driver that is on this platform.

Note that a named device may not necessarily do both playing and recording so the arrays returned with the `dir` parameter in each value is not necessarily the same.

Returns:
  A platform dependent string for the video player/recorder.

static PStringArray PVideoChannel::GetDeviceNames | ( | Directions | dir | ) | `[static]`

Get all of the names for video devices/drivers that are available on this platform.

Note that a named device may not necessarily do both playing and recording so the arrays returned with the `dir` parameter in each value is not necessarily the same.

Returns:
  An array of platform dependent strings for each video player/recorder.

Parameters:

  dir | Video I/O direction

PString PVideoChannel::GetErrorText | ( |  | ) | const

virtual PINDEX PVideoChannel::GetGrabHeight | ( |  | ) | `[virtual]`

Return the height of the currently selected grabbing device.

virtual PINDEX PVideoChannel::GetGrabWidth | ( |  | ) | `[virtual]`

Return the width of the currently selected grabbing device.

virtual PString PVideoChannel::GetName | ( |  | ) | const`[virtual]`

Get the platform and I/O channel type name of the channel.

For example, it would return the filename in `PFile` type channels.

Returns:
  the name of the channel.

Reimplemented from PChannel.

PINDEX PVideoChannel::GetRenderHeight | ( |  | ) |

Return the previously specified height.

PINDEX PVideoChannel::GetRenderWidth | ( |  | ) |

Return the previously specified width.

virtual PVideoOutputDevice* PVideoChannel::GetVideoPlayer | ( |  | ) | `[virtual]`

Return a pointer to the class for displaying video.

virtual PVideoInputDevice* PVideoChannel::GetVideoReader | ( |  | ) | `[virtual]`

Return a pointer to the class for acquiring video.

virtual PBoolean PVideoChannel::IsGrabberOpen | ( |  | ) | `[virtual]`

See if the grabber is open.

PBoolean PVideoChannel::IsOpen | ( |  | ) | const`[virtual]`

return True if one (or both) of the video device class pointers is non NULL.

If either pointer is non NULL, then a device is ready to be written to, which indicates this channel is open.

Reimplemented from PChannel.

virtual PBoolean PVideoChannel::IsRenderOpen | ( |  | ) | `[virtual]`

See if the rendering device is open.

PBoolean PVideoChannel::Open | ( | const PString & | device,
|  | Directions | dir |
| ) |  |  |

Open the specified device for playing or recording.

The device name is platform specific and is as returned in the GetDevices() function.

Returns:
  true if the video device is valid for playing/recording.

Parameters:

  device | Name of video driver/device
  dir | Video I/O direction

virtual PBoolean PVideoChannel::Read | ( | void * | buf,
|  | PINDEX | len |
| ) |  |  | `[virtual]`

Low level read from the channel.

This function may block until the requested number of characters were read or the read timeout was reached. The GetLastReadCount() function returns the actual number of bytes read.

The GetErrorCode() function should be consulted after Read() returns false to determine what caused the failure.

Returns:
  true indicates that at least one character was read from the channel. false means no bytes were read due to timeout or some other I/O error.

Reimplemented from PChannel.

virtual PBoolean PVideoChannel::Redraw | ( | const void * | frame | ) | `[virtual]`

Cause the referenced data to be drawn to the previously defined media.

void PVideoChannel::RestrictAccess | ( |  | ) |

Restrict others from using this video channel.

virtual void PVideoChannel::SetGrabberFrameSize | ( | int | width,
|  | int | height |
| ) |  |  | `[virtual]`

Specifiy the width and height of the video stream, which is to be extracted from the previously specified device.

virtual void PVideoChannel::SetRenderFrameSize | ( | int | width,
|  | int | height,
|  | int | sarwidth,
|  | int | sarheight |
| ) |  |  | `[virtual]`

Specify the width and height of the video stream, which is to be rendered onto the previously specified device including sample aspect ratio.

virtual void PVideoChannel::SetRenderFrameSize | ( | int | width,
|  | int | height |
| ) |  |  | `[virtual]`

Specify the width and height of the video stream, which is to be rendered onto the previously specified device.

PBoolean PVideoChannel::ToggleVFlipInput | ( |  | ) |

Toggle the vertical flip state of the video grabber.

virtual PBoolean PVideoChannel::Write | ( | const void * | buf,
|  | PINDEX | len,
|  | void * | mark |
| ) |  |  | `[virtual]`

Low level write to the video channel with marker.

Parameters:

  buf | Pointer to a block of memory to write.
  len | Number of bytes to write.
  mark | Unique Marker to identify write

PBoolean PVideoChannel::Write | ( | const void * | buf,
|  | PINDEX | len |
| ) |  |  | `[virtual]`

Low level write to the channel, which is data to be rendered to the local video display device.

Reimplemented from PChannel.

## Member Data Documentation

PMutex PVideoChannel::accessMutex `[protected]`

For displaying video on the screen.

PString PVideoChannel::deviceName `[protected]`

PMutex PVideoChannel::dictMutex `[static, protected]`

Directions PVideoChannel::direction `[protected]`

PVideoInputDevice* PVideoChannel::mpInput `[protected]`

Specified video device name, eg /dev/video0.

PVideoOutputDevice* PVideoChannel::mpOutput `[protected]`

For grabbing video from the camera.

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

- video.h