From d71c28eef0607b97ded600868792234af188a164 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 18 Nov 2024 15:09:50 +0100 Subject: [PATCH] vcap,disp/decklink: allow \: in fourcc opts this now allows specifying the IP address including port: uv -d 'decklink:d=DeckLink IP/SDI HD (1):noav=239.255.194.25\:16666' --- src/video_capture/decklink.cpp | 8 +++++++- src/video_display/decklink.cpp | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/video_capture/decklink.cpp b/src/video_capture/decklink.cpp index ef61c1ac6..ccd4f1f43 100644 --- a/src/video_capture/decklink.cpp +++ b/src/video_capture/decklink.cpp @@ -82,6 +82,7 @@ #include "utils/color_out.h" #include "utils/macros.h" #include "utils/math.h" +#include "utils/string.h" // for replace_all, DELDEL, ESCAPED_COLON #include "utils/windows.h" #include "video.h" #include "video_capture.h" @@ -786,10 +787,13 @@ static bool parse_option(struct vidcap_decklink_state *s, const char *opt) } else if (strstr(opt, "keep-settings") == opt) { s->keep_device_defaults = true; } else if ((strchr(opt, '=') != nullptr && strchr(opt, '=') - opt == 4) || strlen(opt) == 4) { + char val[STR_LEN]; + snprintf_ch(val, "%s", strchr(opt, '=') + 1); + replace_all(val, DELDEL, ":"); ret = s ->device_options[( BMDDeckLinkConfigurationID) bmd_read_fourcc(opt)] - .parse(strchr(opt, '=') + 1); + .parse(val); } else { log_msg(LOG_LEVEL_ERROR, MOD_NAME "unknown option in init string: %s\n", opt); return false; @@ -814,6 +818,8 @@ static bool settings_init_key_val(struct vidcap_decklink_state *s, char **save_p static bool settings_init(struct vidcap_decklink_state *s, char *fmt) { + replace_all(fmt, ESCAPED_COLON, DELDEL); // replace all '\:' with 2xDEL + char *tmp; char *save_ptr = NULL; diff --git a/src/video_display/decklink.cpp b/src/video_display/decklink.cpp index e2350f77a..fb991e5b1 100644 --- a/src/video_display/decklink.cpp +++ b/src/video_display/decklink.cpp @@ -1208,6 +1208,7 @@ static bool settings_init(struct state_decklink *s, const char *fmt, char tmp[STR_LEN]; snprintf_ch(tmp, "%s", fmt); strcpy(tmp, fmt); + replace_all(tmp, ESCAPED_COLON, DELDEL); // replace all '\:' with 2xDEL char *save_ptr = nullptr; char *ptr = strtok_r(tmp, ":", &save_ptr); assert(ptr != nullptr); @@ -1312,9 +1313,12 @@ static bool settings_init(struct state_decklink *s, const char *fmt, } else if (strncasecmp(ptr, "targetbuffer=", strlen("targetbuffer=")) == 0) { s->audio_drift_fixer.set_target_buffer(parse_uint32(strchr(ptr, '=') + 1)); } else if ((strchr(ptr, '=') != nullptr && strchr(ptr, '=') - ptr == 4) || strlen(ptr) == 4) { + char val[STR_LEN]; + snprintf_ch(val, "%s", strchr(ptr, '=') + 1); + replace_all(val, DELDEL, ":"); ret &= s->device_options[(BMDDeckLinkConfigurationID) bmd_read_fourcc(ptr)] - .parse(strchr(ptr, '=') + 1); + .parse(val); } else { log_msg(LOG_LEVEL_ERROR, MOD_NAME "unknown option in config string: %s\n", ptr); return false;