From: Steinar H. Gunderson Date: Sat, 2 Jun 2018 07:57:32 +0000 (+0200) Subject: Default to SDI inputs instead of HDMI. X-Git-Tag: 1.7.4~9 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=e08f8c2acf17cbdc4bd878edb1d779bf898aac76 Default to SDI inputs instead of HDMI. This is generally a more useful default; if you have a card that takes in both, you're more likely to use SDI than HDMI. Add an option --default-hdmi-input to revert to the old behavior. Adapted from a patch by Yoann Dubreuil. --- diff --git a/decklink_output.cpp b/decklink_output.cpp index a3d220b..28f433a 100644 --- a/decklink_output.cpp +++ b/decklink_output.cpp @@ -115,8 +115,10 @@ bool DeckLinkOutput::set_device(IDeckLink *decklink) // HDMI or SDI generally mean “both HDMI and SDI at the same time” on DeckLink cards // that support both; pick_default_video_connection() will generally pick one of those - // if they exist. We're not very likely to need analog outputs, so we don't need a way - // to change beyond that. + // if they exist. (--prefer-hdmi-input would also affect the selection despite the name + // of the option, but since either generally means both, it's inconsequential.) + // We're not very likely to need analog outputs, so we don't need a way to change + // beyond that. video_connection = pick_default_video_connection(decklink, BMDDeckLinkVideoOutputConnections, card_index); return true; } diff --git a/decklink_util.cpp b/decklink_util.cpp index d808196..4b701ab 100644 --- a/decklink_util.cpp +++ b/decklink_util.cpp @@ -4,6 +4,7 @@ #include #include "decklink_util.h" +#include "flags.h" using namespace bmusb; using namespace std; @@ -72,15 +73,18 @@ BMDVideoConnection pick_default_video_connection(IDeckLink *card, BMDDeckLinkAtt if (attribute_id == BMDDeckLinkVideoInputConnections) { fprintf(stderr, "Card %u has no input connections\n", card_index); } else { - fprintf(stderr, "Card %u has no outpu connectionss\n", card_index); + fprintf(stderr, "Card %u has no output connections\n", card_index); } exit(1); } - if (connection_mask & bmdVideoConnectionHDMI) { + if ((connection_mask & bmdVideoConnectionHDMI) && + global_flags.default_hdmi_input) { return bmdVideoConnectionHDMI; } else if (connection_mask & bmdVideoConnectionSDI) { return bmdVideoConnectionSDI; + } else if (connection_mask & bmdVideoConnectionHDMI) { + return bmdVideoConnectionHDMI; } else { // Fallback: Return lowest-set bit, whatever that might be. return connection_mask & (-connection_mask); diff --git a/flags.cpp b/flags.cpp index 70c85b1..cd648b9 100644 --- a/flags.cpp +++ b/flags.cpp @@ -16,6 +16,7 @@ enum LongOption { OPTION_HELP = 1000, OPTION_MULTICHANNEL, OPTION_MIDI_MAPPING, + OPTION_DEFAULT_HDMI_INPUT, OPTION_FAKE_CARDS_AUDIO, OPTION_HTTP_UNCOMPRESSED_VIDEO, OPTION_HTTP_X264_VIDEO, @@ -86,6 +87,7 @@ void usage(Program program) fprintf(stderr, " -M, --input-mapping=FILE start with the given audio input mapping (implies --multichannel)\n"); fprintf(stderr, " --multichannel start in multichannel audio mapping mode\n"); fprintf(stderr, " --midi-mapping=FILE start with the given MIDI controller mapping (implies --multichannel)\n"); + fprintf(stderr, " --default-hdmi-input default to HDMI over SDI inputs for cards that have both\n"); fprintf(stderr, " --fake-cards-audio make fake (disconnected) cards output a simple tone\n"); fprintf(stderr, " --http-uncompressed-video send uncompressed NV12 video to HTTP clients\n"); fprintf(stderr, " --http-x264-video send x264-compressed video to HTTP clients\n"); @@ -173,6 +175,7 @@ void parse_flags(Program program, int argc, char * const argv[]) { "va-display", required_argument, 0, 'v' }, { "multichannel", no_argument, 0, OPTION_MULTICHANNEL }, { "midi-mapping", required_argument, 0, OPTION_MIDI_MAPPING }, + { "default-hdmi-input", no_argument, 0, OPTION_DEFAULT_HDMI_INPUT }, { "fake-cards-audio", no_argument, 0, OPTION_FAKE_CARDS_AUDIO }, { "http-uncompressed-video", no_argument, 0, OPTION_HTTP_UNCOMPRESSED_VIDEO }, { "http-x264-video", no_argument, 0, OPTION_HTTP_X264_VIDEO }, @@ -280,6 +283,9 @@ void parse_flags(Program program, int argc, char * const argv[]) global_flags.midi_mapping_filename = optarg; global_flags.multichannel_mapping_mode = true; break; + case OPTION_DEFAULT_HDMI_INPUT: + global_flags.default_hdmi_input = true; + break; case OPTION_FAKE_CARDS_AUDIO: global_flags.fake_cards_audio = true; break; diff --git a/flags.h b/flags.h index 147c62a..1cd2755 100644 --- a/flags.h +++ b/flags.h @@ -46,6 +46,7 @@ struct Flags { bool multichannel_mapping_mode = false; // Implicitly true if input_mapping_filename is nonempty. std::string input_mapping_filename; // Empty for none. std::string midi_mapping_filename; // Empty for none. + bool default_hdmi_input = false; bool print_video_latency = false; double audio_queue_length_ms = 100.0; bool ycbcr_rec709_coefficients = false; // Will be overridden by HDMI/SDI output if ycbcr_auto_coefficients == true.