diff options
Diffstat (limited to 'kms++util/src/videodevice.cpp')
-rw-r--r-- | kms++util/src/videodevice.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/kms++util/src/videodevice.cpp b/kms++util/src/videodevice.cpp index 0121c7c..9530d60 100644 --- a/kms++util/src/videodevice.cpp +++ b/kms++util/src/videodevice.cpp @@ -32,7 +32,7 @@ static vector<PixelFormat> v4l2_get_formats(int fd, uint32_t buf_type) { vector<PixelFormat> v; - v4l2_fmtdesc desc { }; + v4l2_fmtdesc desc{}; desc.type = buf_type; while (ioctl(fd, VIDIOC_ENUM_FMT, &desc) == 0) { @@ -51,7 +51,7 @@ static void v4l2_set_format(int fd, PixelFormat fmt, uint32_t width, uint32_t he { int r; - v4l2_format v4lfmt { }; + v4l2_format v4lfmt{}; v4lfmt.type = buf_type; r = ioctl(fd, VIDIOC_G_FMT, &v4lfmt); @@ -177,7 +177,7 @@ static void v4l2_set_selection(int fd, uint32_t& left, uint32_t& top, uint32_t& static void v4l2_request_bufs(int fd, uint32_t queue_size, uint32_t buf_type) { - v4l2_requestbuffers v4lreqbuf { }; + v4l2_requestbuffers v4lreqbuf{}; v4lreqbuf.type = buf_type; v4lreqbuf.memory = V4L2_MEMORY_DMABUF; v4lreqbuf.count = queue_size; @@ -188,7 +188,7 @@ static void v4l2_request_bufs(int fd, uint32_t queue_size, uint32_t buf_type) static void v4l2_queue_dmabuf(int fd, uint32_t index, DumbFramebuffer* fb, uint32_t buf_type) { - v4l2_buffer buf { }; + v4l2_buffer buf{}; buf.type = buf_type; buf.memory = V4L2_MEMORY_DMABUF; buf.index = index; @@ -200,7 +200,7 @@ static void v4l2_queue_dmabuf(int fd, uint32_t index, DumbFramebuffer* fb, uint3 if (mplane) { buf.length = pfi.num_planes; - v4l2_plane planes[4] { }; + v4l2_plane planes[4]{}; buf.m.planes = planes; for (unsigned i = 0; i < pfi.num_planes; ++i) { @@ -221,12 +221,12 @@ static void v4l2_queue_dmabuf(int fd, uint32_t index, DumbFramebuffer* fb, uint3 static uint32_t v4l2_dequeue(int fd, uint32_t buf_type) { - v4l2_buffer buf { }; + v4l2_buffer buf{}; buf.type = buf_type; buf.memory = V4L2_MEMORY_DMABUF; // V4L2 crashes if planes are not set - v4l2_plane planes[4] { }; + v4l2_plane planes[4]{}; buf.m.planes = planes; buf.length = 4; @@ -237,11 +237,8 @@ static uint32_t v4l2_dequeue(int fd, uint32_t buf_type) return buf.index; } - - - VideoDevice::VideoDevice(const string& dev) - :VideoDevice(::open(dev.c_str(), O_RDWR | O_NONBLOCK)) + : VideoDevice(::open(dev.c_str(), O_RDWR | O_NONBLOCK)) { } @@ -251,7 +248,7 @@ VideoDevice::VideoDevice(int fd) if (fd < 0) throw runtime_error("bad fd"); - struct v4l2_capability cap = { }; + struct v4l2_capability cap = {}; int r = ioctl(fd, VIDIOC_QUERYCAP, &cap); ASSERT(r == 0); @@ -321,7 +318,7 @@ vector<tuple<uint32_t, uint32_t>> VideoDevice::get_discrete_frame_sizes(PixelFor { vector<tuple<uint32_t, uint32_t>> v; - v4l2_frmsizeenum v4lfrms { }; + v4l2_frmsizeenum v4lfrms{}; v4lfrms.pixel_format = (uint32_t)fmt; int r = ioctl(m_fd, VIDIOC_ENUM_FRAMESIZES, &v4lfrms); @@ -339,7 +336,7 @@ vector<tuple<uint32_t, uint32_t>> VideoDevice::get_discrete_frame_sizes(PixelFor VideoDevice::VideoFrameSize VideoDevice::get_frame_sizes(PixelFormat fmt) { - v4l2_frmsizeenum v4lfrms { }; + v4l2_frmsizeenum v4lfrms{}; v4lfrms.pixel_format = (uint32_t)fmt; int r = ioctl(m_fd, VIDIOC_ENUM_FRAMESIZES, &v4lfrms); @@ -406,11 +403,9 @@ vector<string> VideoDevice::get_m2m_devices() return v; } - VideoStreamer::VideoStreamer(int fd, StreamerType type) : m_fd(fd), m_type(type) { - } std::vector<string> VideoStreamer::get_ports() @@ -419,9 +414,9 @@ std::vector<string> VideoStreamer::get_ports() switch (m_type) { case StreamerType::CaptureSingle: - case StreamerType::CaptureMulti: - { - struct v4l2_input input { }; + case StreamerType::CaptureMulti: { + struct v4l2_input input { + }; while (ioctl(m_fd, VIDIOC_ENUMINPUT, &input) == 0) { v.push_back(string((char*)&input.name)); @@ -432,9 +427,9 @@ std::vector<string> VideoStreamer::get_ports() } case StreamerType::OutputSingle: - case StreamerType::OutputMulti: - { - struct v4l2_output output { }; + case StreamerType::OutputMulti: { + struct v4l2_output output { + }; while (ioctl(m_fd, VIDIOC_ENUMOUTPUT, &output) == 0) { v.push_back(string((char*)&output.name)); |