some fixes

This commit is contained in:
Johanness
2026-05-30 22:12:47 +03:00
parent 8b5fb3dc36
commit 2206fd71b3
4 changed files with 62 additions and 9 deletions
+32 -2
View File
@@ -4,6 +4,8 @@
#include <mxl/mxl.h>
#include <mxl/time.h>
#include <DeckLinkAPIConfiguration.h>
#include <spdlog/spdlog.h>
#include <cstring>
@@ -32,6 +34,18 @@ void DeckLinkOutNode::configure(const nlohmann::json& params) {
spdlog::warn("DeckLink-out: unknown mode '{}', defaulting to 1080i50", mode_str);
}
}
if (params.contains("output_connection")) {
auto conn_str = params["output_connection"].get<std::string>();
if (conn_str == "sdi") output_connection_ = bmdVideoConnectionSDI;
else if (conn_str == "hdmi") output_connection_ = bmdVideoConnectionHDMI;
else if (conn_str == "optical_sdi") output_connection_ = bmdVideoConnectionOpticalSDI;
else if (conn_str == "component") output_connection_ = bmdVideoConnectionComponent;
else if (conn_str == "composite") output_connection_ = bmdVideoConnectionComposite;
else if (conn_str == "svideo") output_connection_ = bmdVideoConnectionSVideo;
else {
spdlog::warn("DeckLink-out: unknown output_connection '{}', defaulting to auto", conn_str);
}
}
}
void DeckLinkOutNode::on_add_reader(const std::string& port_id, mxlFlowReader reader) {
@@ -95,6 +109,20 @@ bool DeckLinkOutNode::open_device() {
decklink_ = device;
if (output_connection_ != bmdVideoConnectionUnspecified) {
IDeckLinkConfiguration* config = nullptr;
if (decklink_->QueryInterface(IID_IDeckLinkConfiguration, (void**)&config) == S_OK && config) {
if (config->SetInt(bmdDeckLinkConfigVideoOutputConnection, output_connection_) != S_OK) {
spdlog::warn("DeckLink-out: failed to set output connection");
} else {
spdlog::info("DeckLink-out: set output connection configured");
}
config->Release();
} else {
spdlog::warn("DeckLink-out: IDeckLinkConfiguration not available");
}
}
callback_ = std::make_unique<OutputCallback>(*this);
output_->SetScheduledFrameCompletionCallback(callback_.get());
@@ -143,12 +171,14 @@ void DeckLinkOutNode::schedule_frame(void* mxl_payload, long width, long height,
if (!output_) return;
int32_t out_row_bytes = 0;
output_->RowBytesForPixelFormat(bmdFormat10BitYUV, width, &out_row_bytes);
if (output_->RowBytesForPixelFormat(bmdFormat10BitYUV, width, &out_row_bytes) != S_OK || out_row_bytes <= 0) {
out_row_bytes = ((width + 5) / 6) * 16;
}
IDeckLinkMutableVideoFrame* frame = nullptr;
if (output_->CreateVideoFrame(width, height, out_row_bytes, bmdFormat10BitYUV,
bmdFrameFlagDefault, &frame) != S_OK) {
spdlog::warn("DeckLink-out: failed to create output frame");
spdlog::warn("DeckLink-out: failed to create output frame {}x{}", width, height);
return;
}