@whereby.com/media 9.7.4 → 10.0.1

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/index.cjs CHANGED
@@ -64,8 +64,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
64
64
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
65
65
  };
66
66
 
67
- var _a$7;
68
- (_a$7 = adapterRaw.default) !== null && _a$7 !== void 0 ? _a$7 : adapterRaw;
67
+ var _a$6;
68
+ (_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6 : adapterRaw;
69
69
  const RTCSTATS_PROTOCOL_VERSION = "1.0";
70
70
  const GETSTATS_BUFFER_SIZE = 20;
71
71
  const clientInfo = {
@@ -308,11 +308,11 @@ class Logger {
308
308
  }
309
309
  }
310
310
 
311
- var _a$6, _b$2;
312
- const adapter$6 = (_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6 : adapterRaw;
311
+ var _a$5, _b$2;
312
+ const adapter$5 = (_a$5 = adapterRaw.default) !== null && _a$5 !== void 0 ? _a$5 : adapterRaw;
313
313
  const logger$b = new Logger();
314
- const browserName$2 = (_b$2 = adapter$6.browserDetails) === null || _b$2 === void 0 ? void 0 : _b$2.browser;
315
- const browserVersion$1 = adapter$6.browserDetails.version;
314
+ const browserName$2 = (_b$2 = adapter$5.browserDetails) === null || _b$2 === void 0 ? void 0 : _b$2.browser;
315
+ const browserVersion$1 = adapter$5.browserDetails.version;
316
316
  function setCodecPreferenceSDP({ sdp, redOn }) {
317
317
  var _a, _b;
318
318
  try {
@@ -500,8 +500,8 @@ function trackAnnotations(o) {
500
500
  return props;
501
501
  }
502
502
 
503
- var _a$5;
504
- const adapter$5 = (_a$5 = adapterRaw.default) !== null && _a$5 !== void 0 ? _a$5 : adapterRaw;
503
+ var _a$4;
504
+ const adapter$4 = (_a$4 = adapterRaw.default) !== null && _a$4 !== void 0 ? _a$4 : adapterRaw;
505
505
  const logger$a = new Logger();
506
506
  class Session {
507
507
  constructor({ clientId, bandwidth, peerConnectionConfig, deprioritizeH264Encoding, incrementAnalyticMetric, mediaPrefs, }) {
@@ -658,7 +658,7 @@ class Session {
658
658
  if (this.pc.signalingState === "closed") {
659
659
  return;
660
660
  }
661
- if (((_a = adapter$5.browserDetails) === null || _a === void 0 ? void 0 : _a.browser) === "safari" && candidate && candidate.candidate === "") {
661
+ if (((_a = adapter$4.browserDetails) === null || _a === void 0 ? void 0 : _a.browser) === "safari" && candidate && candidate.candidate === "") {
662
662
  return;
663
663
  }
664
664
  this.pc.addIceCandidate(candidate).catch((e) => {
@@ -771,39 +771,6 @@ class Session {
771
771
 
772
772
  const MEDIA_JITTER_BUFFER_TARGET = 400;
773
773
 
774
- var _a$4;
775
- const adapter$4 = (_a$4 = adapterRaw.default) !== null && _a$4 !== void 0 ? _a$4 : adapterRaw;
776
- function detectMicrophoneNotWorking(pc) {
777
- var _a, _b;
778
- if (((_a = adapter$4.browserDetails) === null || _a === void 0 ? void 0 : _a.browser) !== "chrome" ||
779
- ((_b = adapter$4.browserDetails) === null || _b === void 0 ? void 0 : _b.browser) < 58 ||
780
- pc.signalingState === "closed") {
781
- return Promise.resolve("");
782
- }
783
- const sendingAudio = pc.getSenders().some((sender) => { var _a; return ((_a = sender.track) === null || _a === void 0 ? void 0 : _a.kind) === "audio"; });
784
- const receivingAudio = pc.getReceivers().some((receiver) => { var _a; return ((_a = receiver.track) === null || _a === void 0 ? void 0 : _a.kind) === "audio"; });
785
- return pc.getStats(null).then((result) => {
786
- let microphoneFailed = "";
787
- result.forEach((report) => {
788
- if (report.type === "outbound-rtp" &&
789
- (report.kind === "audio" || report.mediaType === "audio") &&
790
- sendingAudio) {
791
- if (report.bytesSent === 0) {
792
- microphoneFailed = "outbound";
793
- }
794
- }
795
- else if (report.type === "inbound-rtp" &&
796
- (report.kind === "audio" || report.mediaType === "audio") &&
797
- receivingAudio) {
798
- if (report.bytesReceived === 0) {
799
- microphoneFailed = "inbound";
800
- }
801
- }
802
- });
803
- return microphoneFailed;
804
- });
805
- }
806
-
807
774
  const PROTOCOL_REQUESTS = {
808
775
  BLOCK_CLIENT: "block_client",
809
776
  CANCEL_ROOM_KNOCK: "cancel_room_knock",
@@ -992,9 +959,7 @@ ipRegex.v4 = (options) => options && options.exact ? v4exact : new RegExp(`${bou
992
959
  ipRegex.v6 = (options) => options && options.exact ? v6exact : new RegExp(`${boundry(options)}${v6}${boundry(options)}`, "g");
993
960
 
994
961
  var rtcManagerEvents = {
995
- CAMERA_NOT_WORKING: "camera_not_working",
996
962
  CONNECTION_BLOCKED_BY_NETWORK: "connection_blocked_by_network",
997
- MICROPHONE_NOT_WORKING: "microphone_not_working",
998
963
  MICROPHONE_STOPPED_WORKING: "microphone_stopped_working",
999
964
  CAMERA_STOPPED_WORKING: "camera_stopped_working",
1000
965
  NEW_PC: "new_pc",
@@ -2450,79 +2415,11 @@ fromLocation(typeof window !== "undefined" ? window.location : undefined);
2450
2415
 
2451
2416
  var _a$2, _b$1;
2452
2417
  const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
2453
- const isSafari = ((_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser) === "safari";
2454
- const parseResolution = (res) => res.split(/[^\d]/g).map((n) => parseInt(n, 10));
2455
- function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }) {
2456
- var _a, _b;
2457
- let HIGH_HEIGHT = 480;
2458
- let LOW_HEIGHT = 240;
2459
- if (hd) {
2460
- HIGH_HEIGHT = lax || isSafari ? 720 : { min: 360, ideal: 720 };
2461
- }
2462
- if (simulcast) {
2463
- if (hd === false) {
2464
- HIGH_HEIGHT = 360;
2465
- LOW_HEIGHT = 270;
2466
- }
2467
- else {
2468
- LOW_HEIGHT = 360;
2469
- }
2470
- }
2471
- const constraints = {
2472
- audio: Object.assign({}, (preferredDeviceIds.audioId && { deviceId: preferredDeviceIds.audioId })),
2473
- video: Object.assign(Object.assign({}, (preferredDeviceIds.videoId ? { deviceId: preferredDeviceIds.videoId } : { facingMode: "user" })), { height: lowDataMode ? LOW_HEIGHT : HIGH_HEIGHT, frameRate: lowDataMode && !simulcast ? 15 : 24 }),
2474
- };
2475
- if (lax) {
2476
- if (!((_a = constraints.audio) === null || _a === void 0 ? void 0 : _a.deviceId))
2477
- constraints.audio = true;
2478
- (_b = constraints.video) === null || _b === void 0 ? true : delete _b.facingMode;
2479
- return constraints;
2480
- }
2481
- if (resolution) {
2482
- const [w, h, fps] = parseResolution(resolution);
2483
- if (w)
2484
- constraints.video.width = { exact: w };
2485
- if (h)
2486
- constraints.video.height = { exact: h };
2487
- if (fps)
2488
- constraints.video.frameRate = { exact: fps };
2489
- delete constraints.video.facingMode;
2490
- }
2491
- else {
2492
- constraints.video.aspectRatio = widescreen ? 16 / 9 : 4 / 3;
2493
- }
2494
- if (disableAGC)
2495
- constraints.audio.autoGainControl = false;
2496
- if (disableAEC)
2497
- constraints.audio.echoCancellation = false;
2498
- return constraints;
2499
- }
2500
- function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2501
- const strict = !!devices;
2502
- const audioDevices = devices === null || devices === void 0 ? void 0 : devices.filter((d) => d.kind === "audioinput");
2503
- const videoDevices = devices === null || devices === void 0 ? void 0 : devices.filter((d) => d.kind === "videoinput");
2504
- const useDefaultAudio = !audioId || (strict && !(audioDevices === null || audioDevices === void 0 ? void 0 : audioDevices.some((d) => d.deviceId === audioId)));
2505
- const useDefaultVideo = !videoId || (strict && !(videoDevices === null || videoDevices === void 0 ? void 0 : videoDevices.some((d) => d.deviceId === videoId)));
2506
- const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2507
- audioId: useDefaultAudio ? null : { [type]: audioId },
2508
- videoId: useDefaultVideo ? null : { [type]: videoId },
2509
- } }, options));
2510
- if (audioId === false || (strict && !(audioDevices === null || audioDevices === void 0 ? void 0 : audioDevices.length))) {
2511
- delete constraints.audio;
2512
- }
2513
- if (videoId === false || (strict && !(videoDevices === null || videoDevices === void 0 ? void 0 : videoDevices.length))) {
2514
- delete constraints.video;
2515
- }
2516
- return constraints;
2517
- }
2518
-
2519
- var _a$1, _b;
2520
- const adapter$1 = (_a$1 = adapterRaw.default) !== null && _a$1 !== void 0 ? _a$1 : adapterRaw;
2521
2418
  const logger$6 = new Logger();
2522
2419
  const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
2523
2420
  const ICE_RESTART_DELAY = 2 * 1000;
2524
- const browserName$1 = (_b = adapter$1.browserDetails) === null || _b === void 0 ? void 0 : _b.browser;
2525
- const browserVersion = adapter$1.browserDetails.version;
2421
+ const browserName$1 = (_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser;
2422
+ const browserVersion = adapter$2.browserDetails.version;
2526
2423
  let unloading$1 = false;
2527
2424
  if (browserName$1 === "chrome") {
2528
2425
  window.document.addEventListener("beforeunload", () => {
@@ -2548,7 +2445,6 @@ class P2pRtcManager {
2548
2445
  this._closed = false;
2549
2446
  this._videoTrackIdByStreamId = {};
2550
2447
  this._fetchMediaServersTimer = null;
2551
- this._stopCameraTimeout = null;
2552
2448
  this._icePublicIPGatheringTimeoutID = null;
2553
2449
  this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
2554
2450
  this._audioTrackOnEnded = () => {
@@ -2568,7 +2464,6 @@ class P2pRtcManager {
2568
2464
  });
2569
2465
  this.analytics = {
2570
2466
  P2POffendingInitialOffer: 0,
2571
- P2PNonErrorRejectionValueGUMError: 0,
2572
2467
  numNewPc: 0,
2573
2468
  numIceConnected: 0,
2574
2469
  numIceDisconnected: 0,
@@ -2589,7 +2484,6 @@ class P2pRtcManager {
2589
2484
  P2PReplaceTrackNoStream: 0,
2590
2485
  P2PReplaceTrackNewTrackNotInStream: 0,
2591
2486
  P2POnTrackNoStream: 0,
2592
- P2PMicNotWorking: 0,
2593
2487
  P2PLocalNetworkFailed: 0,
2594
2488
  P2PRelayedIceCandidate: 0,
2595
2489
  P2PAddIceCandidateFailure: 0,
@@ -2601,9 +2495,8 @@ class P2pRtcManager {
2601
2495
  isInitializedWith({ selfId, roomName, isSfu }) {
2602
2496
  return this._selfId === selfId && this._roomName === roomName && !isSfu;
2603
2497
  }
2604
- addCameraStream(stream, { videoPaused, beforeEffectTracks = [] } = { beforeEffectTracks: [] }) {
2498
+ addCameraStream(stream, { beforeEffectTracks = [] } = { beforeEffectTracks: [] }) {
2605
2499
  logger$6.info("addCameraStream: [stream.id: %s]", stream.id);
2606
- this._webcamPaused = videoPaused;
2607
2500
  if (stream === this._localCameraStream) {
2608
2501
  return;
2609
2502
  }
@@ -3097,14 +2990,6 @@ class P2pRtcManager {
3097
2990
  logger$6.info(`connectionState changed to ${pc.connectionState} for session ${session.clientId}`);
3098
2991
  switch (pc.connectionState) {
3099
2992
  case "connected":
3100
- setTimeout(() => {
3101
- detectMicrophoneNotWorking(session.pc).then((failureDirection) => {
3102
- if (failureDirection) {
3103
- this.analytics.P2PMicNotWorking++;
3104
- rtcStats.sendEvent("P2PMicNotWorking", { clientId, failureDirection });
3105
- }
3106
- });
3107
- }, 3000);
3108
2993
  (_a = session.registerConnected) === null || _a === void 0 ? void 0 : _a.call(session, {});
3109
2994
  break;
3110
2995
  case "failed":
@@ -3480,65 +3365,7 @@ class P2pRtcManager {
3480
3365
  }
3481
3366
  }
3482
3367
  }
3483
- stopOrResumeVideo(localStream, enable) {
3484
- var _a;
3485
- logger$6.info("stopOrResumeVideo() [enable: %s]", enable);
3486
- this._webcamPaused = !enable;
3487
- if (!["chrome", "safari"].includes(browserName$1)) {
3488
- return;
3489
- }
3490
- if (this._stopCameraTimeout) {
3491
- clearTimeout(this._stopCameraTimeout);
3492
- this._stopCameraTimeout = null;
3493
- }
3494
- if (enable === false) {
3495
- const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
3496
- this._stopCameraTimeout = setTimeout(() => {
3497
- localStream.getVideoTracks().forEach((track) => {
3498
- if (track.enabled === false) {
3499
- track.stop();
3500
- localStream.removeTrack(track);
3501
- this._emit(EVENTS.LOCAL_STREAM_TRACK_REMOVED, {
3502
- stream: localStream,
3503
- track,
3504
- });
3505
- this._handleStopOrResumeVideo({ enable, track });
3506
- }
3507
- });
3508
- }, stopCameraDelay);
3509
- }
3510
- else {
3511
- if (localStream.getVideoTracks().length === 0) {
3512
- const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
3513
- if (!constraints) {
3514
- return;
3515
- }
3516
- navigator.mediaDevices
3517
- .getUserMedia({ video: constraints })
3518
- .then((stream) => {
3519
- const track = stream.getVideoTracks()[0];
3520
- if (this._webcamPaused) {
3521
- track.stop();
3522
- return;
3523
- }
3524
- localStream.addTrack(track);
3525
- this._monitorVideoTrack(track);
3526
- this._emit(EVENTS.LOCAL_STREAM_TRACK_ADDED, {
3527
- streamId: localStream.id,
3528
- tracks: [track],
3529
- screenShare: false,
3530
- });
3531
- this._handleStopOrResumeVideo({ enable, track });
3532
- })
3533
- .catch((e) => {
3534
- if (!(e instanceof Error)) {
3535
- this.analytics.P2PNonErrorRejectionValueGUMError++;
3536
- e = new Error(`non-error gUM rejection value: ${JSON.stringify(e)}`);
3537
- }
3538
- throw e;
3539
- });
3540
- }
3541
- }
3368
+ stopOrResumeVideo() {
3542
3369
  }
3543
3370
  removeScreenshareStream(stream, { requestedByClientId } = {}) {
3544
3371
  logger$6.info("removeScreenshareStream() [stream.id: %s, requestedByClientId: %s]", stream.id, requestedByClientId);
@@ -4406,10 +4233,10 @@ const STREAM_TYPES = {
4406
4233
  screenshare: "screenshare",
4407
4234
  };
4408
4235
 
4409
- var _a;
4410
- const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
4236
+ var _a$1;
4237
+ const adapter$1 = (_a$1 = adapterRaw.default) !== null && _a$1 !== void 0 ? _a$1 : adapterRaw;
4411
4238
  const logger$2 = new Logger();
4412
- const browserName = adapter.browserDetails.browser;
4239
+ const browserName = adapter$1.browserDetails.browser;
4413
4240
  let unloading = false;
4414
4241
  const RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS = 3500;
4415
4242
  const RESTARTICE_ERROR_MAX_RETRY_COUNT = 5;
@@ -4460,7 +4287,6 @@ class VegaRtcManager {
4460
4287
  this._sndTransportIceRestartPromise = null;
4461
4288
  this._rcvTransportIceRestartPromise = null;
4462
4289
  this._colocation = null;
4463
- this._stopCameraTimeout = null;
4464
4290
  this._audioTrackOnEnded = () => {
4465
4291
  rtcStats.sendEvent("audio_ended", { unloading });
4466
4292
  this._emitToPWA(rtcManagerEvents.MICROPHONE_STOPPED_WORKING, {});
@@ -4503,7 +4329,6 @@ class VegaRtcManager {
4503
4329
  vegaIceRestarts: 0,
4504
4330
  vegaIceRestartMissingTransport: 0,
4505
4331
  vegaIceRestartWrongTransportId: 0,
4506
- vegaNonErrorRejectionValueGUMError: 0,
4507
4332
  vegaReplaceTrackNoProducerNoEnabledTrack: 0,
4508
4333
  vegaMicProducerFailed: 0,
4509
4334
  vegaWebcamProducerFailed: 0,
@@ -5553,9 +5378,9 @@ class VegaRtcManager {
5553
5378
  return;
5554
5379
  }
5555
5380
  }
5556
- stopOrResumeAudio(stream, enabled) {
5557
- logger$2.info("stopOrResumeAudio() [enabled:%s]", enabled);
5558
- this._micPaused = !enabled;
5381
+ stopOrResumeAudio({ enable }) {
5382
+ logger$2.info("stopOrResumeAudio() [enable:%s]", enable);
5383
+ this._micPaused = !enable;
5559
5384
  this._pauseResumeMic();
5560
5385
  }
5561
5386
  _handleStopOrResumeVideo({ enable, track }) {
@@ -5570,61 +5395,10 @@ class VegaRtcManager {
5570
5395
  this._sendWebcam(track);
5571
5396
  }
5572
5397
  }
5573
- stopOrResumeVideo(localStream, enable) {
5574
- var _a;
5398
+ stopOrResumeVideo({ enable }) {
5575
5399
  logger$2.info("stopOrResumeVideo() [enable:%s]", enable);
5576
5400
  this._webcamPaused = !enable;
5577
5401
  this._pauseResumeWebcam();
5578
- if (!["chrome", "safari"].includes(browserName)) {
5579
- return;
5580
- }
5581
- if (this._stopCameraTimeout) {
5582
- clearTimeout(this._stopCameraTimeout);
5583
- this._stopCameraTimeout = null;
5584
- }
5585
- if (!enable) {
5586
- const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
5587
- this._stopCameraTimeout = setTimeout(() => {
5588
- localStream.getVideoTracks().forEach((track) => {
5589
- if (track.enabled === false) {
5590
- track.stop();
5591
- localStream.removeTrack(track);
5592
- this._emitToPWA(EVENTS.LOCAL_STREAM_TRACK_REMOVED, {
5593
- stream: localStream,
5594
- track,
5595
- });
5596
- this._handleStopOrResumeVideo({ enable, track });
5597
- }
5598
- });
5599
- }, stopCameraDelay);
5600
- }
5601
- else if (localStream.getVideoTracks().length === 0) {
5602
- const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
5603
- navigator.mediaDevices
5604
- .getUserMedia({ video: constraints })
5605
- .then((stream) => {
5606
- const track = stream.getVideoTracks()[0];
5607
- if (this._webcamPaused) {
5608
- track.stop();
5609
- return;
5610
- }
5611
- localStream.addTrack(track);
5612
- this._monitorVideoTrack(track);
5613
- this._emitToPWA(EVENTS.LOCAL_STREAM_TRACK_ADDED, {
5614
- streamId: localStream.id,
5615
- tracks: [track],
5616
- screenShare: false,
5617
- });
5618
- this._handleStopOrResumeVideo({ enable, track });
5619
- })
5620
- .catch((e) => {
5621
- if (!(e instanceof Error)) {
5622
- this.analytics.vegaNonErrorRejectionValueGUMError++;
5623
- e = new Error(`non-error gUM rejection value: ${JSON.stringify(e)}`);
5624
- }
5625
- throw e;
5626
- });
5627
- }
5628
5402
  }
5629
5403
  acceptNewStream({ streamId, clientId }) {
5630
5404
  logger$2.info("acceptNewStream()", { streamId, clientId });
@@ -7233,6 +7007,74 @@ class BandwidthTester extends EventEmitter {
7233
7007
  }
7234
7008
  }
7235
7009
 
7010
+ var _a, _b;
7011
+ const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
7012
+ const isSafari = ((_b = adapter.browserDetails) === null || _b === void 0 ? void 0 : _b.browser) === "safari";
7013
+ const parseResolution = (res) => res.split(/[^\d]/g).map((n) => parseInt(n, 10));
7014
+ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }) {
7015
+ var _a, _b;
7016
+ let HIGH_HEIGHT = 480;
7017
+ let LOW_HEIGHT = 240;
7018
+ if (hd) {
7019
+ HIGH_HEIGHT = lax || isSafari ? 720 : { min: 360, ideal: 720 };
7020
+ }
7021
+ if (simulcast) {
7022
+ if (hd === false) {
7023
+ HIGH_HEIGHT = 360;
7024
+ LOW_HEIGHT = 270;
7025
+ }
7026
+ else {
7027
+ LOW_HEIGHT = 360;
7028
+ }
7029
+ }
7030
+ const constraints = {
7031
+ audio: Object.assign({}, (preferredDeviceIds.audioId && { deviceId: preferredDeviceIds.audioId })),
7032
+ video: Object.assign(Object.assign({}, (preferredDeviceIds.videoId ? { deviceId: preferredDeviceIds.videoId } : { facingMode: "user" })), { height: lowDataMode ? LOW_HEIGHT : HIGH_HEIGHT, frameRate: lowDataMode && !simulcast ? 15 : 24 }),
7033
+ };
7034
+ if (lax) {
7035
+ if (!((_a = constraints.audio) === null || _a === void 0 ? void 0 : _a.deviceId))
7036
+ constraints.audio = true;
7037
+ (_b = constraints.video) === null || _b === void 0 ? true : delete _b.facingMode;
7038
+ return constraints;
7039
+ }
7040
+ if (resolution) {
7041
+ const [w, h, fps] = parseResolution(resolution);
7042
+ if (w)
7043
+ constraints.video.width = { exact: w };
7044
+ if (h)
7045
+ constraints.video.height = { exact: h };
7046
+ if (fps)
7047
+ constraints.video.frameRate = { exact: fps };
7048
+ delete constraints.video.facingMode;
7049
+ }
7050
+ else {
7051
+ constraints.video.aspectRatio = widescreen ? 16 / 9 : 4 / 3;
7052
+ }
7053
+ if (disableAGC)
7054
+ constraints.audio.autoGainControl = false;
7055
+ if (disableAEC)
7056
+ constraints.audio.echoCancellation = false;
7057
+ return constraints;
7058
+ }
7059
+ function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
7060
+ const strict = !!devices;
7061
+ const audioDevices = devices === null || devices === void 0 ? void 0 : devices.filter((d) => d.kind === "audioinput");
7062
+ const videoDevices = devices === null || devices === void 0 ? void 0 : devices.filter((d) => d.kind === "videoinput");
7063
+ const useDefaultAudio = !audioId || (strict && !(audioDevices === null || audioDevices === void 0 ? void 0 : audioDevices.some((d) => d.deviceId === audioId)));
7064
+ const useDefaultVideo = !videoId || (strict && !(videoDevices === null || videoDevices === void 0 ? void 0 : videoDevices.some((d) => d.deviceId === videoId)));
7065
+ const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
7066
+ audioId: useDefaultAudio ? null : { [type]: audioId },
7067
+ videoId: useDefaultVideo ? null : { [type]: videoId },
7068
+ } }, options));
7069
+ if (audioId === false || (strict && !(audioDevices === null || audioDevices === void 0 ? void 0 : audioDevices.length))) {
7070
+ delete constraints.audio;
7071
+ }
7072
+ if (videoId === false || (strict && !(videoDevices === null || videoDevices === void 0 ? void 0 : videoDevices.length))) {
7073
+ delete constraints.video;
7074
+ }
7075
+ return constraints;
7076
+ }
7077
+
7236
7078
  const logger = new Logger();
7237
7079
  const isMobile = typeof navigator !== "undefined" && /mobi/i.test(navigator.userAgent);
7238
7080
  class NoDevicesError extends Error {
@@ -7306,9 +7148,9 @@ function getSettingsFromTrack(kind, track, devices, lastUsedId) {
7306
7148
  settings.deviceId = (_c = track.getConstraints()) === null || _c === void 0 ? void 0 : _c.deviceId;
7307
7149
  return settings;
7308
7150
  }
7309
- function getDeviceData({ audioTrack, videoTrack, devices, stoppedVideoTrack, lastAudioId, lastVideoId, }) {
7151
+ function getDeviceData({ audioTrack, videoTrack, devices, lastAudioId, lastVideoId, }) {
7310
7152
  const usable = (d) => ((d === null || d === void 0 ? void 0 : d.readyState) === "live" ? d : null);
7311
- videoTrack = usable(videoTrack) || stoppedVideoTrack;
7153
+ videoTrack = usable(videoTrack);
7312
7154
  audioTrack = usable(audioTrack);
7313
7155
  const video = getSettingsFromTrack("videoinput", videoTrack, devices, lastVideoId);
7314
7156
  const audio = getSettingsFromTrack("audioinput", audioTrack, devices, lastAudioId);
@@ -7707,7 +7549,6 @@ exports.createACFCalculator = createACFCalculator;
7707
7549
  exports.createMicAnalyser = createMicAnalyser;
7708
7550
  exports.createWorker = createWorker;
7709
7551
  exports.deprioritizeH264 = deprioritizeH264;
7710
- exports.detectMicrophoneNotWorking = detectMicrophoneNotWorking;
7711
7552
  exports.enumerate = enumerate;
7712
7553
  exports.external_stun_servers = external_stun_servers;
7713
7554
  exports.filterMidExtension = filterMidExtension;
package/dist/index.d.cts CHANGED
@@ -435,7 +435,6 @@ type VegaAnalytics = {
435
435
  vegaIceRestarts: number;
436
436
  vegaIceRestartMissingTransport: number;
437
437
  vegaIceRestartWrongTransportId: number;
438
- vegaNonErrorRejectionValueGUMError: number;
439
438
  vegaReplaceTrackNoProducerNoEnabledTrack: number;
440
439
  vegaMicProducerFailed: number;
441
440
  vegaWebcamProducerFailed: number;
@@ -904,6 +903,7 @@ interface CloudRecordingStartedEvent {
904
903
  }
905
904
  interface ClientLeftEvent {
906
905
  clientId: string;
906
+ eventClaim: string;
907
907
  }
908
908
  interface NewClientEvent {
909
909
  client: SignalClient;
@@ -1361,8 +1361,6 @@ declare class BandwidthTester extends EventEmitter {
1361
1361
  _clearTimeouts(): void;
1362
1362
  }
1363
1363
 
1364
- declare function detectMicrophoneNotWorking(pc: RTCPeerConnection): Promise<string>;
1365
-
1366
1364
  declare const MEDIA_JITTER_BUFFER_TARGET = 400;
1367
1365
 
1368
1366
  declare function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }: GetMediaConstraintsOptions): any;
@@ -1382,11 +1380,10 @@ declare function buildDeviceList({ busyDeviceIds, devices, kind }: BuildDeviceLi
1382
1380
  label: string;
1383
1381
  }[];
1384
1382
  declare function getUserMedia(constraints: any): Promise<MediaStream>;
1385
- declare function getDeviceData({ audioTrack, videoTrack, devices, stoppedVideoTrack, lastAudioId, lastVideoId, }: {
1383
+ declare function getDeviceData({ audioTrack, videoTrack, devices, lastAudioId, lastVideoId, }: {
1386
1384
  audioTrack?: MediaStreamTrack | null;
1387
1385
  videoTrack?: MediaStreamTrack | null;
1388
1386
  devices: MediaDeviceInfo[];
1389
- stoppedVideoTrack?: MediaStreamTrack;
1390
1387
  lastAudioId?: string | undefined;
1391
1388
  lastVideoId?: string | undefined;
1392
1389
  }): GetDeviceDataResult;
@@ -1631,7 +1628,6 @@ interface NegotiatePeerConnectionOptions {
1631
1628
  }
1632
1629
  type P2PAnalytics = {
1633
1630
  P2POffendingInitialOffer: number;
1634
- P2PNonErrorRejectionValueGUMError: number;
1635
1631
  numNewPc: number;
1636
1632
  numIceConnected: number;
1637
1633
  numIceDisconnected: number;
@@ -1652,7 +1648,6 @@ type P2PAnalytics = {
1652
1648
  P2PReplaceTrackNoStream: number;
1653
1649
  P2PReplaceTrackNewTrackNotInStream: number;
1654
1650
  P2POnTrackNoStream: number;
1655
- P2PMicNotWorking: number;
1656
1651
  P2PLocalNetworkFailed: number;
1657
1652
  P2PRelayedIceCandidate: number;
1658
1653
  P2PAddIceCandidateFailure: number;
@@ -1685,7 +1680,6 @@ declare class P2pRtcManager implements RtcManager {
1685
1680
  _turnServers: any;
1686
1681
  _mediaserverConfigTtlSeconds: any;
1687
1682
  _fetchMediaServersTimer: ClearableTimeout | null;
1688
- _stopCameraTimeout: ClearableTimeout | null;
1689
1683
  _icePublicIPGatheringTimeoutID: ClearableTimeout | null;
1690
1684
  _stoppedVideoTrack?: MediaStreamTrack;
1691
1685
  _videoTrackBeingMonitored?: MediaStreamTrack;
@@ -1693,7 +1687,6 @@ declare class P2pRtcManager implements RtcManager {
1693
1687
  _closed: boolean;
1694
1688
  analytics: P2PAnalytics;
1695
1689
  _rtcStatsDisconnectTimeout?: ReturnType<typeof setTimeout>;
1696
- _webcamPaused?: boolean;
1697
1690
  _videoTrackIdByStreamId: Record<string, string>;
1698
1691
  constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features }: RtcManagerOptions);
1699
1692
  numberOfPeerconnections(): number;
@@ -1702,7 +1695,7 @@ declare class P2pRtcManager implements RtcManager {
1702
1695
  roomName: string;
1703
1696
  isSfu: boolean;
1704
1697
  }): boolean;
1705
- addCameraStream(stream: MediaStream, { videoPaused, beforeEffectTracks }?: AddCameraStreamOptions): void;
1698
+ addCameraStream(stream: MediaStream, { beforeEffectTracks }?: AddCameraStreamOptions): void;
1706
1699
  _enableStopResumeVideoForBrowserSDK(stream: MediaStream): void;
1707
1700
  addScreenshareStream(stream: MediaStream): void;
1708
1701
  replaceTrack(oldTrack: MediaStreamTrack | null, newTrack: MediaStreamTrack): Promise<void | any[]>;
@@ -1756,7 +1749,7 @@ declare class P2pRtcManager implements RtcManager {
1756
1749
  enable: boolean;
1757
1750
  track: MediaStreamTrack;
1758
1751
  }): void;
1759
- stopOrResumeVideo(localStream: MediaStream, enable: boolean): void;
1752
+ stopOrResumeVideo(): void;
1760
1753
  removeScreenshareStream(stream: MediaStream, { requestedByClientId }?: RemoveScreenshareStreamOptions): void;
1761
1754
  hasClient(clientId: string): boolean;
1762
1755
  shouldAcceptStreamsFromBothSides(): boolean;
@@ -1777,9 +1770,7 @@ declare class RtcManagerDispatcher {
1777
1770
  }
1778
1771
 
1779
1772
  declare const _default: {
1780
- CAMERA_NOT_WORKING: string;
1781
1773
  CONNECTION_BLOCKED_BY_NETWORK: string;
1782
- MICROPHONE_NOT_WORKING: string;
1783
1774
  MICROPHONE_STOPPED_WORKING: string;
1784
1775
  CAMERA_STOPPED_WORKING: string;
1785
1776
  NEW_PC: string;
@@ -2015,7 +2006,6 @@ declare class VegaRtcManager implements RtcManager {
2015
2006
  _sndTransportIceRestartPromise: any;
2016
2007
  _rcvTransportIceRestartPromise: any;
2017
2008
  _colocation: any;
2018
- _stopCameraTimeout: ClearableTimeout | null;
2019
2009
  _audioTrackOnEnded: any;
2020
2010
  _videoTrackOnEnded: any;
2021
2011
  _socketListenerDeregisterFunctions: any;
@@ -2094,12 +2084,16 @@ declare class VegaRtcManager implements RtcManager {
2094
2084
  _enableStopResumeVideoForBrowserSDK(stream: MediaStream): void;
2095
2085
  addScreenshareStream(stream: MediaStream): void;
2096
2086
  _syncMicAnalyser(): void;
2097
- stopOrResumeAudio(stream: MediaStream, enabled: boolean): void;
2087
+ stopOrResumeAudio({ enable }: {
2088
+ enable: boolean;
2089
+ }): void;
2098
2090
  _handleStopOrResumeVideo({ enable, track }: {
2099
2091
  enable: boolean;
2100
2092
  track: MediaStreamTrack;
2101
2093
  }): void;
2102
- stopOrResumeVideo(localStream: MediaStream, enable: boolean): void;
2094
+ stopOrResumeVideo({ enable }: {
2095
+ enable: boolean;
2096
+ }): void;
2103
2097
  acceptNewStream({ streamId, clientId }: {
2104
2098
  streamId: string;
2105
2099
  clientId: string;
@@ -2159,5 +2153,5 @@ declare class VegaRtcManager implements RtcManager {
2159
2153
  hasClient(clientId: string): boolean;
2160
2154
  }
2161
2155
 
2162
- export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getInitialStream, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
2156
+ export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getInitialStream, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
2163
2157
  export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdateRequest, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatFileShare, ChatMessage, ChatMessageError, ChatMessageRemoved, ChatMessageRequest, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, FileShareErrorCode, FileUploadUrl, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetInitialStreamOptions, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, GetUserMediaAttempt, GetUserMediaAttemptOutcome, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockOnHoldEvent, KnockRejectedEvent, KnockResponse, KnockResponseSender, KnockRoomRequest, KnockerLeftEvent, LiveCaptionEvent, LiveCaptionsStartedEvent, LiveCaptionsStoppedEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, MediaPrefs, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError, RemoveScreenshareStreamOptions, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomEmptyError, RoomFullError, RoomJoinPermissionDeniedError, RoomJoinedErrors, RoomJoinedEvent, RoomJoinedSuccess, RoomKnockedEvent, RoomLockedError, RoomLockedEvent, RoomMeetingTimeExhaustedError, RoomMode, RoomSessionEndedEvent, RtcClientConnectionStatusChangedPayload, RtcEventEmitter, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcManagerOptions, RtcStreamAddedPayload, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalIceCandidateMessage, SignalIceEndOfCandidatesMessage, SignalIceServer, SignalKnocker, SignalMediaServerConfig, SignalRTCSessionDescription, SignalReadyToReceiveOfferMessage, SignalRequests, SignalRoom, SignalSDPMessage, SignalSFUServer, SignalTurnServer, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UniqueRoleAlreadyInRoomError, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaConnectionOptions, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };