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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#pragma once
#include <string>
#include <memory>
#include <kms++/kms++.h>
class VideoStreamer;
class VideoDevice
{
public:
struct VideoFrameSize
{
uint32_t min_w, max_w, step_w;
uint32_t min_h, max_h, step_h;
};
VideoDevice(const std::string& dev);
VideoDevice(int fd);
~VideoDevice();
VideoDevice(const VideoDevice& other) = delete;
VideoDevice& operator=(const VideoDevice& other) = delete;
VideoStreamer* get_capture_streamer();
VideoStreamer* get_output_streamer();
std::vector<std::tuple<uint32_t, uint32_t>> get_discrete_frame_sizes(kms::PixelFormat fmt);
VideoFrameSize get_frame_sizes(kms::PixelFormat fmt);
int fd() const { return m_fd; }
bool has_capture() const { return m_has_capture; }
bool has_output() const { return m_has_output; }
bool has_m2m() const { return m_has_m2m; }
static std::vector<std::string> get_capture_devices();
static std::vector<std::string> get_m2m_devices();
private:
int m_fd;
bool m_has_capture;
bool m_has_mplane_capture;
bool m_has_output;
bool m_has_mplane_output;
bool m_has_m2m;
bool m_has_mplane_m2m;
std::vector<kms::DumbFramebuffer*> m_capture_fbs;
std::vector<kms::DumbFramebuffer*> m_output_fbs;
std::unique_ptr<VideoStreamer> m_capture_streamer;
std::unique_ptr<VideoStreamer> m_output_streamer;
};
class VideoStreamer
{
public:
enum class StreamerType {
CaptureSingle,
CaptureMulti,
OutputSingle,
OutputMulti,
};
VideoStreamer(int fd, StreamerType type);
std::vector<std::string> get_ports();
void set_port(uint32_t index);
std::vector<kms::PixelFormat> get_formats();
void set_format(kms::PixelFormat fmt, uint32_t width, uint32_t height);
void get_selection(uint32_t& left, uint32_t& top, uint32_t& width, uint32_t& height);
void set_selection(uint32_t& left, uint32_t& top, uint32_t& width, uint32_t& height);
void set_queue_size(uint32_t queue_size);
void queue(kms::DumbFramebuffer* fb);
kms::DumbFramebuffer* dequeue();
void stream_on();
void stream_off();
int fd() const { return m_fd; }
private:
int m_fd;
StreamerType m_type;
std::vector<kms::DumbFramebuffer*> m_fbs;
};
|