ontrackd 0.14.0 → 0.15.0
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/dist/core/attachmentTypes.d.ts +4 -1
- package/dist/core/attachmentTypes.js +25 -4
- package/dist/core/attachmentTypes.js.map +1 -1
- package/dist/core/feedbackTypes.d.ts +4 -1
- package/dist/core/untrusted.js +3 -2
- package/dist/core/untrusted.js.map +1 -1
- package/dist/integration/middleware.js +11 -0
- package/dist/integration/middleware.js.map +1 -1
- package/dist/overlay/api.d.ts +9 -1
- package/dist/overlay/api.js +10 -2
- package/dist/overlay/api.js.map +1 -1
- package/dist/overlay/camera.d.ts +130 -0
- package/dist/overlay/camera.js +388 -0
- package/dist/overlay/camera.js.map +1 -0
- package/dist/overlay/cameraEffects.d.ts +10 -0
- package/dist/overlay/cameraEffects.js +240 -0
- package/dist/overlay/cameraEffects.js.map +1 -0
- package/dist/overlay/cameraPanel.d.ts +39 -0
- package/dist/overlay/cameraPanel.js +275 -0
- package/dist/overlay/cameraPanel.js.map +1 -0
- package/dist/overlay/cameraPlayback.d.ts +75 -0
- package/dist/overlay/cameraPlayback.js +291 -0
- package/dist/overlay/cameraPlayback.js.map +1 -0
- package/dist/overlay/directReviewer.d.ts +10 -1
- package/dist/overlay/directReviewer.js +22 -9
- package/dist/overlay/directReviewer.js.map +1 -1
- package/dist/overlay/effects/NOTICE.md +10 -0
- package/dist/overlay/effects/selfie_segmenter.tflite +0 -0
- package/dist/overlay/effects/vision_wasm_internal.js +9155 -0
- package/dist/overlay/effects/vision_wasm_internal.wasm +0 -0
- package/dist/overlay/icons.js +8 -1
- package/dist/overlay/icons.js.map +1 -1
- package/dist/overlay/recorder.d.ts +3 -0
- package/dist/overlay/recorder.js +27 -3
- package/dist/overlay/recorder.js.map +1 -1
- package/dist/overlay/recordingEditor.js +6 -5
- package/dist/overlay/recordingEditor.js.map +1 -1
- package/dist/overlay/recordingPlayer.d.ts +11 -1
- package/dist/overlay/recordingPlayer.js +113 -45
- package/dist/overlay/recordingPlayer.js.map +1 -1
- package/dist/overlay/recordingPlayerShell.d.ts +19 -0
- package/dist/overlay/recordingPlayerShell.js +51 -0
- package/dist/overlay/recordingPlayerShell.js.map +1 -0
- package/dist/overlay/runtime.js +324 -31
- package/dist/overlay/runtime.js.map +1 -1
- package/dist/overlay/storageFull.d.ts +16 -0
- package/dist/overlay/storageFull.js +39 -0
- package/dist/overlay/storageFull.js.map +1 -0
- package/dist/overlay/styles.js +88 -20
- package/dist/overlay/styles.js.map +1 -1
- package/dist/overlay/tasks-vision.js +3 -0
- package/dist/overlay/upload.d.ts +2 -2
- package/dist/overlay/upload.js +4 -2
- package/dist/overlay/upload.js.map +1 -1
- package/dist/sidecar/commentFiles.js +4 -2
- package/dist/sidecar/commentFiles.js.map +1 -1
- package/dist/storage/localAttachments.js +1 -1
- package/dist/storage/localAttachments.js.map +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera and voice on a page recording (issue #127). The reviewer's face (a round bubble) and voice are recorded by
|
|
3
|
+
* MediaRecorder beside the rrweb recording and uploaded as a second, paired file. Nothing here starts by itself: the
|
|
4
|
+
* browser is only asked for the camera or the microphone when the panel opens and a switch is turned on, or when a
|
|
5
|
+
* recording starts with choices the reviewer saved.
|
|
6
|
+
*/
|
|
7
|
+
/** Tolerant: an older Worker, a missing or malformed field is "no camera", never an error. */
|
|
8
|
+
export function cameraLimitOf(body) {
|
|
9
|
+
const found = body?.features?.camera;
|
|
10
|
+
if (!found || typeof found !== 'object' || typeof found.available !== 'boolean' || typeof found.bytes !== 'number' || !Number.isFinite(found.bytes))
|
|
11
|
+
return null;
|
|
12
|
+
return { available: found.available, bytes: found.bytes };
|
|
13
|
+
}
|
|
14
|
+
/** A touch screen has no camera bubble in release 1. */
|
|
15
|
+
export function touchScreen() {
|
|
16
|
+
return typeof window.matchMedia === 'function' && window.matchMedia('(pointer: coarse)').matches;
|
|
17
|
+
}
|
|
18
|
+
export const CORNERS = ['bottom-left', 'bottom-right', 'top-left', 'top-right'];
|
|
19
|
+
export const BACKGROUNDS = ['none', 'blur', 'office'];
|
|
20
|
+
const PREFS_KEY = 'feedback:camera';
|
|
21
|
+
export function defaultPrefs() {
|
|
22
|
+
return { camera: false, mic: false, cameraId: '', micId: '', corner: 'bottom-left', at: null, background: 'none' };
|
|
23
|
+
}
|
|
24
|
+
const fraction = (value) => typeof value === 'number' && Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : null;
|
|
25
|
+
export function loadCameraPrefs() {
|
|
26
|
+
const prefs = defaultPrefs();
|
|
27
|
+
try {
|
|
28
|
+
const saved = JSON.parse(localStorage.getItem(PREFS_KEY) ?? 'null');
|
|
29
|
+
if (!saved || typeof saved !== 'object')
|
|
30
|
+
return prefs;
|
|
31
|
+
prefs.camera = saved.camera === true;
|
|
32
|
+
prefs.mic = saved.mic === true;
|
|
33
|
+
if (typeof saved.cameraId === 'string')
|
|
34
|
+
prefs.cameraId = saved.cameraId.slice(0, 300);
|
|
35
|
+
if (typeof saved.micId === 'string')
|
|
36
|
+
prefs.micId = saved.micId.slice(0, 300);
|
|
37
|
+
if (CORNERS.includes(saved.corner))
|
|
38
|
+
prefs.corner = saved.corner;
|
|
39
|
+
// Older saved choices have no background: none, so nothing is loaded until it is picked.
|
|
40
|
+
if (BACKGROUNDS.includes(saved.background))
|
|
41
|
+
prefs.background = saved.background;
|
|
42
|
+
const at = saved.at;
|
|
43
|
+
const x = fraction(at?.x), y = fraction(at?.y);
|
|
44
|
+
if (x !== null && y !== null)
|
|
45
|
+
prefs.at = { x, y };
|
|
46
|
+
}
|
|
47
|
+
catch { /* Private mode or a broken value: the defaults. */ }
|
|
48
|
+
return prefs;
|
|
49
|
+
}
|
|
50
|
+
export function saveCameraPrefs(prefs) {
|
|
51
|
+
try {
|
|
52
|
+
localStorage.setItem(PREFS_KEY, JSON.stringify(prefs));
|
|
53
|
+
}
|
|
54
|
+
catch { /* Not saved: the next recording starts from the defaults. */ }
|
|
55
|
+
}
|
|
56
|
+
const VIDEO_MIMES = [
|
|
57
|
+
{ mime: 'video/mp4;codecs=avc1,mp4a', type: 'video/mp4', extension: 'mp4' },
|
|
58
|
+
{ mime: 'video/mp4', type: 'video/mp4', extension: 'mp4' },
|
|
59
|
+
{ mime: 'video/webm;codecs=vp9,opus', type: 'video/webm', extension: 'webm' },
|
|
60
|
+
{ mime: 'video/webm', type: 'video/webm', extension: 'webm' },
|
|
61
|
+
];
|
|
62
|
+
const AUDIO_MIMES = [
|
|
63
|
+
{ mime: 'audio/mp4', type: 'audio/mp4', extension: 'm4a' },
|
|
64
|
+
{ mime: 'audio/webm;codecs=opus', type: 'audio/webm', extension: 'weba' },
|
|
65
|
+
{ mime: 'audio/webm', type: 'audio/webm', extension: 'weba' },
|
|
66
|
+
];
|
|
67
|
+
/** MP4 where the browser records it (Chrome, Safari), WebM otherwise (Firefox); audio only has its own pair. */
|
|
68
|
+
export function pickCameraMime(video, supported = (type) => typeof MediaRecorder !== 'undefined' && MediaRecorder.isTypeSupported(type)) {
|
|
69
|
+
return (video ? VIDEO_MIMES : AUDIO_MIMES).find((candidate) => supported(candidate.mime)) ?? null;
|
|
70
|
+
}
|
|
71
|
+
// ---- Getting the media -----------------------------------------------------------------------------------------
|
|
72
|
+
/** Words for a refused or missing device. Blocked by the person, by the browser or by the page's Permissions-Policy read the same. */
|
|
73
|
+
export function mediaErrorText(error, what) {
|
|
74
|
+
const name = error?.name;
|
|
75
|
+
const label = what === 'camera' ? 'camera' : 'microphone';
|
|
76
|
+
if (name === 'NotFoundError' || name === 'OverconstrainedError')
|
|
77
|
+
return `No ${label} was found.`;
|
|
78
|
+
if (name === 'NotReadableError' || name === 'AbortError')
|
|
79
|
+
return `The ${label} is in use by another app.`;
|
|
80
|
+
return `Access to the ${label} was denied or blocked on this site. Allow it in the browser, or record the page only.`;
|
|
81
|
+
}
|
|
82
|
+
export async function getMedia(what, deviceId) {
|
|
83
|
+
const devices = typeof navigator !== 'undefined' ? navigator.mediaDevices : undefined;
|
|
84
|
+
if (!devices?.getUserMedia)
|
|
85
|
+
throw Object.assign(new Error('Media devices are not available'), { name: 'NotAllowedError' });
|
|
86
|
+
// The saved device exactly: as an ideal it is weighed against the size and rate, and the browser may pick another one.
|
|
87
|
+
const ask = (device) => devices.getUserMedia(what === 'camera'
|
|
88
|
+
? { video: { ...device, width: { ideal: 640 }, height: { ideal: 480 }, frameRate: { ideal: 24 } }, audio: false }
|
|
89
|
+
: { audio: { ...device, channelCount: 1, echoCancellation: true, noiseSuppression: true }, video: false });
|
|
90
|
+
if (!deviceId)
|
|
91
|
+
return ask({});
|
|
92
|
+
try {
|
|
93
|
+
return await ask({ deviceId: { exact: deviceId } });
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
// Unplugged, or its ID changed (cleared site data): the browser's default instead.
|
|
97
|
+
if (error instanceof Error && (error.name === 'OverconstrainedError' || error.name === 'NotFoundError'))
|
|
98
|
+
return ask({});
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// ---- Background effects ----------------------------------------------------------------------------------------
|
|
103
|
+
let usable = null;
|
|
104
|
+
/**
|
|
105
|
+
* Whether the page lets background effects run, decided without a request: compiling the smallest WebAssembly module
|
|
106
|
+
* throws under a Content-Security-Policy without 'wasm-unsafe-eval', and a 2D canvas with captureStream is what the
|
|
107
|
+
* processed picture is drawn on.
|
|
108
|
+
*/
|
|
109
|
+
export function effectsUsable() {
|
|
110
|
+
usable ??= (async () => {
|
|
111
|
+
try {
|
|
112
|
+
await WebAssembly.compile(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0]));
|
|
113
|
+
const canvas = document.createElement('canvas');
|
|
114
|
+
return canvas.getContext('2d') !== null && typeof canvas.captureStream === 'function';
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
})();
|
|
120
|
+
return usable;
|
|
121
|
+
}
|
|
122
|
+
/** The camera with its background replaced. The segmentation model is only imported here, so None never loads it. */
|
|
123
|
+
export async function withBackground(camera, kind) {
|
|
124
|
+
const { applyBackground } = await import('./cameraEffects.js');
|
|
125
|
+
return applyBackground(camera, kind);
|
|
126
|
+
}
|
|
127
|
+
/** Said when an effect cannot load on this page: the camera goes on without one. */
|
|
128
|
+
export const EFFECT_FAILED_TEXT = 'Background effects could not be loaded on this page. Using your plain camera.';
|
|
129
|
+
export const stopStream = (stream) => { for (const track of stream?.getTracks() ?? [])
|
|
130
|
+
track.stop(); };
|
|
131
|
+
/** Calls `level` (0 to 1) as the microphone gets louder; the returned function stops it. */
|
|
132
|
+
export function watchLevel(stream, level) {
|
|
133
|
+
const Context = window.AudioContext ?? window.webkitAudioContext;
|
|
134
|
+
if (!Context || stream.getAudioTracks().length === 0)
|
|
135
|
+
return () => undefined;
|
|
136
|
+
const context = new Context();
|
|
137
|
+
const analyser = context.createAnalyser();
|
|
138
|
+
analyser.fftSize = 256;
|
|
139
|
+
context.createMediaStreamSource(stream).connect(analyser);
|
|
140
|
+
void context.resume().catch(() => undefined);
|
|
141
|
+
const samples = new Uint8Array(analyser.fftSize);
|
|
142
|
+
const timer = window.setInterval(() => {
|
|
143
|
+
analyser.getByteTimeDomainData(samples);
|
|
144
|
+
let sum = 0;
|
|
145
|
+
for (const sample of samples)
|
|
146
|
+
sum += ((sample - 128) / 128) ** 2;
|
|
147
|
+
level(Math.min(1, Math.sqrt(sum / samples.length) * 3));
|
|
148
|
+
}, 80);
|
|
149
|
+
return () => { window.clearInterval(timer); void context.close().catch(() => undefined); level(0); };
|
|
150
|
+
}
|
|
151
|
+
/** Lucide `camera` (ISC), inlined: the generated icon set belongs to the build script. */
|
|
152
|
+
export function cameraIcon(size = 17) {
|
|
153
|
+
return `<svg width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z" /><circle cx="12" cy="13" r="3" /></svg>`;
|
|
154
|
+
}
|
|
155
|
+
// ---- The bubble ------------------------------------------------------------------------------------------------
|
|
156
|
+
export const BUBBLE_SIZE = 160;
|
|
157
|
+
const MARGIN = 24;
|
|
158
|
+
/**
|
|
159
|
+
* The round live picture of the reviewer. It sits in the overlay's shadow tree, which the page recording blocks, so it
|
|
160
|
+
* is never in the DOM recording; its position goes in as `ontrackd-camera` custom events instead.
|
|
161
|
+
*/
|
|
162
|
+
export class CameraBubble {
|
|
163
|
+
moved;
|
|
164
|
+
element;
|
|
165
|
+
video;
|
|
166
|
+
left = 0;
|
|
167
|
+
top = 0;
|
|
168
|
+
lastEmit = 0;
|
|
169
|
+
onResize = () => { this.place(this.left, this.top); };
|
|
170
|
+
constructor(parent, stream, prefs, moved) {
|
|
171
|
+
this.moved = moved;
|
|
172
|
+
this.element = document.createElement('div');
|
|
173
|
+
this.element.className = 'fb-camera-bubble';
|
|
174
|
+
this.element.setAttribute('data-fb-camera-bubble', '');
|
|
175
|
+
this.element.setAttribute('role', 'img');
|
|
176
|
+
this.element.setAttribute('aria-label', 'Your camera. Drag to move it.');
|
|
177
|
+
this.video = document.createElement('video');
|
|
178
|
+
this.video.muted = true;
|
|
179
|
+
this.video.playsInline = true;
|
|
180
|
+
this.video.srcObject = stream;
|
|
181
|
+
this.element.append(this.video);
|
|
182
|
+
parent.append(this.element);
|
|
183
|
+
void this.video.play().catch(() => undefined);
|
|
184
|
+
if (prefs.at)
|
|
185
|
+
this.place(prefs.at.x * window.innerWidth - BUBBLE_SIZE / 2, prefs.at.y * window.innerHeight - BUBBLE_SIZE / 2);
|
|
186
|
+
else
|
|
187
|
+
this.place(prefs.corner.endsWith('left') ? MARGIN : window.innerWidth - MARGIN - BUBBLE_SIZE, prefs.corner.startsWith('top') ? MARGIN : window.innerHeight - MARGIN - BUBBLE_SIZE);
|
|
188
|
+
this.element.addEventListener('pointerdown', (event) => this.drag(event));
|
|
189
|
+
window.addEventListener('resize', this.onResize);
|
|
190
|
+
}
|
|
191
|
+
get move() {
|
|
192
|
+
const round = (value) => Math.round(value * 10000) / 10000;
|
|
193
|
+
return { x: round((this.left + BUBBLE_SIZE / 2) / window.innerWidth), y: round((this.top + BUBBLE_SIZE / 2) / window.innerHeight), size: round(BUBBLE_SIZE / window.innerWidth) };
|
|
194
|
+
}
|
|
195
|
+
/** Where it was left, to save: null while it is still in its corner. */
|
|
196
|
+
get centre() { const { x, y } = this.move; return { x, y }; }
|
|
197
|
+
place(left, top) {
|
|
198
|
+
this.left = Math.max(0, Math.min(window.innerWidth - BUBBLE_SIZE, left));
|
|
199
|
+
this.top = Math.max(0, Math.min(window.innerHeight - BUBBLE_SIZE, top));
|
|
200
|
+
this.element.style.left = `${this.left}px`;
|
|
201
|
+
this.element.style.top = `${this.top}px`;
|
|
202
|
+
}
|
|
203
|
+
drag(event) {
|
|
204
|
+
if (event.button !== 0)
|
|
205
|
+
return;
|
|
206
|
+
event.preventDefault();
|
|
207
|
+
const dx = event.clientX - this.left, dy = event.clientY - this.top;
|
|
208
|
+
this.element.setPointerCapture(event.pointerId);
|
|
209
|
+
this.element.dataset.dragging = 'true';
|
|
210
|
+
const move = (next) => {
|
|
211
|
+
this.place(next.clientX - dx, next.clientY - dy);
|
|
212
|
+
const now = performance.now();
|
|
213
|
+
if (now - this.lastEmit >= 60) {
|
|
214
|
+
this.lastEmit = now;
|
|
215
|
+
this.moved(this.move, false);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const end = () => {
|
|
219
|
+
this.element.removeEventListener('pointermove', move);
|
|
220
|
+
this.element.removeEventListener('pointerup', end);
|
|
221
|
+
this.element.removeEventListener('pointercancel', end);
|
|
222
|
+
delete this.element.dataset.dragging;
|
|
223
|
+
this.moved(this.move, true);
|
|
224
|
+
};
|
|
225
|
+
this.element.addEventListener('pointermove', move);
|
|
226
|
+
this.element.addEventListener('pointerup', end);
|
|
227
|
+
this.element.addEventListener('pointercancel', end);
|
|
228
|
+
}
|
|
229
|
+
remove() {
|
|
230
|
+
window.removeEventListener('resize', this.onResize);
|
|
231
|
+
this.video.srcObject = null;
|
|
232
|
+
this.element.remove();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// ---- Recording -------------------------------------------------------------------------------------------------
|
|
236
|
+
const two = (value) => String(value).padStart(2, '0');
|
|
237
|
+
const FRAME = 320;
|
|
238
|
+
const FPS = 24;
|
|
239
|
+
/**
|
|
240
|
+
* The camera and microphone of one recording: a 320 x 320 crop of the camera drawn to a canvas (24 fps, about 250 kbps)
|
|
241
|
+
* and the microphone (mono, about 32 kbps), or the microphone alone. Started and finished with the page recording.
|
|
242
|
+
*/
|
|
243
|
+
export class CameraCapture {
|
|
244
|
+
camera;
|
|
245
|
+
mic;
|
|
246
|
+
bubble;
|
|
247
|
+
maxBytes;
|
|
248
|
+
effect;
|
|
249
|
+
recorder = null;
|
|
250
|
+
chunks = [];
|
|
251
|
+
drawer;
|
|
252
|
+
finished = null;
|
|
253
|
+
mime = null;
|
|
254
|
+
constructor(camera, mic, bubble, maxBytes, effect = null) {
|
|
255
|
+
this.camera = camera;
|
|
256
|
+
this.mic = mic;
|
|
257
|
+
this.bubble = bubble;
|
|
258
|
+
this.maxBytes = maxBytes;
|
|
259
|
+
this.effect = effect;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Asks for what the saved choices turn on. `problems` says what could not be had; with nothing at all, `capture` is null
|
|
263
|
+
* and the recording is the page alone.
|
|
264
|
+
*/
|
|
265
|
+
static async open(parent, prefs, maxBytes, moved) {
|
|
266
|
+
const problems = [];
|
|
267
|
+
let camera = null, mic = null;
|
|
268
|
+
let effect = null;
|
|
269
|
+
if (prefs.camera) {
|
|
270
|
+
try {
|
|
271
|
+
camera = await getMedia('camera', prefs.cameraId);
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
problems.push(mediaErrorText(error, 'camera'));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (camera && prefs.background !== 'none' && await effectsUsable()) {
|
|
278
|
+
try {
|
|
279
|
+
effect = await withBackground(camera, prefs.background);
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
// The raw camera records; the choice goes back to None so the next recording does not try again.
|
|
283
|
+
saveCameraPrefs({ ...loadCameraPrefs(), background: 'none' });
|
|
284
|
+
problems.push(EFFECT_FAILED_TEXT);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (prefs.mic) {
|
|
288
|
+
try {
|
|
289
|
+
mic = await getMedia('mic', prefs.micId);
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
problems.push(mediaErrorText(error, 'mic'));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (!camera && !mic)
|
|
296
|
+
return { capture: null, problems };
|
|
297
|
+
const bubble = camera ? new CameraBubble(parent, effect?.stream ?? camera, prefs, moved) : null;
|
|
298
|
+
return { capture: new CameraCapture(camera, mic, bubble, maxBytes, effect), problems };
|
|
299
|
+
}
|
|
300
|
+
/** Starts recording. False when this browser cannot (no supported container): the capture is already released. */
|
|
301
|
+
start() {
|
|
302
|
+
try {
|
|
303
|
+
const mime = pickCameraMime(this.camera !== null);
|
|
304
|
+
if (!mime)
|
|
305
|
+
throw new Error('No container');
|
|
306
|
+
this.mime = mime;
|
|
307
|
+
let stream;
|
|
308
|
+
if (this.camera && this.bubble) {
|
|
309
|
+
const canvas = document.createElement('canvas');
|
|
310
|
+
canvas.width = FRAME;
|
|
311
|
+
canvas.height = FRAME;
|
|
312
|
+
const context = canvas.getContext('2d');
|
|
313
|
+
const video = this.bubble.video;
|
|
314
|
+
const draw = () => {
|
|
315
|
+
const side = Math.min(video.videoWidth, video.videoHeight);
|
|
316
|
+
if (!side)
|
|
317
|
+
return;
|
|
318
|
+
context.drawImage(video, (video.videoWidth - side) / 2, (video.videoHeight - side) / 2, side, side, 0, 0, FRAME, FRAME);
|
|
319
|
+
};
|
|
320
|
+
draw();
|
|
321
|
+
this.drawer = window.setInterval(draw, 1000 / FPS);
|
|
322
|
+
stream = canvas.captureStream(FPS);
|
|
323
|
+
for (const track of this.mic?.getAudioTracks() ?? [])
|
|
324
|
+
stream.addTrack(track);
|
|
325
|
+
}
|
|
326
|
+
else
|
|
327
|
+
stream = new MediaStream(this.mic.getAudioTracks());
|
|
328
|
+
this.recorder = new MediaRecorder(stream, { mimeType: mime.mime, ...(this.camera ? { videoBitsPerSecond: 250_000 } : {}), audioBitsPerSecond: 32_000 });
|
|
329
|
+
this.recorder.ondataavailable = (event) => { if (event.data.size > 0)
|
|
330
|
+
this.chunks.push(event.data); };
|
|
331
|
+
this.recorder.start(1000);
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
this.release();
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/** Stops and hands back the file (null when empty, over the plan's cap, or never started). Everything is released. */
|
|
340
|
+
finish() {
|
|
341
|
+
this.finished ??= new Promise((resolve) => {
|
|
342
|
+
const done = () => {
|
|
343
|
+
const mime = this.mime;
|
|
344
|
+
const blob = new Blob(this.chunks, { type: mime?.type ?? '' });
|
|
345
|
+
this.chunks = [];
|
|
346
|
+
this.release();
|
|
347
|
+
if (!mime || blob.size === 0) {
|
|
348
|
+
resolve({ file: null, tooBig: false });
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (blob.size > this.maxBytes) {
|
|
352
|
+
resolve({ file: null, tooBig: true });
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
const at = new Date();
|
|
356
|
+
resolve({ file: new File([blob], `camera-${at.getFullYear()}${two(at.getMonth() + 1)}${two(at.getDate())}-${two(at.getHours())}${two(at.getMinutes())}${two(at.getSeconds())}.${mime.extension}`, { type: mime.type }), tooBig: false });
|
|
357
|
+
};
|
|
358
|
+
const recorder = this.recorder;
|
|
359
|
+
if (!recorder || recorder.state === 'inactive') {
|
|
360
|
+
done();
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
recorder.onstop = done;
|
|
364
|
+
try {
|
|
365
|
+
recorder.stop();
|
|
366
|
+
}
|
|
367
|
+
catch {
|
|
368
|
+
done();
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
return this.finished;
|
|
372
|
+
}
|
|
373
|
+
/** Throws it away: nothing is uploaded and nothing keeps the camera on. */
|
|
374
|
+
dispose() { void this.finish(); }
|
|
375
|
+
release() {
|
|
376
|
+
window.clearInterval(this.drawer);
|
|
377
|
+
this.bubble?.remove();
|
|
378
|
+
this.effect?.stop();
|
|
379
|
+
this.effect = null;
|
|
380
|
+
stopStream(this.camera);
|
|
381
|
+
stopStream(this.mic);
|
|
382
|
+
this.camera = null;
|
|
383
|
+
this.mic = null;
|
|
384
|
+
for (const track of this.recorder?.stream.getTracks() ?? [])
|
|
385
|
+
track.stop();
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
//# sourceMappingURL=camera.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../../src/overlay/camera.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,8FAA8F;AAC9F,MAAM,UAAU,aAAa,CAAC,IAAa;IACzC,MAAM,KAAK,GAAI,IAA+E,EAAE,QAAQ,EAAE,MAAM,CAAC;IACjH,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CA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}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** An original office, drawn once: a soft wall, a window, a shelf with books, a desk, a plant. Muted colours. */
|
|
2
|
+
export declare function drawOffice(canvas: HTMLCanvasElement): void;
|
|
3
|
+
/**
|
|
4
|
+
* The same camera with its background replaced. The result has the picture only (the microphone is not part of it);
|
|
5
|
+
* `stop()` ends the loop, closes the segmenter and stops the camera tracks it was given.
|
|
6
|
+
*/
|
|
7
|
+
export declare function applyBackground(source: MediaStream, kind: 'blur' | 'office', base?: URL): Promise<{
|
|
8
|
+
stream: MediaStream;
|
|
9
|
+
stop(): void;
|
|
10
|
+
}>;
|