JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
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, int const dmafd)
 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...
 
int dmaFd () const
 Get the dma_buf fd associated with this buffer, which was given at construction. More...
 

Constructor & Destructor Documentation

◆ VideoBuf()

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

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 27 of file VideoBuf.C.

References length(), and PLFATAL.

◆ ~VideoBuf()

jevois::VideoBuf::~VideoBuf ( )

Destructor unmaps the memory.

Definition at line 49 of file VideoBuf.C.

References PLERROR.

Member Function Documentation

◆ bytesUsed()

size_t jevois::VideoBuf::bytesUsed ( ) const

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

Definition at line 123 of file VideoBuf.C.

◆ data()

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

Get a pointer to the buffer data.

Definition at line 105 of file VideoBuf.C.

◆ dmaFd()

int jevois::VideoBuf::dmaFd ( ) const

Get the dma_buf fd associated with this buffer, which was given at construction.

Definition at line 129 of file VideoBuf.C.

◆ length()

size_t jevois::VideoBuf::length ( ) const

Get the allocated memory length.

Definition at line 111 of file VideoBuf.C.

Referenced by VideoBuf().

◆ setBytesUsed()

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 117 of file VideoBuf.C.

◆ sync()

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 85 of file VideoBuf.C.

References clearcache(), and LERROR.


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