feat: NDI in node receives and writes audio flow

- FlowDef.hpp: add make_audio_flow_def (NMOS IS-04 audio/Lnn flow)
- NDIReceiver: replace capture_v210 with capture() — single recv call
  dispatches to FrameKind::{Video,Audio,None}; AudioInfo struct carries
  sample_rate/channels/samples/channel_stride
- ndiin: optional audio writer when graph wires audio_flow_id; single
  loop with 5ms NDI poll; audio grains written immediately on arrival;
  video grains written when mxlGetCurrentIndex reaches video_index
- build_graph: rename ndiin video port flow_id → video_flow_id; add
  audio_flow_id edge (no sink yet — wired to ndiin only)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
JohannesItten
2026-07-01 12:39:35 +03:00
parent ee47d85cbd
commit cc1011cced
4 changed files with 196 additions and 80 deletions
+32
View File
@@ -36,4 +36,36 @@ inline std::string make_video_flow_def(
}.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", "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},
{"bit_depth", bit_depth},
}.dump();
}
} // namespace dmf