From ba2d634c2ddc7316e239e4d31ff3bd78ae240756 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Thu, 6 Jun 2024 09:35:13 +0200 Subject: [PATCH] decklink_set_profile: handle help --- src/blackmagic_common.cpp | 15 +++++++++++++++ src/blackmagic_common.hpp | 1 + 2 files changed, 16 insertions(+) diff --git a/src/blackmagic_common.cpp b/src/blackmagic_common.cpp index 95b149bff..e4570e740 100644 --- a/src/blackmagic_common.cpp +++ b/src/blackmagic_common.cpp @@ -399,6 +399,12 @@ bool decklink_set_profile(IDeckLink *deckLink, bmd_option const &req_profile, bo return true; } + if (req_profile.is_help()) { + printf("Available profiles:\n"); + print_bmd_device_profiles("\t"); + return false; + } + bool ret = true; IDeckLinkProfileManager *manager = nullptr; IDeckLinkProfileIterator *it = nullptr; @@ -695,6 +701,10 @@ const char *bmd_option::get_string() const { bool bmd_option::is_default() const { return m_type == type_tag::t_default; } +bool bmd_option::is_help() const { + return m_type == type_tag::t_string && + strcmp(get_string(), "help") == 0; +} bool bmd_option::is_user_set() const { return m_user_specified; } @@ -727,6 +737,11 @@ void bmd_option::parse(const char *val) return; } + if (strcmp(val, "help") == 0) { + set_string(val); + return; + } + // explicitly typed (either "str" or 'fcc') if ((val[0] == '"' && val[strlen(val) - 1] == '"') || (val[0] == '\'' && val[strlen(val) - 1] == '\'')) { string raw_val(val + 1); diff --git a/src/blackmagic_common.hpp b/src/blackmagic_common.hpp index 939ee03eb..54271af7f 100644 --- a/src/blackmagic_common.hpp +++ b/src/blackmagic_common.hpp @@ -98,6 +98,7 @@ public: explicit bmd_option(int64_t val, bool user_spec = true); explicit bmd_option(bool val, bool user_spec = true); bool is_default() const; + [[nodiscard]] bool is_help() const; bool is_user_set() const; void set_keep(); bool keep() const;