checking capabilities
git-svn-id: svn://anubis/misc/WebcamTracker@120 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
7d1f710d57
commit
ca070c2d8c
@ -6,19 +6,54 @@
|
||||
#include <sys/ioctl.h> /* ioctl() */
|
||||
#include <libv4lconvert.h>
|
||||
#include <iostream>
|
||||
#include "WebcamTracker.h"
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
int fd = open("/dev/video0", O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
cerr << "bad fd" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
struct v4l2_capability cap;
|
||||
ioctl(fd, VIDIOC_QUERYCAP, &cap);
|
||||
|
||||
close(fd);
|
||||
WebcamTracker("/dev/video0");
|
||||
}
|
||||
|
||||
WebcamTracker::WebcamTracker(const char * device)
|
||||
{
|
||||
m_open = false;
|
||||
m_fd = open(device, O_RDWR);
|
||||
if (m_fd >= 0)
|
||||
{
|
||||
m_open = true;
|
||||
|
||||
struct v4l2_capability cap;
|
||||
ioctl(m_fd, VIDIOC_QUERYCAP, &cap);
|
||||
#define check_cap(x) do { \
|
||||
if (cap.capabilities & (x)) \
|
||||
cout << " cap: " << #x << endl; \
|
||||
} while (0)
|
||||
check_cap(V4L2_CAP_VIDEO_CAPTURE);
|
||||
check_cap(V4L2_CAP_VIDEO_OUTPUT);
|
||||
check_cap(V4L2_CAP_VIDEO_OVERLAY);
|
||||
check_cap(V4L2_CAP_VBI_CAPTURE);
|
||||
check_cap(V4L2_CAP_VBI_OUTPUT);
|
||||
check_cap(V4L2_CAP_SLICED_VBI_CAPTURE);
|
||||
check_cap(V4L2_CAP_SLICED_VBI_OUTPUT);
|
||||
check_cap(V4L2_CAP_RDS_CAPTURE);
|
||||
check_cap(V4L2_CAP_VIDEO_OUTPUT_OVERLAY);
|
||||
check_cap(V4L2_CAP_TUNER);
|
||||
check_cap(V4L2_CAP_AUDIO);
|
||||
check_cap(V4L2_CAP_RADIO);
|
||||
check_cap(V4L2_CAP_READWRITE);
|
||||
check_cap(V4L2_CAP_ASYNCIO);
|
||||
check_cap(V4L2_CAP_STREAMING);
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "Could not open device '" << device << "'" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
WebcamTracker::~WebcamTracker()
|
||||
{
|
||||
if (m_open)
|
||||
{
|
||||
close(m_fd);
|
||||
}
|
||||
}
|
||||
|
19
WebcamTracker.h
Normal file
19
WebcamTracker.h
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h> /* exit() */
|
||||
#include <sys/ioctl.h> /* ioctl() */
|
||||
#include <libv4lconvert.h>
|
||||
#include <iostream>
|
||||
|
||||
class WebcamTracker
|
||||
{
|
||||
public:
|
||||
WebcamTracker(const char * device);
|
||||
~WebcamTracker();
|
||||
|
||||
protected:
|
||||
bool m_open;
|
||||
int m_fd;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user