You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB

8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __VIDEO_INPUT_V4L2_HEADER__
  2. #define __VIDEO_INPUT_V4L2_HEADER__
  3. #include "video_in.h"
  4. #include <fcntl.h>
  5. #include <sys/ioctl.h>
  6. #include <linux/ioctl.h>
  7. #include <linux/videodev2.h>
  8. #include <vector>
  9. class _V4L2_VideoInput: public _VideoInput {
  10. private:
  11. /* Vars */
  12. int m_nFileDescriptor;
  13. int m_nBufferCounts;
  14. char m_pDevicePath[1024];
  15. struct v4l2_capability m_sDeviceCaps;
  16. struct v4l2_format m_sVideoFormat;
  17. struct v4l2_requestbuffers m_sBufRequest;
  18. struct v4l2_buffer m_sBufferInfo;
  19. void* m_pBufferStart;
  20. /* Methods */
  21. bool openDevice( void );
  22. bool openDevice( unsigned char *DevicePath );
  23. bool readDevCaps( void );
  24. bool setVideoFormat( void );
  25. bool assignBuffers( int BuffersCount );
  26. bool allocateBuffers( void );
  27. bool enqueueBuffer( int BufferID );
  28. bool dequeueBuffer( void );
  29. bool activateStreaming( void );
  30. bool deactivateStreaming( void );
  31. bool closeDevice( void );
  32. protected:
  33. void m_fInputProc( void );
  34. public:
  35. _V4L2_VideoInput();
  36. _V4L2_VideoInput( char *DevicePath );
  37. ~_V4L2_VideoInput();
  38. void make10th( char *FileName );
  39. };
  40. //Based on https://jwhsmith.net/2014/12/capturing-a-webcam-stream-using-v4l2/
  41. #endif