mediasfu-shared 1.2.3 → 1.2.5
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/CHANGELOG.md +4 -0
- package/dist/audioProcessing-0z5KlcmO.js +35 -0
- package/dist/audioProcessing-0z5KlcmO.js.map +1 -0
- package/dist/audioProcessing-BpbrdCk-.cjs +34 -0
- package/dist/audioProcessing-BpbrdCk-.cjs.map +1 -0
- package/dist/consumers/audioProcessing.d.ts +8 -0
- package/dist/consumers/audioProcessing.d.ts.map +1 -0
- package/dist/consumers/createSendTransport.d.ts.map +1 -1
- package/dist/consumers/gridLayout/addVideosGrid.engine.d.ts +6 -0
- package/dist/consumers/gridLayout/addVideosGrid.engine.d.ts.map +1 -1
- package/dist/consumers/index.cjs +3 -2
- package/dist/consumers/index.cjs.map +1 -1
- package/dist/consumers/index.js +14 -13
- package/dist/consumers/signalNewConsumerTransport.d.ts.map +1 -1
- package/dist/consumers/switchUserAudio.d.ts +3 -1
- package/dist/consumers/switchUserAudio.d.ts.map +1 -1
- package/dist/consumers/transportRecovery.d.ts +8 -0
- package/dist/consumers/transportRecovery.d.ts.map +1 -0
- package/dist/{getParticipantMedia-AwwtMCTz.cjs → getParticipantMedia-CP4hE5Rg.cjs} +9 -4
- package/dist/getParticipantMedia-CP4hE5Rg.cjs.map +1 -0
- package/dist/{getParticipantMedia-CyaOk2oD.js → getParticipantMedia-CvXdDj03.js} +9 -4
- package/dist/getParticipantMedia-CvXdDj03.js.map +1 -0
- package/dist/index.cjs +106 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +173 -89
- package/dist/index.js.map +1 -1
- package/dist/index.native.cjs +8 -7
- package/dist/index.native.cjs.map +1 -1
- package/dist/index.native.js +19 -18
- package/dist/{joinLocalRoom-Bu3gz27d.js → joinLocalRoom-Cx1y3Ojj.js} +4 -4
- package/dist/{joinLocalRoom-Bu3gz27d.js.map → joinLocalRoom-Cx1y3Ojj.js.map} +1 -1
- package/dist/{joinLocalRoom-Cii5D5IG.cjs → joinLocalRoom-DNJ2zb8W.cjs} +10 -10
- package/dist/{joinLocalRoom-Cii5D5IG.cjs.map → joinLocalRoom-DNJ2zb8W.cjs.map} +1 -1
- package/dist/{joinRoomOnMediaSFU-y6vJ1OBo.js → joinRoomOnMediaSFU-BnAWLciF.js} +9 -3
- package/dist/joinRoomOnMediaSFU-BnAWLciF.js.map +1 -0
- package/dist/{joinRoomOnMediaSFU-CC8RVJgr.cjs → joinRoomOnMediaSFU-D2C7q1GK.cjs} +9 -3
- package/dist/joinRoomOnMediaSFU-D2C7q1GK.cjs.map +1 -0
- package/dist/methods/index.cjs +3 -3
- package/dist/methods/index.js +3 -3
- package/dist/methods/stream/clickAudio.d.ts +3 -1
- package/dist/methods/stream/clickAudio.d.ts.map +1 -1
- package/dist/methods/stream/switchAudio.d.ts +3 -1
- package/dist/methods/stream/switchAudio.d.ts.map +1 -1
- package/dist/methods/utils/headless/virtualBackground.d.ts +3 -1
- package/dist/methods/utils/headless/virtualBackground.d.ts.map +1 -1
- package/dist/methods/utils/virtualBackgroundFrameLoop.d.ts +10 -0
- package/dist/methods/utils/virtualBackgroundFrameLoop.d.ts.map +1 -0
- package/dist/{translationConsumerSwitch-C20MfNNq.cjs → translationConsumerSwitch-BAsQUpH6.cjs} +9 -1
- package/dist/translationConsumerSwitch-BAsQUpH6.cjs.map +1 -0
- package/dist/{translationConsumerSwitch-zKuS5wgH.js → translationConsumerSwitch-BUODiT6o.js} +20 -12
- package/dist/translationConsumerSwitch-BUODiT6o.js.map +1 -0
- package/dist/types/index.cjs +3 -3
- package/dist/types/index.js +3 -3
- package/dist/types/shared-base-types.d.ts +12 -0
- package/dist/types/shared-base-types.d.ts.map +1 -1
- package/dist/{updateParticipantAudioDecibels-QZyahisU.cjs → updateParticipantAudioDecibels-BJ2PxJJD.cjs} +203 -46
- package/dist/updateParticipantAudioDecibels-BJ2PxJJD.cjs.map +1 -0
- package/dist/{updateParticipantAudioDecibels-CnEXJBmc.js → updateParticipantAudioDecibels-DiJ_LFfH.js} +200 -43
- package/dist/updateParticipantAudioDecibels-DiJ_LFfH.js.map +1 -0
- package/package.json +1 -1
- package/src/consumers/audioProcessing.ts +26 -0
- package/src/consumers/createSendTransport.ts +5 -20
- package/src/consumers/gridLayout/addVideosGrid.engine.ts +13 -0
- package/src/consumers/signalNewConsumerTransport.ts +7 -25
- package/src/consumers/switchUserAudio.ts +18 -5
- package/src/consumers/transportRecovery.ts +170 -0
- package/src/index.ts +2 -0
- package/src/methods/stream/clickAudio.ts +13 -5
- package/src/methods/stream/switchAudio.ts +10 -1
- package/src/methods/utils/headless/virtualBackground.ts +21 -13
- package/src/methods/utils/virtualBackgroundFrameLoop.ts +69 -0
- package/src/types/shared-base-types.ts +3 -0
- package/dist/getParticipantMedia-AwwtMCTz.cjs.map +0 -1
- package/dist/getParticipantMedia-CyaOk2oD.js.map +0 -1
- package/dist/joinRoomOnMediaSFU-CC8RVJgr.cjs.map +0 -1
- package/dist/joinRoomOnMediaSFU-y6vJ1OBo.js.map +0 -1
- package/dist/translationConsumerSwitch-C20MfNNq.cjs.map +0 -1
- package/dist/translationConsumerSwitch-zKuS5wgH.js.map +0 -1
- package/dist/updateParticipantAudioDecibels-CnEXJBmc.js.map +0 -1
- package/dist/updateParticipantAudioDecibels-QZyahisU.cjs.map +0 -1
- package/dist/validateAlphanumeric-DKn5BsUP.cjs +0 -15
- package/dist/validateAlphanumeric-DKn5BsUP.cjs.map +0 -1
- package/dist/validateAlphanumeric-Dk1JB80W.js +0 -16
- package/dist/validateAlphanumeric-Dk1JB80W.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const joinLocalRoom = require("./joinLocalRoom-
|
|
4
|
-
const updateParticipantAudioDecibels = require("./updateParticipantAudioDecibels-
|
|
5
|
-
const joinRoomOnMediaSFU = require("./joinRoomOnMediaSFU-
|
|
6
|
-
const translationConsumerSwitch = require("./translationConsumerSwitch-
|
|
7
|
-
const getParticipantMedia = require("./getParticipantMedia-
|
|
3
|
+
const joinLocalRoom = require("./joinLocalRoom-DNJ2zb8W.cjs");
|
|
4
|
+
const updateParticipantAudioDecibels = require("./updateParticipantAudioDecibels-BJ2PxJJD.cjs");
|
|
5
|
+
const joinRoomOnMediaSFU = require("./joinRoomOnMediaSFU-D2C7q1GK.cjs");
|
|
6
|
+
const translationConsumerSwitch = require("./translationConsumerSwitch-BAsQUpH6.cjs");
|
|
7
|
+
const getParticipantMedia = require("./getParticipantMedia-CP4hE5Rg.cjs");
|
|
8
8
|
const methods_index = require("./methods/index.cjs");
|
|
9
|
-
const
|
|
9
|
+
const audioProcessing = require("./audioProcessing-BpbrdCk-.cjs");
|
|
10
10
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
11
11
|
var selfie_segmentation = {};
|
|
12
12
|
var hasRequiredSelfie_segmentation;
|
|
@@ -2329,6 +2329,86 @@ function compositeVirtualBackgroundFrame({
|
|
|
2329
2329
|
ctx.restore();
|
|
2330
2330
|
}
|
|
2331
2331
|
}
|
|
2332
|
+
const activeLoops = /* @__PURE__ */ new WeakMap();
|
|
2333
|
+
const activeFrames = /* @__PURE__ */ new WeakMap();
|
|
2334
|
+
function startVirtualBackgroundFrameLoop({
|
|
2335
|
+
owner,
|
|
2336
|
+
processFrame,
|
|
2337
|
+
shouldContinue,
|
|
2338
|
+
keepProcessingWhenHidden = true
|
|
2339
|
+
}) {
|
|
2340
|
+
activeLoops.get(owner)?.();
|
|
2341
|
+
let stopped = false;
|
|
2342
|
+
let inFlight = false;
|
|
2343
|
+
let animationFrameId = null;
|
|
2344
|
+
let timeoutId = null;
|
|
2345
|
+
const cancelScheduledFrame = () => {
|
|
2346
|
+
if (animationFrameId !== null) cancelAnimationFrame(animationFrameId);
|
|
2347
|
+
if (timeoutId !== null) clearTimeout(timeoutId);
|
|
2348
|
+
animationFrameId = null;
|
|
2349
|
+
timeoutId = null;
|
|
2350
|
+
};
|
|
2351
|
+
const stop = () => {
|
|
2352
|
+
if (stopped) return;
|
|
2353
|
+
stopped = true;
|
|
2354
|
+
cancelScheduledFrame();
|
|
2355
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
2356
|
+
if (activeLoops.get(owner) === stop) activeLoops.delete(owner);
|
|
2357
|
+
};
|
|
2358
|
+
const schedule = () => {
|
|
2359
|
+
if (stopped || inFlight) return;
|
|
2360
|
+
if (!shouldContinue()) {
|
|
2361
|
+
stop();
|
|
2362
|
+
return;
|
|
2363
|
+
}
|
|
2364
|
+
if (document.hidden && keepProcessingWhenHidden) {
|
|
2365
|
+
timeoutId = setTimeout(() => {
|
|
2366
|
+
void runFrame();
|
|
2367
|
+
}, 200);
|
|
2368
|
+
} else {
|
|
2369
|
+
animationFrameId = requestAnimationFrame(() => {
|
|
2370
|
+
void runFrame();
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
};
|
|
2374
|
+
const runFrame = async () => {
|
|
2375
|
+
animationFrameId = null;
|
|
2376
|
+
timeoutId = null;
|
|
2377
|
+
if (stopped || inFlight) return;
|
|
2378
|
+
if (!shouldContinue()) {
|
|
2379
|
+
stop();
|
|
2380
|
+
return;
|
|
2381
|
+
}
|
|
2382
|
+
inFlight = true;
|
|
2383
|
+
try {
|
|
2384
|
+
const previousFrame = activeFrames.get(owner);
|
|
2385
|
+
if (previousFrame) await previousFrame.catch(() => void 0);
|
|
2386
|
+
if (stopped || !shouldContinue()) {
|
|
2387
|
+
stop();
|
|
2388
|
+
return;
|
|
2389
|
+
}
|
|
2390
|
+
const currentFrame = Promise.resolve(processFrame());
|
|
2391
|
+
activeFrames.set(owner, currentFrame);
|
|
2392
|
+
try {
|
|
2393
|
+
await currentFrame;
|
|
2394
|
+
} finally {
|
|
2395
|
+
if (activeFrames.get(owner) === currentFrame) activeFrames.delete(owner);
|
|
2396
|
+
}
|
|
2397
|
+
} catch {
|
|
2398
|
+
} finally {
|
|
2399
|
+
inFlight = false;
|
|
2400
|
+
schedule();
|
|
2401
|
+
}
|
|
2402
|
+
};
|
|
2403
|
+
const onVisibilityChange = () => {
|
|
2404
|
+
cancelScheduledFrame();
|
|
2405
|
+
schedule();
|
|
2406
|
+
};
|
|
2407
|
+
activeLoops.set(owner, stop);
|
|
2408
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
2409
|
+
void runFrame();
|
|
2410
|
+
return stop;
|
|
2411
|
+
}
|
|
2332
2412
|
const MEDIAPIPE_CDN = "https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation";
|
|
2333
2413
|
let session = null;
|
|
2334
2414
|
function loadImage(src) {
|
|
@@ -2347,7 +2427,8 @@ async function applyVirtualBackground({
|
|
|
2347
2427
|
modelSelection = 1,
|
|
2348
2428
|
publish = true,
|
|
2349
2429
|
assetPath = MEDIAPIPE_CDN,
|
|
2350
|
-
blurPixels = 0
|
|
2430
|
+
blurPixels = 0,
|
|
2431
|
+
keepProcessingWhenHidden = true
|
|
2351
2432
|
}) {
|
|
2352
2433
|
const live = getParticipantMedia.getCurrentParams({ parameters });
|
|
2353
2434
|
if (live.audioOnlyRoom) {
|
|
@@ -2411,26 +2492,27 @@ async function applyVirtualBackground({
|
|
|
2411
2492
|
}
|
|
2412
2493
|
});
|
|
2413
2494
|
let stopped = false;
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2495
|
+
const stopFrameLoop = startVirtualBackgroundFrameLoop({
|
|
2496
|
+
owner: segmentation,
|
|
2497
|
+
keepProcessingWhenHidden,
|
|
2498
|
+
shouldContinue: () => !stopped && processingTrack.readyState === "live",
|
|
2499
|
+
processFrame: () => video.readyState >= 2 ? segmentation.send({ image: video }) : void 0
|
|
2500
|
+
});
|
|
2501
|
+
let processed;
|
|
2502
|
+
try {
|
|
2503
|
+
processed = canvas.captureStream(frameRate);
|
|
2504
|
+
} catch (error) {
|
|
2505
|
+
stopFrameLoop();
|
|
2506
|
+
throw error;
|
|
2507
|
+
}
|
|
2427
2508
|
if (!processed?.getVideoTracks?.().length) {
|
|
2509
|
+
stopFrameLoop();
|
|
2428
2510
|
throw new Error("The processed background stream produced no video track.");
|
|
2429
2511
|
}
|
|
2430
2512
|
const stop = () => {
|
|
2431
2513
|
if (stopped) return;
|
|
2432
2514
|
stopped = true;
|
|
2433
|
-
|
|
2515
|
+
stopFrameLoop();
|
|
2434
2516
|
try {
|
|
2435
2517
|
segmentation.close();
|
|
2436
2518
|
} catch {
|
|
@@ -2625,6 +2707,7 @@ exports.isSpeakerInMyBreakoutRoom = translationConsumerSwitch.isSpeakerInMyBreak
|
|
|
2625
2707
|
exports.pauseOriginalProducer = translationConsumerSwitch.pauseOriginalProducer;
|
|
2626
2708
|
exports.resolveHostVideoStream = translationConsumerSwitch.resolveHostVideoStream;
|
|
2627
2709
|
exports.resolveMainHostRenderMode = translationConsumerSwitch.resolveMainHostRenderMode;
|
|
2710
|
+
exports.resolveSidePanelForceFullDisplay = translationConsumerSwitch.resolveSidePanelForceFullDisplay;
|
|
2628
2711
|
exports.resumeOriginalProducer = translationConsumerSwitch.resumeOriginalProducer;
|
|
2629
2712
|
exports.stopConsumingTranslation = translationConsumerSwitch.stopConsumingTranslation;
|
|
2630
2713
|
exports.syncTranslationStateAfterBreakoutChange = translationConsumerSwitch.syncTranslationStateAfterBreakoutChange;
|
|
@@ -2846,7 +2929,7 @@ exports.updatedCoHost = methods_index.updatedCoHost;
|
|
|
2846
2929
|
exports.userWaiting = methods_index.userWaiting;
|
|
2847
2930
|
exports.validateWelcomeAlphanumeric = methods_index.validateWelcomeAlphanumeric;
|
|
2848
2931
|
exports.validateWelcomeInputs = methods_index.validateWelcomeInputs;
|
|
2849
|
-
exports.validateAlphanumeric =
|
|
2932
|
+
exports.validateAlphanumeric = audioProcessing.validateAlphanumeric;
|
|
2850
2933
|
exports.DEFAULT_BACKGROUND_BLUR_PIXELS = DEFAULT_BACKGROUND_BLUR_PIXELS;
|
|
2851
2934
|
exports.VIRTUAL_BACKGROUND_BLUR = VIRTUAL_BACKGROUND_BLUR;
|
|
2852
2935
|
exports.applyBackgroundBlur = applyBackgroundBlur;
|
|
@@ -2855,4 +2938,5 @@ exports.clearVirtualBackground = clearVirtualBackground;
|
|
|
2855
2938
|
exports.compositeVirtualBackgroundFrame = compositeVirtualBackgroundFrame;
|
|
2856
2939
|
exports.isVirtualBackgroundBlur = isVirtualBackgroundBlur;
|
|
2857
2940
|
exports.isVirtualBackgroundRunning = isVirtualBackgroundRunning;
|
|
2941
|
+
exports.startVirtualBackgroundFrameLoop = startVirtualBackgroundFrameLoop;
|
|
2858
2942
|
//# sourceMappingURL=index.cjs.map
|