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.
Files changed (42) hide show
  1. package/CHANGELOG.md +17 -4
  2. package/README.md +145 -131
  3. package/dist/consumers/connectIps.d.ts.map +1 -1
  4. package/dist/consumers/index.cjs +1 -1
  5. package/dist/consumers/index.js +1 -1
  6. package/dist/{getParticipantMedia-DC_Nca8S.cjs → getParticipantMedia-AwwtMCTz.cjs} +4 -4
  7. package/dist/getParticipantMedia-AwwtMCTz.cjs.map +1 -0
  8. package/dist/{getParticipantMedia-Bu_aZlxe.js → getParticipantMedia-CyaOk2oD.js} +4 -4
  9. package/dist/getParticipantMedia-CyaOk2oD.js.map +1 -0
  10. package/dist/index.cjs +36 -7
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.js +37 -8
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.native.cjs +3 -3
  15. package/dist/index.native.js +3 -3
  16. package/dist/{joinLocalRoom-7ibqv7zZ.js → joinLocalRoom-Bu3gz27d.js} +2 -2
  17. package/dist/{joinLocalRoom-7ibqv7zZ.js.map → joinLocalRoom-Bu3gz27d.js.map} +1 -1
  18. package/dist/{joinLocalRoom-BJBDvTYh.cjs → joinLocalRoom-Cii5D5IG.cjs} +2 -2
  19. package/dist/{joinLocalRoom-BJBDvTYh.cjs.map → joinLocalRoom-Cii5D5IG.cjs.map} +1 -1
  20. package/dist/methods/recording/startRecording.d.ts.map +1 -1
  21. package/dist/methods/utils/headless/virtualBackground.d.ts +13 -1
  22. package/dist/methods/utils/headless/virtualBackground.d.ts.map +1 -1
  23. package/dist/methods/utils/virtualBackgroundCompositor.d.ts +4 -0
  24. package/dist/methods/utils/virtualBackgroundCompositor.d.ts.map +1 -1
  25. package/dist/sockets/SocketManager.d.ts +0 -27
  26. package/dist/sockets/SocketManager.d.ts.map +1 -1
  27. package/dist/types/index.cjs +2 -2
  28. package/dist/types/index.js +2 -2
  29. package/dist/{updateParticipantAudioDecibels-C_MygF6q.js → updateParticipantAudioDecibels-CnEXJBmc.js} +85 -13
  30. package/dist/updateParticipantAudioDecibels-CnEXJBmc.js.map +1 -0
  31. package/dist/{updateParticipantAudioDecibels-bZ6R8WHj.cjs → updateParticipantAudioDecibels-QZyahisU.cjs} +85 -13
  32. package/dist/updateParticipantAudioDecibels-QZyahisU.cjs.map +1 -0
  33. package/package.json +1 -1
  34. package/src/consumers/connectIps.ts +46 -7
  35. package/src/methods/recording/startRecording.ts +7 -1
  36. package/src/methods/utils/headless/virtualBackground.ts +34 -2
  37. package/src/methods/utils/virtualBackgroundCompositor.ts +18 -1
  38. package/src/sockets/SocketManager.ts +54 -7
  39. package/dist/getParticipantMedia-Bu_aZlxe.js.map +0 -1
  40. package/dist/getParticipantMedia-DC_Nca8S.cjs.map +0 -1
  41. package/dist/updateParticipantAudioDecibels-C_MygF6q.js.map +0 -1
  42. package/dist/updateParticipantAudioDecibels-bZ6R8WHj.cjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { a, b, d, c, e, f, j, m, p, u } from "./joinLocalRoom-7ibqv7zZ.js";
2
- import { Y, Z, a as a2, _, $, b as b2, W, d as d2, e as e2, f as f2, g, h, aa, i, j as j2, k, l, m as m2, a8, c as c2, a0, n, o, p as p2, q, a9, r, s, a1, a2 as a22, a3, t, X, T, v, U, w, x, y, V, C, G, z, A, a4, B, D, E, F, a5, N, H, I, J, K, L, M, O, P, Q, R, S, u as u2, a6, a7 } from "./updateParticipantAudioDecibels-C_MygF6q.js";
1
+ import { a, b, d, c, e, f, j, m, p, u } from "./joinLocalRoom-Bu3gz27d.js";
2
+ import { Y, Z, a as a2, _, $, b as b2, W, d as d2, e as e2, f as f2, g, h, aa, i, j as j2, k, l, m as m2, a8, c as c2, a0, n, o, p as p2, q, a9, r, s, a1, a2 as a22, a3, t, X, T, v, U, w, x, y, V, C, G, z, A, a4, B, D, E, F, a5, N, H, I, J, K, L, M, O, P, Q, R, S, u as u2, a6, a7 } from "./updateParticipantAudioDecibels-CnEXJBmc.js";
3
3
  import { Q as Q2, u as u3, m as m3, A as A2, f as f3, e as e3, a as a10, c as c3, b as b3, d as d3, l as l2, y as y2, p as p3, D as D2, g as g2, k as k2, x as x2, o as o2, C as C2, h as h2, j as j3, q as q2, z as z2, r as r2, E as E2, F as F2, s as s2, i as i2, w as w2, n as n2, B as B2, t as t2, v as v2 } from "./joinRoomOnMediaSFU-y6vJ1OBo.js";
4
4
  import { b as b4, d as d4, c as c4, f as f4, e as e4, k as k3, j as j4, h as h3, i as i3, p as p4, a as a11, r as r3, g as g3, s as s3, l as l3 } from "./translationConsumerSwitch-zKuS5wgH.js";
5
- import { _ as getCurrentParams, W as getLocalVideoStream } from "./getParticipantMedia-Bu_aZlxe.js";
6
- import { aD, aR, w as w3, x as x3, f as f5, y as y3, aP, ar, aU, aS, ab, at, aI, a4 as a42, Z as Z2, au, aV, aL, az, X as X2, aG, a7 as a72, N as N2, a8 as a82, b0, a2 as a23, aM, aQ, aq, aO, aw, av, ai, V as V2, U as U2, T as T2, Y as Y2, a6 as a62, aN, ax, aA, an, q as q3, t as t3, h as h4, Q as Q3, a as a12, R as R2, u as u4, l as l4, b as b5, c as c5, S as S2, g as g4, d as d5, i as i4, j as j5, k as k4, n as n3, v as v3, z as z3, H as H2, J as J2, O as O2, $ as $2, a5 as a52, a3 as a32, o as o3, m as m4, e as e5, ad, aa as aa2, p as p5, ak, aY, a_, aZ, aW, aT, aF, A as A3, B as B3, C as C3, D as D3, ae, r as r4, a$, ag, I as I2, P as P2, af, al, a1 as a13, a0 as a02, s as s4, aC, ah, a9 as a92, aB, aK, ay, E as E3, aj, ao, aE, ac, aX, F as F3, am, ap, K as K2, aH, aJ, L as L2, M as M2, G as G2, as } from "./getParticipantMedia-Bu_aZlxe.js";
5
+ import { _ as getCurrentParams, W as getLocalVideoStream } from "./getParticipantMedia-CyaOk2oD.js";
6
+ import { aD, aR, w as w3, x as x3, f as f5, y as y3, aP, ar, aU, aS, ab, at, aI, a4 as a42, Z as Z2, au, aV, aL, az, X as X2, aG, a7 as a72, N as N2, a8 as a82, b0, a2 as a23, aM, aQ, aq, aO, aw, av, ai, V as V2, U as U2, T as T2, Y as Y2, a6 as a62, aN, ax, aA, an, q as q3, t as t3, h as h4, Q as Q3, a as a12, R as R2, u as u4, l as l4, b as b5, c as c5, S as S2, g as g4, d as d5, i as i4, j as j5, k as k4, n as n3, v as v3, z as z3, H as H2, J as J2, O as O2, $ as $2, a5 as a52, a3 as a32, o as o3, m as m4, e as e5, ad, aa as aa2, p as p5, ak, aY, a_, aZ, aW, aT, aF, A as A3, B as B3, C as C3, D as D3, ae, r as r4, a$, ag, I as I2, P as P2, af, al, a1 as a13, a0 as a02, s as s4, aC, ah, a9 as a92, aB, aK, ay, E as E3, aj, ao, aE, ac, aX, F as F3, am, ap, K as K2, aH, aJ, L as L2, M as M2, G as G2, as } from "./getParticipantMedia-CyaOk2oD.js";
7
7
  import { COMMON_LANGUAGE_CODES, MediaStream as MediaStream2, MediaStreamTrack, RTCView, SUPPORTED_LANGUAGE_CODES, SoundPlayer, TTS_PROVIDERS, addPanelist, addedAsPanelist, allMembers, allMembersRest, allWaitingRoomMembers, banParticipant, bulkUpdateParticipantPermissions, clickChat, controlMediaHost, createLiveSubtitle, createResponseJoinRoom, createRoomOnMediaSFU, disconnect, disconnectUserSelf, fetchLanguagesViaSocket, fetchVoicesViaSocket, focusPanelists, formatNumber, generateRandomMessages, generateRandomParticipants, generateRandomPolls, generateRandomRequestList, generateRandomWaitingRoomList, getAvailableVoices, getCommonLanguages, getDomains, getLanguageMetadata, getLanguageName, getLanguageNativeName, getOverlayPosition, getSubtitleForSpeaker, getSupportedLanguages, handleCreateRoom, handleJoinRoom, handleWelcomeRequest, initialValuesState, isLanguageSupported, isSubtitleExpired, launchPanelists, launchPermissions, mediaDevices, meetingEnded, meetingStillThere, meetingTimeRemaining, normalizeLanguageCode, panelistControlMedia, panelistFocusChanged, panelistsUpdated, participantRequested, permissionConfigUpdated, permissionUpdated, personJoined, pollUpdated, producerMediaClosed, producerMediaPaused, producerMediaResumed, pruneExpiredSubtitles, reInitiateRecording, receiveMessage, recordingNotice, registerGlobals, removePanelist, removedFromPanelists, roomRecordParams, screenProducerId, sleep, startMeetingProgressTimer, startRecords, stoppedRecording, translationChannelsAvailable, translationConfigUpdated, translationError, translationLanguageSet, translationMemberState, translationProducerClosed, translationProducerReady, translationRoomConfig, translationSpeakerOutputChanged, translationSubscribed, translationTranscript, translationUnsubscribed, unfocusPanelists, updateConsumingDomains, updateLiveSubtitlesFromTranscript, updateMediaSettings, updatePanelists, updateParticipantPermission, updatePermissionConfig, updatedCoHost, userWaiting, validateWelcomeAlphanumeric, validateWelcomeInputs } from "./methods/index.js";
8
8
  import { v as v4 } from "./validateAlphanumeric-Dk1JB80W.js";
9
9
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -2283,6 +2283,11 @@ function requireSelfie_segmentation() {
2283
2283
  return selfie_segmentation;
2284
2284
  }
2285
2285
  var selfie_segmentationExports = /* @__PURE__ */ requireSelfie_segmentation();
2286
+ const VIRTUAL_BACKGROUND_BLUR = "blur";
2287
+ const DEFAULT_BACKGROUND_BLUR_PIXELS = 16;
2288
+ function isVirtualBackgroundBlur(value) {
2289
+ return value === VIRTUAL_BACKGROUND_BLUR;
2290
+ }
2286
2291
  function compositeVirtualBackgroundFrame({
2287
2292
  ctx,
2288
2293
  segmentationMask,
@@ -2308,7 +2313,14 @@ function compositeVirtualBackgroundFrame({
2308
2313
  ctx.fillRect(0, 0, width, height);
2309
2314
  } else if (blurFallbackPixels > 0) {
2310
2315
  ctx.filter = `blur(${blurFallbackPixels}px)`;
2311
- ctx.drawImage(sourceImage, 0, 0, width, height);
2316
+ const bleed = Math.max(2, blurFallbackPixels * 2);
2317
+ ctx.drawImage(
2318
+ sourceImage,
2319
+ -bleed,
2320
+ -bleed,
2321
+ width + bleed * 2,
2322
+ height + bleed * 2
2323
+ );
2312
2324
  }
2313
2325
  } finally {
2314
2326
  ctx.filter = previousFilter || "none";
@@ -2333,7 +2345,8 @@ async function applyVirtualBackground({
2333
2345
  frameRate = 30,
2334
2346
  modelSelection = 1,
2335
2347
  publish = true,
2336
- assetPath = MEDIAPIPE_CDN
2348
+ assetPath = MEDIAPIPE_CDN,
2349
+ blurPixels = 0
2337
2350
  }) {
2338
2351
  const live = getCurrentParams({ parameters });
2339
2352
  if (live.audioOnlyRoom) {
@@ -2353,7 +2366,8 @@ async function applyVirtualBackground({
2353
2366
  const settings = sourceTrack.getSettings ? sourceTrack.getSettings() : {};
2354
2367
  const width = Number(settings.width) || 640;
2355
2368
  const height = Number(settings.height) || 360;
2356
- const backgroundImage = typeof image === "string" ? await loadImage(image) : image;
2369
+ const resolvedBlurPixels = Math.max(0, Number(blurPixels) || 0);
2370
+ const backgroundImage = resolvedBlurPixels > 0 ? null : typeof image === "string" ? await loadImage(image) : image;
2357
2371
  const producer = publish ? live.videoProducer || live.localVideoProducer : null;
2358
2372
  const processingTrack = sourceTrack.clone?.();
2359
2373
  if (!processingTrack) throw new Error("This camera cannot create the isolated track required for a virtual background.");
@@ -2389,7 +2403,8 @@ async function applyVirtualBackground({
2389
2403
  sourceImage: results.image,
2390
2404
  backgroundImage,
2391
2405
  width: canvas.width,
2392
- height: canvas.height
2406
+ height: canvas.height,
2407
+ blurFallbackPixels: resolvedBlurPixels
2393
2408
  });
2394
2409
  } catch {
2395
2410
  }
@@ -2451,6 +2466,16 @@ async function applyVirtualBackground({
2451
2466
  };
2452
2467
  }
2453
2468
  }
2469
+ function applyBackgroundBlur({
2470
+ blurPixels = DEFAULT_BACKGROUND_BLUR_PIXELS,
2471
+ ...options
2472
+ }) {
2473
+ return applyVirtualBackground({
2474
+ ...options,
2475
+ image: null,
2476
+ blurPixels
2477
+ });
2478
+ }
2454
2479
  async function clearVirtualBackground({
2455
2480
  parameters
2456
2481
  }) {
@@ -2481,6 +2506,7 @@ function isVirtualBackgroundRunning() {
2481
2506
  }
2482
2507
  export {
2483
2508
  COMMON_LANGUAGE_CODES,
2509
+ DEFAULT_BACKGROUND_BLUR_PIXELS,
2484
2510
  MediaStream2 as MediaStream,
2485
2511
  MediaStreamTrack,
2486
2512
  Q2 as QnHDCons,
@@ -2491,6 +2517,7 @@ export {
2491
2517
  SUPPORTED_LANGUAGE_CODES,
2492
2518
  SoundPlayer,
2493
2519
  TTS_PROVIDERS,
2520
+ VIRTUAL_BACKGROUND_BLUR,
2494
2521
  f3 as aParams,
2495
2522
  addPanelist,
2496
2523
  a as addVideosGrid,
@@ -2498,6 +2525,7 @@ export {
2498
2525
  allMembers,
2499
2526
  allMembersRest,
2500
2527
  allWaitingRoomMembers,
2528
+ applyBackgroundBlur,
2501
2529
  applyVirtualBackground,
2502
2530
  aD as assignParticipantToBreakoutRoom,
2503
2531
  aR as attachPlayback,
@@ -2644,6 +2672,7 @@ export {
2644
2672
  isLanguageSupported,
2645
2673
  i3 as isSpeakerInMyBreakoutRoom,
2646
2674
  isSubtitleExpired,
2675
+ isVirtualBackgroundBlur,
2647
2676
  isVirtualBackgroundRunning,
2648
2677
  X as joinConRoom,
2649
2678
  T as joinConsumeRoom,