Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions include/upipe-blackmagic/upipe_blackmagic_sink.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Open Broadcast Systems Ltd.
* Copyright (C) 2026 EasyTools
*
* Authors: Kieran Kunhya
*
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
59 changes: 59 additions & 0 deletions lib/upipe-blackmagic/upipe_blackmagic_sink.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014-2016 Open Broadcast Systems Ltd.
* Copyright (C) 2026 EasyTools
*
* Authors: Kieran Kunhya
* Rafaël Carré
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 *);
Expand Down
Loading