diff --git a/services/node-agent/index.js b/services/node-agent/index.js index 04b7526..4d1b842 100644 --- a/services/node-agent/index.js +++ b/services/node-agent/index.js @@ -75,6 +75,8 @@ let _dcBridge = null; // ChildProcess | null let _dcSidecarCount = 0; // active deltacast sidecars on this node // Map containerId -> sourceType so stop() can decrement the deltacast counter. const _containerSourceType = new Map(); +// port -> fmt JSON from bridge stderr (inject into sidecar env) +const _dcPortFmt = new Map(); function _dcBridgeRunning() { return _dcBridge !== null && _dcBridge.exitCode === null && _dcBridge.signalCode === null; @@ -104,8 +106,12 @@ function startDeltacastBridge() { const t = line.trim(); if (!t) continue; // Format JSON lines go to stdout so node-agent can log/forward them. - if (t.startsWith('{')) console.log('[dc-bridge] ' + t); - else console.error('[dc-bridge] ' + t); + if (t.startsWith('{')) { + console.log('[dc-bridge] ' + t); + try { const f = JSON.parse(t); if (typeof f.port === 'number') _dcPortFmt.set(f.port, f); } catch (_) {} + } else { + console.error('[dc-bridge] ' + t); + } } }); @@ -273,6 +279,18 @@ async function handleSidecarStart(body, res) { if (sourceType === 'deltacast') { _dcSidecarCount++; startDeltacastBridge(); + // Inject per-port signal format so capture-manager uses real dimensions/fps + const _srcCfg = (env.find(e => e.startsWith('SOURCE_CONFIG=')) || '').slice(14); + let _portNum = NaN; + try { _portNum = JSON.parse(_srcCfg).port; } catch (_) {} + if (Number.isFinite(_portNum) && _dcPortFmt.has(_portNum)) { + const _fmt = _dcPortFmt.get(_portNum); + const _fps = (_fmt.fps_den && _fmt.fps_den !== 1) ? `${_fmt.fps_num}/${_fmt.fps_den}` : String(_fmt.fps_num); + sidecarEnv.push(`DELTACAST_VIDEO_SIZE=${_fmt.width}x${_fmt.height}`); + sidecarEnv.push(`DELTACAST_FRAMERATE=${_fps}`); + sidecarEnv.push(`DELTACAST_INTERLACED=${_fmt.interlaced ? '1' : '0'}`); + console.log(`[dc-bridge] port ${_portNum} fmt: ${_fmt.width}x${_fmt.height} ${_fps} interlaced=${_fmt.interlaced}`); + } } let containerId;