summaryrefslogtreecommitdiff
path: root/lib/libcamera-source.cpp
diff options
context:
space:
mode:
authorDaniel Scally <dan.scally@ideasonboard.com>2023-01-13 16:27:10 +0000
committerDaniel Scally <dan.scally@ideasonboard.com>2023-01-16 13:10:16 +0000
commitafd7ad5f9dbef7f31162b9a49b9f85c0a309a3a0 (patch)
tree23899ca2c135c2245ef3f6821227bb7bfad8923e /lib/libcamera-source.cpp
parent4d9897c5aa5376f89e0d5ed1534536f680939e0d (diff)
lib/video-source: Add video_source_import_buffers
We need to be able to place encoded data into the sink device's bufs. To facilitate that add a video_source operation that allows the source to import buffers from the sink. Add a .import_buffers() callback so that the libcamera-source can access a sink's buffers. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Diffstat (limited to 'lib/libcamera-source.cpp')
-rw-r--r--lib/libcamera-source.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/libcamera-source.cpp b/lib/libcamera-source.cpp
index 7b4e212..4e22688 100644
--- a/lib/libcamera-source.cpp
+++ b/lib/libcamera-source.cpp
@@ -227,6 +227,17 @@ static int libcamera_source_export_buffers(struct video_source *s,
return 0;
}
+static int libcamera_source_import_buffers(struct video_source *s,
+ struct video_buffer_set *buffers)
+{
+ struct libcamera_source *src = to_libcamera_source(s);
+
+ for (unsigned int i = 0; i < buffers->nbufs; i++)
+ src->buffers.buffers[i].mem = buffers->buffers[i].mem;
+
+ return 0;
+}
+
static int libcamera_source_free_buffers(struct video_source *s)
{
struct libcamera_source *src = to_libcamera_source(s);
@@ -328,6 +339,7 @@ static const struct video_source_ops libcamera_source_ops = {
.set_frame_rate = libcamera_source_set_frame_rate,
.alloc_buffers = libcamera_source_alloc_buffers,
.export_buffers = libcamera_source_export_buffers,
+ .import_buffers = libcamera_source_import_buffers,
.free_buffers = libcamera_source_free_buffers,
.stream_on = libcamera_source_stream_on,
.stream_off = libcamera_source_stream_off,