From 29ff9edaec72098f1d9e0a1f5bb18c1f6fdfdde4 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Tue, 22 Nov 2022 15:41:50 +0000 Subject: main: add support for jpg_source Add facilities in main() to allow selection and usage of jpg_source. Reviewed-by: Kieran Bingham Reviewed-by: Daniel Scally Signed-off-by: Paul Elder Signed-off-by: Kieran Bingham --- src/main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 606a4ac..c2d59f8 100644 --- a/src/main.c +++ b/src/main.c @@ -16,6 +16,7 @@ #include "stream.h" #include "v4l2-source.h" #include "test-source.h" +#include "jpg-source.h" static void usage(const char *argv0) { @@ -58,6 +59,7 @@ int main(int argc, char *argv[]) { char *function = NULL; char *cap_device = NULL; + char *img_path = NULL; struct uvc_function_config *fc; struct uvc_stream *stream = NULL; struct video_source *src = NULL; @@ -65,12 +67,16 @@ int main(int argc, char *argv[]) int ret = 0; int opt; - while ((opt = getopt(argc, argv, "c:h")) != -1) { + while ((opt = getopt(argc, argv, "c:i:h")) != -1) { switch (opt) { case 'c': cap_device = optarg; break; + case 'i': + img_path = optarg; + break; + case 'h': usage(argv[0]); return 0; @@ -91,6 +97,12 @@ int main(int argc, char *argv[]) return 1; } + if (cap_device != NULL && img_path != NULL) { + printf("Both capture device and still image specified\n"); + printf("Please specify only one\n"); + return 1; + } + /* * Create the events handler. Register a signal handler for SIGINT, * received when the user presses CTRL-C. This will allow the main loop @@ -104,6 +116,8 @@ int main(int argc, char *argv[]) /* Create and initialize a video source. */ if (cap_device) src = v4l2_video_source_create(cap_device); + else if (img_path) + src = jpg_video_source_create(img_path); else src = test_video_source_create(); if (src == NULL) { -- cgit v1.2.3