From c65ffb7cd928894788411a3563aec87e22791ca8 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sat, 11 Jun 2016 23:40:49 +0300 Subject: kmsutils: add VideoDevice --- kms++util/inc/kms++util/videodevice.h | 86 +++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 kms++util/inc/kms++util/videodevice.h (limited to 'kms++util/inc') diff --git a/kms++util/inc/kms++util/videodevice.h b/kms++util/inc/kms++util/videodevice.h new file mode 100644 index 0000000..68e2b01 --- /dev/null +++ b/kms++util/inc/kms++util/videodevice.h @@ -0,0 +1,86 @@ +#pragma once + +#include +#include + +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> 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 get_capture_devices(); + static std::vector 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 m_capture_fbs; + std::vector m_output_fbs; + + VideoStreamer* m_capture_streamer; + VideoStreamer* m_output_streamer; +}; + +class VideoStreamer +{ +public: + enum class StreamerType { + CaptureSingle, + CaptureMulti, + OutputSingle, + OutputMulti, + }; + + VideoStreamer(int fd, StreamerType type); + + std::vector get_ports(); + void set_port(uint32_t index); + + std::vector get_formats(); + void set_format(kms::PixelFormat fmt, 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 m_fbs; +}; -- cgit v1.2.3