mediascale-sdk 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.js CHANGED
@@ -1,2 +1,4 @@
1
1
  export { createClient } from "./client.js";
2
2
  export { FrameCompositor } from "./record-frame-compositor.js";
3
+ export { DEFAULT_RECORDING_FPS } from "./record.js";
4
+ export { DEFAULT_RTMP_FPS, DEFAULT_RTMP_BITRATE } from "./live.js";
package/src/live.js ADDED
@@ -0,0 +1,100 @@
1
+ import { CanvasRecorder, clampFps } from "./record.js";
2
+
3
+ /** Default live (RTMP) frame rate. Override with createClient({ rtmpFps }). */
4
+ export const DEFAULT_RTMP_FPS = 30;
5
+ /** Default live (RTMP) video bitrate in bps. Override with createClient({ rtmpBitrate }). */
6
+ export const DEFAULT_RTMP_BITRATE = 2_500_000;
7
+
8
+ /**
9
+ * Stage compositor for RTMP live streaming.
10
+ *
11
+ * Same layout as the recording (screen + up to six cameras, name pills, brand
12
+ * background, mixed audio), but with its own frame rate and no MediaRecorder,
13
+ * IndexedDB, or chunk upload. Its `videoTrack` / `audioTrack` are published to
14
+ * the origin as hidden `rtmp-video` (H264) / `rtmp-audio` (Opus) tracks.
15
+ */
16
+ export class LiveCompositor extends CanvasRecorder {
17
+ static supported() {
18
+ return typeof document !== "undefined"
19
+ && typeof HTMLCanvasElement !== "undefined"
20
+ && typeof HTMLCanvasElement.prototype.captureStream === "function"
21
+ && typeof AudioContext !== "undefined";
22
+ }
23
+
24
+ constructor({ fps = DEFAULT_RTMP_FPS, selfName, canvasBackground, onFailure } = {}) {
25
+ const id = `live-${Math.random().toString(36).slice(2, 10)}`;
26
+ super({
27
+ webinarId: id,
28
+ webinarName: id,
29
+ recordingId: id,
30
+ endpoint: "",
31
+ token: "",
32
+ selfName,
33
+ canvasBackground,
34
+ onFailure,
35
+ fps: clampFps(fps, DEFAULT_RTMP_FPS),
36
+ });
37
+ this.eventPrefix = "live";
38
+ // RTMP platforms expect a constant frame rate even when the stage is static.
39
+ this.steadyFrames = true;
40
+ }
41
+
42
+ get videoTrack() {
43
+ return this.capture || null;
44
+ }
45
+
46
+ get audioTrack() {
47
+ return this.dest?.stream.getAudioTracks()[0] || null;
48
+ }
49
+
50
+ // No local chunk storage or upload for live output.
51
+ async dropOtherWebinars() {}
52
+
53
+ async flushStored() {}
54
+
55
+ async store() {}
56
+
57
+ pump() {
58
+ return Promise.resolve();
59
+ }
60
+
61
+ async upload() {
62
+ return true;
63
+ }
64
+
65
+ kickFinalize() {}
66
+
67
+ async finalize() {}
68
+
69
+ async beginCapture() {
70
+ if (this.finishing || this.capturing || !this.prepared) return;
71
+ this.capturing = true;
72
+ this.compositor?.setActive(true);
73
+ this.setDrawActive?.(true);
74
+ for (const video of this.videos.values()) void video.play().catch(() => {});
75
+ this.onCaptureChange(true);
76
+ }
77
+
78
+ async pauseCapture() {
79
+ if (!this.capturing) return;
80
+ this.capturing = false;
81
+ this.compositor?.setActive(false);
82
+ this.setDrawActive?.(false);
83
+ this.onCaptureChange(false);
84
+ }
85
+
86
+ async finish() {
87
+ if (this.finishing) return;
88
+ this.finishing = true;
89
+ this.wanted = false;
90
+ this.capturing = false;
91
+ this.compositor?.setActive(false);
92
+ this.setDrawActive?.(false);
93
+ this.release?.();
94
+ this.release = undefined;
95
+ }
96
+
97
+ async handoff() {
98
+ await this.finish();
99
+ }
100
+ }
@@ -30,7 +30,7 @@ function bounded(promise, timeoutMs) {
30
30
  }
31
31
 
32
32
  /** Probe real frame transfer before selecting the background-capable compositor. */
33
- export async function createWorkerCompositor({ width, height, fps, background = "#2563eb", onError = () => {} }) {
33
+ export async function createWorkerCompositor({ width, height, fps, background = "#0A0036", steady = false, onError = () => {} }) {
34
34
  let worker, output, probeInput, probeClone, outputProbe, reader, inputWriter, probeFrame;
35
35
  const deadline = Date.now() + 3000;
36
36
  const remaining = () => Math.max(1, deadline - Date.now());
@@ -40,7 +40,7 @@ export async function createWorkerCompositor({ width, height, fps, background =
40
40
  worker = new Worker(new URL("./record-worker.js", import.meta.url), { type: "module" });
41
41
  const { standard } = await ask({ type: "capabilities" });
42
42
  if (standard) {
43
- const ready = await ask({ type: "init", standard: true, width, height, fps, background });
43
+ const ready = await ask({ type: "init", standard: true, width, height, fps, background, steady });
44
44
  output = ready.track;
45
45
  const canvas = document.createElement("canvas");
46
46
  canvas.width = canvas.height = 2;
@@ -52,7 +52,7 @@ export async function createWorkerCompositor({ width, height, fps, background =
52
52
  } else {
53
53
  if (typeof MediaStreamTrackProcessor !== "function" || typeof MediaStreamTrackGenerator !== "function") throw new Error("Native recording track processor/generator are unavailable");
54
54
  output = new MediaStreamTrackGenerator({ kind: "video" });
55
- await ask({ type: "init", width, height, fps, background, writable: output.writable }, [output.writable]);
55
+ await ask({ type: "init", width, height, fps, background, steady, writable: output.writable }, [output.writable]);
56
56
  outputProbe = output.clone();
57
57
  reader = new MediaStreamTrackProcessor({ track: outputProbe, maxBufferSize: 1 }).readable.getReader();
58
58
  const received = reader.read();
@@ -83,16 +83,29 @@ export async function createWorkerCompositor({ width, height, fps, background =
83
83
  const keys = new Set(desired.map((source) => source.key));
84
84
  for (const [key, entry] of owned) if (!keys.has(key)) { release(entry); owned.delete(key); }
85
85
  const transfer = [];
86
- const updates = desired.map(({ key, track, rect, crop }) => {
86
+ const updates = desired.map((source) => {
87
+ const { key, track, rect, crop, label, accent, radius, muted, fit, fillStyle } = source;
88
+ const chrome = {
89
+ key,
90
+ rect,
91
+ crop: crop || null,
92
+ label: label || "",
93
+ accent: Boolean(accent),
94
+ radius: radius == null ? 0 : radius,
95
+ muted: Boolean(muted),
96
+ fit: fit === "contain" ? "contain" : "cover",
97
+ ...(fillStyle ? { fillStyle } : {}),
98
+ };
87
99
  const previous = owned.get(key);
88
- if (previous?.original === track) return { key, rect, crop: crop || null };
100
+ if (previous?.original === track) return chrome;
89
101
  if (previous) release(previous);
102
+ if (!track) return chrome;
90
103
  const clone = track.clone();
91
104
  owned.set(key, { clone, original: track });
92
- if (standard) { transfer.push(clone); return { key, rect, crop: crop || null, track: clone }; }
105
+ if (standard) { transfer.push(clone); return { ...chrome, track: clone }; }
93
106
  const readable = new MediaStreamTrackProcessor({ track: clone, maxBufferSize: 1 }).readable;
94
107
  transfer.push(readable);
95
- return { key, rect, crop: crop || null, readable };
108
+ return { ...chrome, readable };
96
109
  });
97
110
  worker.postMessage({ type: "sources", sources: updates }, transfer);
98
111
  };
@@ -47,11 +47,15 @@ function softBlob(ctx, cx, cy, rx, ry, color, alpha) {
47
47
  ctx.fill();
48
48
  }
49
49
 
50
+ /** Recording stage backdrop — solid dark navy from the design (no wave chrome). */
51
+ export const STAGE_BACKGROUND = "#0A0036";
52
+
50
53
  /**
51
- * Brand canvas backdrop: deep radial field + soft corner waves from `color`.
54
+ * Canvas backdrop gradient derived from the parent-configured CSS color
55
+ * (`createClient({ recordingCanvasBackground })`).
52
56
  */
53
- export function fillRadialBackground(ctx, x, y, w, h, color = "#2563eb") {
54
- const base = parseCssColor(color) || { r: 37, g: 99, b: 235 };
57
+ export function fillRadialBackground(ctx, x, y, w, h, color = STAGE_BACKGROUND) {
58
+ const base = parseCssColor(color) || { r: 10, g: 0, b: 54 };
55
59
  const deep = shadeRgb(base, 0.28);
56
60
  const mid = shadeRgb(base, 0.72);
57
61
  const glow = shadeRgb(base, 1.35);
@@ -68,12 +72,60 @@ export function fillRadialBackground(ctx, x, y, w, h, color = "#2563eb") {
68
72
  ctx.fillStyle = field;
69
73
  ctx.fillRect(x, y, w, h);
70
74
 
71
- // Soft wave-like glows (top-left / bottom-right), matching the reference stage look.
72
75
  softBlob(ctx, x + w * 0.18, y + h * 0.1, w * 0.42, h * 0.32, glow, 0.38);
73
76
  softBlob(ctx, x + w * 0.82, y + h * 0.88, w * 0.4, h * 0.3, glow, 0.3);
74
77
  softBlob(ctx, x + w * 0.7, y + h * 0.18, w * 0.28, h * 0.22, mid, 0.22);
75
78
  }
76
79
 
80
+ /** Stable per-name camera-off gradients (same name → same color). */
81
+ export const TILE_TONES = [
82
+ { mid: { r: 196, g: 48, b: 168 }, edge: { r: 58, g: 10, b: 70 } }, // magenta
83
+ { mid: { r: 110, g: 95, b: 200 }, edge: { r: 30, g: 24, b: 80 } }, // indigo
84
+ { mid: { r: 180, g: 165, b: 70 }, edge: { r: 55, g: 50, b: 18 } }, // olive
85
+ { mid: { r: 170, g: 45, b: 70 }, edge: { r: 55, g: 12, b: 28 } }, // burgundy
86
+ { mid: { r: 50, g: 140, b: 150 }, edge: { r: 15, g: 45, b: 55 } }, // teal
87
+ { mid: { r: 200, g: 110, b: 50 }, edge: { r: 60, g: 30, b: 15 } }, // amber
88
+ ];
89
+
90
+ export function toneForName(name) {
91
+ const s = String(name || "").trim().toLowerCase();
92
+ let hash = 0;
93
+ for (let i = 0; i < s.length; i += 1) hash = (hash * 31 + s.charCodeAt(i)) >>> 0;
94
+ return TILE_TONES[hash % TILE_TONES.length];
95
+ }
96
+
97
+ export function fillNameTone(ctx, x, y, w, h, name) {
98
+ const tone = toneForName(name) || TILE_TONES[0];
99
+ const mid = tone.mid || TILE_TONES[0].mid;
100
+ const edge = tone.edge || TILE_TONES[0].edge;
101
+ const cx = x + w / 2;
102
+ const cy = y + h / 2;
103
+ const span = Math.max(w, h) * 0.72;
104
+ const field = ctx.createRadialGradient(cx, cy, 0, cx, cy, span);
105
+ field.addColorStop(0, cssRgb(mid));
106
+ field.addColorStop(0.55, cssRgb(shadeRgb(mid, 0.72)));
107
+ field.addColorStop(1, cssRgb(edge));
108
+ ctx.fillStyle = field;
109
+ ctx.fillRect(x, y, w, h);
110
+ }
111
+
112
+ export function drawInitialAvatar(ctx, x, y, w, h, name) {
113
+ const cx = Math.round(x + w / 2);
114
+ const cy = Math.round(y + h / 2);
115
+ const diameter = Math.round(Math.min(Math.max(Math.min(w, h) * 0.22, 28), 72));
116
+ const letter = String(name || "?").trim();
117
+ const ch = letter ? letter[0].toUpperCase() : "?";
118
+ ctx.beginPath();
119
+ ctx.arc(cx, cy, diameter / 2, 0, Math.PI * 2);
120
+ ctx.fillStyle = "rgba(255, 255, 255, 0.22)";
121
+ ctx.fill();
122
+ ctx.fillStyle = "#ffffff";
123
+ ctx.font = `600 ${Math.round(diameter * 0.42)}px "Segoe UI", Roboto, Helvetica, Arial, sans-serif`;
124
+ ctx.textAlign = "center";
125
+ ctx.textBaseline = "middle";
126
+ ctx.fillText(ch, cx, cy + 1);
127
+ }
128
+
77
129
  export function roundedRectPath(ctx, x, y, w, h, radius) {
78
130
  const r = Math.max(0, Math.min(radius, w / 2, h / 2));
79
131
  ctx.beginPath();
@@ -85,45 +137,47 @@ export function roundedRectPath(ctx, x, y, w, h, radius) {
85
137
  ctx.closePath();
86
138
  }
87
139
 
88
- /** Bottom-left name pill — text only (no mic / signal icons). */
89
- export function drawNamePill(ctx, x, y, w, h, label) {
140
+ /** Neon magenta presenter ring — matches the live stage / webinar UI. */
141
+ export const PRESENTER_ACCENT = "#e879f9";
142
+
143
+ /**
144
+ * Bottom-left name label (design): plain white text + soft scrim. No mic / signal icons.
145
+ */
146
+ export function drawNamePill(ctx, x, y, w, h, label, _opts = {}) {
90
147
  const text = String(label || "").trim().slice(0, 40);
91
148
  if (!text) return;
92
149
  const padX = Math.max(10, Math.round(Math.min(w, h) * 0.04));
93
150
  const padY = Math.max(8, Math.round(Math.min(w, h) * 0.035));
94
- const namePx = Math.round(Math.min(Math.max(Math.min(w, h) * 0.085, 11), 16));
151
+ const namePx = Math.round(Math.min(Math.max(Math.min(w, h) * 0.075, 11), 16));
152
+ const scrimH = Math.max(padY * 2 + namePx, Math.round(h * 0.22));
95
153
  ctx.save();
96
- ctx.font = `600 ${namePx}px "Segoe UI", Roboto, Helvetica, Arial, sans-serif`;
154
+ const scrim = ctx.createLinearGradient(x, y + h - scrimH, x, y + h);
155
+ scrim.addColorStop(0, "rgba(0, 0, 0, 0)");
156
+ scrim.addColorStop(0.45, "rgba(0, 0, 0, 0.25)");
157
+ scrim.addColorStop(1, "rgba(0, 0, 0, 0.55)");
158
+ ctx.fillStyle = scrim;
159
+ ctx.fillRect(x, y + h - scrimH, w, scrimH);
160
+ ctx.font = `500 ${namePx}px "Segoe UI", Roboto, Helvetica, Arial, sans-serif`;
97
161
  ctx.textAlign = "left";
98
- ctx.textBaseline = "middle";
99
- const textW = ctx.measureText(text).width;
100
- const pillH = namePx + padY;
101
- const pillW = Math.min(w - padX * 2, textW + padX * 1.6);
102
- const pillX = x + padX;
103
- const pillY = y + h - padY - pillH;
104
- const radius = pillH / 2;
105
- roundedRectPath(ctx, pillX, pillY, pillW, pillH, radius);
106
- ctx.fillStyle = "rgba(15, 23, 42, 0.72)";
107
- ctx.fill();
162
+ ctx.textBaseline = "bottom";
108
163
  ctx.fillStyle = "#ffffff";
109
- ctx.fillText(text, pillX + padX * 0.75, pillY + pillH / 2 + 0.5, pillW - padX * 1.2);
164
+ ctx.shadowColor = "rgba(0, 0, 0, 0.45)";
165
+ ctx.shadowBlur = 3;
166
+ ctx.fillText(text, x + padX, y + h - padY, Math.max(8, w - padX * 2));
110
167
  ctx.restore();
111
168
  }
112
169
 
113
- export function strokeTileBorder(ctx, x, y, w, h, radius, { accent = false, accentColor = "#a855f7" } = {}) {
114
- if (!(radius > 0) && !accent) return;
115
- const base = parseCssColor(accentColor) || { r: 168, g: 85, b: 247 };
170
+ export function strokeTileBorder(ctx, x, y, w, h, radius, { accent = false, accentColor = PRESENTER_ACCENT } = {}) {
171
+ // Recording layout is flush (no borders). Accent only affects the name pill.
172
+ if (!(radius > 0)) return;
173
+ const base = parseCssColor(accentColor) || { r: 232, g: 121, b: 249 };
116
174
  ctx.save();
117
- if (radius > 0) roundedRectPath(ctx, x + 0.5, y + 0.5, w - 1, h - 1, radius);
118
- else {
119
- ctx.beginPath();
120
- ctx.rect(x + 0.5, y + 0.5, w - 1, h - 1);
121
- }
175
+ roundedRectPath(ctx, x + 0.5, y + 0.5, w - 1, h - 1, radius);
122
176
  if (accent) {
123
- ctx.strokeStyle = cssRgb(shadeRgb(base, 1.15));
177
+ ctx.strokeStyle = cssRgb(shadeRgb(base, 1.05));
124
178
  ctx.lineWidth = 3;
125
- ctx.shadowColor = cssRgb(base, 0.85);
126
- ctx.shadowBlur = 10;
179
+ ctx.shadowColor = cssRgb(base, 0.95);
180
+ ctx.shadowBlur = 14;
127
181
  } else {
128
182
  ctx.strokeStyle = "rgba(255, 255, 255, 0.45)";
129
183
  ctx.lineWidth = 1.5;
@@ -134,8 +188,9 @@ export function strokeTileBorder(ctx, x, y, w, h, radius, { accent = false, acce
134
188
  }
135
189
 
136
190
  /**
137
- * Draw a video/image source into a rounded tile with border + name pill.
138
- * `source` may be an HTMLVideoElement or VideoFrame-like canvas image source.
191
+ * Draw a video/image source into a rounded tile + bottom-left name (no mic icons).
192
+ * `fit: "cover"` fills the rect (cameras). `fit: "contain"` letterboxes screenshare.
193
+ * Without a live source, paints the per-name camera-off gradient + initial avatar.
139
194
  */
140
195
  export function paintRoundedTile(ctx, {
141
196
  source,
@@ -146,20 +201,33 @@ export function paintRoundedTile(ctx, {
146
201
  sh,
147
202
  label = "",
148
203
  accent = false,
149
- accentColor = "#a855f7",
150
- radius = 14,
151
- fillStyle = "#0f172a",
204
+ accentColor = PRESENTER_ACCENT,
205
+ radius = 0,
206
+ fillStyle = STAGE_BACKGROUND,
207
+ muted = false,
208
+ fit = "cover",
209
+ placeholder = false,
152
210
  }) {
153
211
  const { x, y, w, h } = rect;
154
212
  ctx.save();
155
213
  if (radius > 0) {
156
214
  roundedRectPath(ctx, x, y, w, h, radius);
157
215
  ctx.clip();
216
+ } else {
217
+ ctx.beginPath();
218
+ ctx.rect(x, y, w, h);
219
+ ctx.clip();
158
220
  }
159
- ctx.fillStyle = fillStyle;
160
- ctx.fillRect(x, y, w, h);
161
- if (source && sw > 0 && sh > 0) {
162
- const scale = Math.min(w / sw, h / sh);
221
+ const hasVideo = Boolean(source && sw > 0 && sh > 0);
222
+ if (!hasVideo || placeholder) {
223
+ fillNameTone(ctx, x, y, w, h, label);
224
+ drawInitialAvatar(ctx, x, y, w, h, label);
225
+ } else {
226
+ ctx.fillStyle = fillStyle;
227
+ ctx.fillRect(x, y, w, h);
228
+ const scale = fit === "contain"
229
+ ? Math.min(w / sw, h / sh)
230
+ : Math.max(w / sw, h / sh);
163
231
  const dw = sw * scale;
164
232
  const dh = sh * scale;
165
233
  const prev = ctx.imageSmoothingEnabled;
@@ -168,21 +236,22 @@ export function paintRoundedTile(ctx, {
168
236
  ctx.imageSmoothingEnabled = prev;
169
237
  }
170
238
  ctx.restore();
171
- if (radius > 0) strokeTileBorder(ctx, x, y, w, h, radius, { accent, accentColor });
172
- if (label) drawNamePill(ctx, x, y, w, h, label);
239
+ if (label) drawNamePill(ctx, x, y, w, h, label, { presenter: accent, muted });
173
240
  }
174
241
 
175
242
  /** Owns at most one input frame per source and one output write. */
176
243
  export class FrameCompositor {
177
244
  constructor({ canvas, ctx = canvas.getContext("2d"), writer, fps = 15,
178
- background = "#2563eb",
245
+ background = STAGE_BACKGROUND, steady = false,
179
246
  now = () => performance.now(), makeFrame = (surface, init) => new VideoFrame(surface, init),
180
247
  onError = () => {} }) {
181
248
  this.canvas = canvas;
182
249
  this.ctx = ctx;
183
250
  this.writer = writer;
184
251
  this.interval = 1000 / fps;
185
- this.background = String(background || "").trim() || "#2563eb";
252
+ /** Live output: emit every interval even when nothing changed (encoders need a steady rate). */
253
+ this.steady = Boolean(steady);
254
+ this.background = String(background || "").trim() || STAGE_BACKGROUND;
186
255
  this.now = now;
187
256
  this.makeFrame = makeFrame;
188
257
  this.onError = onError;
@@ -226,28 +295,33 @@ export class FrameCompositor {
226
295
 
227
296
  flush() {
228
297
  const now = this.now();
229
- if (!this.active || !this.dirty || this.writing || now - this.lastDraw < this.interval) return;
298
+ if (!this.active || (!this.dirty && !this.steady) || this.writing || now - this.lastDraw < this.interval) return;
230
299
  fillRadialBackground(this.ctx, 0, 0, this.canvas.width, this.canvas.height, this.background);
231
300
  for (const source of this.sources) {
232
- const { key, rect, crop, label, accent, radius } = source;
301
+ const { key, rect, crop, label, accent, radius, muted, fit, fillStyle, placeholder } = source;
233
302
  const frame = this.frames.get(key);
234
303
  if (!rect) continue;
235
- const tileRadius = radius == null ? 14 : radius;
304
+ const tileRadius = radius == null ? 0 : radius;
305
+ const chrome = {
306
+ label: label || "",
307
+ accent: Boolean(accent),
308
+ accentColor: PRESENTER_ACCENT,
309
+ radius: tileRadius,
310
+ muted: Boolean(muted),
311
+ fillStyle: fillStyle || STAGE_BACKGROUND,
312
+ fit: fit === "contain" ? "contain" : "cover",
313
+ placeholder: Boolean(placeholder),
314
+ };
236
315
  if (!frame) {
237
- // Still show the name pill while the first video frame is arriving.
238
- if (label) {
239
- paintRoundedTile(this.ctx, {
240
- source: null,
241
- rect,
242
- sw: 0,
243
- sh: 0,
244
- label,
245
- accent: Boolean(accent),
246
- accentColor: this.background,
247
- radius: tileRadius,
248
- fillStyle: "#0f172a",
249
- });
250
- }
316
+ // Camera-off / waiting: gradient + initial + name.
317
+ paintRoundedTile(this.ctx, {
318
+ source: null,
319
+ rect,
320
+ sw: 0,
321
+ sh: 0,
322
+ ...chrome,
323
+ placeholder: true,
324
+ });
251
325
  continue;
252
326
  }
253
327
  const width = frame.displayWidth || frame.codedWidth || rect.w;
@@ -271,11 +345,7 @@ export class FrameCompositor {
271
345
  sy,
272
346
  sw,
273
347
  sh,
274
- label: label || "",
275
- accent: Boolean(accent),
276
- accentColor: this.background,
277
- radius: tileRadius,
278
- fillStyle: "#0f172a",
348
+ ...chrome,
279
349
  });
280
350
  }
281
351
  this.timestamp = Math.max(this.timestamp + 1, Math.round((now - this.startedAt) * 1000));
@@ -46,7 +46,7 @@ self.onmessage = async ({ data }) => {
46
46
  track = generator.track;
47
47
  } else writer = data.writable.getWriter();
48
48
  const canvas = new OffscreenCanvas(data.width, data.height);
49
- compositor = new FrameCompositor({ canvas, writer, fps: data.fps, background: data.background, onError: error });
49
+ compositor = new FrameCompositor({ canvas, writer, fps: data.fps, background: data.background, steady: data.steady, onError: error });
50
50
  // Native input frames drive rendering. This tick only flushes a final dirty frame.
51
51
  tick = setInterval(() => compositor.flush(), Math.round(1000 / data.fps));
52
52
  postMessage({ requestId: data.requestId, track }, track ? [track] : []);
@@ -69,7 +69,17 @@ self.onmessage = async ({ data }) => {
69
69
  } else if (data.type === "sources") {
70
70
  const keys = new Set(data.sources.map((source) => source.key));
71
71
  for (const key of readers.keys()) if (!keys.has(key)) remove(key);
72
- compositor.setSources(data.sources.map(({ key, rect, crop }) => ({ key, rect, crop: crop || null })));
72
+ compositor.setSources(data.sources.map(({ key, rect, crop, label, accent, radius, muted, fit, fillStyle }) => ({
73
+ key,
74
+ rect,
75
+ crop: crop || null,
76
+ label: label || "",
77
+ accent: Boolean(accent),
78
+ radius: radius == null ? 0 : radius,
79
+ muted: Boolean(muted),
80
+ fit: fit === "contain" ? "contain" : "cover",
81
+ ...(fillStyle ? { fillStyle } : {}),
82
+ })));
73
83
  for (const source of data.sources) {
74
84
  if (!source.readable && !source.track) continue;
75
85
  remove(source.key);