Skip to content

Commit c7bf90f

Browse files
committed
decklink fcc opt parse unified + moved to common
1 parent 26794a1 commit c7bf90f

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

src/blackmagic_common.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#include "utils/color_out.h"
6868
#include "utils/debug.h" // for DEBUG_TIMER_*
6969
#include "utils/macros.h"
70+
#include "utils/string.h" // for DELDEL
7071
#include "utils/windows.h"
7172
#include "utils/worker.h"
7273

@@ -1877,6 +1878,24 @@ bmd_unsubscribe_notify(BMDNotificationCallback *notificationCallback)
18771878
notificationCallback->Release();
18781879
}
18791880

1881+
/// parse bmd_option from given arg in format FourCC[=val]
1882+
bool
1883+
bmd_parse_fourcc_arg(
1884+
map<BMDDeckLinkConfigurationID, bmd_option> &device_options,
1885+
const char *arg)
1886+
{
1887+
const char *val = nullptr;
1888+
1889+
char tmp[STR_LEN];
1890+
if (strchr(arg, '=') != nullptr) {
1891+
snprintf_ch(tmp, "%s", strchr(arg, '=') + 1);
1892+
replace_all(tmp, DELDEL, ":");
1893+
val = tmp;
1894+
}
1895+
return device_options[(BMDDeckLinkConfigurationID) bmd_read_fourcc(arg)]
1896+
.parse(val);
1897+
}
1898+
18801899
ADD_TO_PARAM(R10K_FULL_OPT, "* " R10K_FULL_OPT "\n"
18811900
" Do not do conversion from/to limited range on in/out for R10k on BMD devs.\n");
18821901
ADD_TO_PARAM(BMD_NAT_SORT, "* " BMD_NAT_SORT "\n"

src/blackmagic_common.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,5 +201,9 @@ bmd_print_status_subscribe_notify(IDeckLink *deckLink, const char *log_prefix,
201201
bool capture);
202202
void bmd_unsubscribe_notify(BMDNotificationCallback *notificationCallback);
203203

204+
bool bmd_parse_fourcc_arg(
205+
std::map<BMDDeckLinkConfigurationID, bmd_option> &device_options,
206+
const char *arg);
207+
204208
#endif // defined BLACKMAGIC_COMMON_HPP
205209

src/video_capture/decklink.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -791,17 +791,7 @@ static bool parse_option(struct vidcap_decklink_state *s, const char *opt)
791791
} else if (strstr(opt, "keep-settings") == opt) {
792792
s->keep_device_defaults = true;
793793
} else if ((strchr(opt, '=') != nullptr && strchr(opt, '=') - opt == 4) || strlen(opt) == 4) {
794-
char *val = nullptr;
795-
char tmp[STR_LEN];
796-
if (strchr(opt, '=') != nullptr) {
797-
snprintf_ch(tmp, "%s", strchr(opt, '=') + 1);
798-
replace_all(tmp, DELDEL, ":");
799-
val = tmp;
800-
}
801-
ret = s
802-
->device_options[(
803-
BMDDeckLinkConfigurationID) bmd_read_fourcc(opt)]
804-
.parse(val);
794+
ret = bmd_parse_fourcc_arg(s->device_options, opt);
805795
} else {
806796
log_msg(LOG_LEVEL_ERROR, MOD_NAME "unknown option in init string: %s\n", opt);
807797
return false;

src/video_display/decklink.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,16 +1328,7 @@ static bool settings_init(struct state_decklink *s, const char *fmt,
13281328
} else if (strncasecmp(ptr, "targetbuffer=", strlen("targetbuffer=")) == 0) {
13291329
s->audio_drift_fixer.set_target_buffer(parse_uint32(strchr(ptr, '=') + 1));
13301330
} else if ((strchr(ptr, '=') != nullptr && strchr(ptr, '=') - ptr == 4) || strlen(ptr) == 4) {
1331-
char *val = nullptr;
1332-
char tmp[STR_LEN];
1333-
if (strchr(ptr, '=') != nullptr) {
1334-
snprintf_ch(tmp, "%s", strchr(ptr, '=') + 1);
1335-
replace_all(tmp, DELDEL, ":");
1336-
val = tmp;
1337-
}
1338-
ret &= s->device_options[(BMDDeckLinkConfigurationID)
1339-
bmd_read_fourcc(ptr)]
1340-
.parse(val);
1331+
ret &= bmd_parse_fourcc_arg(s->device_options, ptr);
13411332
} else {
13421333
log_msg(LOG_LEVEL_ERROR, MOD_NAME "unknown option in config string: %s\n", ptr);
13431334
return false;

0 commit comments

Comments
 (0)