diff options
-rw-r--r-- | include/uvcgadget/video-source.h | 4 | ||||
-rw-r--r-- | lib/libcamera-source.cpp | 12 | ||||
-rw-r--r-- | lib/video-source.c | 6 |
3 files changed, 22 insertions, 0 deletions
diff --git a/include/uvcgadget/video-source.h b/include/uvcgadget/video-source.h index f888ce4..61aeaf7 100644 --- a/include/uvcgadget/video-source.h +++ b/include/uvcgadget/video-source.h @@ -22,6 +22,8 @@ struct video_source_ops { int(*alloc_buffers)(struct video_source *src, unsigned int nbufs); int(*export_buffers)(struct video_source *src, struct video_buffer_set **buffers); + int(*import_buffers)(struct video_source *src, + struct video_buffer_set *buffers); int(*free_buffers)(struct video_source *src); int(*stream_on)(struct video_source *src); int(*stream_off)(struct video_source *src); @@ -62,6 +64,8 @@ int video_source_set_frame_rate(struct video_source *src, unsigned int fps); int video_source_alloc_buffers(struct video_source *src, unsigned int nbufs); int video_source_export_buffers(struct video_source *src, struct video_buffer_set **buffers); +int video_source_import_buffers(struct video_source *src, + struct video_buffer_set *buffers); int video_source_free_buffers(struct video_source *src); int video_source_stream_on(struct video_source *src); int video_source_stream_off(struct video_source *src); 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, diff --git a/lib/video-source.c b/lib/video-source.c index 17f008a..78020f2 100644 --- a/lib/video-source.c +++ b/lib/video-source.c @@ -45,6 +45,12 @@ int video_source_export_buffers(struct video_source *src, return src->ops->export_buffers(src, buffers); } +int video_source_import_buffers(struct video_source *src, + struct video_buffer_set *buffers) +{ + return src->ops->import_buffers(src, buffers); +} + int video_source_free_buffers(struct video_source *src) { return src->ops->free_buffers(src); |