some fixes
This commit is contained in:
@@ -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 DeckLinkInNode::configure(const nlohmann::json& params) {
|
||||
spdlog::warn("DeckLink-in: unknown mode '{}', defaulting to 1080i50", mode_str);
|
||||
}
|
||||
}
|
||||
if (params.contains("input_connection")) {
|
||||
auto conn_str = params["input_connection"].get<std::string>();
|
||||
if (conn_str == "sdi") input_connection_ = bmdVideoConnectionSDI;
|
||||
else if (conn_str == "hdmi") input_connection_ = bmdVideoConnectionHDMI;
|
||||
else if (conn_str == "optical_sdi") input_connection_ = bmdVideoConnectionOpticalSDI;
|
||||
else if (conn_str == "component") input_connection_ = bmdVideoConnectionComponent;
|
||||
else if (conn_str == "composite") input_connection_ = bmdVideoConnectionComposite;
|
||||
else if (conn_str == "svideo") input_connection_ = bmdVideoConnectionSVideo;
|
||||
else {
|
||||
spdlog::warn("DeckLink-in: unknown input_connection '{}', defaulting to auto", conn_str);
|
||||
}
|
||||
}
|
||||
|
||||
if (!open_device()) {
|
||||
spdlog::error("DeckLink-in: failed to open device during configure");
|
||||
@@ -90,6 +104,18 @@ bool DeckLinkInNode::open_device() {
|
||||
device->GetModelName(&model_name);
|
||||
spdlog::info("DeckLink-in: opened device '{}'", model_name ? model_name : "unknown");
|
||||
|
||||
if (input_connection_ != bmdVideoConnectionUnspecified) {
|
||||
IDeckLinkConfiguration* config = nullptr;
|
||||
if (device->QueryInterface(IID_IDeckLinkConfiguration, (void**)&config) == S_OK && config) {
|
||||
if (config->SetInt(bmdDeckLinkConfigVideoInputConnection, input_connection_) != S_OK) {
|
||||
spdlog::warn("DeckLink-in: failed to set input connection");
|
||||
} else {
|
||||
spdlog::info("DeckLink-in: input connection configured");
|
||||
}
|
||||
config->Release();
|
||||
}
|
||||
}
|
||||
|
||||
if (device->QueryInterface(IID_IDeckLinkInput, (void**)&input_) != S_OK) {
|
||||
spdlog::error("DeckLink-in: device has no input interface");
|
||||
device->Release();
|
||||
@@ -119,13 +145,8 @@ bool DeckLinkInNode::open_device() {
|
||||
is_interlaced_ = (display_mode_ == bmdModeHD1080i50 ||
|
||||
display_mode_ == bmdModeHD1080i5994);
|
||||
|
||||
if (is_interlaced_) {
|
||||
grain_rate_.numerator = static_cast<int32_t>(2 * scale);
|
||||
grain_rate_.denominator = static_cast<int32_t>(duration);
|
||||
} else {
|
||||
grain_rate_.numerator = static_cast<int32_t>(scale);
|
||||
grain_rate_.denominator = static_cast<int32_t>(duration);
|
||||
}
|
||||
|
||||
auto g = std::__gcd(grain_rate_.numerator, grain_rate_.denominator);
|
||||
grain_rate_.numerator /= g;
|
||||
|
||||
@@ -46,6 +46,7 @@ private:
|
||||
|
||||
int device_index_ = 0;
|
||||
BMDDisplayMode display_mode_ = bmdModeHD1080i50;
|
||||
BMDVideoConnection input_connection_ = bmdVideoConnectionUnspecified;
|
||||
|
||||
IDeckLink* decklink_ = nullptr;
|
||||
IDeckLinkInput* input_ = nullptr;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ private:
|
||||
|
||||
int device_index_ = 0;
|
||||
BMDDisplayMode display_mode_ = bmdModeHD1080i50;
|
||||
BMDVideoConnection output_connection_ = bmdVideoConnectionUnspecified;
|
||||
|
||||
IDeckLink* decklink_ = nullptr;
|
||||
IDeckLinkOutput* output_ = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user