Skip to content

Commit 116096b

Browse files
committed
vdisp/decklink: allow setting video connection
Usually not needed but needed when needing Composite output instead of Component, because it is using the same wire as Y of component.
1 parent 37bd9d5 commit 116096b

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

src/blackmagic_common.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ static const struct {
606606
BMDFCC(bmdDeckLinkConfigSMPTELevelAOutput),
607607
BMDFCC(bmdDeckLinkConfigVideoInputConnection),
608608
BMDFCC(bmdDeckLinkConfigVideoInputConversionMode),
609+
BMDFCC(bmdDeckLinkConfigVideoOutputConnection),
609610
BMDFCC(bmdDeckLinkConfigVideoOutputConversionMode),
610611
BMDFCC(bmdDeckLinkConfigVideoOutputIdleOperation),
611612
};
@@ -939,8 +940,12 @@ bool bmd_option::device_write(IDeckLinkConfiguration *deckLinkConfiguration, BMD
939940
return true;
940941
}
941942
ostringstream value_oss;
942-
if (opt == bmdDeckLinkConfigVideoInputConnection && get_connection_string_map().find((BMDVideoConnection) get_int()) != get_connection_string_map().end()) {
943-
value_oss << get_connection_string_map().at((BMDVideoConnection) get_int());
943+
if ((opt == bmdDeckLinkConfigVideoInputConnection ||
944+
opt == bmdDeckLinkConfigVideoOutputConnection) &&
945+
get_connection_string_map().find((BMDVideoConnection) get_int()) !=
946+
get_connection_string_map().end()) {
947+
value_oss << get_connection_string_map().at(
948+
(BMDVideoConnection) get_int());
944949
} else {
945950
value_oss << *this;
946951
}
@@ -1298,6 +1303,17 @@ print_bmd_connections(IDeckLinkProfileAttributes *deckLinkAttributes,
12981303
col() << "\n";
12991304
}
13001305

1306+
BMDVideoConnection
1307+
bmd_get_connection_by_name(const char *connection)
1308+
{
1309+
for (auto const &it : get_connection_string_map()) {
1310+
if (strcasecmp(connection, it.second.c_str()) == 0) {
1311+
return it.first;
1312+
}
1313+
}
1314+
return bmdVideoConnectionUnspecified;
1315+
}
1316+
13011317
/* ____ _ _ _ _ ____ _ _
13021318
* | _ \ ___ ___| | _| | (_)_ __ | | __/ ___|| |_ __ _| |_ _ _ ___
13031319
* | | | |/ _ \/ __| |/ / | | | '_ \| |/ /\___ \| __/ _` | __| | | / __|

src/blackmagic_common.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ void print_bmd_attribute(IDeckLinkProfileAttributes *deckLinkAttributes,
181181
void print_bmd_connections(IDeckLinkProfileAttributes *deckLinkAttributes,
182182
BMDDeckLinkAttributeID id,
183183
const char *module_prefix);
184+
BMDVideoConnection bmd_get_connection_by_name(const char *connection);
184185

185186
/**
186187
* @details parameters:

src/video_capture/decklink.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -732,15 +732,13 @@ static bool parse_option(struct vidcap_decklink_state *s, const char *opt)
732732
}
733733
} else if (IS_KEY_PREFIX(opt, "connection")) {
734734
const char *connection = strchr(opt, '=') + 1;
735-
for (auto const & it : get_connection_string_map()) {
736-
if (strcasecmp(connection, it.second.c_str()) == 0) {
737-
s->device_options[bmdDeckLinkConfigVideoInputConnection] = bmd_option((int64_t) it.first);
738-
}
739-
}
740-
if (s->device_options.find(bmdDeckLinkConfigVideoInputConnection) == s->device_options.end()) {
741-
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Unrecognized connection %s.\n", connection);
735+
auto bmd_conn = bmd_get_connection_by_name(connection);
736+
if (bmd_conn == bmdVideoConnectionUnspecified) {
737+
MSG(ERROR, "Unrecognized connection %s.\n", connection);
742738
return false;
743739
}
740+
s->device_options[bmdDeckLinkConfigVideoInputConnection] =
741+
bmd_option((int64_t) bmd_conn);
744742
} else if(strncasecmp(opt, "audio_level=",
745743
strlen("audio_level=")) == 0) {
746744
s->device_options[bmdDeckLinkConfigAnalogAudioConsumerLevels] =

src/video_display/decklink.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ show_help(bool full, const char *query_prop_fcc = nullptr)
618618
col() << SBOLD("\tUse1080PsF[=true|false|keep]") << " flag sets use of PsF on output instead of progressive (default is false)\n";
619619
col() << SBOLD("\tprofile=<P>") << "\tuse desired device profile:\n";
620620
print_bmd_device_profiles("\t\t");
621+
col() << SBOLD("\tconnection=<conn>") << " set output video connection (usually unneeded)\n";
621622
col() << SBOLD("\tmaxresample=<N>") << " maximum amount the resample delta can be when scaling is applied. Measured in Hz\n";
622623
col() << SBOLD("\tminresample=<N>") << " minimum amount the resample delta can be when scaling is applied. Measured in Hz\n";
623624
col() << SBOLD("\ttargetbuffer=<N>") << " target amount of samples to have in the buffer (per channel)\n";
@@ -1302,6 +1303,17 @@ static bool settings_init(struct state_decklink *s, const char *fmt,
13021303
return false;
13031304
}
13041305
}
1306+
} else if (IS_KEY_PREFIX(ptr, "connection")) {
1307+
const char *connection = strchr(ptr, '=') + 1;
1308+
auto bmd_conn = bmd_get_connection_by_name(connection);
1309+
if (bmd_conn == bmdVideoConnectionUnspecified) {
1310+
MSG(ERROR, "Unrecognized connection %s.\n",
1311+
connection);
1312+
return false;
1313+
}
1314+
s->device_options
1315+
[bmdDeckLinkConfigVideoOutputConnection] =
1316+
bmd_option((int64_t) bmd_conn);
13051317
} else if (strstr(ptr, "keep-settings") == ptr) {
13061318
s->keep_device_defaults = true;
13071319
} else if (strstr(ptr, "drift_fix") == ptr) {

0 commit comments

Comments
 (0)