vc::videoDevice Class Reference

#include <videoDevice.h>

List of all members.


Detailed Description

The core videoDevice object.

This devices accesses the attached hardware through the appropriate interfaces and simplifies interaction through a smaller, unified API.

Public Member Functions

 videoDevice (string)
 ~videoDevice ()
void init ()
 Initialize the device.
void getFrame (vdFrame &)
 Get a frame from the device.
bool getIntegerControlUsed (const vdIntegerControl)
 Gets whether the control is used on the device.
int getIntegerControlValue (const vdIntegerControl)
 Get the current setting of an integer control, if possible.
int getIntegerControlMinimum (const vdIntegerControl)
 Get the minimum setting of an integer control, if possible.
int getIntegerControlMaximum (const vdIntegerControl)
 Get the maximum setting of an integer control, if possible.
int getIntegerControlStep (const vdIntegerControl)
 Get the minimum effective interval for an integer control, if possible.
void setIntegerControlValue (const vdIntegerControl, const int)
 Sets an integer control on the device, if possible.
vector
< vdIntegerControl
getValidIntegerControls ()
 Gets all integer controls that "should" work on this device.
string getCardName ()
 Get the card name.
bool setDimensions (unsigned int, unsigned int)
 Attempts to set the device to the specified dimensions.
vector< pair< int,
int > > 
getValidDimensions ()
 Get the dimensions that the device is capable of capturing in.
pair< int, int > getDimensions ()

Static Public Member Functions

static string getIntegerControlString (const vdIntegerControl)
 Get what an integer control represents as a "string".
static vector< string > enumerateDevices ()
 Attempts to enumerate the devices attached to the system.

Public Attributes

sigc::signal< void,
int, string > 
sig_progress

Private Member Functions

void v2_init ()
 Initialize V4L2 devices.
void v1_init ()
 Initialize V4L1 devices.
string v1_paletteName (int)
void setBufferSize ()
 Set the buffer size for frames.
void fmt_VIDEO_PALETTE_RGB24 (vdFrame &)
 Convert the palette to the default format.

Private Attributes

string deviceName
bool live
int fd
bool isV4L2
v4l2_capability v2_capabilities
v4l2_input v2_inputs [MAX_INPUTS]
int inputCount
int currentInput
v4l2_queryctrl brightness
v4l2_queryctrl contrast
v4l2_queryctrl saturation
v4l2_queryctrl hue
video_capability v1_capabilities
video_channel v1_inputs [MAX_INPUTS]
video_picture v1_controls
video_window v1_window
vector< pair< int,
int > > 
capableDimensions
unsigned int bufferSize


Constructor & Destructor Documentation

vc::videoDevice::videoDevice ( string  _deviceName  ) 

vc::videoDevice::~videoDevice (  ) 


Member Function Documentation

void vc::videoDevice::init (  ) 

Initialize the device.

Todo:
Straighten this up, maybe break it up.
Todo:
Get better error strings from ioctl and stuff.
Exceptions:
string Descriptive error string.

void vc::videoDevice::getFrame ( vdFrame frame  ) 

Get a frame from the device.

Todo:
V4L2 Implementation.
Todo:
Memory mapping implementation.
Exceptions:
string If device is not initialized.
string If it is a V4L2 device.
string If camera uses an unsupported format.
Parameters:
frame The vdFrame struct to store into.

Todo:
Timestamp!

Todo:
Set buffer size somewhere else and base it on palette.

Todo:
The rest of these formats...

bool vc::videoDevice::getIntegerControlUsed ( const   vdIntegerControl  ) 

Gets whether the control is used on the device.

Exceptions:
string If device not started.
string If an invalid control is specified.
Parameters:
controlType The type of integer control to check.
Returns:
True if used.

Todo:
Is saturation == colour?

int vc::videoDevice::getIntegerControlValue ( const   vdIntegerControl  ) 

Get the current setting of an integer control, if possible.

Exceptions:
string If device not started.
string If an invalid control is specified.
string If that control is not used on this device.
string If it can't retrieve the value.
Parameters:
controlType The type of integer control to get.
Returns:
The integer control value.

int vc::videoDevice::getIntegerControlMinimum ( const   vdIntegerControl  ) 

Get the minimum setting of an integer control, if possible.

Exceptions:
string If device not started.
string If an invalid control is specified.
string If that control is not used on this device.
string If it can't retrieve the value.
Parameters:
controlType The type of integer control to get.
Returns:
The minimum value.

int vc::videoDevice::getIntegerControlMaximum ( const   vdIntegerControl  ) 

Get the maximum setting of an integer control, if possible.

Exceptions:
string If device not started.
string If an invalid control is specified.
string If that control is not used on this device.
string If it can't retrieve the value.
Parameters:
controlType The type of integer control to get.
Returns:
The maximum value.

int vc::videoDevice::getIntegerControlStep ( const   vdIntegerControl  ) 

Get the minimum effective interval for an integer control, if possible.

Exceptions:
string If device not started.
string If an invalid control is specified.
string If that control is not used on this device.
string If it can't retrieve the value.
Parameters:
controlType The type of integer control to get.
Returns:
The minimum effective interval for the brightness value.

void vc::videoDevice::setIntegerControlValue ( const   vdIntegerControl,
const   int 
)

Sets an integer control on the device, if possible.

Exceptions:
string If device not started.
string If an invalid control is specified.
string If that control is not used on this device.
string If it can't setthe value.
Parameters:
controlType The integer control to set.
value The new brightness value.

string vc::videoDevice::getIntegerControlString ( const   vdIntegerControl  )  [static]

Get what an integer control represents as a "string".

Exceptions:
string On invalid control type.
Returns:
The name of the control.

vector< vdIntegerControl > vc::videoDevice::getValidIntegerControls (  ) 

Gets all integer controls that "should" work on this device.

No promises though.

Exceptions:
string If device not initialized.
string If V4L2 - Not yet supported.
Todo:
Add V4L2 support.
Returns:
A vector of control types.

string vc::videoDevice::getCardName (  ) 

Get the card name.

Exceptions:
string If device is not initialized.
Returns:
The name of the card.

bool vc::videoDevice::setDimensions ( unsigned int  width,
unsigned int  height 
)

Attempts to set the device to the specified dimensions.

Exceptions:
string If V4L2 device.
Parameters:
width The width to set.
height The height to set.
Returns:
True if set exactly to those values. False otherwise.

vector< pair< int, int > > vc::videoDevice::getValidDimensions (  ) 

Get the dimensions that the device is capable of capturing in.

Exceptions:
string If device is not initialized.
Returns:
A vector of pairs of dimensions, pair[0] is width, pair[1] is height.

pair<int,int> vc::videoDevice::getDimensions (  ) 

vector< string > vc::videoDevice::enumerateDevices (  )  [static]

Attempts to enumerate the devices attached to the system.

Checks for devices named "video#" in the /dev directory.

Note:
These are not guaranteed to be legitimate or compatible devices, it's best guess.
Exceptions:
string When it cannot open the /dev directory.
Returns:
A vector of strings containing the absolute path to the device.

void vc::videoDevice::v2_init (  )  [private]

Initialize V4L2 devices.

Exceptions:
string On any initialization error.

Todo:
Can we use V4L2_CAP_VIDEO_OVERLAY ?

Todo:
Handle tuners...

Todo:
Handle input standards specs?

Todo:
Finish this.

void vc::videoDevice::v1_init (  )  [private]

Initialize V4L1 devices.

Exceptions:
string On any failure to initialize.

Todo:
How about VID_TYPE_OVERLAY?
Todo:
Need to handle VID_TYPE_SUBCAPTURE at some point.

Todo:
This doesn't work very well. Not accurate.

Todo:
Split this function up into common chunks. Like the setBufferSize above.

string vc::videoDevice::v1_paletteName ( int  p  )  [private]

void vc::videoDevice::setBufferSize (  )  [private]

Set the buffer size for frames.

This should change on capture size change, capture mode change.

Exceptions:
string If this is a V4L2 device, we don't have an implementation yet.
Todo:
V4L2 implementation.

void vc::videoDevice::fmt_VIDEO_PALETTE_RGB24 ( vdFrame frame  )  [private]

Convert the palette to the default format.

Todo:
Performance check.
Parameters:
frame The frame to operate on. Must be filled correctly.


Member Data Documentation

sigc::signal<void,int,string> vc::videoDevice::sig_progress

string vc::videoDevice::deviceName [private]

bool vc::videoDevice::live [private]

int vc::videoDevice::fd [private]

bool vc::videoDevice::isV4L2 [private]

v4l2_capability vc::videoDevice::v2_capabilities [private]

v4l2_input vc::videoDevice::v2_inputs[MAX_INPUTS] [private]

int vc::videoDevice::inputCount [private]

int vc::videoDevice::currentInput [private]

v4l2_queryctrl vc::videoDevice::brightness [private]

Todo:
Add more controls

v4l2_queryctrl vc::videoDevice::contrast [private]

v4l2_queryctrl vc::videoDevice::saturation [private]

v4l2_queryctrl vc::videoDevice::hue [private]

video_capability vc::videoDevice::v1_capabilities [private]

video_channel vc::videoDevice::v1_inputs[MAX_INPUTS] [private]

video_picture vc::videoDevice::v1_controls [private]

video_window vc::videoDevice::v1_window [private]

vector< pair <int,int> > vc::videoDevice::capableDimensions [private]

unsigned int vc::videoDevice::bufferSize [private]


The documentation for this class was generated from the following files:
Generated on Mon Jul 28 16:14:11 2008 for libvcvideo by  doxygen 1.5.3