Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e8625b8
fix(recording): link PGM video to the recorder's video_in_0 pad
wagenet Sep 28, 2026
8507c7d
fix(recording): set the recorder's filename_prefix, not prefix
wagenet Sep 28, 2026
f9bf40f
fix(recording): AAC-encode the main mix before the recorder
wagenet Sep 28, 2026
f63a8f9
docs(recording): match the recorder's filename template in comments
wagenet Sep 28, 2026
4466020
fix(recording): record picture only when Strom has no audio encoder
wagenet Sep 28, 2026
40b55a2
feat(recording): show activation warnings as a toast in the controller
wagenet Sep 28, 2026
f082951
fix(recording): clear activation warnings when activation fails
wagenet Sep 28, 2026
16853cc
fix(recording): send activation warnings once the production is live
wagenet Sep 28, 2026
70d62d1
test(recording): build the warning fixture from makeActivationResult
wagenet Oct 1, 2026
34f961d
test(recording): update main's tests for warnings and video_in_0
wagenet Oct 6, 2026
01a2f51
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 8, 2026
cc3f50f
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 8, 2026
85e97fd
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 8, 2026
d611d2d
test(strom-public-url): add warnings to the activation mock
wagenet Oct 8, 2026
025a2c6
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 9, 2026
2ea3603
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 9, 2026
570f7d3
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 12, 2026
bae0e53
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 12, 2026
a36eb4d
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 13, 2026
dea5a0d
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 13, 2026
3ee1b38
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 15, 2026
f8e64d1
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 15, 2026
62694ff
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 15, 2026
7756d07
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 15, 2026
dca27dc
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 15, 2026
d22635c
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 16, 2026
d698284
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 16, 2026
4d39188
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 16, 2026
17e356e
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 16, 2026
32dd716
Merge branch 'main' into wagenet/fix-recorder-video-pad
birme Oct 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/controller-websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ per-effect parameters.

Outbound frames are JSON objects, each with a `type` discriminator. Most are sent via
`broadcast(productionId, ...)` to every client subscribed to the production; a few
(`ERROR`, `MACRO_ERROR`) are sent only to the originating socket. The following types
(`ERROR`, `MACRO_ERROR`) are sent only to the originating socket, except for activation
warnings (see `ERROR` below). The following types
are emitted from `src/ws/controller.ts` and `src/services/meter-relay.ts`:

| `type` | Fields | Emitted when |
Expand Down Expand Up @@ -223,7 +224,7 @@ are emitted from `src/ws/controller.ts` and `src/services/meter-relay.ts`:
| `IDLE_WARNING_CLEARED` | `productionId: string` | A pending idle warning was cancelled because activity reset the idle timer (a subscriber joined or a `KEEP_ALIVE` was received). |
| `RETURN_STATE` | `mixerInput: string`, `mode: 'program' \| 'program-minus'` | A per-guest return feed's mix-minus mode changed on `mixerInput` (crew via `PUT .../returns/{mixerInput}/mode`, the `RETURN_SET` WS command, or the guest via `PUT /api/v1/guests/{inviteId}/session/return`). `program-minus` closes that guest's own send; `program` opens it (epic #208, issue #300). Also emitted once per configured return during the connect-time snapshot. |
| `GUEST_STATE` | `guestId: string`, `mixerInput: string`, `state: 'invited' \| 'joined' \| 'previewing' \| 'on-air' \| 'left' \| 'error'`, `label?`, `intercomLine?` | A guest's lifecycle state changed (epic #208, issue #301). Broadcast on the persisted join/leave/kick transitions and emitted once per live guest in the connect-time snapshot. `previewing`/`on-air` are **derived** from the live vision-mixer contribution set (#209); a guest composited only as a PiP *inset* reads `joined` until the PiP-inset tally gap #209 raises is closed. |
| `ERROR` | `error: string` | An inbound frame was invalid or an operation failed (sent to originating socket) |
| `ERROR` | `error: string` | An inbound frame was invalid or an operation failed (sent to originating socket). Also carries each activation warning (`ProductionDoc.activationWarnings`, e.g. a recording with no sound): broadcast when the production goes active, and sent to each client that connects while it is active. Not a response to any command. |

`pgmBg` is the mixer input a PiP on program is composited over. It is `null` unless
`pgmPip` is set — the same PiP-slot index that `TALLY` now carries directly (and that
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/activation-failure-relay-stop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function makeActivationResult(flowId: string, mixerBlockId: string) {
returnBuses: [],
returnWhepEntries: [],
mixerInputMap: {},
warnings: [],
};
}

Expand Down
101 changes: 101 additions & 0 deletions src/__tests__/activation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ vi.mock('../lib/strom.js', async (importOriginal) => {
};
});

const mockBroadcast = vi.fn();
vi.mock('../services/tally.service.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../services/tally.service.js')>();
return { ...actual, broadcast: (...args: unknown[]) => mockBroadcast(...args) };
});

// Mock strom-token
vi.mock('../lib/strom-token.js', () => ({
getStromToken: vi.fn().mockResolvedValue('test-token'),
Expand Down Expand Up @@ -128,6 +134,7 @@ function makeActivationResult(flowId: string, mixerBlockId: string) {
recorderBlockId: undefined,
whepOutputEntries: [],
pgmWhepEndpointId: undefined,
warnings: [],
sourceOffsetBlockIds: {},
sourceAudioOffsetBlockIds: {},
clipPlayerBlockIds: {},
Expand All @@ -137,6 +144,18 @@ function makeActivationResult(flowId: string, mixerBlockId: string) {
};
}

const noAudioWarning = { type: 'recording-no-audio', message: 'Recording "VOD" has no sound' };

function activationResultWithWarning() {
return {
...makeActivationResult('flow-abc', ''),
mixerBlockId: null,
audioMixerBlockId: null,
loudnessMainBlockId: null,
warnings: [noAudioWarning],
};
}

// ---------------------------------------------------------------------------
// Tests: POST /api/v1/productions/:id/activate
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -168,6 +187,88 @@ describe('POST /api/v1/productions/:id/activate', () => {
expect(body.id).toBe('prod-test-1');
});

it('saves activation warnings, and sends each as an ERROR frame once the production is live', async () => {
const doc = makeProductionDoc();
mockGet.mockResolvedValue(doc);
mockInsert.mockResolvedValue({ rev: '2-bcd', ok: true, id: doc._id });
mockActivateStromFlow.mockResolvedValue(activationResultWithWarning());
mockStromFlowsGet.mockResolvedValue({ flow: { id: 'flow-abc', running: true, blocks: [] } });

const app = await buildServer();
await app.inject({ method: 'POST', url: '/api/v1/productions/prod-test-1/activate' });

await vi.waitFor(() => {
expect(mockBroadcast).toHaveBeenCalledWith('prod-test-1', { type: 'ERROR', error: noAudioWarning.message });
});
const saved = mockInsert.mock.calls.map((c) => c[0] as Record<string, unknown>);
expect(saved.some((d) => d['stromFlowId'] === 'flow-abc' && (d['activationWarnings'] as unknown[])?.length === 1)).toBe(true);
await app.close();
});

it('does not send the warning if the production is deactivated before it goes live', async () => {
const doc = makeProductionDoc();
mockGet.mockResolvedValue(doc);
let releaseStep2!: () => void;
const step2Gate = new Promise<void>((r) => { releaseStep2 = r; });
let step2Reached = false;
mockInsert.mockImplementation(async (d: Record<string, unknown>) => {
if (d['stromFlowId'] === 'flow-abc' && d['activationWarnings']) {
step2Reached = true;
await step2Gate;
}
return { rev: '2-bcd', ok: true, id: doc._id };
});
mockActivateStromFlow.mockResolvedValue(activationResultWithWarning());
mockStromFlowsGet.mockResolvedValue({ flow: { id: 'flow-abc', running: true, blocks: [] } });
mockDeactivateStromFlow.mockResolvedValue(undefined);

const app = await buildServer();
await app.inject({ method: 'POST', url: '/api/v1/productions/prod-test-1/activate' });
await vi.waitFor(() => expect(step2Reached).toBe(true));
await app.inject({ method: 'POST', url: '/api/v1/productions/prod-test-1/deactivate' });
releaseStep2();

await vi.waitFor(() => expect(mockDeactivateStromFlow).toHaveBeenCalledWith('flow-abc', expect.anything()));
const types = mockBroadcast.mock.calls.map((c) => (c[1] as { type: string }).type);
expect(types).toContain('PRODUCTION_DEACTIVATED');
expect(types).not.toContain('ERROR');
await app.close();
});

it('clears the previous activation warnings when the production is activated again', async () => {
const doc = makeProductionDoc({ status: 'ended', activationWarnings: [noAudioWarning] });
mockGet.mockResolvedValue(doc);
mockInsert.mockResolvedValue({ rev: '2-bcd', ok: true, id: doc._id });
mockActivateStromFlow.mockReturnValue(new Promise(() => {}));

const app = await buildServer();
await app.inject({ method: 'POST', url: '/api/v1/productions/prod-test-1/activate' });

const activating = mockInsert.mock.calls[0]![0] as Record<string, unknown>;
expect(activating['status']).toBe('activating');
expect(activating['activationWarnings']).toBeUndefined();
await app.close();
});

it('clears activation warnings when activation fails', async () => {
const doc = makeProductionDoc();
mockGet.mockImplementation(async () => mockInsert.mock.calls.at(-1)?.[0] ?? doc);
mockInsert.mockResolvedValue({ rev: '2-bcd', ok: true, id: doc._id });
mockActivateStromFlow.mockResolvedValue(activationResultWithWarning());
mockStromFlowsGet.mockRejectedValue(new Error('Strom down'));
mockDeactivateStromFlow.mockResolvedValue(undefined);

const app = await buildServer();
await app.inject({ method: 'POST', url: '/api/v1/productions/prod-test-1/activate' });

await vi.waitFor(() => {
const last = mockInsert.mock.calls.at(-1)?.[0] as Record<string, unknown>;
expect(last['status']).toBe('inactive');
expect(last['activationWarnings']).toBeUndefined();
});
await app.close();
});

it('returns 409 if production is already active', async () => {
const doc = makeProductionDoc({ status: 'active' });
mockGet.mockResolvedValue(doc);
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/flow-generator-encoders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ type Link = Record<string, unknown>;
const byName = (blocks: Block[], name: string) =>
blocks.find((b) => b['block_definition_id'] === 'builtin.videoenc' && b['name'] === name);

const feedFor = (links: Link[], blockId: string) =>
links.find((l) => l['to'] === `${blockId}:video_in`);
const feedFor = (links: Link[], blockId: string, pad = 'video_in') =>
links.find((l) => l['to'] === `${blockId}:${pad}`);

const whepOutput = 'whep' as const;
const recordingOutput = 'recording' as const;
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('flow-generator — viewer/program encoder split (#413)', () => {

// Recorder stays on the full-rate program encode.
const recorder = blocks.find((b) => b['block_definition_id'] === 'builtin.recorder')!;
expect(feedFor(links, recorder['id'] as string)!['from']).toBe(encPgmPad);
expect(feedFor(links, recorder['id'] as string, 'video_in_0')!['from']).toBe(encPgmPad);

// The dynamic WHEP viewer output is fed from the low-bitrate viewer encode.
const whep = blocks.find((b) => b['block_definition_id'] === 'builtin.whep_output' && b['name'] === 'Viewer WHEP')!;
Expand Down
62 changes: 59 additions & 3 deletions src/__tests__/recording-wiring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ vi.mock('../db/index.js', () => ({
getGraphicsDb: () => ({ get: vi.fn().mockRejectedValue(new Error('not found')) }),
}));

function makeStromClient() {
function makeStromClient(blockIds: string[] = ['builtin.recorder', 'builtin.audioenc']) {
const capturedFlows: Record<string, unknown>[] = [];
return {
blocks: {
list: vi.fn().mockResolvedValue({ blocks: blockIds.map((id) => ({ id })) }),
},
flows: {
create: vi.fn().mockImplementation((flow: Record<string, unknown>) => {
capturedFlows.push(flow);
Expand Down Expand Up @@ -88,12 +91,64 @@ describe('flow-generator — recorder wiring (#41)', () => {
'recordings/prod-rec-1',
);
expect(result.recorderOutputDir).toBe('recordings/prod-rec-1');
expect((recorder!['properties'] as Record<string, unknown>)['filename_prefix']).toBe('prod-rec-1');

// Recorder receives the PGM video feed and the main audio bus
const videoIn = links.find((l) => l['to'] === `${recId}:video_in`);
// Recorder receives the PGM video feed and the main audio bus, AAC-encoded
// because the recorder refuses raw audio
const videoIn = links.find((l) => l['to'] === `${recId}:video_in_0`);
const audioIn = links.find((l) => l['to'] === `${recId}:audio_in_0`);
expect(videoIn).toBeDefined();
expect(audioIn).toBeDefined();
const [encId, encPad] = (audioIn!['from'] as string).split(':');
expect(encPad).toBe('encoded_out');
const enc = blocks.find((b) => b['id'] === encId);
expect(enc?.['block_definition_id']).toBe('builtin.audioenc');
expect((enc!['properties'] as Record<string, unknown>)['codec']).toBe('aac');
const encIn = links.find((l) => l['to'] === `${encId}:audio_in`);
expect(encIn?.['from']).toMatch(/:main_out$/);
expect(result.warnings).toEqual([]);
});

it('records picture only, with a warning, when Strom has no builtin.audioenc', async () => {
const { activateStromFlow } = await import('../lib/flow-generator.js');
const strom = makeStromClient(['builtin.recorder']);
const production = makeProduction([{ sourceId: '__test1__', mixerInput: 'video_in_1' }]);

const result = await activateStromFlow(
production as never,
strom as never,
'http://localhost:7000',
[recordingOutput] as never,
);

const flow = strom.capturedFlows[0]!;
const blocks = flow['blocks'] as Array<Record<string, unknown>>;
const links = flow['links'] as Array<Record<string, unknown>>;
expect(blocks.find((b) => b['block_definition_id'] === 'builtin.audioenc')).toBeUndefined();
const recId = result.recorderBlockId!;
expect(links.find((l) => l['to'] === `${recId}:video_in_0`)).toBeDefined();
expect(links.find((l) => l['to'] === `${recId}:audio_in_0`)).toBeUndefined();
expect(result.warnings).toEqual([
expect.objectContaining({ type: 'recording-no-audio', message: expect.stringContaining('0.6.9') }),
]);
});

it('keeps the audio encoder when the block list cannot be read', async () => {
const { activateStromFlow } = await import('../lib/flow-generator.js');
const strom = makeStromClient();
strom.blocks.list.mockRejectedValue(new Error('Strom API error 503'));
const production = makeProduction([{ sourceId: '__test1__', mixerInput: 'video_in_1' }]);

const result = await activateStromFlow(
production as never,
strom as never,
'http://localhost:7000',
[recordingOutput] as never,
);

const blocks = strom.capturedFlows[0]!['blocks'] as Array<Record<string, unknown>>;
expect(blocks.find((b) => b['block_definition_id'] === 'builtin.audioenc')).toBeDefined();
expect(result.warnings).toEqual([]);
});

it('wires at most one recorder block even if two recording outputs are assigned', async () => {
Expand Down Expand Up @@ -124,6 +179,7 @@ describe('flow-generator — recorder wiring (#41)', () => {
const blocks = flow['blocks'] as Array<Record<string, unknown>>;
expect(blocks.find((b) => b['block_definition_id'] === 'builtin.recorder')).toBeUndefined();
expect(result.recorderBlockId).toBeUndefined();
expect(strom.blocks.list).not.toHaveBeenCalled();
});
});

Expand Down
1 change: 1 addition & 0 deletions src/__tests__/strom-public-url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ async function activate(): Promise<Record<string, unknown>> {
returnBuses: [],
returnWhepEntries: [{ mixerInput: 'video_in_1', endpointId: 'ret-ep' }],
mixerInputMap: {},
warnings: [],
});

const app = await buildServer();
Expand Down
30 changes: 30 additions & 0 deletions src/__tests__/ws-production-status-snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,33 @@ describe('WS connect snapshot — PRODUCTION_STATUS (spec §3)', () => {
expect(evt!.outputs).toEqual([{ id: 'out-1', status: 'healthy' }]);
});
});

describe('WS connect snapshot — activation warnings', () => {
const warning = { type: 'recording-no-audio', message: 'Recording "VOD" has no sound' };

it('sends each activation warning as an ERROR frame while the production is live', async () => {
mockGet.mockResolvedValue(makeProductionDoc({
status: 'active',
stromFlowId: 'flow-abc',
activationWarnings: [warning],
}));

const messages = await connectAndCollect('prod-ws-1');
expect(messages.filter((m) => m.type === 'ERROR')).toEqual([{ type: 'ERROR', error: warning.message }]);
});

it('sends no warning while the production is still activating, or stopped with a stale flow id', async () => {
for (const status of ['activating', 'inactive']) {
mockGet.mockResolvedValue(makeProductionDoc({ status, stromFlowId: 'flow-abc', activationWarnings: [warning] }));
const messages = await connectAndCollect('prod-ws-1');
expect(messages.filter((m) => m.type === 'ERROR')).toEqual([]);
}
});

it('sends no warning for a production that is not live', async () => {
mockGet.mockResolvedValue(makeProductionDoc({ status: 'ended', activationWarnings: [warning] }));

const messages = await connectAndCollect('prod-ws-1');
expect(messages.filter((m) => m.type === 'ERROR')).toEqual([]);
});
});
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const config = {
/**
* MinIO / S3 object storage for VOD recordings (epic #5, issue #41).
*
* Strom's recorder writes local files only ({media_path}/{output_dir}/{prefix}_%05d.{ext},
* Strom's recorder writes local files only ({media_path}/{output_dir}/{filename_prefix}_{timestamp}_%05d.{ext},
* backend/src/blocks/builtin/recorder.rs) — it has no native S3/MinIO sink. So open-live
* uploads the recorder's local segments to object storage after a production deactivates,
* fetching them via Strom's existing media download API (`GET /api/media/file/:path`).
Expand Down
5 changes: 5 additions & 0 deletions src/db/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,11 @@ export interface ProductionDoc {
intercomProductionId?: string;
/** Warnings accumulated when a referenced source/graphic/output was deleted while production was inactive */
deletionWarnings?: Array<{ type: 'source' | 'graphic' | 'output'; name: string }>;
/**
* Problems found while going on air that did not stop activation, such as a
* recording that will have no sound. Cleared on next activation.
*/
activationWarnings?: Array<{ type: 'recording-no-audio'; message: string }>;
/** Set when the idle watchdog auto-deactivated this production; cleared on next activation */
autoDeactivated?: boolean;
/**
Expand Down
Loading
Loading