Skip to content

Commit

Permalink
vdisp/decklink: allow setting video connection
Browse files Browse the repository at this point in the history
Usually not needed but needed when needing Composite output instead of
Component, because it is using the same wire as Y of component.
  • Loading branch information
MartinPulec committed Nov 27, 2024
1 parent 37bd9d5 commit 116096b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
20 changes: 18 additions & 2 deletions src/blackmagic_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ static const struct {
BMDFCC(bmdDeckLinkConfigSMPTELevelAOutput),
BMDFCC(bmdDeckLinkConfigVideoInputConnection),
BMDFCC(bmdDeckLinkConfigVideoInputConversionMode),
BMDFCC(bmdDeckLinkConfigVideoOutputConnection),
BMDFCC(bmdDeckLinkConfigVideoOutputConversionMode),
BMDFCC(bmdDeckLinkConfigVideoOutputIdleOperation),
};
Expand Down Expand Up @@ -939,8 +940,12 @@ bool bmd_option::device_write(IDeckLinkConfiguration *deckLinkConfiguration, BMD
return true;
}
ostringstream value_oss;
if (opt == bmdDeckLinkConfigVideoInputConnection && get_connection_string_map().find((BMDVideoConnection) get_int()) != get_connection_string_map().end()) {
value_oss << get_connection_string_map().at((BMDVideoConnection) get_int());
if ((opt == bmdDeckLinkConfigVideoInputConnection ||
opt == bmdDeckLinkConfigVideoOutputConnection) &&
get_connection_string_map().find((BMDVideoConnection) get_int()) !=
get_connection_string_map().end()) {
value_oss << get_connection_string_map().at(
(BMDVideoConnection) get_int());
} else {
value_oss << *this;
}
Expand Down Expand Up @@ -1298,6 +1303,17 @@ print_bmd_connections(IDeckLinkProfileAttributes *deckLinkAttributes,
col() << "\n";
}

BMDVideoConnection
bmd_get_connection_by_name(const char *connection)
{
for (auto const &it : get_connection_string_map()) {
if (strcasecmp(connection, it.second.c_str()) == 0) {
return it.first;
}
}
return bmdVideoConnectionUnspecified;
}

/* ____ _ _ _ _ ____ _ _
* | _ \ ___ ___| | _| | (_)_ __ | | __/ ___|| |_ __ _| |_ _ _ ___
* | | | |/ _ \/ __| |/ / | | | '_ \| |/ /\___ \| __/ _` | __| | | / __|
Expand Down
1 change: 1 addition & 0 deletions src/blackmagic_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ void print_bmd_attribute(IDeckLinkProfileAttributes *deckLinkAttributes,
void print_bmd_connections(IDeckLinkProfileAttributes *deckLinkAttributes,
BMDDeckLinkAttributeID id,
const char *module_prefix);
BMDVideoConnection bmd_get_connection_by_name(const char *connection);

/**
* @details parameters:
Expand Down
12 changes: 5 additions & 7 deletions src/video_capture/decklink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,15 +732,13 @@ static bool parse_option(struct vidcap_decklink_state *s, const char *opt)
}
} else if (IS_KEY_PREFIX(opt, "connection")) {
const char *connection = strchr(opt, '=') + 1;
for (auto const & it : get_connection_string_map()) {
if (strcasecmp(connection, it.second.c_str()) == 0) {
s->device_options[bmdDeckLinkConfigVideoInputConnection] = bmd_option((int64_t) it.first);
}
}
if (s->device_options.find(bmdDeckLinkConfigVideoInputConnection) == s->device_options.end()) {
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Unrecognized connection %s.\n", connection);
auto bmd_conn = bmd_get_connection_by_name(connection);
if (bmd_conn == bmdVideoConnectionUnspecified) {
MSG(ERROR, "Unrecognized connection %s.\n", connection);
return false;
}
s->device_options[bmdDeckLinkConfigVideoInputConnection] =
bmd_option((int64_t) bmd_conn);
} else if(strncasecmp(opt, "audio_level=",
strlen("audio_level=")) == 0) {
s->device_options[bmdDeckLinkConfigAnalogAudioConsumerLevels] =
Expand Down
12 changes: 12 additions & 0 deletions src/video_display/decklink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ show_help(bool full, const char *query_prop_fcc = nullptr)
col() << SBOLD("\tUse1080PsF[=true|false|keep]") << " flag sets use of PsF on output instead of progressive (default is false)\n";
col() << SBOLD("\tprofile=<P>") << "\tuse desired device profile:\n";
print_bmd_device_profiles("\t\t");
col() << SBOLD("\tconnection=<conn>") << " set output video connection (usually unneeded)\n";
col() << SBOLD("\tmaxresample=<N>") << " maximum amount the resample delta can be when scaling is applied. Measured in Hz\n";
col() << SBOLD("\tminresample=<N>") << " minimum amount the resample delta can be when scaling is applied. Measured in Hz\n";
col() << SBOLD("\ttargetbuffer=<N>") << " target amount of samples to have in the buffer (per channel)\n";
Expand Down Expand Up @@ -1302,6 +1303,17 @@ static bool settings_init(struct state_decklink *s, const char *fmt,
return false;
}
}
} else if (IS_KEY_PREFIX(ptr, "connection")) {
const char *connection = strchr(ptr, '=') + 1;
auto bmd_conn = bmd_get_connection_by_name(connection);
if (bmd_conn == bmdVideoConnectionUnspecified) {
MSG(ERROR, "Unrecognized connection %s.\n",
connection);
return false;
}
s->device_options
[bmdDeckLinkConfigVideoOutputConnection] =
bmd_option((int64_t) bmd_conn);
} else if (strstr(ptr, "keep-settings") == ptr) {
s->keep_device_defaults = true;
} else if (strstr(ptr, "drift_fix") == ptr) {
Expand Down

0 comments on commit 116096b

Please sign in to comment.