From 4d9897c5aa5376f89e0d5ed1534536f680939e0d Mon Sep 17 00:00:00 2001 From: Daniel Scally Date: Tue, 10 Jan 2023 11:58:04 +0000 Subject: lib: Add video_source_type enumeration Add an enum to struct video_source that details the type of source we're dealing with. This will be used to make decisions about buffer allocation and handling in a more explicit way. Use the video_source_type associated with a video_source to decide on the appropriate allocation function and buffer handler at stream on time. This is a more explicit method than relying on the presence of the .alloc_buffers op and allows more flexibility. Reviewed-by: Kieran Bingham Signed-off-by: Daniel Scally --- include/uvcgadget/video-source.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/uvcgadget/video-source.h') diff --git a/include/uvcgadget/video-source.h b/include/uvcgadget/video-source.h index b1a3cf4..f888ce4 100644 --- a/include/uvcgadget/video-source.h +++ b/include/uvcgadget/video-source.h @@ -32,11 +32,24 @@ struct video_source_ops { typedef void(*video_source_buffer_handler_t)(void *, struct video_source *, struct video_buffer *); +/* + * video_source_type - Enumeration of the different kinds of video source + * @VIDEO_SOURCE_DMABUF A source that can share data with the sink via a + * DMA file descriptor. + * @VIDEO_SOURCE_STATIC A source that draws data from an unchanging + * buffer such as a .jpg file + */ +enum video_source_type { + VIDEO_SOURCE_DMABUF, + VIDEO_SOURCE_STATIC, +}; + struct video_source { const struct video_source_ops *ops; struct events *events; video_source_buffer_handler_t handler; void *handler_data; + enum video_source_type type; }; void video_source_set_buffer_handler(struct video_source *src, -- cgit v1.2.3