From 1962f81149e1a1230b7888f1c7da0ac4c0b33c08 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Wed, 9 Aug 2023 12:58:17 +0300 Subject: main: Allow to pass different devices and height/width Bug-AGL: SPEC-4877 Signed-off-by: Marius Vlad Change-Id: Ic35267e93a95589be6af0b3d2e0bb9839303b519 --- README.md | 2 ++ app/main.cpp | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a7f64b7..bb1db89 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,5 @@ camera-gstreamer Assumes that /dev/video0 is present and is set as a capture device. Use DEFAULT_V4L2_DEVICE environmental variable to change it. +DEFAULT_V4L2_DEVICE_WIDTH and DEFAULT_V4L2_DEVICE_HEIGHT to specify the +dimensions. diff --git a/app/main.cpp b/app/main.cpp index 1acb70f..d4c0671 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -652,6 +652,12 @@ int main(int argc, char *argv[]) struct receiver_data receiver_data = {}; struct display *display; struct window *window; + const char *camera_device = NULL; + const char *width_str = NULL; + const char *height_str = NULL; + int width; + int height; + char pipeline_str[1024]; GError *error = NULL; const char *app_id = "camera-gstreamer"; @@ -667,9 +673,24 @@ int main(int argc, char *argv[]) gargv[0] = strdup(argv[0]); gargv[1] = strdup("--gst-debug-level=2"); + camera_device = getenv("DEFAULT_V4L2_DEVICE"); + if (!camera_device) + camera_device = get_first_camera_device(); + width_str = getenv("DEFAULT_V4L2_DEVICE_WIDTH"); + if (!width_str) + width = WINDOW_WIDTH_SIZE; + else + width = atoi(width_str); + + height_str = getenv("DEFAULT_V4L2_DEVICE_HEIGHT"); + if (!height_str) + height = WINDOW_HEIGHT_SIZE; + else + height = atoi(height_str); + memset(pipeline_str, 0, sizeof(pipeline_str)); snprintf(pipeline_str, sizeof(pipeline_str), "v4l2src device=%s ! video/x-raw,width=%d,height=%d ! waylandsink", - get_first_camera_device(), WINDOW_WIDTH_SIZE, WINDOW_HEIGHT_SIZE); + camera_device, width, height); gst_init(&gargc, &gargv); setbuf(stdout, NULL); -- cgit 1.2.3-korg