JeVois  1.0
JeVois Smart Embedded Machine Vision Toolkit
jevois::VideoBuf Class Reference

#include <jevois/Core/VideoBuf.H>

A V4L2 video buffer, to be held in a shared_ptr.

Requests an MMAP'ed memory area from the given file descriptor at construction, and unmaps it at destruction. VideoBuf is used to pass MMAP'ed video buffers from Camera and Gadget drivers to application code, via RawImage. The actual memory allocation is performed by the kernel driver. Hence, VideoBuf pixel arrays cannot be moved from one memory location to another.

Definition at line 29 of file VideoBuf.H.

Public Member Functions

 VideoBuf (int const fd, size_t const length, unsigned int offset)
 Construct and allocate MMAP'd memory. More...
 
 ~VideoBuf ()
 Destructor unmaps the memory. More...
 
void sync ()
 Sync the data. More...
 
void * data () const
 Get a pointer to the buffer data. More...
 
size_t length () const
 Get the allocated memory length. More...
 
void setBytesUsed (size_t n)
 Set the number of bytes used, eg, for MJPEG images that application code compressed into the buffer. More...
 
size_t bytesUsed () const
 Get the number of bytes used, valid only for MJPEG images. More...
 

Constructor & Destructor Documentation

jevois::VideoBuf::VideoBuf ( int const  fd,
size_t const  length,
unsigned int  offset 
)

Construct and allocate MMAP'd memory.

Mostly for debugging purposes (supporting VideoDisplay), if fd is -1 then we perform a regular memory allocation instead of mmap.

Definition at line 25 of file VideoBuf.C.

References length(), and PLFATAL.

jevois::VideoBuf::~VideoBuf ( )

Destructor unmaps the memory.

Definition at line 47 of file VideoBuf.C.

References PLERROR.

Member Function Documentation

size_t jevois::VideoBuf::bytesUsed ( ) const

Get the number of bytes used, valid only for MJPEG images.

Definition at line 115 of file VideoBuf.C.

void * jevois::VideoBuf::data ( ) const

Get a pointer to the buffer data.

Definition at line 97 of file VideoBuf.C.

size_t jevois::VideoBuf::length ( ) const

Get the allocated memory length.

Definition at line 103 of file VideoBuf.C.

Referenced by VideoBuf().

void jevois::VideoBuf::setBytesUsed ( size_t  n)

Set the number of bytes used, eg, for MJPEG images that application code compressed into the buffer.

Definition at line 109 of file VideoBuf.C.

void jevois::VideoBuf::sync ( )

Sync the data.

This may be useful in some cases to avoid cache coherency issues between DMA-capable driver and CPU.

Definition at line 77 of file VideoBuf.C.

References LERROR.


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