Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

CVideoDevice Class Reference

Base class for a video capturing device. More...

#include <VideoDevice.h>

Inheritance diagram for CVideoDevice:

CVideoDeviceLinux CVideoDeviceWin32 List of all members.

Public Types

Public Slots

Signals

Public Member Functions

Protected Member Functions

Protected Attributes


Detailed Description

Base class for a video capturing device.

This class is the (abstract) base of all platform dependant classes. It has the common functionality of video capturing:

(*) This is mainly due to the Windows platform, because there it is the driver that supplies the various dialogs that control the parameters of the device like width & height, brightness, input, tuner frequency, etc. This in contrast to Linux, which has it all wrapped up in the Video4Linux API. The behaviour is simulated under Linux :-)

The class supports output in both RGB and YUV (4:2:0) format; a caller has to specify which format he desires (maybe even both). CVideoDevice internally transforms one format to the other. If no format is specified, no image is captured!

Support for TV tuners is also built in; the user can specify a list of presets through a dialog supplied by this class.


Member Enumeration Documentation

enum CVideoDevice::ErrorCodes
 

Enumeration values:
NoError 
SizeChangeFailed 

enum CVideoDevice::Signals
 

Enumeration values:
frame_ready 


Constructor & Destructor Documentation

CVideoDevice::CVideoDevice  ) 
 

CVideoDevice::~CVideoDevice  )  [virtual]
 

Destroys the object; also closes the associated file descriptor

CVideoDevice::CVideoDevice const QString &  node_name  ) 
 

Parameters:
node_name The /dev/video* device name of the video device
The constructor will do some basic checks to see if this is a valid device. If yes, IsValid() will return TRUE, otherwise FALSE.

CVideoDevice::~CVideoDevice  ) 
 


Member Function Documentation

void CVideoDevice::ChangedTunerNorm int  tuner,
int  norm
[signal]
 

The frequency or norm changed.

void CVideoDevice::ChangedVideoInput int  input  )  [signal]
 

The video input channel has changed.

void CVideoDevice::Close  ) 
 

void CVideoDevice::Close  ) 
 

Closes the device provisionally.

This function decrements the usage counter of the VideoDevice. If the counter reaches 0, the device is really closed. See also Open().

void CVideoDevice::Closed  )  [signal]
 

The device is being closed by the last user; the device is not accessible

void CVideoDevice::Closed  )  [signal]
 

The device is being closed by the last user; the device is not accessible

void CVideoDevice::CreateImagesRGB  )  [protected, pure virtual]
 

void CVideoDevice::CreateImagesYUV  )  [protected, pure virtual]
 

void CVideoDevice::CreateVideoFrames  )  [protected]
 

Create our VideoFrames list.

Call this function when you have created your RGB/YUV images. It will create m_Buffers CVideoFrames, mapped to these RGB/YUV images.

Initially all frames are placed on the empty list.

virtual void CVideoDevice::DeleteImagesRGB  )  [protected, pure virtual]
 

virtual void CVideoDevice::DeleteImagesYUV  )  [protected, pure virtual]
 

void CVideoDevice::DeleteVideoFrames  )  [protected]
 

void CVideoDevice::DisableRGB  )  [slot]
 

void CVideoDevice::DisableYUV  )  [slot]
 

void CVideoDevice::EnableRGB bool  isOn  ) 
 

Enable/disable retrieval of RGB image(s).

This tells the object if RGB images are desired. This will help in selecting the proper PALETTE for the device. Both RGB and YUV images may be enabled. See also EnableYUV.

Multiple calls to EnableRGB(TRUE) will require the same amount of calls to EnableRGB(FALSE) to turn RGB retrieval completely off.

void CVideoDevice::EnableRGB  )  [slot]
 

void CVideoDevice::EnableYUV bool  isOn  ) 
 

Enable/disable retrieval of YUV image(s).

This tells the object if YUV (planar) images are desired. This will help in selecting the proper PALETTE for the device. Both YUV and RGB images may be enabled. See also EnableRGB.

Multiple calls to EnableYUV(TRUE) will require the same amount of calls to EnableYUV(FALSE) to turn YUV retrieval completely off.

void CVideoDevice::EnableYUV  )  [slot]
 

void CVideoDevice::Error int  err_num  )  [signal]
 

An error occured. err_num is one of the errno values.

void CVideoDevice::Error int  err_num  )  [signal]
 

An error occured. err_num is one of the errno values.

bool CVideoDevice::event QEvent *   )  [virtual]
 

virtual void CVideoDevice::Exit  )  [protected, pure virtual]
 

Implemented in CVideoDeviceLinux, and CVideoDeviceWin32.

void CVideoDevice::FramerateChanged int   )  [signal]
 

The frame rate has been changed.

void CVideoDevice::FramerateChanged int  rate  )  [signal]
 

New framerate

void CVideoDevice::FrameReady  )  [signal]
 

One ore more new image(s) is(are) available.

CVideoAudioInput * CVideoDevice::GetAudioInput int  number = -1  )  const
 

Returns an audio input channel (source) object.

Parameters:
number The desired input channel; -1 for the current one
Returns:
An object of type CVideoAudioInput, or NULL if number is out of range
This returns a pointer to a CVideoAudioInput object; when number is -1 (the default value), it returns the current input.

int CVideoDevice::GetAudioInputs  )  const
 

Return number of audio channels on the device.

Note! There is no SelectAudioInput! I suppose it's switched together with the video input... Also there is no way to find out to which audio input is associated with which video input. It looks more like this class is meant for manipulating the FM sound decoder on the tuner than really setting anything on the input.

int CVideoDevice::GetBrightness  )  const
 

Return brightness setting of device.

Returns:
unsigned integer in the range 0-65535. 65535 may indicate setting is not available.

Reimplemented in CVideoDeviceLinux.

int CVideoDevice::GetBuffers  )  const
 

int CVideoDevice::GetBuffers  )  const
 

Return available buffers.

Returns:
The number of image buffers used internally. The device must be opened.
Returns the numbers of buffers in use for this device, regardless if it supports mmap() or not.

int CVideoDevice::GetCaptureCount  )  const [protected]
 

int CVideoDevice::GetColour  )  const
 

Return colour saturation setting of device.

Returns:
unsigned integer in the range 0-65535. 65535 may indicate setting is not available.
A colour saturation of 0 means no colour at all, so the returned images are grayscale.

Reimplemented in CVideoDeviceLinux.

void CVideoDevice::GetConfiguration QDomNode &  node  )  const [virtual]
 

Return information in XML subtree.

This function returns the common part of the video device as an XML node. Specifically, it contains the TV channel/tuner part.

You should overload this function in your OS-specific subclass, and merge this node with the private settings from your device.

Reimplemented in CVideoDeviceLinux.

int CVideoDevice::GetContrast  )  const
 

Return contrast setting of device.

Returns:
unsigned integer in the range 0-65535. 65535 may indicate setting is not available.

Reimplemented in CVideoDeviceLinux.

TVChannel CVideoDevice::GetCurrentTVChannel  )  const
 

Return info of the current TV channel.

Returns:
A TVChannel struct, which contains information about the currently selected channel
This simply returns a TVChannel struct with the name, frequency system, etc. of the current selected channel.

int CVideoDevice::GetCurrentVideoInput  )  const
 

Return current input.

Returns:
input number, or -1 if current input is unknown
This will return the current input, if known. Unfortunately, there is no way to query the video device for the selected channel so until SelectInput() is called this function returns -1.

int CVideoDevice::GetDescriptor  )  const
 

Reimplemented in CVideoDeviceLinux, and CVideoDeviceWin32.

int CVideoDevice::GetDescriptor  )  const [pure virtual]
 

System dependant descriptor to device.

File descriptor under Unix, WHND under Windows; should be casted to apropriate type.

Only valid when the device is open!

Implemented in CVideoDeviceLinux, and CVideoDeviceWin32.

CVideoFrame * CVideoDevice::GetFillFrame  )  [protected]
 

Get a videoframe that can be filled.

Returns:
A CVideoFrame, or NULL
When a frame is ready from the device, call this function to get a free CVideoFrame that you can use to fill. This CVideoFrame is taken from the empty list first, then the full list if nobody is using the frame.

This function will return NULL when no CVideoFrame is available.

See also ReturnFillFrame

int CVideoDevice::GetFramerate  )  const
 

Returns the current framerate.

Returns:
The framerate in frames per second.
This applies to some webcams that allow setting of a framerate. In case of a device that does not support select() we use the framerate to set the timer. By default the framerate is set to 10.

Returns -1 in case of error.

Reimplemented in CVideoDeviceLinux.

int CVideoDevice::GetHue  )  const
 

Return hue (color shift) setting of device.

Returns:
unsigned integer in the range 0-65535. 65535 may indicate setting is not available.
Hue is a way to correct for colour deviations. It is something different than GetColour.

Reimplemented in CVideoDeviceLinux.

virtual int CVideoDevice::GetInput  )  const [pure virtual]
 

Get currently selected input.

Returns:
A positive integer, or -1 in case input is unknown
Returns the number of the currently selected input (if known). Otherwise returns -1.

Usually this variable will be initialized during SetConfiguration().

Implemented in CVideoDeviceLinux.

QString CVideoDevice::GetIntfName  )  const
 

QString CVideoDevice::GetIntfName  )  const
 

Returns internal name of device.

This function returns the name of the device through the V4L interface.

CVideoFrame * CVideoDevice::GetLatestVideoFrame int  backlog = 0  ) 
 

Return the latest video frame.

This will return a (shallow copy) of CVideoFrame. Delete the object when you're done with it.

QSize CVideoDevice::GetMaxSize  )  const
 

Return the maximum image size this device supports.

Returns:
an Object of type QSize
With this function the maximum image size in pixels is retrieved. See also GetMinSize and SetSize

Not all sizes between the minimum and maximum size may be allowed by the device; however, there is currently no way to retrieve a list of possible sizes. It's safest to stick to CIF (352x288) and SIF (320x240) formats and subsizes hereof, and VGA. Also it's wise to use to multiples of 8 in both directions. SetSize will return FALSE when the size was rejected by the driver.

Reimplemented in CVideoDeviceLinux.

int CVideoDevice::GetMBuffers  )  const
 

Return number of mmaped() buffers.

Returns:
0 if no mmap() support exists. The device must be opened.
In case the device supports mmap(), this returns the number of buffers that are available and mapped.

QSize CVideoDevice::GetMinSize  )  const
 

Return the minimum image size this device supports.

Returns:
an Object of type QSize
With this function the minium image size in pixels is retrieved.

Reimplemented in CVideoDeviceLinux.

QString CVideoDevice::GetNodeName  )  const
 

QString CVideoDevice::GetNodeName  )  const
 

Returns device inode name.

This function returns the name of the device inode, like /dev/video0, /dev/video1, etc.

virtual int CVideoDevice::GetNumberOfInputs  )  const [pure virtual]
 

Implemented in CVideoDeviceLinux.

virtual int CVideoDevice::GetNumberOfTuners  )  const [pure virtual]
 

Get number of tuners attached to this video device.

Returns:
A positive integer
When you use a TV card, it has a tuner on board which you can use to select a frequency to watch. This function tells the number of tuners attached. Rarely this will be larger than 1.

You may have to select a specific input to watch TV; some cards also have S-VHS or composite input. Unfortunately it is not possible to determine to which input a tuner is attached.

Implemented in CVideoDeviceLinux.

unsigned int CVideoDevice::GetNumberOfTVChannels  )  const
 

Return number of programmed TV channels.

Returns:
a positive integer
The user (and to some extent the program) has the ability to define channels for the Tuner through the ShowTunerDialog(). This function returns the number of presets stored.

It is not possible to define new channels directly in CVideoDevice; this is left to the TunerDialog. You can only query and select them.

Note:
The returned of channels can change at any time! Especially if the TunerDialog is open...

The channels are stored in the XML tree with GetConfiguration().

The correct tuner + input has to be selected first in order to get a picture from the tuner...

QImage * CVideoDevice::GetRGB int  offset = 0  )  const
 

Get an RGB image.

Parameters:
offset Offset in images buffer.
Retrieve pointer to an RGB image; note that this is a pointer, not a (shallow) copy. The QImage is a 32 bit deep image.

When buffering is active any of the previous images in the buffer can be retrieved. The 'offset' parameter indicates the negative offset in the (circular) list of images. When offset = 0 (the default) the latest image is returned; when offset = 1 is the previous image, offset = 2 the image before that, etc. up to the number of Buffers - 1.

If offset is outside the range a NULL pointer will be returned.

QString CVideoDevice::GetSerialNumber  )  const
 

Returns serial number of device, when available.

Returns:
A QSstring; is a null string when no serial number is available
This function returns the serial number of the device; this is not always possible, but USB devices do in general have a serial number. If no number could be determined, a null string is returned.

QSize CVideoDevice::GetSize  ) 
 

Return current size from the driver.

Returns:
An object of type QSize.
Returns the current image size as reported by the device. Returns a size of (0, 0) when the device is closed or an error occured.

QSize CVideoDevice::GetSize  )  const [virtual]
 

virtual int CVideoDevice::GetTuner  )  const [pure virtual]
 

Implemented in CVideoDeviceLinux.