diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2023-08-09 12:58:17 +0300 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2023-08-09 14:04:45 +0300 |
commit | 1962f81149e1a1230b7888f1c7da0ac4c0b33c08 (patch) | |
tree | 6ce4a56b139a0ab37d7218b2be3520999833e62a | |
parent | 30c275c5c87b9d4f0bc3b0e0e3175775d3738319 (diff) |
main: Allow to pass different devices and height/width
Bug-AGL: SPEC-4877
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: Ic35267e93a95589be6af0b3d2e0bb9839303b519
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | app/main.cpp | 23 |
2 files changed, 24 insertions, 1 deletions
@@ -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); |