21a8ee4ba0
studio-manager: call mxlGarbageCollectFlows before launching nodes to
clean up stale flow directories left by previous crashed runs.
shared/NodeBase.hpp: add mxl_status_str(mxlStatus) — converts error
codes to readable names (e.g. MXL_ERR_OUT_OF_RANGE_TOO_LATE). All
nodes now log these names instead of raw integers.
shared/FlowDef.hpp: use "audio/float32" as media_type for 32-bit audio
flows, matching the MXL SDK examples. audio/L{n} kept for other depths.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
76 lines
2.9 KiB
C++
76 lines
2.9 KiB
C++
#pragma once
|
|
#include <string>
|
|
#include <nlohmann/json.hpp>
|
|
|
|
namespace dmf {
|
|
|
|
// Generates a minimal but valid NMOS IS-04 flow definition JSON string
|
|
// for a video/v210 flow. MXL uses this to set up the ring buffer geometry.
|
|
inline std::string make_video_flow_def(
|
|
const std::string& flow_id,
|
|
const std::string& label,
|
|
int width, int height,
|
|
int fps_num, int fps_den = 1)
|
|
{
|
|
using json = nlohmann::json;
|
|
return json{
|
|
{"id", flow_id},
|
|
{"format", "urn:x-nmos:format:video"},
|
|
{"label", label},
|
|
{"description", label + " MXL Video Flow"},
|
|
{"media_type", "video/v210"},
|
|
{"parents", json::array()},
|
|
{"grain_rate", {{"numerator", fps_num}, {"denominator", fps_den}}},
|
|
{"frame_width", width},
|
|
{"frame_height", height},
|
|
{"interlace_mode", "progressive"},
|
|
{"colorspace", "BT709"},
|
|
{"tags", {
|
|
{"urn:x-nmos:tag:grouphint/v1.0", json::array({label + ":Video"})}
|
|
}},
|
|
{"components", json::array({
|
|
{{"name","Y"}, {"width",width}, {"height",height}, {"bit_depth",10}},
|
|
{{"name","Cb"}, {"width",width/2}, {"height",height}, {"bit_depth",10}},
|
|
{{"name","Cr"}, {"width",width/2}, {"height",height}, {"bit_depth",10}}
|
|
})}
|
|
}.dump();
|
|
}
|
|
|
|
// Generates a minimal but valid NMOS IS-04 flow definition JSON string
|
|
// for a raw PCM audio flow. grain_rate_num/den sets the grain delivery rate
|
|
// (default 25/1 = one grain per video frame). MXL computes grain size as
|
|
// sample_rate / grain_rate samples per grain.
|
|
inline std::string make_audio_flow_def(
|
|
const std::string& flow_id,
|
|
const std::string& label,
|
|
int sample_rate,
|
|
int channels,
|
|
int bit_depth = 32,
|
|
int grain_rate_num = 25,
|
|
int grain_rate_den = 1)
|
|
{
|
|
using json = nlohmann::json;
|
|
static const char* ch_labels[] = {"L","R","C","LFE","Ls","Rs","Lss","Rss"};
|
|
json ch_arr = json::array();
|
|
for (int i = 0; i < channels; ++i)
|
|
ch_arr.push_back({{"label", i < 8 ? ch_labels[i] : ("Ch" + std::to_string(i + 1))}});
|
|
return json{
|
|
{"id", flow_id},
|
|
{"format", "urn:x-nmos:format:audio"},
|
|
{"label", label},
|
|
{"description", label + " MXL Audio Flow"},
|
|
{"media_type", bit_depth == 32 ? "audio/float32" : "audio/L" + std::to_string(bit_depth)},
|
|
{"parents", json::array()},
|
|
{"grain_rate", {{"numerator", grain_rate_num}, {"denominator", grain_rate_den}}},
|
|
{"sample_rate", {{"numerator", sample_rate}, {"denominator", 1}}},
|
|
{"channels", ch_arr}, // NMOS IS-04 metadata (ignored by MXL)
|
|
{"channel_count", channels}, // MXL uses this for grain buffer geometry
|
|
{"bit_depth", bit_depth}, // must be 32 or 64
|
|
{"tags", {
|
|
{"urn:x-nmos:tag:grouphint/v1.0", json::array({label + ":Audio"})}
|
|
}},
|
|
}.dump();
|
|
}
|
|
|
|
} // namespace dmf
|