From f625f8529fc034da09e93bceebe26421e9d6071a Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Thu, 6 Jun 2019 16:28:56 +0200 Subject: [PATCH] DeckLink: correctly set duplex mode for quad-link Correctly set the duplex mode for quad-link (implies bmdProfileOneSubDevicesHalfDuplex). * changed the duplex options + slightly modified usage --- src/video_capture/decklink.cpp | 24 +++++++++++++++--------- src/video_display/decklink.cpp | 18 +++++++++++------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/video_capture/decklink.cpp b/src/video_capture/decklink.cpp index e97f97fca..f22dce46c 100644 --- a/src/video_capture/decklink.cpp +++ b/src/video_capture/decklink.cpp @@ -82,6 +82,9 @@ #define STDMETHODCALLTYPE #endif +#define DEFAULT 0 +#define KEEP -1 + #define RELEASE_IF_NOT_NULL(x) if (x != nullptr) { x->Release(); x = nullptr; } using namespace std; @@ -436,8 +439,8 @@ decklink_help() cout << style::bold << "[no]passthrough\n" << style::reset; printf("\tEnable/disable capture passthrough.\n"); printf("\n"); - cout << style::bold << "half-duplex|full-duplex|no-half-duplex\n" << style::reset; - printf("\tUse half-/full-duplex, no-half-duplex suppresses automatically set half-duplex (for quad-link)\n"); + cout << style::bold << "half-duplex|full-duplex|one-device-half-duplex|keep-duplex\n" << style::reset; + printf("\tUse half-/full-duplex (1-dev-1/2-duplex is for 8K Pro), keep-duplex suppresses automatically set one-device-half-duplex (for quad-link)\n"); printf("\n"); cout << style::bold << "single-/dual-/quad-link\n" << style::reset; printf("\tUse single-/dual-/quad-link.\n"); @@ -601,8 +604,12 @@ static bool parse_option(struct vidcap_decklink_state *s, const char *opt) : bmdDeckLinkCapturePassthroughModeCleanSwitch; } else if (strcasecmp(opt, "half-duplex") == 0) { s->duplex = bmdDuplexHalf; + } else if (strcasecmp(opt, "one-device-half-duplex") == 0) { + s->duplex = bmdDuplexSimplex; } else if (strcasecmp(opt, "full-duplex") == 0) { s->duplex = bmdDuplexFull; + } else if (strcasecmp(opt, "keep-duplex") == 0) { + s->duplex = KEEP; } else if (strcasecmp(opt, "single-link") == 0) { s->link = bmdLinkConfigurationSingleLink; } else if (strcasecmp(opt, "dual-link") == 0) { @@ -960,12 +967,11 @@ vidcap_decklink_init(const struct vidcap_params *params, void **state) } if (s->link == bmdLinkConfigurationQuadLink) { - if (s->duplex == bmdDuplexFull) { - LOG(LOG_LEVEL_WARNING) << MOD_NAME "Setting quad-link and full-duplex may not be supported!\n"; - } - if (s->duplex == 0) { - LOG(LOG_LEVEL_WARNING) << MOD_NAME "Quad-link detected - setting half-duplex automatically, use 'no-half-duplex' to override.\n"; - s->duplex = bmdDuplexHalf; + if (s->duplex == DEFAULT) { + LOG(LOG_LEVEL_WARNING) << MOD_NAME "Quad-link detected - setting half-duplex automatically, use 'keep-duplex' to override.\n"; + s->duplex = bmdDuplexSimplex; + } else (s->duplex != KEEP) { + LOG(LOG_LEVEL_WARNING) << MOD_NAME "Setting quad-link and duplex mode that may not be supported!\n"; } } @@ -1069,7 +1075,7 @@ vidcap_decklink_init(const struct vidcap_params *params, void **state) LOG(LOG_LEVEL_INFO) << "Using device " << deviceName << "\n"; } - if (s->duplex != 0 && s->duplex != (uint32_t) -1) { + if (s->duplex != DEFAULT && s->duplex != (uint32_t) KEEP) { decklink_set_duplex(s->state[i].deckLink, (BMDDuplexMode) s->duplex); } diff --git a/src/video_display/decklink.cpp b/src/video_display/decklink.cpp index 3cfa38a30..ccbd672f9 100644 --- a/src/video_display/decklink.cpp +++ b/src/video_display/decklink.cpp @@ -320,7 +320,7 @@ static void show_help(bool full) int numDevices = 0; printf("Decklink (output) options:\n"); - cout << style::bold << fg::red << "\t-d decklink[:device=]" << fg::reset << "[:timecode][:single-link|:dual-link|:quad-link][:LevelA|:LevelB][:3D[:HDMI3DPacking=]][:audio_level={line|mic}][:conversion=][:Use1080pNotPsF={true|false}][:[no-]low-latency][:half-duplex|full-duplex][:quad-[no-]square]\n" << style::reset; + cout << style::bold << fg::red << "\t-d decklink[:device=]" << fg::reset << "[:fullhelp][:timecode][:-link][:Level{A|B}][:3D[:HDMI3DPacking=]][:audio_level={line|mic}][:conversion=][:Use1080pNotPsF={true|false}][:[no-]low-latency][:-duplex][:quad-[no-]square]\n" << style::reset; cout << style::bold << "\t\t" << style::reset << " is coma-separated indices or names of output devices\n"; cout << style::bold << "\t\tsingle-link/dual-link/quad-link" << style::reset << " specifies if the video output will be in a single-link (HD/3G/6G/12G), dual-link HD-SDI mode or quad-link HD/3G/6G/12G\n"; cout << style::bold << "\t\tLevelA/LevelB" << style::reset << " specifies 3G-SDI output level\n"; @@ -345,6 +345,9 @@ static void show_help(bool full) style::bold << "\t\t\tup1i" << style::reset << " - simultaneous output of SD and up-converted pollarbox 1080i\n"; cout << style::bold << "\t\tHDMI3DPacking" << style::reset << " can be:\n" << style::bold << "\t\t\tSideBySideHalf, LineByLine, TopAndBottom, FramePacking, LeftOnly, RightOnly\n" << style::reset; + cout << style::bold << "\t\thalf-duplex|full-duplex|one-device-half-duplex|keep-duplex\n" << style::reset; + cout << "\t\t\tUse half-/full-duplex (1-dev-1/2-duplex is for 8K Pro), keep-duplex suppresses automatically set one-device-half-duplex (for quad-link)\n"; + } // Create an IDeckLinkIterator object to enumerate all DeckLink cards in the system @@ -726,13 +729,12 @@ display_decklink_reconfigure_video(void *state, struct video_desc desc) } CALL_AND_CHECK(s->state[i].deckLinkConfiguration->SetInt(bmdDeckLinkConfigSDIOutputLinkConfiguration, link), "Unable set output SDI link mode"); - if (link == bmdLinkConfigurationQuadLink && s->duplex_req == bmdDuplexFull) { - LOG(LOG_LEVEL_WARNING) << MOD_NAME "Setting quad-link and full-duplex may not be supported!\n"; - } if (s->duplex_req == DEFAULT && link == bmdLinkConfigurationQuadLink) { - LOG(LOG_LEVEL_WARNING) << MOD_NAME "Quad-link detected - setting half-duplex automatically, use 'no-half-duplex' to override.\n"; + LOG(LOG_LEVEL_WARNING) << MOD_NAME "Quad-link detected - setting half-duplex automatically, use 'keep-duplex' to override.\n"; decklink_set_duplex(s->state[i].deckLink, bmdDuplexSimplex); + } else if (link == bmdLinkConfigurationQuadLink && s->duplex_req != KEEP) { + LOG(LOG_LEVEL_WARNING) << MOD_NAME "Setting quad-link and an incompatible duplex may not be supported!\n"; } BMD_BOOL quad_link_supp; @@ -939,10 +941,12 @@ static void *display_decklink_init(struct module *parent, const char *fmt, unsig s->link_req = bmdLinkConfigurationQuadLink; } else if(strcasecmp(ptr, "half-duplex") == 0) { s->duplex_req = bmdDuplexHalf; - } else if(strcasecmp(ptr, "no-half-duplex") == 0) { - s->duplex_req = KEEP; + } else if(strcasecmp(ptr, "one-device-half-duplex") == 0) { + s->duplex_req = bmdDuplexSimplex; } else if(strcasecmp(ptr, "full-duplex") == 0) { s->duplex_req = bmdDuplexFull; + } else if(strcasecmp(ptr, "keep-duplex") == 0) { + s->duplex_req = KEEP; } else if(strcasecmp(ptr, "LevelA") == 0) { s->level = 'A'; } else if(strcasecmp(ptr, "LevelB") == 0) {