From d2b0811d8bd4385397bf092fc42c319313baf8b2 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Tue, 22 Nov 2022 10:54:56 +0000 Subject: main: add default option to use test-source Now that we have test-source which provides video by generating a test pattern in userspace, allow its selection in the command line options. Since it isn't backed by anything, it is set as the default video source if nothing else is specified. Reviewed-by: Daniel Scally Reviewed-by: Kieran Bingham Signed-off-by: Paul Elder Signed-off-by: Kieran Bingham --- src/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 14197eb..606a4ac 100644 --- a/src/main.c +++ b/src/main.c @@ -15,6 +15,7 @@ #include "events.h" #include "stream.h" #include "v4l2-source.h" +#include "test-source.h" static void usage(const char *argv0) { @@ -56,7 +57,7 @@ static void sigint_handler(int signal __attribute__((unused))) int main(int argc, char *argv[]) { char *function = NULL; - char *cap_device = "/dev/video1"; + char *cap_device = NULL; struct uvc_function_config *fc; struct uvc_stream *stream = NULL; struct video_source *src = NULL; @@ -101,13 +102,17 @@ int main(int argc, char *argv[]) signal(SIGINT, sigint_handler); /* Create and initialize a video source. */ - src = v4l2_video_source_create(cap_device); + if (cap_device) + src = v4l2_video_source_create(cap_device); + else + src = test_video_source_create(); if (src == NULL) { ret = 1; goto done; } - v4l2_video_source_init(src, &events); + if (cap_device) + v4l2_video_source_init(src, &events); /* Create and initialise the stream. */ stream = uvc_stream_new(fc->video); -- cgit v1.2.3