]> git.sesse.net Git - nageru/commitdiff
Default to SDI inputs instead of HDMI.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 2 Jun 2018 07:57:32 +0000 (09:57 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 2 Jun 2018 07:57:32 +0000 (09:57 +0200)
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.

decklink_output.cpp
decklink_util.cpp
flags.cpp
flags.h

index a3d220b37c98bb96834415af5a277c47424b83cb..28f433a8872945b3191608cc7283eea5fea4669e 100644 (file)
@@ -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;
 }
index d8081961e9880a2c35ab3216cb9794f6b5f8e5c5..4b701abed3799448d2d6755652190a1c57769b77 100644 (file)
@@ -4,6 +4,7 @@
 #include <assert.h>
 
 #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);
index 70c85b16c6fa5cbf8c63271e3d64edaa7ed66357..cd648b9d1ec53eff80a8185763b8131ca8cae550 100644 (file)
--- 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 147c62a0b1b80c3406ce69fa01bd3fdbe5e480e2..1cd2755b9641600db4d35f594a73ddef29252bab 100644 (file)
--- 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.