DeckLink cap.: "query=" - try all types

Do not use "<FourCC>F" syntax (for flags). Try all possible types if
the previous query returns E_INVALIDARG until success, instead.
This commit is contained in:
Martin Pulec
2023-10-18 10:46:50 +02:00
parent 74c4192b88
commit e063ebc651
2 changed files with 38 additions and 18 deletions

View File

@@ -63,7 +63,6 @@
using std::clamp;
using std::fixed;
using std::dec;
using std::hex;
using std::invalid_argument;
using std::map;
@@ -1009,34 +1008,53 @@ print_bmd_attribute(IDeckLinkProfileAttributes *deckLinkAttributes,
{
if (strcmp(query_prop_fcc, "help") == 0) {
col{} << "Query usage:\n"
<< SBOLD("\tq[uery]=<fcc>") << " - gets Int value\n"
<< SBOLD("\tq[uery]=<fcc>F")
<< " - gets Flag (bool) value\n"
<< "(other types not yet supported)\n";
<< SBOLD("\tq[uery]=<fcc>")
<< " - gets DeckLink attribute value\n";
return;
}
union {
char fcc[5] = "";
char fcc[sizeof(BMDDeckLinkAttributeID)] = "";
BMDDeckLinkAttributeID key;
};
strncpy(fcc, query_prop_fcc, sizeof fcc);
key = (BMDDeckLinkAttributeID) htonl(key);
int64_t val = 0;
HRESULT result = 0;
if (tolower(fcc[4]) == 'f') {
result = deckLinkAttributes->GetFlag(key, (BMD_BOOL *) &val);
fcc[4] = '\0';
} else {
result = deckLinkAttributes->GetInt(key, &val);
}
BMD_BOOL bool_val{};
int64_t int_val{};
double float_val{};
BMD_STR string_val{};
ostringstream oss;
HRESULT result = deckLinkAttributes->GetFlag(key, &bool_val);
if (result == S_OK) {
col() << "\t" << hex << "Value of " << SBOLD(query_prop_fcc)
<< " for this device is 0x" << val << dec << " (" << val
<< ")\n";
} else {
oss << (bool_val ? "true" : "false");
}
if (result == E_INVALIDARG) {
result = deckLinkAttributes->GetInt(key, &int_val);
if (result == S_OK) {
oss << int_val << " (0x" << hex << int_val << ")";
}
}
if (result == E_INVALIDARG) {
result = deckLinkAttributes->GetFloat(key, &float_val);
if (result == S_OK) {
oss << float_val;
}
}
if (result == E_INVALIDARG) {
result = deckLinkAttributes->GetString(key, &string_val);
if (result == S_OK) {
string str = get_str_from_bmd_api_str(string_val);
release_bmd_api_str(string_val);
oss << str;
}
}
if (result != S_OK) {
LOG(LOG_LEVEL_ERROR)
<< MOD_NAME << "Cannot get " << query_prop_fcc << ": "
<< bmd_hresult_to_string(result) << "\n";
return;
}
col() << "\t" << hex << "Value of " << SBOLD(query_prop_fcc)
<< " attribute for this device is " << SBOLD(oss.str()) << "\n";
}
ADD_TO_PARAM(R10K_FULL_OPT, "* " R10K_FULL_OPT "\n"

View File

@@ -434,6 +434,7 @@ VideoDelegate::VideoInputFrameArrived (IDeckLinkVideoInputFrame *videoFrame, IDe
return S_OK;
}
/// @param query_prop_fcc if not NULL, print corresponding BMDDeckLinkAttribute
static void
vidcap_decklink_print_card_info(IDeckLink *deckLink, const char *query_prop_fcc)
{
@@ -479,6 +480,7 @@ vidcap_decklink_print_card_info(IDeckLink *deckLink, const char *query_prop_fcc)
if (query_prop_fcc != nullptr) {
print_bmd_attribute(deckLinkAttributes, query_prop_fcc);
cout << "\n";
}
// Release the IDeckLink instance when we've finished with it to prevent leaks