diff options
author | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2022-12-14 23:17:31 +0000 |
---|---|---|
committer | Daniel Scally <dan.scally@ideasonboard.com> | 2023-01-16 13:10:15 +0000 |
commit | 3f6aee6a13233e9ffcbb133ab9490aead7e2ced3 (patch) | |
tree | b6aef69b052c7f77286d1842be14f03520af7782 /src | |
parent | 006aa232ac92e3ccde06a3b1536d6e02e8496766 (diff) |
main: Provide a libcamera source
Allow callers to create a libcamera source when available. libcamera
support is optional, so conditionally compile the new options
depending on whether libcamera is available.
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 24 | ||||
-rw-r--r-- | src/meson.build | 2 |
2 files changed, 24 insertions, 2 deletions
@@ -11,9 +11,11 @@ #include <stdio.h> #include <unistd.h> +#include "config.h" #include "configfs.h" #include "events.h" #include "stream.h" +#include "libcamera-source.h" #include "v4l2-source.h" #include "test-source.h" #include "jpg-source.h" @@ -23,6 +25,9 @@ static void usage(const char *argv0) { fprintf(stderr, "Usage: %s [options] <uvc device>\n", argv0); fprintf(stderr, "Available options are\n"); +#ifdef HAVE_LIBCAMERA + fprintf(stderr, " -c <index|id> libcamera camera name\n"); +#endif fprintf(stderr, " -d device V4L2 source device\n"); fprintf(stderr, " -i image MJPEG image\n"); fprintf(stderr, " -s directory directory of slideshow images\n"); @@ -60,6 +65,9 @@ static void sigint_handler(int signal __attribute__((unused))) int main(int argc, char *argv[]) { char *function = NULL; +#ifdef HAVE_LIBCAMERA + char *camera = NULL; +#endif char *cap_device = NULL; char *img_path = NULL; char *slideshow_dir = NULL; @@ -71,8 +79,13 @@ int main(int argc, char *argv[]) int ret = 0; int opt; - while ((opt = getopt(argc, argv, "d:i:s:k:h")) != -1) { + while ((opt = getopt(argc, argv, "c:d:i:s:k:h")) != -1) { switch (opt) { +#ifdef HAVE_LIBCAMERA + case 'c': + camera = optarg; + break; +#endif case 'd': cap_device = optarg; break; @@ -124,6 +137,10 @@ int main(int argc, char *argv[]) /* Create and initialize a video source. */ if (cap_device) src = v4l2_video_source_create(cap_device); +#ifdef HAVE_LIBCAMERA + else if (camera) + src = libcamera_source_create(camera); +#endif else if (img_path) src = jpg_video_source_create(img_path); else if (slideshow_dir) @@ -138,6 +155,11 @@ int main(int argc, char *argv[]) if (cap_device) v4l2_video_source_init(src, &events); +#ifdef HAVE_LIBCAMERA + if (camera) + libcamera_source_init(src, &events); +#endif + /* Create and initialise the stream. */ stream = uvc_stream_new(fc->video); if (stream == NULL) { diff --git a/src/meson.build b/src/meson.build index a457c28..b2fdd9a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -6,5 +6,5 @@ gadget = executable('uvc-gadget', 'main.c', dependencies : [ libuvcgadget, ], - include_directories : includes, + include_directories : [includes, config_includes], install : true) |