#ifndef V4L2ACCESS_H
#define V4L2ACCESS_H

#include "kylinv4l2_global.h"
#include "V4l2Device.h"

class KYLINV4L2_EXPORT V4l2Access
{
public:
    enum IoType
    {
        IOTYPE_READWRITE,
        IOTYPE_MMAP
    };

    V4l2Access(V4l2Device* device);
    virtual ~V4l2Access();

    int getFd()         { return m_device->getFd(); }
    unsigned int getBufferSize()    { return m_device->getBufferSize(); }
    unsigned int getFormat()        { return m_device->getFormat(); }
    unsigned int getWidth()         { return m_device->getWidth(); }
    unsigned int getHeight()        { return m_device->getHeight(); }

    void queryFormat()  { m_device->queryFormat(); }
    int setFormat(unsigned int format, unsigned int width, unsigned int height) { return m_device->setFormat(format, width, height); }

    int setControl(int id, int value)    { return m_device->configureContrl(m_device->getFd(), id, value); }
    int getControl(int id, int *pvalue)    { return m_device->getContrl(m_device->getFd(), id, pvalue); }
    int queryControl(int id, struct v4l2_queryctrl *pvalue)     { return m_device->queryControl(id, pvalue); }

    int isReady()       { return m_device->isReady(); }
    int start()         { return m_device->start(); }
    int stop()          { return m_device->stop(); }

private:
    V4l2Access(const V4l2Access&);
    V4l2Access & operator=(const V4l2Access&);

protected:
    V4l2Device *m_device;
};

#endif // V4L2ACCESS_H
