]> git.sesse.net Git - nageru/blob - nageru/v4l_output.h
Update v4l2loopback modprobe line.
[nageru] / nageru / v4l_output.h
1 #ifndef _V4L_OUTPUT_H
2 #define _V4L_OUTPUT_H 1
3
4 // Video-only V4L2 output. The intended use-case is output into
5 // v4l2loopback to get into videoconferencing or the likes:
6 //
7 //   sudo apt install v4l2loopback-dkms
8 //   sudo modprobe v4l2loopback video_nr=2 card_label='Nageru loopback' max_width=1280 max_height=720 exclusive_caps=1
9 //   nageru --v4l2-output /dev/video2
10 //
11 // Start Nageru before any readers.
12 //
13 // Unlike DecklinkOutput, this output does not own the master clock;
14 // it is entirely unsynchronized, and runs off of the normal master clock.
15 // It comes in addition to any other output, and is not GUI-controlled.
16
17 #include <stddef.h>
18 #include <stdint.h>
19
20 #include <memory>
21
22 class V4LOutput {
23 public:
24         V4LOutput(const char *device_path, unsigned width, unsigned height);
25         ~V4LOutput();
26
27         // Expects NV12 data.
28         void send_frame(const uint8_t *data);
29
30 private:
31         const unsigned width, height;
32         const size_t image_size_bytes;
33         std::unique_ptr<uint8_t[]> yuv420_buf;
34         int video_fd;
35 };
36
37 #endif  // !defined(_V4L_OUTPUT_H)