blob: 474c05b58cef8d842b2a94a59d3062c86938a91e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* v4l2_device.h - V4L2 Device
*/
#ifndef __LIBCAMERA_V4L2_DEVICE_H__
#define __LIBCAMERA_V4L2_DEVICE_H__
#include <string>
#include <linux/videodev2.h>
namespace libcamera {
struct V4L2Capability final : v4l2_capability {
const char *driver() const
{
return reinterpret_cast<const char *>(v4l2_capability::driver);
}
const char *card() const
{
return reinterpret_cast<const char *>(v4l2_capability::card);
}
const char *bus_info() const
{
return reinterpret_cast<const char *>(v4l2_capability::bus_info);
}
bool isCapture() const { return capabilities & V4L2_CAP_VIDEO_CAPTURE; }
bool isOutput() const { return capabilities & V4L2_CAP_VIDEO_OUTPUT; }
bool hasStreaming() const { return capabilities & V4L2_CAP_STREAMING; }
};
class V4L2Device
{
public:
V4L2Device(const std::string &devnode);
V4L2Device(const V4L2Device &) = delete;
~V4L2Device();
void operator=(const V4L2Device &) = delete;
int open();
bool isOpen() const;
void close();
const char *driverName() const { return caps_.driver(); }
const char *deviceName() const { return caps_.card(); }
const char *busName() const { return caps_.bus_info(); }
private:
std::string devnode_;
int fd_;
V4L2Capability caps_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_V4L2_DEVICE_H__ */
|