oficina / meet Public

Clone
git clone https://amadan.net/oficina/meet

Plain git — no account needed to clone.

Download

Download this file

1// syntheticMedia is an init script, used only when CALLS_SYNTHETIC_MEDIA
2// is set: for a machine where Chromium's fake devices cannot be used.
3// Chromium asks macOS for camera and microphone access even for them, on
4// behalf of whatever launched it, and when that process has never been
5// granted it (TCC "not determined") nobody can answer and getUserMedia
6// never settles — every scenario then stops at "Connecting to the call."
7// (2026-10-05, from an agent's shell). This draws the camera and the
8// screen on canvases instead (a head and shoulders on a gradient, moving;
9// a 16:10 document) and makes the microphone a quiet tone. Scenarios that
10// assert on Chromium's own fake device names do not hold under it: it is
11// a stand-in, said so in the run, never the gate's normal way.
12export const syntheticMedia = () => {
13 const md = navigator.mediaDevices;
14 if (!md) return;
15 const drawn = (w, h, draw) => {
16 const c = document.createElement('canvas');
17 c.width = w;
18 c.height = h;
19 const g = c.getContext('2d');
20 let t = 0;
21 draw(g, w, h, 0);
22 setInterval(() => draw(g, w, h, ++t), 50);
23 return c.captureStream(20).getVideoTracks()[0];
24 };
25 const camera = () => drawn(640, 360, (g, w, h, t) => {
26 const sky = g.createLinearGradient(0, 0, w, h);
27 sky.addColorStop(0, '#6d8fb3');
28 sky.addColorStop(1, '#2f3d2a');
29 g.fillStyle = sky;
30 g.fillRect(0, 0, w, h);
31 g.fillStyle = '#c99a78';
32 g.beginPath(); g.ellipse(w / 2, h * 0.36, w * 0.09, h * 0.2, 0, 0, Math.PI * 2); g.fill();
33 g.fillStyle = '#7a3b2e';
34 g.beginPath(); g.ellipse(w / 2, h * 1.02, w * 0.24, h * 0.42, 0, 0, Math.PI * 2); g.fill();
35 g.fillStyle = '#ffffff';
36 g.fillRect((t * 7) % w, h - 8, 40, 4);
37 });
38 const screen = () => drawn(1280, 800, (g, w, h, t) => {
39 g.fillStyle = '#f4f1ea';
40 g.fillRect(0, 0, w, h);
41 g.fillStyle = '#1f6f8b';
42 g.fillRect(0, 0, w, 48);
43 g.fillStyle = '#c0392b';
44 g.fillRect(w - 160, h - 120, 120, 80);
45 g.fillStyle = '#333';
46 for (let y = 90; y < h - 40; y += 28) g.fillRect(60, y, w - 120 - ((y * 37) % 300), 10);
47 g.fillStyle = '#f39c12';
48 g.fillRect((t * 9) % w, 56, 30, 30);
49 });
50 const tone = () => {
51 const ac = new AudioContext();
52 const o = ac.createOscillator();
53 const gain = ac.createGain();
54 gain.gain.value = 0.02;
55 const out = ac.createMediaStreamDestination();
56 o.connect(gain).connect(out);
57 o.start();
58 return out.stream.getAudioTracks()[0];
59 };
60 md.getUserMedia = async (c = {}) => {
61 const tracks = [];
62 if (c.audio) tracks.push(tone());
63 if (c.video) tracks.push(camera());
64 return new MediaStream(tracks);
65 };
66 md.getDisplayMedia = async () => new MediaStream([screen()]);
67};
68