diff options
| author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2022-10-04 10:10:07 +0300 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2022-10-04 11:02:56 +0300 |
| commit | 3e17a921680737c50a818bebf7eded511f4d6029 (patch) | |
| tree | 53d55973d5b32f33881b8b7886ad04cc9872867f | |
| parent | dfa9e526a43086a1b0936b74ec243f23396d5f69 (diff) | |
v4l2: Add VideoStreamer::export_buffer
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
| -rw-r--r-- | py/pyv4l2/pyv4l2.cpp | 3 | ||||
| -rw-r--r-- | v4l2++/inc/v4l2++/videodevice.h | 2 | ||||
| -rw-r--r-- | v4l2++/src/videodevice.cpp | 11 |
3 files changed, 15 insertions, 1 deletions
diff --git a/py/pyv4l2/pyv4l2.cpp b/py/pyv4l2/pyv4l2.cpp index fd3982f..91b8f6c 100644 --- a/py/pyv4l2/pyv4l2.cpp +++ b/py/pyv4l2/pyv4l2.cpp @@ -77,7 +77,8 @@ PYBIND11_MODULE(pyv4l2, m) .def("queue", &VideoStreamer::queue) .def("dequeue", &VideoStreamer::dequeue) .def("stream_on", &VideoStreamer::stream_on) - .def("stream_off", &VideoStreamer::stream_off); + .def("stream_off", &VideoStreamer::stream_off) + .def("export_buffer", &VideoStreamer::export_buffer); py::class_<MetaStreamer>(m, "MetaStreamer") .def_property_readonly("fd", &MetaStreamer::fd) diff --git a/v4l2++/inc/v4l2++/videodevice.h b/v4l2++/inc/v4l2++/videodevice.h index bdb290e..9016a7f 100644 --- a/v4l2++/inc/v4l2++/videodevice.h +++ b/v4l2++/inc/v4l2++/videodevice.h @@ -106,6 +106,8 @@ public: void stream_on(); void stream_off(); + int export_buffer(uint32_t index); + int fd() const { return m_fd; } protected: diff --git a/v4l2++/src/videodevice.cpp b/v4l2++/src/videodevice.cpp index 858b82b..c25e9be 100644 --- a/v4l2++/src/videodevice.cpp +++ b/v4l2++/src/videodevice.cpp @@ -624,7 +624,18 @@ void VideoStreamer::stream_off() FAIL_IF(r, "Failed to disable stream: %d", r); } +int VideoStreamer::export_buffer(uint32_t index) +{ + struct v4l2_exportbuffer expbuf; + + memset(&expbuf, 0, sizeof(expbuf)); + expbuf.type = get_buf_type(m_type); + expbuf.index = index; + int r = ioctl(m_fd, VIDIOC_EXPBUF, &expbuf); + FAIL_IF(r, "VIDIOC_EXPBUF failed: %d", r); + return expbuf.fd; +} |
