Instrument Neutral Distributed Interface INDI  2.0.2
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
INDI::V4L2_Base Class Reference

#include <v4l2_base.h>

Classes

struct  buffer
 

Public Types

enum  io_method { IO_METHOD_READ , IO_METHOD_MMAP , IO_METHOD_USERPTR }
 

Public Member Functions

 V4L2_Base ()
 
virtual ~V4L2_Base ()
 
virtual int connectCam (const char *devpath, char *errmsg, int pixelFormat=-1, int width=-1, int height=-1)
 
virtual void disconnectCam (bool stopcapture)
 
char * getDeviceName ()
 
void setDeviceName (const char *name)
 
bool isLXmodCapable ()
 
void callFrame (void *p)
 
int getFormat ()
 
int getWidth ()
 
int getHeight ()
 
int getBpp ()
 
void setNative (bool value)
 
virtual int setSize (int x, int y)
 
virtual void getMaxMinSize (int &x_max, int &y_max, int &x_min, int &y_min)
 
unsigned char * getY ()
 
unsigned char * getU ()
 
unsigned char * getV ()
 
unsigned char * getMJPEGBuffer (int &size)
 
unsigned char * getRGBBuffer ()
 
float * getLinearY ()
 
void registerCallback (WPF *fp, void *ud)
 
int start_capturing (char *errmsg)
 
int stop_capturing (char *errmsg)
 
void enumerate_ctrl ()
 
void enumerate_menu ()
 
bool enumerate_ext_ctrl ()
 
int queryINTControls (INumberVectorProperty *nvp)
 
bool queryExtControls (INumberVectorProperty *nvp, unsigned int *nnumber, ISwitchVectorProperty **options, unsigned int *noptions, const char *dev, const char *group)
 
void queryControls (INumberVectorProperty *nvp, unsigned int *nnumber, ISwitchVectorProperty **options, unsigned int *noptions, const char *dev, const char *group)
 
int getControl (unsigned int ctrl_id, double *value, char *errmsg)
 
int setINTControl (unsigned int ctrl_id, double new_value, char *errmsg)
 
int setOPTControl (unsigned int ctrl_id, unsigned int new_value, char *errmsg)
 
int query_ctrl (unsigned int ctrl_id, double &ctrl_min, double &ctrl_max, double &ctrl_step, double &ctrl_value, char *errmsg)
 
void getinputs (ISwitchVectorProperty *inputssp)
 
int setinput (unsigned int inputindex, char *errmsg)
 
void getcaptureformats (ISwitchVectorProperty *captureformatssp)
 
int setcaptureformat (unsigned int captureformatindex, char *errmsg)
 
void getcapturesizes (ISwitchVectorProperty *capturesizessp, INumberVectorProperty *capturesizenp)
 
int setcapturesize (unsigned int w, unsigned int h, char *errmsg)
 
void getframerates (ISwitchVectorProperty *frameratessp, INumberVectorProperty *frameratenp)
 
int setcroprect (int x, int y, int w, int h, char *errmsg)
 
struct v4l2_rect getcroprect ()
 
void setColorProcessing (bool quantization, bool colorconvert, bool linearization)
 
void setlxstate (short s)
 
short getlxstate ()
 
bool isstreamactive ()
 
void doDecode (bool)
 

Static Public Member Functions

static std::map< std::string, std::string > enumerate ()
 
static int video_dev_file_select (const dirent *entry)
 
static void newFrame (int fd, void *p)
 

Public Attributes

int(V4L2_Base::* setframerate )(struct v4l2_fract frate, char *errmsg)
 
struct v4l2_fract(V4L2_Base::* getframerate )()
 

Protected Member Functions

int xioctl (int fd, int request, void *arg, char const *const request_str)
 
int ioctl_set_format (struct v4l2_format new_fmt, char *errmsg)
 
int read_frame (char *errsg)
 
int uninit_device (char *errmsg)
 
int open_device (const char *devpath, char *errmsg)
 
int check_device (char *errmsg)
 
int init_device (char *errmsg)
 
int init_mmap (char *errmsg)
 
int errno_exit (const char *s, char *errmsg)
 
void close_device ()
 
void init_userp (unsigned int buffer_size)
 
void init_read (unsigned int buffer_size)
 
void findMinMax ()
 
int stdsetframerate (struct v4l2_fract frate, char *errmsg)
 
int pwcsetframerate (struct v4l2_fract frate, char *errmsg)
 
struct v4l2_fract stdgetframerate ()
 
bool is_compressed () const
 Helper indicating whether current pixel format is compressed or not. More...
 

Protected Attributes

int enumeratedInputs
 
int enumeratedCaptureFormats
 
struct v4l2_capability cap
 
struct v4l2_cropcap cropcap
 
struct v4l2_crop crop
 
struct v4l2_format fmt
 
struct v4l2_input input
 
struct v4l2_buffer buf
 
bool cancrop
 
bool cropset
 
bool cansetrate
 
bool streamedonce
 
bool streamactive
 
short lxstate
 
struct v4l2_queryctrl queryctrl
 
struct v4l2_querymenu querymenu
 
bool has_ext_pix_format
 
WPFcallback
 
void * uptr
 
char dev_name [64]
 
const char * path
 
bool m_Native {false}
 
io_method io
 
int fd
 
struct bufferbuffers
 
unsigned int n_buffers
 
bool reallocate_buffers
 
struct v4l2_fract frameRate
 
int xmax
 
int xmin
 
int ymax
 
int ymin
 
int selectCallBackID
 
V4L2_Decodev4l2_decode
 
V4L2_Decoderdecoder
 
bool dodecode
 
int bpp
 
char deviceName [MAXINDIDEVICE]
 

Friends

class ::V4L2_Driver
 

Detailed Description

Definition at line 58 of file v4l2_base.h.

Member Enumeration Documentation

◆ io_method

Enumerator
IO_METHOD_READ 
IO_METHOD_MMAP 
IO_METHOD_USERPTR 

Definition at line 64 of file v4l2_base.h.

Constructor & Destructor Documentation

◆ V4L2_Base()

INDI::V4L2_Base::V4L2_Base ( )

Definition at line 135 of file v4l2_base.cpp.

◆ ~V4L2_Base()

INDI::V4L2_Base::~V4L2_Base ( )
virtual

Definition at line 185 of file v4l2_base.cpp.

Member Function Documentation

◆ callFrame()

void INDI::V4L2_Base::callFrame ( void *  p)

◆ check_device()

int INDI::V4L2_Base::check_device ( char *  errmsg)
protected

Definition at line 970 of file v4l2_base.cpp.

◆ close_device()

void INDI::V4L2_Base::close_device ( )
protected

Definition at line 1335 of file v4l2_base.cpp.

◆ connectCam()

int INDI::V4L2_Base::connectCam ( const char *  devpath,
char *  errmsg,
int  pixelFormat = -1,
int  width = -1,
int  height = -1 
)
virtual

Definition at line 365 of file v4l2_base.cpp.

◆ disconnectCam()

void INDI::V4L2_Base::disconnectCam ( bool  stopcapture)
virtual

Definition at line 389 of file v4l2_base.cpp.

◆ doDecode()

void INDI::V4L2_Base::doDecode ( bool  d)

Definition at line 360 of file v4l2_base.cpp.

◆ enumerate()

std::map< std::string, std::string > INDI::V4L2_Base::enumerate ( )
static

Find all /dev/videoXXX devices and open them one by one to query the common of the device. We use this later to match against the device label so that we can automatically open the desired device automatically without having to manually set the device port manually. return a map of pairs common_name:device_path (e.g. {"Logitech D9000", "/dev/video3"})

Definition at line 2991 of file v4l2_base.cpp.

◆ enumerate_ctrl()

void INDI::V4L2_Base::enumerate_ctrl ( )

Definition at line 2018 of file v4l2_base.cpp.

◆ enumerate_ext_ctrl()

bool INDI::V4L2_Base::enumerate_ext_ctrl ( )

Definition at line 2709 of file v4l2_base.cpp.

◆ enumerate_menu()

void INDI::V4L2_Base::enumerate_menu ( )

Definition at line 2095 of file v4l2_base.cpp.

◆ errno_exit()

int INDI::V4L2_Base::errno_exit ( const char *  s,
char *  errmsg 
)
protected

Definition at line 349 of file v4l2_base.cpp.

◆ findMinMax()

void INDI::V4L2_Base::findMinMax ( )
protected

Definition at line 1979 of file v4l2_base.cpp.

◆ getBpp()

int INDI::V4L2_Base::getBpp ( )

Definition at line 1825 of file v4l2_base.cpp.

◆ getcaptureformats()

void INDI::V4L2_Base::getcaptureformats ( ISwitchVectorProperty captureformatssp)

Definition at line 1458 of file v4l2_base.cpp.

◆ getcapturesizes()

void INDI::V4L2_Base::getcapturesizes ( ISwitchVectorProperty capturesizessp,
INumberVectorProperty capturesizenp 
)

Definition at line 1533 of file v4l2_base.cpp.

◆ getControl()

int INDI::V4L2_Base::getControl ( unsigned int  ctrl_id,
double *  value,
char *  errmsg 
)

Definition at line 2624 of file v4l2_base.cpp.

◆ getcroprect()

struct v4l2_rect INDI::V4L2_Base::getcroprect ( )

Definition at line 1830 of file v4l2_base.cpp.

◆ getDeviceName()

char * INDI::V4L2_Base::getDeviceName ( )

Definition at line 1895 of file v4l2_base.cpp.

◆ getFormat()

int INDI::V4L2_Base::getFormat ( )

Definition at line 1830 of file v4l2_base.cpp.

◆ getframerates()

void INDI::V4L2_Base::getframerates ( ISwitchVectorProperty frameratessp,
INumberVectorProperty frameratenp 
)

Definition at line 1622 of file v4l2_base.cpp.

◆ getHeight()

int INDI::V4L2_Base::getHeight ( )

Definition at line 1817 of file v4l2_base.cpp.

◆ getinputs()

void INDI::V4L2_Base::getinputs ( ISwitchVectorProperty inputssp)

Definition at line 1386 of file v4l2_base.cpp.

◆ getLinearY()

float * INDI::V4L2_Base::getLinearY ( )

Definition at line 1968 of file v4l2_base.cpp.

◆ getlxstate()

short INDI::V4L2_Base::getlxstate ( )
inline

Definition at line 145 of file v4l2_base.h.

◆ getMaxMinSize()

void INDI::V4L2_Base::getMaxMinSize ( int &  x_max,
int &  y_max,
int &  x_min,
int &  y_min 
)
virtual

Definition at line 1900 of file v4l2_base.cpp.

◆ getMJPEGBuffer()

unsigned char * INDI::V4L2_Base::getMJPEGBuffer ( int &  size)

Definition at line 1958 of file v4l2_base.cpp.

◆ getRGBBuffer()

unsigned char * INDI::V4L2_Base::getRGBBuffer ( )

Definition at line 1963 of file v4l2_base.cpp.

◆ getU()

unsigned char * INDI::V4L2_Base::getU ( )

Definition at line 1948 of file v4l2_base.cpp.

◆ getV()

unsigned char * INDI::V4L2_Base::getV ( )

Definition at line 1953 of file v4l2_base.cpp.

◆ getWidth()

int INDI::V4L2_Base::getWidth ( )

Definition at line 1809 of file v4l2_base.cpp.

◆ getY()

unsigned char * INDI::V4L2_Base::getY ( )

Definition at line 1943 of file v4l2_base.cpp.

◆ init_device()

int INDI::V4L2_Base::init_device ( char *  errmsg)
protected

Definition at line 1310 of file v4l2_base.cpp.

◆ init_mmap()

int INDI::V4L2_Base::init_mmap ( char *  errmsg)
protected

Definition at line 860 of file v4l2_base.cpp.

◆ init_read()

void INDI::V4L2_Base::init_read ( unsigned int  buffer_size)
protected

Definition at line 840 of file v4l2_base.cpp.

◆ init_userp()

void INDI::V4L2_Base::init_userp ( unsigned int  buffer_size)
protected

Definition at line 925 of file v4l2_base.cpp.

◆ ioctl_set_format()

int INDI::V4L2_Base::ioctl_set_format ( struct v4l2_format  new_fmt,
char *  errmsg 
)
protected

Definition at line 289 of file v4l2_base.cpp.

◆ is_compressed()

bool INDI::V4L2_Base::is_compressed ( ) const
protected

Helper indicating whether current pixel format is compressed or not.

This function is used in read_frame to check for corrupted frames.

Returns
true if pixel format is considered compressed by the driver, else false.
Warning
If kernel headers 3.17 or later are available, this function will rely on field 'flags', else will compare the current pixel format against an arbitrary list of known format codes.

Definition at line 201 of file v4l2_base.cpp.

◆ isLXmodCapable()

bool INDI::V4L2_Base::isLXmodCapable ( )

Definition at line 407 of file v4l2_base.cpp.

◆ isstreamactive()

bool INDI::V4L2_Base::isstreamactive ( )
inline

Definition at line 149 of file v4l2_base.h.

◆ newFrame()

void INDI::V4L2_Base::newFrame ( int  fd,
void *  p 
)
static

Definition at line 808 of file v4l2_base.cpp.

◆ open_device()

int INDI::V4L2_Base::open_device ( const char *  devpath,
char *  errmsg 
)
protected

Definition at line 1346 of file v4l2_base.cpp.

◆ pwcsetframerate()

int INDI::V4L2_Base::pwcsetframerate ( struct v4l2_fract  frate,
char *  errmsg 
)
protected

Definition at line 1861 of file v4l2_base.cpp.

◆ query_ctrl()

int INDI::V4L2_Base::query_ctrl ( unsigned int  ctrl_id,
double &  ctrl_min,
double &  ctrl_max,
double &  ctrl_step,
double &  ctrl_value,
char *  errmsg 
)

Definition at line 2133 of file v4l2_base.cpp.

◆ queryControls()

void INDI::V4L2_Base::queryControls ( INumberVectorProperty nvp,
unsigned int *  nnumber,
ISwitchVectorProperty **  options,
unsigned int *  noptions,
const char *  dev,
const char *  group 
)

Definition at line 2179 of file v4l2_base.cpp.

◆ queryExtControls()

bool INDI::V4L2_Base::queryExtControls ( INumberVectorProperty nvp,
unsigned int *  nnumber,
ISwitchVectorProperty **  options,
unsigned int *  noptions,
const char *  dev,
const char *  group 
)

Definition at line 2759 of file v4l2_base.cpp.

◆ queryINTControls()

int INDI::V4L2_Base::queryINTControls ( INumberVectorProperty nvp)

Definition at line 2511 of file v4l2_base.cpp.

◆ read_frame()

int INDI::V4L2_Base::read_frame ( char *  errsg)
protected

Definition at line 469 of file v4l2_base.cpp.

◆ registerCallback()

void INDI::V4L2_Base::registerCallback ( WPF fp,
void *  ud 
)

Definition at line 1973 of file v4l2_base.cpp.

◆ setcaptureformat()

int INDI::V4L2_Base::setcaptureformat ( unsigned int  captureformatindex,
char *  errmsg 
)

Definition at line 1522 of file v4l2_base.cpp.

◆ setcapturesize()

int INDI::V4L2_Base::setcapturesize ( unsigned int  w,
unsigned int  h,
char *  errmsg 
)

Definition at line 1612 of file v4l2_base.cpp.

◆ setColorProcessing()

void INDI::V4L2_Base::setColorProcessing ( bool  quantization,
bool  colorconvert,
bool  linearization 
)

Definition at line 1935 of file v4l2_base.cpp.

◆ setcroprect()

int INDI::V4L2_Base::setcroprect ( int  x,
int  y,
int  w,
int  h,
char *  errmsg 
)

Definition at line 1694 of file v4l2_base.cpp.

◆ setDeviceName()

void INDI::V4L2_Base::setDeviceName ( const char *  name)

Definition at line 2978 of file v4l2_base.cpp.

◆ setinput()

int INDI::V4L2_Base::setinput ( unsigned int  inputindex,
char *  errmsg 
)

Definition at line 1428 of file v4l2_base.cpp.

◆ setINTControl()

int INDI::V4L2_Base::setINTControl ( unsigned int  ctrl_id,
double  new_value,
char *  errmsg 
)

Definition at line 2637 of file v4l2_base.cpp.

◆ setlxstate()

void INDI::V4L2_Base::setlxstate ( short  s)
inline

Definition at line 140 of file v4l2_base.h.

◆ setNative()

void INDI::V4L2_Base::setNative ( bool  value)
inline

Definition at line 91 of file v4l2_base.h.

◆ setOPTControl()

int INDI::V4L2_Base::setOPTControl ( unsigned int  ctrl_id,
unsigned int  new_value,
char *  errmsg 
)

Definition at line 2673 of file v4l2_base.cpp.

◆ setSize()

int INDI::V4L2_Base::setSize ( int  x,
int  y 
)
virtual

Definition at line 1914 of file v4l2_base.cpp.

◆ start_capturing()

int INDI::V4L2_Base::start_capturing ( char *  errmsg)

Definition at line 740 of file v4l2_base.cpp.

◆ stdgetframerate()

struct v4l2_fract INDI::V4L2_Base::stdgetframerate ( )
protected

Definition at line 1861 of file v4l2_base.cpp.

◆ stdsetframerate()

int INDI::V4L2_Base::stdsetframerate ( struct v4l2_fract  frate,
char *  errmsg 
)
protected

Definition at line 1840 of file v4l2_base.cpp.

◆ stop_capturing()

int INDI::V4L2_Base::stop_capturing ( char *  errmsg)

Definition at line 705 of file v4l2_base.cpp.

◆ uninit_device()

int INDI::V4L2_Base::uninit_device ( char *  errmsg)
protected

Definition at line 815 of file v4l2_base.cpp.

◆ video_dev_file_select()

int INDI::V4L2_Base::video_dev_file_select ( const dirent *  entry)
static

Definition at line 3041 of file v4l2_base.cpp.

◆ xioctl()

int INDI::V4L2_Base::xioctl ( int  fd,
int  request,
void *  arg,
char const *const  request_str 
)
protected

Definition at line 245 of file v4l2_base.cpp.

Friends And Related Function Documentation

◆ ::V4L2_Driver

friend class ::V4L2_Driver
friend

Definition at line 228 of file v4l2_base.h.

Member Data Documentation

◆ bpp

int INDI::V4L2_Base::bpp
protected

Definition at line 226 of file v4l2_base.h.

◆ buf

struct v4l2_buffer INDI::V4L2_Base::buf
protected

Definition at line 179 of file v4l2_base.h.

◆ buffers

struct buffer* INDI::V4L2_Base::buffers
protected

Definition at line 210 of file v4l2_base.h.

◆ callback

WPF* INDI::V4L2_Base::callback
protected

Definition at line 203 of file v4l2_base.h.

◆ cancrop

bool INDI::V4L2_Base::cancrop
protected

Definition at line 189 of file v4l2_base.h.

◆ cansetrate

bool INDI::V4L2_Base::cansetrate
protected

Definition at line 191 of file v4l2_base.h.

◆ cap

struct v4l2_capability INDI::V4L2_Base::cap
protected

Definition at line 179 of file v4l2_base.h.

◆ crop

struct v4l2_crop INDI::V4L2_Base::crop
protected

Definition at line 179 of file v4l2_base.h.

◆ cropcap

struct v4l2_cropcap INDI::V4L2_Base::cropcap
protected

Definition at line 179 of file v4l2_base.h.

◆ cropset

bool INDI::V4L2_Base::cropset
protected

Definition at line 190 of file v4l2_base.h.

◆ decoder

V4L2_Decoder* INDI::V4L2_Base::decoder
protected

Definition at line 223 of file v4l2_base.h.

◆ dev_name

char INDI::V4L2_Base::dev_name[64]
protected

Definition at line 205 of file v4l2_base.h.

◆ deviceName

char INDI::V4L2_Base::deviceName[MAXINDIDEVICE]
protected

Definition at line 230 of file v4l2_base.h.

◆ dodecode

bool INDI::V4L2_Base::dodecode
protected

Definition at line 224 of file v4l2_base.h.

◆ enumeratedCaptureFormats

int INDI::V4L2_Base::enumeratedCaptureFormats
protected

Definition at line 175 of file v4l2_base.h.

◆ enumeratedInputs

int INDI::V4L2_Base::enumeratedInputs
protected

Definition at line 174 of file v4l2_base.h.

◆ fd

int INDI::V4L2_Base::fd
protected

Definition at line 209 of file v4l2_base.h.

◆ fmt

struct v4l2_format INDI::V4L2_Base::fmt
protected

Definition at line 179 of file v4l2_base.h.

◆ frameRate

struct v4l2_fract INDI::V4L2_Base::frameRate
protected

Definition at line 212 of file v4l2_base.h.

◆ getframerate

struct v4l2_fract(V4L2_Base::* INDI::V4L2_Base::getframerate) ()

Definition at line 96 of file v4l2_base.h.

◆ has_ext_pix_format

bool INDI::V4L2_Base::has_ext_pix_format
protected

Definition at line 199 of file v4l2_base.h.

◆ input

struct v4l2_input INDI::V4L2_Base::input
protected

Definition at line 179 of file v4l2_base.h.

◆ io

io_method INDI::V4L2_Base::io
protected

Definition at line 208 of file v4l2_base.h.

◆ lxstate

short INDI::V4L2_Base::lxstate
protected

Definition at line 195 of file v4l2_base.h.

◆ m_Native

bool INDI::V4L2_Base::m_Native {false}
protected

Definition at line 207 of file v4l2_base.h.

◆ n_buffers

unsigned int INDI::V4L2_Base::n_buffers
protected

Definition at line 211 of file v4l2_base.h.

◆ path

const char* INDI::V4L2_Base::path
protected

Definition at line 206 of file v4l2_base.h.

◆ queryctrl

struct v4l2_queryctrl INDI::V4L2_Base::queryctrl
protected

Definition at line 195 of file v4l2_base.h.

◆ querymenu

struct v4l2_querymenu INDI::V4L2_Base::querymenu
protected

Definition at line 195 of file v4l2_base.h.

◆ reallocate_buffers

bool INDI::V4L2_Base::reallocate_buffers
protected

Definition at line 212 of file v4l2_base.h.

◆ selectCallBackID

int INDI::V4L2_Base::selectCallBackID
protected

Definition at line 219 of file v4l2_base.h.

◆ setframerate

int(V4L2_Base::* INDI::V4L2_Base::setframerate) (struct v4l2_fract frate, char *errmsg)

Definition at line 96 of file v4l2_base.h.

◆ streamactive

bool INDI::V4L2_Base::streamactive
protected

Definition at line 193 of file v4l2_base.h.

◆ streamedonce

bool INDI::V4L2_Base::streamedonce
protected

Definition at line 192 of file v4l2_base.h.

◆ uptr

void* INDI::V4L2_Base::uptr
protected

Definition at line 204 of file v4l2_base.h.

◆ v4l2_decode

V4L2_Decode* INDI::V4L2_Base::v4l2_decode
protected

Definition at line 222 of file v4l2_base.h.

◆ xmax

int INDI::V4L2_Base::xmax
protected

Definition at line 218 of file v4l2_base.h.

◆ xmin

int INDI::V4L2_Base::xmin
protected

Definition at line 218 of file v4l2_base.h.

◆ ymax

int INDI::V4L2_Base::ymax
protected

Definition at line 218 of file v4l2_base.h.

◆ ymin

int INDI::V4L2_Base::ymin
protected

Definition at line 218 of file v4l2_base.h.


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