mediasfu-shared 1.2.1 → 1.2.3
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 +17 -4
- package/README.md +145 -131
- package/dist/consumers/connectIps.d.ts.map +1 -1
- package/dist/consumers/index.cjs +1 -1
- package/dist/consumers/index.js +1 -1
- package/dist/{getParticipantMedia-DC_Nca8S.cjs → getParticipantMedia-AwwtMCTz.cjs} +4 -4
- package/dist/getParticipantMedia-AwwtMCTz.cjs.map +1 -0
- package/dist/{getParticipantMedia-Bu_aZlxe.js → getParticipantMedia-CyaOk2oD.js} +4 -4
- package/dist/getParticipantMedia-CyaOk2oD.js.map +1 -0
- package/dist/index.cjs +36 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -8
- package/dist/index.js.map +1 -1
- package/dist/index.native.cjs +3 -3
- package/dist/index.native.js +3 -3
- package/dist/{joinLocalRoom-7ibqv7zZ.js → joinLocalRoom-Bu3gz27d.js} +2 -2
- package/dist/{joinLocalRoom-7ibqv7zZ.js.map → joinLocalRoom-Bu3gz27d.js.map} +1 -1
- package/dist/{joinLocalRoom-BJBDvTYh.cjs → joinLocalRoom-Cii5D5IG.cjs} +2 -2
- package/dist/{joinLocalRoom-BJBDvTYh.cjs.map → joinLocalRoom-Cii5D5IG.cjs.map} +1 -1
- package/dist/methods/recording/startRecording.d.ts.map +1 -1
- package/dist/methods/utils/headless/virtualBackground.d.ts +13 -1
- package/dist/methods/utils/headless/virtualBackground.d.ts.map +1 -1
- package/dist/methods/utils/virtualBackgroundCompositor.d.ts +4 -0
- package/dist/methods/utils/virtualBackgroundCompositor.d.ts.map +1 -1
- package/dist/sockets/SocketManager.d.ts +0 -27
- package/dist/sockets/SocketManager.d.ts.map +1 -1
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.js +2 -2
- package/dist/{updateParticipantAudioDecibels-C_MygF6q.js → updateParticipantAudioDecibels-CnEXJBmc.js} +85 -13
- package/dist/updateParticipantAudioDecibels-CnEXJBmc.js.map +1 -0
- package/dist/{updateParticipantAudioDecibels-bZ6R8WHj.cjs → updateParticipantAudioDecibels-QZyahisU.cjs} +85 -13
- package/dist/updateParticipantAudioDecibels-QZyahisU.cjs.map +1 -0
- package/package.json +1 -1
- package/src/consumers/connectIps.ts +46 -7
- package/src/methods/recording/startRecording.ts +7 -1
- package/src/methods/utils/headless/virtualBackground.ts +34 -2
- package/src/methods/utils/virtualBackgroundCompositor.ts +18 -1
- package/src/sockets/SocketManager.ts +54 -7
- package/dist/getParticipantMedia-Bu_aZlxe.js.map +0 -1
- package/dist/getParticipantMedia-DC_Nca8S.cjs.map +0 -1
- package/dist/updateParticipantAudioDecibels-C_MygF6q.js.map +0 -1
- package/dist/updateParticipantAudioDecibels-bZ6R8WHj.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const joinLocalRoom = require("./joinLocalRoom-
|
|
4
|
-
const updateParticipantAudioDecibels = require("./updateParticipantAudioDecibels-
|
|
3
|
+
const joinLocalRoom = require("./joinLocalRoom-Cii5D5IG.cjs");
|
|
4
|
+
const updateParticipantAudioDecibels = require("./updateParticipantAudioDecibels-QZyahisU.cjs");
|
|
5
5
|
const joinRoomOnMediaSFU = require("./joinRoomOnMediaSFU-CC8RVJgr.cjs");
|
|
6
6
|
const translationConsumerSwitch = require("./translationConsumerSwitch-C20MfNNq.cjs");
|
|
7
|
-
const getParticipantMedia = require("./getParticipantMedia-
|
|
7
|
+
const getParticipantMedia = require("./getParticipantMedia-AwwtMCTz.cjs");
|
|
8
8
|
const methods_index = require("./methods/index.cjs");
|
|
9
9
|
const validateAlphanumeric = require("./validateAlphanumeric-DKn5BsUP.cjs");
|
|
10
10
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
@@ -2284,6 +2284,11 @@ function requireSelfie_segmentation() {
|
|
|
2284
2284
|
return selfie_segmentation;
|
|
2285
2285
|
}
|
|
2286
2286
|
var selfie_segmentationExports = /* @__PURE__ */ requireSelfie_segmentation();
|
|
2287
|
+
const VIRTUAL_BACKGROUND_BLUR = "blur";
|
|
2288
|
+
const DEFAULT_BACKGROUND_BLUR_PIXELS = 16;
|
|
2289
|
+
function isVirtualBackgroundBlur(value) {
|
|
2290
|
+
return value === VIRTUAL_BACKGROUND_BLUR;
|
|
2291
|
+
}
|
|
2287
2292
|
function compositeVirtualBackgroundFrame({
|
|
2288
2293
|
ctx,
|
|
2289
2294
|
segmentationMask,
|
|
@@ -2309,7 +2314,14 @@ function compositeVirtualBackgroundFrame({
|
|
|
2309
2314
|
ctx.fillRect(0, 0, width, height);
|
|
2310
2315
|
} else if (blurFallbackPixels > 0) {
|
|
2311
2316
|
ctx.filter = `blur(${blurFallbackPixels}px)`;
|
|
2312
|
-
|
|
2317
|
+
const bleed = Math.max(2, blurFallbackPixels * 2);
|
|
2318
|
+
ctx.drawImage(
|
|
2319
|
+
sourceImage,
|
|
2320
|
+
-bleed,
|
|
2321
|
+
-bleed,
|
|
2322
|
+
width + bleed * 2,
|
|
2323
|
+
height + bleed * 2
|
|
2324
|
+
);
|
|
2313
2325
|
}
|
|
2314
2326
|
} finally {
|
|
2315
2327
|
ctx.filter = previousFilter || "none";
|
|
@@ -2334,7 +2346,8 @@ async function applyVirtualBackground({
|
|
|
2334
2346
|
frameRate = 30,
|
|
2335
2347
|
modelSelection = 1,
|
|
2336
2348
|
publish = true,
|
|
2337
|
-
assetPath = MEDIAPIPE_CDN
|
|
2349
|
+
assetPath = MEDIAPIPE_CDN,
|
|
2350
|
+
blurPixels = 0
|
|
2338
2351
|
}) {
|
|
2339
2352
|
const live = getParticipantMedia.getCurrentParams({ parameters });
|
|
2340
2353
|
if (live.audioOnlyRoom) {
|
|
@@ -2354,7 +2367,8 @@ async function applyVirtualBackground({
|
|
|
2354
2367
|
const settings = sourceTrack.getSettings ? sourceTrack.getSettings() : {};
|
|
2355
2368
|
const width = Number(settings.width) || 640;
|
|
2356
2369
|
const height = Number(settings.height) || 360;
|
|
2357
|
-
const
|
|
2370
|
+
const resolvedBlurPixels = Math.max(0, Number(blurPixels) || 0);
|
|
2371
|
+
const backgroundImage = resolvedBlurPixels > 0 ? null : typeof image === "string" ? await loadImage(image) : image;
|
|
2358
2372
|
const producer = publish ? live.videoProducer || live.localVideoProducer : null;
|
|
2359
2373
|
const processingTrack = sourceTrack.clone?.();
|
|
2360
2374
|
if (!processingTrack) throw new Error("This camera cannot create the isolated track required for a virtual background.");
|
|
@@ -2390,7 +2404,8 @@ async function applyVirtualBackground({
|
|
|
2390
2404
|
sourceImage: results.image,
|
|
2391
2405
|
backgroundImage,
|
|
2392
2406
|
width: canvas.width,
|
|
2393
|
-
height: canvas.height
|
|
2407
|
+
height: canvas.height,
|
|
2408
|
+
blurFallbackPixels: resolvedBlurPixels
|
|
2394
2409
|
});
|
|
2395
2410
|
} catch {
|
|
2396
2411
|
}
|
|
@@ -2452,6 +2467,16 @@ async function applyVirtualBackground({
|
|
|
2452
2467
|
};
|
|
2453
2468
|
}
|
|
2454
2469
|
}
|
|
2470
|
+
function applyBackgroundBlur({
|
|
2471
|
+
blurPixels = DEFAULT_BACKGROUND_BLUR_PIXELS,
|
|
2472
|
+
...options
|
|
2473
|
+
}) {
|
|
2474
|
+
return applyVirtualBackground({
|
|
2475
|
+
...options,
|
|
2476
|
+
image: null,
|
|
2477
|
+
blurPixels
|
|
2478
|
+
});
|
|
2479
|
+
}
|
|
2455
2480
|
async function clearVirtualBackground({
|
|
2456
2481
|
parameters
|
|
2457
2482
|
}) {
|
|
@@ -2822,8 +2847,12 @@ exports.userWaiting = methods_index.userWaiting;
|
|
|
2822
2847
|
exports.validateWelcomeAlphanumeric = methods_index.validateWelcomeAlphanumeric;
|
|
2823
2848
|
exports.validateWelcomeInputs = methods_index.validateWelcomeInputs;
|
|
2824
2849
|
exports.validateAlphanumeric = validateAlphanumeric.validateAlphanumeric;
|
|
2850
|
+
exports.DEFAULT_BACKGROUND_BLUR_PIXELS = DEFAULT_BACKGROUND_BLUR_PIXELS;
|
|
2851
|
+
exports.VIRTUAL_BACKGROUND_BLUR = VIRTUAL_BACKGROUND_BLUR;
|
|
2852
|
+
exports.applyBackgroundBlur = applyBackgroundBlur;
|
|
2825
2853
|
exports.applyVirtualBackground = applyVirtualBackground;
|
|
2826
2854
|
exports.clearVirtualBackground = clearVirtualBackground;
|
|
2827
2855
|
exports.compositeVirtualBackgroundFrame = compositeVirtualBackgroundFrame;
|
|
2856
|
+
exports.isVirtualBackgroundBlur = isVirtualBackgroundBlur;
|
|
2828
2857
|
exports.isVirtualBackgroundRunning = isVirtualBackgroundRunning;
|
|
2829
2858
|
//# sourceMappingURL=index.cjs.map
|