Home | History | Annotate | Download | only in kms++util
      1 #pragma once
      2 
      3 #include <string>
      4 #include <kms++/kms++.h>
      5 
      6 class VideoStreamer;
      7 
      8 class VideoDevice
      9 {
     10 public:
     11 	struct VideoFrameSize
     12 	{
     13 		uint32_t min_w, max_w, step_w;
     14 		uint32_t min_h, max_h, step_h;
     15 	};
     16 
     17 	VideoDevice(const std::string& dev);
     18 	VideoDevice(int fd);
     19 	~VideoDevice();
     20 
     21 	VideoDevice(const VideoDevice& other) = delete;
     22 	VideoDevice& operator=(const VideoDevice& other) = delete;
     23 
     24 	VideoStreamer* get_capture_streamer();
     25 	VideoStreamer* get_output_streamer();
     26 
     27 	std::vector<std::tuple<uint32_t, uint32_t>> get_discrete_frame_sizes(kms::PixelFormat fmt);
     28 	VideoFrameSize get_frame_sizes(kms::PixelFormat fmt);
     29 
     30 	int fd() const { return m_fd; }
     31 	bool has_capture() const { return m_has_capture; }
     32 	bool has_output() const { return m_has_output; }
     33 	bool has_m2m() const { return m_has_m2m; }
     34 
     35 	static std::vector<std::string> get_capture_devices();
     36 	static std::vector<std::string> get_m2m_devices();
     37 
     38 private:
     39 	int m_fd;
     40 
     41 	bool m_has_capture;
     42 	bool m_has_mplane_capture;
     43 
     44 	bool m_has_output;
     45 	bool m_has_mplane_output;
     46 
     47 	bool m_has_m2m;
     48 	bool m_has_mplane_m2m;
     49 
     50 	std::vector<kms::DumbFramebuffer*> m_capture_fbs;
     51 	std::vector<kms::DumbFramebuffer*> m_output_fbs;
     52 
     53 	VideoStreamer* m_capture_streamer;
     54 	VideoStreamer* m_output_streamer;
     55 };
     56 
     57 class VideoStreamer
     58 {
     59 public:
     60 	enum class StreamerType {
     61 		CaptureSingle,
     62 		CaptureMulti,
     63 		OutputSingle,
     64 		OutputMulti,
     65 	};
     66 
     67 	VideoStreamer(int fd, StreamerType type);
     68 
     69 	std::vector<std::string> get_ports();
     70 	void set_port(uint32_t index);
     71 
     72 	std::vector<kms::PixelFormat> get_formats();
     73 	void set_format(kms::PixelFormat fmt, uint32_t width, uint32_t height);
     74 	void set_queue_size(uint32_t queue_size);
     75 	void queue(kms::DumbFramebuffer* fb);
     76 	kms::DumbFramebuffer* dequeue();
     77 	void stream_on();
     78 	void stream_off();
     79 
     80 	int fd() const { return m_fd; }
     81 
     82 private:
     83 	int m_fd;
     84 	StreamerType m_type;
     85 	std::vector<kms::DumbFramebuffer*> m_fbs;
     86 };
     87