OpenVideo Documentation

   Main Page       Modules       Class Hierarchy       Alphabetical List       Compound List       File List       Compound Members       Related Pages   

openvideo::V4L2Src Class Reference
[Node Classes]

A source for grabbing video with v4l2 driver. More...

#include <V4L2Src.h>

Inherits openvideo::Node.

List of all members.

Public Types

enum  IOMode { IO_METHOD_READ, IO_METHOD_MMAP, IO_METHOD_USERPTR }

Public Member Functions

 V4L2Src ()
 ~V4L2Src ()
virtual void initPixelFormats ()
virtual bool setParameter (std::string key, std::string value)
virtual void init ()
virtual void start ()
virtual void process ()
virtual void postProcess ()

Protected Attributes

char videoDevice [40]
int videoWidth
int videoHeight
int fps
PIXEL_FORMAT pixelFormat

Private Member Functions

bool openDevice ()
bool initDevice ()
bool initIORead (unsigned int bufferSize)
bool initIOMMap ()
bool initIOUserp (unsigned int bufferSize)
void closeDevice ()
void processImage (const void *p)
void stop ()
int xioctl (int fd, int request, void *arg)
void setFrameRate (int fps)

Private Attributes

int videoPixelFormat
int videoFd
int ioMode
bufferbuffers
int nBuffers
bool initialized
ConverterYV12 converter

Classes

struct  buffer
 A buffer for storing the video data. More...


Detailed Description

A source for grabbing video with v4l2 driver.

This node can grab video from V4L2 cards (bt878 capture cards). The node takes the following parameters (default values in parentheses): width: Width of capture frame (640). height: Height of capture frame (480). device: The device to capture from (/dev/video0) format: The pixel format to pass on to downstream nodes (R8G8B8X8).

Definition at line 66 of file V4L2Src.h.


Member Enumeration Documentation

enum openvideo::V4L2Src::IOMode
 

Specify the capture mode.

Enumeration values:
IO_METHOD_READ 
IO_METHOD_MMAP 
IO_METHOD_USERPTR 

Definition at line 76 of file V4L2Src.h.


Constructor & Destructor Documentation

openvideo::V4L2Src::V4L2Src  ) 
 

Definition at line 99 of file V4L2Src.cxx.

References openvideo::Node::state, and videoDevice.

openvideo::V4L2Src::~V4L2Src  ) 
 

Definition at line 110 of file V4L2Src.cxx.

References openvideo::Node::state, and openvideo::State::unlockAllBuffers().


Member Function Documentation

void openvideo::V4L2Src::closeDevice  )  [private]
 

Definition at line 653 of file V4L2Src.cxx.

References buffers, IO_METHOD_MMAP, IO_METHOD_READ, IO_METHOD_USERPTR, ioMode, nBuffers, and videoFd.

Referenced by openDevice(), and stop().

void openvideo::V4L2Src::init  )  [virtual]
 

Is called once before the (process)traversal starts.

Init should be used to implement any initializations a specific node needs.

Reimplemented from openvideo::Node.

Definition at line 117 of file V4L2Src.cxx.

References openvideo::State::clear(), openvideo::State::format, fps, openvideo::Manager::getInstance(), openvideo::State::height, initDevice(), initialized, openDevice(), pixelFormat, setFrameRate(), openvideo::Node::state, videoHeight, videoWidth, and openvideo::State::width.

bool openvideo::V4L2Src::initDevice  )  [private]
 

Definition at line 437 of file V4L2Src.cxx.

References initIOMMap(), initIORead(), initIOUserp(), IO_METHOD_MMAP, IO_METHOD_READ, IO_METHOD_USERPTR, ioMode, videoDevice, videoFd, videoHeight, videoWidth, and xioctl().

Referenced by init().

bool openvideo::V4L2Src::initIOMMap  )  [private]
 

initialization for mem-maping

Definition at line 560 of file V4L2Src.cxx.

References buffers, openvideo::V4L2Src::buffer::length, nBuffers, openvideo::V4L2Src::buffer::start, videoDevice, videoFd, and xioctl().

Referenced by initDevice().

bool openvideo::V4L2Src::initIORead unsigned int  bufferSize  )  [private]
 

initialization for normal i/o reading

Definition at line 541 of file V4L2Src.cxx.

References buffers, and start().

Referenced by initDevice().

bool openvideo::V4L2Src::initIOUserp unsigned int  bufferSize  )  [private]
 

initialization for user pointer i/o

Definition at line 617 of file V4L2Src.cxx.

References buffers, nBuffers, start(), videoDevice, videoFd, and xioctl().

Referenced by initDevice().

void openvideo::V4L2Src::initPixelFormats  )  [virtual]
 

return value = the number of supported input formats.

the formats are stored in 'pixelFormats'.

Implements openvideo::Node.

Definition at line 153 of file V4L2Src.cxx.

References openvideo::FORMAT_R8G8B8X8, and openvideo::Node::pixelFormats.

bool openvideo::V4L2Src::openDevice  )  [private]
 

Definition at line 405 of file V4L2Src.cxx.

References closeDevice(), videoDevice, and videoFd.

Referenced by init().

void openvideo::V4L2Src::postProcess  )  [virtual]
 

releases the videoframe (which was previously locked by the process fucntion.

Reimplemented from openvideo::Node.

Definition at line 348 of file V4L2Src.cxx.

void openvideo::V4L2Src::process  )  [virtual]
 

Updates the video frame at its context object.

Reimplemented from openvideo::Node.

Definition at line 219 of file V4L2Src.cxx.

References buffers, openvideo::Manager::getInstance(), initialized, IO_METHOD_MMAP, IO_METHOD_READ, IO_METHOD_USERPTR, ioMode, nBuffers, processImage(), openvideo::V4L2Src::buffer::start, start(), videoFd, and xioctl().

void openvideo::V4L2Src::processImage const void *  p  )  [private]
 

Definition at line 329 of file V4L2Src.cxx.

References converter, openvideo::ConverterYV12::convertToRGB32(), openvideo::State::findFreeBuffer(), openvideo::Manager::getInstance(), openvideo::Buffer::getPixels(), openvideo::V4L2SrcBuffer::incUpdateCounter(), openvideo::Node::state, videoHeight, and videoWidth.

Referenced by process().

void openvideo::V4L2Src::setFrameRate int  fps  )  [private]
 

Allow setting the frame rate (only possible with V4L.

Definition at line 721 of file V4L2Src.cxx.

References videoFd.

Referenced by init().

bool openvideo::V4L2Src::setParameter std::string  key,
std::string  value
[virtual]
 

Sets all relevant parameters.

Reimplemented from openvideo::Node.

Definition at line 353 of file V4L2Src.cxx.

References openvideo::FORMAT_R8G8B8X8, openvideo::PixelFormat::FormatToString(), fps, openvideo::Manager::getInstance(), pixelFormat, openvideo::Node::setParameter(), openvideo::PixelFormat::StringToFormat(), videoHeight, and videoWidth.

void openvideo::V4L2Src::start  )  [virtual]
 

This function calls intializes the videowrapper lib.

it then opens and starts the video stream. Finally it creates a new context where it puts the video specific data on.

Reimplemented from openvideo::Node.

Definition at line 158 of file V4L2Src.cxx.

References buffers, openvideo::Manager::getInstance(), IO_METHOD_MMAP, IO_METHOD_READ, IO_METHOD_USERPTR, ioMode, openvideo::V4L2Src::buffer::length, nBuffers, openvideo::V4L2Src::buffer::start, videoFd, and xioctl().

Referenced by initIORead(), initIOUserp(), and process().

void openvideo::V4L2Src::stop  )  [private, virtual]
 

Is called after the (process)traversal finishes.

Stop should be called to clean up any node specific data.

Reimplemented from openvideo::Node.

Definition at line 686 of file V4L2Src.cxx.

References closeDevice(), initialized, IO_METHOD_MMAP, IO_METHOD_READ, IO_METHOD_USERPTR, ioMode, videoFd, and xioctl().

int openvideo::V4L2Src::xioctl int  fd,
int  request,
void *  arg
[private]
 

Wrapper for making system ioctl call.

Definition at line 710 of file V4L2Src.cxx.

Referenced by initDevice(), initIOMMap(), initIOUserp(), process(), start(), and stop().


Member Data Documentation

struct buffer* openvideo::V4L2Src::buffers [private]
 

Buffers for storing the video data.

Definition at line 181 of file V4L2Src.h.

Referenced by closeDevice(), initIOMMap(), initIORead(), initIOUserp(), process(), and start().

ConverterYV12 openvideo::V4L2Src::converter [private]
 

Image converter between YUV420 -> RGB32, by Daniel Wagner.

Definition at line 190 of file V4L2Src.h.

Referenced by processImage().

int openvideo::V4L2Src::fps [protected]
 

Frames per second (requires v4l.

Definition at line 139 of file V4L2Src.h.

Referenced by init(), and setParameter().

bool openvideo::V4L2Src::initialized [private]
 

Indicates if the driver can be initialized.

Definition at line 187 of file V4L2Src.h.

Referenced by init(), process(), and stop().

int openvideo::V4L2Src::ioMode [private]
 

I/O mode.

Definition at line 178 of file V4L2Src.h.

Referenced by closeDevice(), initDevice(), process(), start(), and stop().

int openvideo::V4L2Src::nBuffers [private]
 

Counter for buffers.

Definition at line 184 of file V4L2Src.h.

Referenced by closeDevice(), initIOMMap(), initIOUserp(), process(), and start().

PIXEL_FORMAT openvideo::V4L2Src::pixelFormat [protected]
 

Holds the pixel format used.

Definition at line 142 of file V4L2Src.h.

Referenced by init(), and setParameter().

char openvideo::V4L2Src::videoDevice[40] [protected]
 

Video device.

Definition at line 130 of file V4L2Src.h.

Referenced by initDevice(), initIOMMap(), initIOUserp(), openDevice(), and V4L2Src().

int openvideo::V4L2Src::videoFd [private]
 

Video stream descriptor.

Definition at line 175 of file V4L2Src.h.

Referenced by closeDevice(), initDevice(), initIOMMap(), initIOUserp(), openDevice(), process(), setFrameRate(), start(), and stop().

int openvideo::V4L2Src::videoHeight [protected]
 

Height of video frame.

Definition at line 136 of file V4L2Src.h.

Referenced by init(), initDevice(), processImage(), and setParameter().

int openvideo::V4L2Src::videoPixelFormat [private]
 

Defines the v4l2 pixel format (Used internally).

Definition at line 172 of file V4L2Src.h.

int openvideo::V4L2Src::videoWidth [protected]
 

Width of video frame.

Definition at line 133 of file V4L2Src.h.

Referenced by init(), initDevice(), processImage(), and setParameter().


The documentation for this class was generated from the following files:
 This page was generated at Wed May 31 13:04:18 2006 for OpenVideo by Doxygen.
 If you have any comments, please send a message to schmalstieg@icg.tu-graz.ac.at.
www.studierstube.org