diff --git a/include/upipe-blackmagic/upipe_blackmagic_sink.h b/include/upipe-blackmagic/upipe_blackmagic_sink.h index cf754e766..6f4e7b961 100644 --- a/include/upipe-blackmagic/upipe_blackmagic_sink.h +++ b/include/upipe-blackmagic/upipe_blackmagic_sink.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2014 Open Broadcast Systems Ltd. + * Copyright (C) 2026 EasyTools * * Authors: Kieran Kunhya * @@ -52,6 +53,8 @@ enum upipe_bmd_sink_command { UPIPE_BMD_SINK_SET_TIMING_ADJUSTMENT, /** adjust timing (int64_t) */ UPIPE_BMD_SINK_ADJUST_TIMING, + /** sets SMPTE level A output (int) */ + UPIPE_BMD_SINK_SET_LEVEL_A, }; /** @This returns the management structure for all bmd sinks. @@ -151,6 +154,18 @@ static inline int upipe_bmd_sink_adjust_timing(struct upipe *upipe, int64_t adj) UPIPE_BMD_SINK_SIGNATURE, adj); } +/** @This sets the SMPTE level A output. + * + * @param upipe description structure of the pipe + * @param enable true to enable, false otherwise + * @return an error code + */ +static inline int upipe_bmd_sink_set_level_a(struct upipe *upipe, bool enable) +{ + return upipe_control(upipe, UPIPE_BMD_SINK_SET_LEVEL_A, + UPIPE_BMD_SINK_SIGNATURE, enable ? 1 : 0); +} + /** @This allocates and initializes a bmd sink pipe. * * @param mgr management structure for bmd sink type diff --git a/lib/upipe-blackmagic/upipe_blackmagic_sink.cpp b/lib/upipe-blackmagic/upipe_blackmagic_sink.cpp index 5f68bc08a..f3ad1e212 100644 --- a/lib/upipe-blackmagic/upipe_blackmagic_sink.cpp +++ b/lib/upipe-blackmagic/upipe_blackmagic_sink.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2014-2016 Open Broadcast Systems Ltd. + * Copyright (C) 2026 EasyTools * * Authors: Kieran Kunhya * Rafaël Carré @@ -332,6 +333,9 @@ struct upipe_bmd_sink { /** is opened? */ bool opened; + + /** SMPTE level A output enabled? */ + bool level_a; }; static int upipe_bmd_sink_check(struct upipe *upipe, struct uref *flow_format); @@ -1610,6 +1614,7 @@ static struct upipe *upipe_bmd_sink_alloc(struct upipe_mgr *mgr, upipe_bmd_sink->mode = bmdModeUnknown; upipe_bmd_sink->selectedMode = bmdModeUnknown; upipe_bmd_sink->timing_adjustment = INT64_MAX; + upipe_bmd_sink->level_a = false; uatomic_init(&upipe_bmd_sink->preroll, PREROLL_FRAMES); uatomic_init(&upipe_bmd_sink->cc, 0); uatomic_init(&upipe_bmd_sink->ttx, 0); @@ -1762,6 +1767,53 @@ static int upipe_bmd_open_vid(struct upipe *upipe) return err; } +/** @internal @This updates the configuration. + * + * @param upipe description structure of the pipe + * @return an error code + */ +static int upipe_bmd_sink_write_conf(struct upipe *upipe) +{ + struct upipe_bmd_sink *upipe_bmd_sink = upipe_bmd_sink_from_upipe(upipe); + if (unlikely(!upipe_bmd_sink->deckLink)) + return UBASE_ERR_INVALID; + + IDeckLinkConfiguration *deckLinkConfiguration = NULL; + HRESULT result = upipe_bmd_sink->deckLink->QueryInterface( + IID_IDeckLinkConfiguration, (void **)&deckLinkConfiguration); + if (result != S_OK) { + upipe_warn(upipe, "fail to write configuration"); + return UBASE_ERR_EXTERNAL; + } + result = deckLinkConfiguration->SetFlag(bmdDeckLinkConfigSMPTELevelAOutput, + upipe_bmd_sink->level_a); + if (result != S_OK) + upipe_warn_va(upipe, "fail to %s SMPTE level A output", + upipe_bmd_sink->level_a ? "enable" : "disable"); + else + upipe_notice_va(upipe, "%s SMPTE level A output", + upipe_bmd_sink->level_a ? "enable" : "disable"); + deckLinkConfiguration->WriteConfigurationToPreferences(); + deckLinkConfiguration->Release(); + return result == S_OK ? UBASE_ERR_NONE : UBASE_ERR_EXTERNAL; +} + +/** @internal @This sets SMPTE level A output. + * + * @param upipe description structure of the pipe + * @param enable true to enable SMPTE level A output, false otherwise + * @return an error code + */ +static int _upipe_bmd_sink_set_level_a(struct upipe *upipe, bool enable) +{ + struct upipe_bmd_sink *upipe_bmd_sink = upipe_bmd_sink_from_upipe(upipe); + upipe_bmd_sink->level_a = enable; + if (unlikely(!upipe_bmd_sink->deckLink)) + return UBASE_ERR_NONE; + + return upipe_bmd_sink_write_conf(upipe); +} + /** @internal @This asks to open the given device. * * @param upipe description structure of the pipe @@ -1846,6 +1898,8 @@ static int upipe_bmd_sink_open_card(struct upipe *upipe) upipe_bmd_sink->deckLink = deckLink; + upipe_bmd_sink_write_conf(upipe); + end: deckLinkIterator->Release(); @@ -2083,6 +2137,11 @@ static int upipe_bmd_sink_control(struct upipe *upipe, int command, va_list args int64_t adj = va_arg(args, int64_t); return _upipe_bmd_sink_adjust_timing(upipe, adj); } + case UPIPE_BMD_SINK_SET_LEVEL_A: { + UBASE_SIGNATURE_CHECK(args, UPIPE_BMD_SINK_SIGNATURE) + bool enable = va_arg(args, int) ? true : false; + return _upipe_bmd_sink_set_level_a(upipe, enable); + } case UPIPE_SET_OPTION: { const char *k = va_arg(args, const char *); const char *v = va_arg(args, const char *);