browser audio detection phase 4

This commit is contained in:
Joren de Graaf
2026-10-02 21:45:24 +02:00
parent 20bdabdd8f
commit 037797aa89
20 changed files with 903 additions and 31 deletions
@@ -15,9 +15,39 @@ export class BrowserSubmissionProcessor {
this.config = config;
this.extractVideo = extractVideo;
this.dependencies = dependencies;
this.userEnabled = false;
this.activeController = null;
}
isEnabled() { return this.config.browserProcessingBeta === true; }
isAvailable() { return this.config.browserProcessingBeta === true; }
isEnabled() { return this.isAvailable() && this.userEnabled; }
setEnabled(enabled) {
if (!enabled) this.cancel();
this.userEnabled = this.isAvailable() && enabled === true;
console.log(`${PREFIX} ${this.userEnabled ? "Browser processing enabled by user." : "Browser processing disabled by user; using existing server flow."}`);
}
cancel() {
this.activeController?.abort();
this.activeController = null;
}
async process(file, { signal, onState } = {}) {
this.cancel();
const controller = new AbortController();
this.activeController = controller;
const abort = () => controller.abort();
signal?.addEventListener("abort", abort, { once: true });
if (signal?.aborted) controller.abort();
try {
return await this.prepare(file, { signal: controller.signal, onState });
} finally {
signal?.removeEventListener("abort", abort);
if (this.activeController === controller) this.activeController = null;
}
}
canProcess(file) {
return this.isEnabled() && Boolean(file) && (BrowserSubmissionProcessor.isAudio(file) || BrowserSubmissionProcessor.isVideo(file));
@@ -102,5 +132,8 @@ export class BrowserSubmissionProcessor {
}
}
cleanup() { console.log("[BoomCast][Cleanup] Browser beta resources released."); }
cleanup() {
this.cancel();
console.log("[BoomCast][Cleanup] Browser beta resources released.");
}
}