mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 21:40:20 +00:00
DeckLink disp.: print used device
+ moved the common code for querying name to a common file
This commit is contained in:
@@ -338,3 +338,18 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
string bmd_get_device_name(IDeckLink *decklink) {
|
||||
BMD_STR deviceNameString = NULL;
|
||||
char * deviceNameCString = NULL;
|
||||
string ret;
|
||||
|
||||
if (decklink->GetDisplayName((BMD_STR *) &deviceNameString) == S_OK) {
|
||||
deviceNameCString = get_cstr_from_bmd_api_str(deviceNameString);
|
||||
ret = deviceNameCString;
|
||||
release_bmd_api_str(deviceNameString);
|
||||
free(deviceNameCString);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ bool blackmagic_api_version_check();
|
||||
void print_decklink_version(void);
|
||||
|
||||
bool decklink_set_duplex(IDeckLink *decklink, BMDDuplexMode duplex);
|
||||
std::string bmd_get_device_name(IDeckLink *decklink);
|
||||
|
||||
#endif // defined BLACKMAGIC_COMMON_H
|
||||
|
||||
|
||||
@@ -452,20 +452,13 @@ decklink_help()
|
||||
// Enumerate all cards in this system
|
||||
while (deckLinkIterator->Next(&deckLink) == S_OK)
|
||||
{
|
||||
BMD_STR deviceNameString = NULL;
|
||||
char * deviceNameCString = NULL;
|
||||
string deviceName = bmd_get_device_name(deckLink);
|
||||
if (deviceName.empty()) {
|
||||
deviceName = "(unable to get name)";
|
||||
}
|
||||
|
||||
// *** Print the model name of the DeckLink card
|
||||
result = deckLink->GetDisplayName((BMD_STR *) &deviceNameString);
|
||||
if (result == S_OK)
|
||||
{
|
||||
deviceNameCString = get_cstr_from_bmd_api_str(deviceNameString);
|
||||
cout << "device: " << style::bold << numDevices << style::reset << ") " << style::bold << deviceNameCString << style::reset << "\n";
|
||||
release_bmd_api_str(deviceNameString);
|
||||
free(deviceNameCString);
|
||||
} else {
|
||||
printf("device: %d) (unable to get name)\n", numDevices);
|
||||
}
|
||||
cout << "device: " << style::bold << numDevices << style::reset << ") " << style::bold << deviceName << style::reset << "\n";
|
||||
|
||||
// Increment the total number of DeckLink cards found
|
||||
numDevices++;
|
||||
@@ -731,14 +724,10 @@ static struct vidcap_type *vidcap_decklink_probe(bool verbose)
|
||||
continue;
|
||||
}
|
||||
|
||||
BMD_STR deviceNameBMDString = NULL;
|
||||
// *** Print the model name of the DeckLink card
|
||||
result = deckLink->GetModelName((BMD_STR *) &deviceNameBMDString);
|
||||
if (result != S_OK) {
|
||||
continue;
|
||||
string deviceName = bmd_get_device_name(deckLink);
|
||||
if (deviceName.empty()) {
|
||||
deviceName = "(unknown)";
|
||||
}
|
||||
string deviceName = get_cstr_from_bmd_api_str(deviceNameBMDString);
|
||||
release_bmd_api_str(deviceNameBMDString);
|
||||
|
||||
vt->card_count += 1;
|
||||
vt->cards = (struct device_info *)
|
||||
@@ -1046,20 +1035,10 @@ vidcap_decklink_init(const struct vidcap_params *params, void **state)
|
||||
return VIDCAP_INIT_FAIL;
|
||||
}
|
||||
bool found = false;
|
||||
BMD_STR deviceNameString = NULL;
|
||||
while (deckLinkIterator->Next(&deckLink) == S_OK) {
|
||||
char* deviceNameCString = NULL;
|
||||
|
||||
result = deckLink->GetDisplayName(&deviceNameString);
|
||||
if (result == S_OK) {
|
||||
deviceNameCString = get_cstr_from_bmd_api_str(deviceNameString);
|
||||
|
||||
if (strcmp(deviceNameCString, s->state[i].device_id.c_str()) == 0) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
release_bmd_api_str(deviceNameString);
|
||||
free(deviceNameCString);
|
||||
string deviceName = bmd_get_device_name(deckLink);
|
||||
if (!deviceName.empty() && deviceName == s->state[i].device_id.c_str()) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (isdigit(s->state[i].device_id.c_str()[0]) && atoi(s->state[i].device_id.c_str()) == dnum) {
|
||||
@@ -1085,12 +1064,9 @@ vidcap_decklink_init(const struct vidcap_params *params, void **state)
|
||||
s->state[i].deckLink = deckLink;
|
||||
|
||||
// Print the model name of the DeckLink card
|
||||
result = deckLink->GetDisplayName(&deviceNameString);
|
||||
if (result == S_OK) {
|
||||
char *deviceNameCString = get_cstr_from_bmd_api_str(deviceNameString);
|
||||
LOG(LOG_LEVEL_INFO) << "Using device " << deviceNameCString << "\n";
|
||||
release_bmd_api_str(deviceNameString);
|
||||
free(deviceNameCString);
|
||||
string deviceName = bmd_get_device_name(deckLink);
|
||||
if (!deviceName.empty()) {
|
||||
LOG(LOG_LEVEL_INFO) << "Using device " << deviceName << "\n";
|
||||
}
|
||||
|
||||
if (s->duplex != 0 && s->duplex != (uint32_t) -1) {
|
||||
|
||||
@@ -318,7 +318,6 @@ static void show_help(bool full)
|
||||
IDeckLinkIterator* deckLinkIterator;
|
||||
IDeckLink* deckLink;
|
||||
int numDevices = 0;
|
||||
HRESULT result;
|
||||
|
||||
printf("Decklink (output) options:\n");
|
||||
cout << style::bold << fg::red << "\t-d decklink[:device=<device(s)>]" << fg::reset << "[:timecode][:single-link|:dual-link|:quad-link][:LevelA|:LevelB][:3D[:HDMI3DPacking=<packing>]][:audio_level={line|mic}][:conversion=<fourcc>][:Use1080pNotPsF={true|false}][:[no-]low-latency][:half-duplex|full-duplex][:quad-[no-]square]\n" << style::reset;
|
||||
@@ -357,19 +356,14 @@ static void show_help(bool full)
|
||||
// Enumerate all cards in this system
|
||||
while (deckLinkIterator->Next(&deckLink) == S_OK)
|
||||
{
|
||||
BMD_STR deviceNameString = NULL;
|
||||
|
||||
// *** Print the model name of the DeckLink card
|
||||
result = deckLink->GetDisplayName(&deviceNameString);
|
||||
cout << "\ndevice: " << style::bold << numDevices << style::reset << ") ";
|
||||
if (result == S_OK) {
|
||||
char *deviceNameCString = get_cstr_from_bmd_api_str(deviceNameString);
|
||||
cout << style::bold << deviceNameCString << style::reset << "\n";
|
||||
release_bmd_api_str(deviceNameString);
|
||||
free(deviceNameCString);
|
||||
} else {
|
||||
printf("(unable to get name)\n");
|
||||
string deviceName = bmd_get_device_name(deckLink);
|
||||
if (deviceName.empty()) {
|
||||
deviceName = "(unable to get name)";
|
||||
}
|
||||
|
||||
// *** Print the model name of the DeckLink card
|
||||
cout << "\ndevice: " << style::bold << numDevices << style::reset << ") "
|
||||
<< style::bold << deviceName << style::reset << "\n";
|
||||
print_output_modes(deckLink);
|
||||
|
||||
// Increment the total number of DeckLink cards found
|
||||
@@ -820,10 +814,10 @@ static void display_decklink_probe(struct device_info **available_cards, int *co
|
||||
// Enumerate all cards in this system
|
||||
while (deckLinkIterator->Next(&deckLink) == S_OK)
|
||||
{
|
||||
BMD_STR deviceNameString = NULL;
|
||||
|
||||
// *** Print the model name of the DeckLink card
|
||||
HRESULT result = deckLink->GetDisplayName(&deviceNameString);
|
||||
string deviceName = bmd_get_device_name(deckLink);
|
||||
if (deviceName.empty()) {
|
||||
deviceName = "(unknown)";
|
||||
}
|
||||
|
||||
*count += 1;
|
||||
*available_cards = (struct device_info *)
|
||||
@@ -832,14 +826,8 @@ static void display_decklink_probe(struct device_info **available_cards, int *co
|
||||
sprintf((*available_cards)[*count - 1].id, "decklink:device=%d", *count - 1);
|
||||
(*available_cards)[*count - 1].repeatable = false;
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
char *deviceNameCString = get_cstr_from_bmd_api_str(deviceNameString);
|
||||
strncpy((*available_cards)[*count - 1].name, deviceNameCString,
|
||||
sizeof (*available_cards)[*count - 1].name - 1);
|
||||
release_bmd_api_str(deviceNameString);
|
||||
free(deviceNameCString);
|
||||
}
|
||||
strncpy((*available_cards)[*count - 1].name, deviceName.c_str(),
|
||||
sizeof (*available_cards)[*count - 1].name - 1);
|
||||
|
||||
// Release the IDeckLink instance when we've finished with it to prevent leaks
|
||||
deckLink->Release();
|
||||
@@ -1051,22 +1039,11 @@ static void *display_decklink_init(struct module *parent, const char *fmt, unsig
|
||||
{
|
||||
bool found = false;
|
||||
for(int i = 0; i < s->devices_cnt; ++i) {
|
||||
BMD_STR deviceNameString = NULL;
|
||||
char* deviceNameCString = NULL;
|
||||
|
||||
result = deckLink->GetDisplayName(&deviceNameString);
|
||||
if (result == S_OK)
|
||||
{
|
||||
deviceNameCString = get_cstr_from_bmd_api_str(deviceNameString);
|
||||
|
||||
if (strcmp(deviceNameCString, cardId[i].c_str()) == 0) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
release_bmd_api_str(deviceNameString);
|
||||
free(deviceNameCString);
|
||||
}
|
||||
string deviceName = bmd_get_device_name(deckLink);
|
||||
|
||||
if (!deviceName.empty() && deviceName == cardId[i]) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (isdigit(cardId[i].c_str()[0]) && dnum == atoi(cardId[i].c_str())){
|
||||
found = true;
|
||||
@@ -1085,6 +1062,11 @@ static void *display_decklink_init(struct module *parent, const char *fmt, unsig
|
||||
LOG(LOG_LEVEL_ERROR) << "No DeckLink PCI card " << cardId[i] <<" found\n";
|
||||
goto error;
|
||||
}
|
||||
// Print the model name of the DeckLink card
|
||||
string deviceName = bmd_get_device_name(s->state[i].deckLink);
|
||||
if (!deviceName.empty()) {
|
||||
LOG(LOG_LEVEL_INFO) << MOD_NAME "Using device " << deviceName << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if(flags & (DISPLAY_FLAG_AUDIO_EMBEDDED | DISPLAY_FLAG_AUDIO_AESEBU | DISPLAY_FLAG_AUDIO_ANALOG)) {
|
||||
|
||||
Reference in New Issue
Block a user