V4l2MmapDevice.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* ---------------------------------------------------------------------------
  2. ** This software is in the public domain, furnished "as is", without technical
  3. ** support, and with no warranty, express or implied, as to its usefulness for
  4. ** any purpose.
  5. **
  6. ** V4l2MmapDevice.h
  7. **
  8. ** V4L2 source using mmap API
  9. **
  10. ** -------------------------------------------------------------------------*/
  11. #ifndef V4L2_MMAP_DEVICE
  12. #define V4L2_MMAP_DEVICE
  13. #include "V4l2Device.h"
  14. #define V4L2MMAP_NBBUFFER 10
  15. class V4l2MmapDevice : public V4l2Device
  16. {
  17. protected:
  18. size_t writeInternal(char* buffer, size_t bufferSize);
  19. bool startPartialWrite(void);
  20. size_t writePartialInternal(char*, size_t);
  21. bool endPartialWrite(void);
  22. size_t readInternal(char* buffer, size_t bufferSize);
  23. public:
  24. V4l2MmapDevice(const V4L2DeviceParameters & params, v4l2_buf_type deviceType);
  25. virtual ~V4l2MmapDevice();
  26. virtual bool init(unsigned int mandatoryiCapabilities);
  27. virtual bool isReady() { return ((m_fd != -1)&& (n_buffers != 0)); }
  28. virtual bool start();
  29. virtual bool stop();
  30. protected:
  31. unsigned int n_buffers;
  32. struct buffer
  33. {
  34. void * start;
  35. size_t length;
  36. };
  37. buffer m_buffer[V4L2MMAP_NBBUFFER];
  38. };
  39. #endif