@whereby.com/media 7.0.1 → 8.0.0

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
@@ -2534,11 +2534,78 @@ var rtcManagerEvents = {
2534
2534
 
2535
2535
  var _a$2, _b$1;
2536
2536
  const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
2537
+ const isSafari = ((_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser) === "safari";
2538
+ const parseResolution = (res) => res.split(/[^\d]/g).map((n) => parseInt(n, 10));
2539
+ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }) {
2540
+ var _a, _b;
2541
+ let HIGH_HEIGHT = 480;
2542
+ let LOW_HEIGHT = 240;
2543
+ if (hd) {
2544
+ HIGH_HEIGHT = lax || isSafari ? 720 : { min: 360, ideal: 720 };
2545
+ }
2546
+ if (simulcast) {
2547
+ if (hd === false) {
2548
+ HIGH_HEIGHT = 360;
2549
+ LOW_HEIGHT = 270;
2550
+ }
2551
+ else {
2552
+ LOW_HEIGHT = 360;
2553
+ }
2554
+ }
2555
+ const constraints = {
2556
+ audio: Object.assign({}, (preferredDeviceIds.audioId && { deviceId: preferredDeviceIds.audioId })),
2557
+ video: Object.assign(Object.assign({}, (preferredDeviceIds.videoId ? { deviceId: preferredDeviceIds.videoId } : { facingMode: "user" })), { height: lowDataMode ? LOW_HEIGHT : HIGH_HEIGHT, frameRate: lowDataMode && !simulcast ? 15 : 24 }),
2558
+ };
2559
+ if (lax) {
2560
+ if (!((_a = constraints.audio) === null || _a === void 0 ? void 0 : _a.deviceId))
2561
+ constraints.audio = true;
2562
+ (_b = constraints.video) === null || _b === void 0 ? true : delete _b.facingMode;
2563
+ return constraints;
2564
+ }
2565
+ if (resolution) {
2566
+ const [w, h, fps] = parseResolution(resolution);
2567
+ if (w)
2568
+ constraints.video.width = { exact: w };
2569
+ if (h)
2570
+ constraints.video.height = { exact: h };
2571
+ if (fps)
2572
+ constraints.video.frameRate = { exact: fps };
2573
+ delete constraints.video.facingMode;
2574
+ }
2575
+ else {
2576
+ constraints.video.aspectRatio = widescreen ? 16 / 9 : 4 / 3;
2577
+ }
2578
+ if (disableAGC)
2579
+ constraints.audio.autoGainControl = false;
2580
+ if (disableAEC)
2581
+ constraints.audio.echoCancellation = false;
2582
+ return constraints;
2583
+ }
2584
+ function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2585
+ const audioDevices = devices.filter((d) => d.kind === "audioinput");
2586
+ const videoDevices = devices.filter((d) => d.kind === "videoinput");
2587
+ const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2588
+ const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2589
+ const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2590
+ audioId: useDefaultAudio ? null : { [type]: audioId },
2591
+ videoId: useDefaultVideo ? null : { [type]: videoId },
2592
+ } }, options));
2593
+ if (audioId === false || !audioDevices.length) {
2594
+ delete constraints.audio;
2595
+ }
2596
+ if (videoId === false || !videoDevices.length) {
2597
+ delete constraints.video;
2598
+ }
2599
+ return constraints;
2600
+ }
2601
+
2602
+ var _a$1, _b;
2603
+ const adapter$1 = (_a$1 = adapterRaw.default) !== null && _a$1 !== void 0 ? _a$1 : adapterRaw;
2537
2604
  const logger$6 = new Logger();
2538
2605
  const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
2539
2606
  const ICE_RESTART_DELAY = 2 * 1000;
2540
- const browserName$1 = (_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser;
2541
- const browserVersion = adapter$2.browserDetails.version;
2607
+ const browserName$1 = (_b = adapter$1.browserDetails) === null || _b === void 0 ? void 0 : _b.browser;
2608
+ const browserVersion = adapter$1.browserDetails.version;
2542
2609
  let unloading$1 = false;
2543
2610
  if (browserName$1 === "chrome") {
2544
2611
  window.document.addEventListener("beforeunload", () => {
@@ -3532,7 +3599,7 @@ class P2pRtcManager {
3532
3599
  }
3533
3600
  else {
3534
3601
  if (localStream.getVideoTracks().length === 0) {
3535
- const constraints = this._webrtcProvider.getMediaConstraints().video;
3602
+ const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
3536
3603
  if (!constraints) {
3537
3604
  return;
3538
3605
  }
@@ -4401,10 +4468,10 @@ const STREAM_TYPES = {
4401
4468
  screenshare: "screenshare",
4402
4469
  };
4403
4470
 
4404
- var _a$1;
4405
- const adapter$1 = (_a$1 = adapterRaw.default) !== null && _a$1 !== void 0 ? _a$1 : adapterRaw;
4471
+ var _a;
4472
+ const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
4406
4473
  const logger$2 = new Logger();
4407
- const browserName = adapter$1.browserDetails.browser;
4474
+ const browserName = adapter.browserDetails.browser;
4408
4475
  let unloading = false;
4409
4476
  const RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS = 3500;
4410
4477
  const RESTARTICE_ERROR_MAX_RETRY_COUNT = 5;
@@ -5491,7 +5558,7 @@ class VegaRtcManager {
5491
5558
  }, stopCameraDelay);
5492
5559
  }
5493
5560
  else if (localStream.getVideoTracks().length === 0) {
5494
- const constraints = this._webrtcProvider.getMediaConstraints().video;
5561
+ const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
5495
5562
  navigator.mediaDevices
5496
5563
  .getUserMedia({ video: constraints })
5497
5564
  .then((stream) => {
@@ -7016,73 +7083,6 @@ class BandwidthTester extends EventEmitter {
7016
7083
  }
7017
7084
  }
7018
7085
 
7019
- var _a, _b;
7020
- const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
7021
- const isSafari = ((_b = adapter.browserDetails) === null || _b === void 0 ? void 0 : _b.browser) === "safari";
7022
- const parseResolution = (res) => res.split(/[^\d]/g).map((n) => parseInt(n, 10));
7023
- function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }) {
7024
- var _a, _b;
7025
- let HIGH_HEIGHT = 480;
7026
- let LOW_HEIGHT = 240;
7027
- if (hd) {
7028
- HIGH_HEIGHT = lax || isSafari ? 720 : { min: 360, ideal: 720 };
7029
- }
7030
- if (simulcast) {
7031
- if (hd === false) {
7032
- HIGH_HEIGHT = 360;
7033
- LOW_HEIGHT = 270;
7034
- }
7035
- else {
7036
- LOW_HEIGHT = 360;
7037
- }
7038
- }
7039
- const constraints = {
7040
- audio: Object.assign({}, (preferredDeviceIds.audioId && { deviceId: preferredDeviceIds.audioId })),
7041
- video: Object.assign(Object.assign({}, (preferredDeviceIds.videoId ? { deviceId: preferredDeviceIds.videoId } : { facingMode: "user" })), { height: lowDataMode ? LOW_HEIGHT : HIGH_HEIGHT, frameRate: lowDataMode && !simulcast ? 15 : 24 }),
7042
- };
7043
- if (lax) {
7044
- if (!((_a = constraints.audio) === null || _a === void 0 ? void 0 : _a.deviceId))
7045
- constraints.audio = true;
7046
- (_b = constraints.video) === null || _b === void 0 ? true : delete _b.facingMode;
7047
- return constraints;
7048
- }
7049
- if (resolution) {
7050
- const [w, h, fps] = parseResolution(resolution);
7051
- if (w)
7052
- constraints.video.width = { exact: w };
7053
- if (h)
7054
- constraints.video.height = { exact: h };
7055
- if (fps)
7056
- constraints.video.frameRate = { exact: fps };
7057
- delete constraints.video.facingMode;
7058
- }
7059
- else {
7060
- constraints.video.aspectRatio = widescreen ? 16 / 9 : 4 / 3;
7061
- }
7062
- if (disableAGC)
7063
- constraints.audio.autoGainControl = false;
7064
- if (disableAEC)
7065
- constraints.audio.echoCancellation = false;
7066
- return constraints;
7067
- }
7068
- function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
7069
- const audioDevices = devices.filter((d) => d.kind === "audioinput");
7070
- const videoDevices = devices.filter((d) => d.kind === "videoinput");
7071
- const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
7072
- const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
7073
- const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
7074
- audioId: useDefaultAudio ? null : { [type]: audioId },
7075
- videoId: useDefaultVideo ? null : { [type]: videoId },
7076
- } }, options));
7077
- if (audioId === false || !audioDevices.length) {
7078
- delete constraints.audio;
7079
- }
7080
- if (videoId === false || !videoDevices.length) {
7081
- delete constraints.video;
7082
- }
7083
- return constraints;
7084
- }
7085
-
7086
7086
  const logger = new Logger();
7087
7087
  const isMobile = /mobi/i.test(navigator.userAgent);
7088
7088
  class NoDevicesError extends Error {
@@ -7156,7 +7156,6 @@ function getSettingsFromTrack(kind, track, devices, lastUsedId) {
7156
7156
  if (settings.deviceId)
7157
7157
  return settings;
7158
7158
  settings.deviceId = (_c = track.getConstraints()) === null || _c === void 0 ? void 0 : _c.deviceId;
7159
- settings.broken = 1;
7160
7159
  return settings;
7161
7160
  }
7162
7161
  function getDeviceData({ audioTrack, videoTrack, devices, stoppedVideoTrack, lastAudioId, lastVideoId, }) {
package/dist/index.d.cts CHANGED
@@ -482,7 +482,7 @@ type SignalIceEndOfCandidatesMessage = {
482
482
  clientId: string;
483
483
  };
484
484
  interface WebRTCProvider {
485
- getMediaConstraints: () => MediaStreamConstraints;
485
+ getMediaOptions: () => GetConstraintsOptions;
486
486
  }
487
487
  type GetMediaConstraintsOptions = {
488
488
  disableAEC: boolean;
@@ -503,7 +503,6 @@ type GetMediaConstraintsOptions = {
503
503
  resolution?: string;
504
504
  simulcast: boolean;
505
505
  widescreen: boolean;
506
- usingAspectRatio16x9: boolean;
507
506
  };
508
507
  type GetConstraintsOptions = {
509
508
  devices: MediaDeviceInfo[];
package/dist/index.d.mts CHANGED
@@ -482,7 +482,7 @@ type SignalIceEndOfCandidatesMessage = {
482
482
  clientId: string;
483
483
  };
484
484
  interface WebRTCProvider {
485
- getMediaConstraints: () => MediaStreamConstraints;
485
+ getMediaOptions: () => GetConstraintsOptions;
486
486
  }
487
487
  type GetMediaConstraintsOptions = {
488
488
  disableAEC: boolean;
@@ -503,7 +503,6 @@ type GetMediaConstraintsOptions = {
503
503
  resolution?: string;
504
504
  simulcast: boolean;
505
505
  widescreen: boolean;
506
- usingAspectRatio16x9: boolean;
507
506
  };
508
507
  type GetConstraintsOptions = {
509
508
  devices: MediaDeviceInfo[];
package/dist/index.d.ts CHANGED
@@ -482,7 +482,7 @@ type SignalIceEndOfCandidatesMessage = {
482
482
  clientId: string;
483
483
  };
484
484
  interface WebRTCProvider {
485
- getMediaConstraints: () => MediaStreamConstraints;
485
+ getMediaOptions: () => GetConstraintsOptions;
486
486
  }
487
487
  type GetMediaConstraintsOptions = {
488
488
  disableAEC: boolean;
@@ -503,7 +503,6 @@ type GetMediaConstraintsOptions = {
503
503
  resolution?: string;
504
504
  simulcast: boolean;
505
505
  widescreen: boolean;
506
- usingAspectRatio16x9: boolean;
507
506
  };
508
507
  type GetConstraintsOptions = {
509
508
  devices: MediaDeviceInfo[];
package/dist/index.mjs CHANGED
@@ -2513,11 +2513,78 @@ var rtcManagerEvents = {
2513
2513
 
2514
2514
  var _a$2, _b$1;
2515
2515
  const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
2516
+ const isSafari = ((_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser) === "safari";
2517
+ const parseResolution = (res) => res.split(/[^\d]/g).map((n) => parseInt(n, 10));
2518
+ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }) {
2519
+ var _a, _b;
2520
+ let HIGH_HEIGHT = 480;
2521
+ let LOW_HEIGHT = 240;
2522
+ if (hd) {
2523
+ HIGH_HEIGHT = lax || isSafari ? 720 : { min: 360, ideal: 720 };
2524
+ }
2525
+ if (simulcast) {
2526
+ if (hd === false) {
2527
+ HIGH_HEIGHT = 360;
2528
+ LOW_HEIGHT = 270;
2529
+ }
2530
+ else {
2531
+ LOW_HEIGHT = 360;
2532
+ }
2533
+ }
2534
+ const constraints = {
2535
+ audio: Object.assign({}, (preferredDeviceIds.audioId && { deviceId: preferredDeviceIds.audioId })),
2536
+ video: Object.assign(Object.assign({}, (preferredDeviceIds.videoId ? { deviceId: preferredDeviceIds.videoId } : { facingMode: "user" })), { height: lowDataMode ? LOW_HEIGHT : HIGH_HEIGHT, frameRate: lowDataMode && !simulcast ? 15 : 24 }),
2537
+ };
2538
+ if (lax) {
2539
+ if (!((_a = constraints.audio) === null || _a === void 0 ? void 0 : _a.deviceId))
2540
+ constraints.audio = true;
2541
+ (_b = constraints.video) === null || _b === void 0 ? true : delete _b.facingMode;
2542
+ return constraints;
2543
+ }
2544
+ if (resolution) {
2545
+ const [w, h, fps] = parseResolution(resolution);
2546
+ if (w)
2547
+ constraints.video.width = { exact: w };
2548
+ if (h)
2549
+ constraints.video.height = { exact: h };
2550
+ if (fps)
2551
+ constraints.video.frameRate = { exact: fps };
2552
+ delete constraints.video.facingMode;
2553
+ }
2554
+ else {
2555
+ constraints.video.aspectRatio = widescreen ? 16 / 9 : 4 / 3;
2556
+ }
2557
+ if (disableAGC)
2558
+ constraints.audio.autoGainControl = false;
2559
+ if (disableAEC)
2560
+ constraints.audio.echoCancellation = false;
2561
+ return constraints;
2562
+ }
2563
+ function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2564
+ const audioDevices = devices.filter((d) => d.kind === "audioinput");
2565
+ const videoDevices = devices.filter((d) => d.kind === "videoinput");
2566
+ const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2567
+ const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2568
+ const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2569
+ audioId: useDefaultAudio ? null : { [type]: audioId },
2570
+ videoId: useDefaultVideo ? null : { [type]: videoId },
2571
+ } }, options));
2572
+ if (audioId === false || !audioDevices.length) {
2573
+ delete constraints.audio;
2574
+ }
2575
+ if (videoId === false || !videoDevices.length) {
2576
+ delete constraints.video;
2577
+ }
2578
+ return constraints;
2579
+ }
2580
+
2581
+ var _a$1, _b;
2582
+ const adapter$1 = (_a$1 = adapterRaw.default) !== null && _a$1 !== void 0 ? _a$1 : adapterRaw;
2516
2583
  const logger$6 = new Logger();
2517
2584
  const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
2518
2585
  const ICE_RESTART_DELAY = 2 * 1000;
2519
- const browserName$1 = (_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser;
2520
- const browserVersion = adapter$2.browserDetails.version;
2586
+ const browserName$1 = (_b = adapter$1.browserDetails) === null || _b === void 0 ? void 0 : _b.browser;
2587
+ const browserVersion = adapter$1.browserDetails.version;
2521
2588
  let unloading$1 = false;
2522
2589
  if (browserName$1 === "chrome") {
2523
2590
  window.document.addEventListener("beforeunload", () => {
@@ -3511,7 +3578,7 @@ class P2pRtcManager {
3511
3578
  }
3512
3579
  else {
3513
3580
  if (localStream.getVideoTracks().length === 0) {
3514
- const constraints = this._webrtcProvider.getMediaConstraints().video;
3581
+ const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
3515
3582
  if (!constraints) {
3516
3583
  return;
3517
3584
  }
@@ -4380,10 +4447,10 @@ const STREAM_TYPES = {
4380
4447
  screenshare: "screenshare",
4381
4448
  };
4382
4449
 
4383
- var _a$1;
4384
- const adapter$1 = (_a$1 = adapterRaw.default) !== null && _a$1 !== void 0 ? _a$1 : adapterRaw;
4450
+ var _a;
4451
+ const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
4385
4452
  const logger$2 = new Logger();
4386
- const browserName = adapter$1.browserDetails.browser;
4453
+ const browserName = adapter.browserDetails.browser;
4387
4454
  let unloading = false;
4388
4455
  const RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS = 3500;
4389
4456
  const RESTARTICE_ERROR_MAX_RETRY_COUNT = 5;
@@ -5470,7 +5537,7 @@ class VegaRtcManager {
5470
5537
  }, stopCameraDelay);
5471
5538
  }
5472
5539
  else if (localStream.getVideoTracks().length === 0) {
5473
- const constraints = this._webrtcProvider.getMediaConstraints().video;
5540
+ const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
5474
5541
  navigator.mediaDevices
5475
5542
  .getUserMedia({ video: constraints })
5476
5543
  .then((stream) => {
@@ -6995,73 +7062,6 @@ class BandwidthTester extends EventEmitter {
6995
7062
  }
6996
7063
  }
6997
7064
 
6998
- var _a, _b;
6999
- const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
7000
- const isSafari = ((_b = adapter.browserDetails) === null || _b === void 0 ? void 0 : _b.browser) === "safari";
7001
- const parseResolution = (res) => res.split(/[^\d]/g).map((n) => parseInt(n, 10));
7002
- function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }) {
7003
- var _a, _b;
7004
- let HIGH_HEIGHT = 480;
7005
- let LOW_HEIGHT = 240;
7006
- if (hd) {
7007
- HIGH_HEIGHT = lax || isSafari ? 720 : { min: 360, ideal: 720 };
7008
- }
7009
- if (simulcast) {
7010
- if (hd === false) {
7011
- HIGH_HEIGHT = 360;
7012
- LOW_HEIGHT = 270;
7013
- }
7014
- else {
7015
- LOW_HEIGHT = 360;
7016
- }
7017
- }
7018
- const constraints = {
7019
- audio: Object.assign({}, (preferredDeviceIds.audioId && { deviceId: preferredDeviceIds.audioId })),
7020
- video: Object.assign(Object.assign({}, (preferredDeviceIds.videoId ? { deviceId: preferredDeviceIds.videoId } : { facingMode: "user" })), { height: lowDataMode ? LOW_HEIGHT : HIGH_HEIGHT, frameRate: lowDataMode && !simulcast ? 15 : 24 }),
7021
- };
7022
- if (lax) {
7023
- if (!((_a = constraints.audio) === null || _a === void 0 ? void 0 : _a.deviceId))
7024
- constraints.audio = true;
7025
- (_b = constraints.video) === null || _b === void 0 ? true : delete _b.facingMode;
7026
- return constraints;
7027
- }
7028
- if (resolution) {
7029
- const [w, h, fps] = parseResolution(resolution);
7030
- if (w)
7031
- constraints.video.width = { exact: w };
7032
- if (h)
7033
- constraints.video.height = { exact: h };
7034
- if (fps)
7035
- constraints.video.frameRate = { exact: fps };
7036
- delete constraints.video.facingMode;
7037
- }
7038
- else {
7039
- constraints.video.aspectRatio = widescreen ? 16 / 9 : 4 / 3;
7040
- }
7041
- if (disableAGC)
7042
- constraints.audio.autoGainControl = false;
7043
- if (disableAEC)
7044
- constraints.audio.echoCancellation = false;
7045
- return constraints;
7046
- }
7047
- function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
7048
- const audioDevices = devices.filter((d) => d.kind === "audioinput");
7049
- const videoDevices = devices.filter((d) => d.kind === "videoinput");
7050
- const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
7051
- const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
7052
- const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
7053
- audioId: useDefaultAudio ? null : { [type]: audioId },
7054
- videoId: useDefaultVideo ? null : { [type]: videoId },
7055
- } }, options));
7056
- if (audioId === false || !audioDevices.length) {
7057
- delete constraints.audio;
7058
- }
7059
- if (videoId === false || !videoDevices.length) {
7060
- delete constraints.video;
7061
- }
7062
- return constraints;
7063
- }
7064
-
7065
7065
  const logger = new Logger();
7066
7066
  const isMobile = /mobi/i.test(navigator.userAgent);
7067
7067
  class NoDevicesError extends Error {
@@ -7135,7 +7135,6 @@ function getSettingsFromTrack(kind, track, devices, lastUsedId) {
7135
7135
  if (settings.deviceId)
7136
7136
  return settings;
7137
7137
  settings.deviceId = (_c = track.getConstraints()) === null || _c === void 0 ? void 0 : _c.deviceId;
7138
- settings.broken = 1;
7139
7138
  return settings;
7140
7139
  }
7141
7140
  function getDeviceData({ audioTrack, videoTrack, devices, stoppedVideoTrack, lastAudioId, lastVideoId, }) {
@@ -2513,11 +2513,78 @@ var rtcManagerEvents = {
2513
2513
 
2514
2514
  var _a$2, _b$1;
2515
2515
  const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
2516
+ const isSafari = ((_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser) === "safari";
2517
+ const parseResolution = (res) => res.split(/[^\d]/g).map((n) => parseInt(n, 10));
2518
+ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }) {
2519
+ var _a, _b;
2520
+ let HIGH_HEIGHT = 480;
2521
+ let LOW_HEIGHT = 240;
2522
+ if (hd) {
2523
+ HIGH_HEIGHT = lax || isSafari ? 720 : { min: 360, ideal: 720 };
2524
+ }
2525
+ if (simulcast) {
2526
+ if (hd === false) {
2527
+ HIGH_HEIGHT = 360;
2528
+ LOW_HEIGHT = 270;
2529
+ }
2530
+ else {
2531
+ LOW_HEIGHT = 360;
2532
+ }
2533
+ }
2534
+ const constraints = {
2535
+ audio: Object.assign({}, (preferredDeviceIds.audioId && { deviceId: preferredDeviceIds.audioId })),
2536
+ video: Object.assign(Object.assign({}, (preferredDeviceIds.videoId ? { deviceId: preferredDeviceIds.videoId } : { facingMode: "user" })), { height: lowDataMode ? LOW_HEIGHT : HIGH_HEIGHT, frameRate: lowDataMode && !simulcast ? 15 : 24 }),
2537
+ };
2538
+ if (lax) {
2539
+ if (!((_a = constraints.audio) === null || _a === void 0 ? void 0 : _a.deviceId))
2540
+ constraints.audio = true;
2541
+ (_b = constraints.video) === null || _b === void 0 ? true : delete _b.facingMode;
2542
+ return constraints;
2543
+ }
2544
+ if (resolution) {
2545
+ const [w, h, fps] = parseResolution(resolution);
2546
+ if (w)
2547
+ constraints.video.width = { exact: w };
2548
+ if (h)
2549
+ constraints.video.height = { exact: h };
2550
+ if (fps)
2551
+ constraints.video.frameRate = { exact: fps };
2552
+ delete constraints.video.facingMode;
2553
+ }
2554
+ else {
2555
+ constraints.video.aspectRatio = widescreen ? 16 / 9 : 4 / 3;
2556
+ }
2557
+ if (disableAGC)
2558
+ constraints.audio.autoGainControl = false;
2559
+ if (disableAEC)
2560
+ constraints.audio.echoCancellation = false;
2561
+ return constraints;
2562
+ }
2563
+ function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2564
+ const audioDevices = devices.filter((d) => d.kind === "audioinput");
2565
+ const videoDevices = devices.filter((d) => d.kind === "videoinput");
2566
+ const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2567
+ const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2568
+ const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2569
+ audioId: useDefaultAudio ? null : { [type]: audioId },
2570
+ videoId: useDefaultVideo ? null : { [type]: videoId },
2571
+ } }, options));
2572
+ if (audioId === false || !audioDevices.length) {
2573
+ delete constraints.audio;
2574
+ }
2575
+ if (videoId === false || !videoDevices.length) {
2576
+ delete constraints.video;
2577
+ }
2578
+ return constraints;
2579
+ }
2580
+
2581
+ var _a$1, _b;
2582
+ const adapter$1 = (_a$1 = adapterRaw.default) !== null && _a$1 !== void 0 ? _a$1 : adapterRaw;
2516
2583
  const logger$6 = new Logger();
2517
2584
  const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
2518
2585
  const ICE_RESTART_DELAY = 2 * 1000;
2519
- const browserName$1 = (_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser;
2520
- const browserVersion = adapter$2.browserDetails.version;
2586
+ const browserName$1 = (_b = adapter$1.browserDetails) === null || _b === void 0 ? void 0 : _b.browser;
2587
+ const browserVersion = adapter$1.browserDetails.version;
2521
2588
  let unloading$1 = false;
2522
2589
  if (browserName$1 === "chrome") {
2523
2590
  window.document.addEventListener("beforeunload", () => {
@@ -3511,7 +3578,7 @@ class P2pRtcManager {
3511
3578
  }
3512
3579
  else {
3513
3580
  if (localStream.getVideoTracks().length === 0) {
3514
- const constraints = this._webrtcProvider.getMediaConstraints().video;
3581
+ const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
3515
3582
  if (!constraints) {
3516
3583
  return;
3517
3584
  }
@@ -4380,10 +4447,10 @@ const STREAM_TYPES = {
4380
4447
  screenshare: "screenshare",
4381
4448
  };
4382
4449
 
4383
- var _a$1;
4384
- const adapter$1 = (_a$1 = adapterRaw.default) !== null && _a$1 !== void 0 ? _a$1 : adapterRaw;
4450
+ var _a;
4451
+ const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
4385
4452
  const logger$2 = new Logger();
4386
- const browserName = adapter$1.browserDetails.browser;
4453
+ const browserName = adapter.browserDetails.browser;
4387
4454
  let unloading = false;
4388
4455
  const RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS = 3500;
4389
4456
  const RESTARTICE_ERROR_MAX_RETRY_COUNT = 5;
@@ -5470,7 +5537,7 @@ class VegaRtcManager {
5470
5537
  }, stopCameraDelay);
5471
5538
  }
5472
5539
  else if (localStream.getVideoTracks().length === 0) {
5473
- const constraints = this._webrtcProvider.getMediaConstraints().video;
5540
+ const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
5474
5541
  navigator.mediaDevices
5475
5542
  .getUserMedia({ video: constraints })
5476
5543
  .then((stream) => {
@@ -6995,73 +7062,6 @@ class BandwidthTester extends EventEmitter {
6995
7062
  }
6996
7063
  }
6997
7064
 
6998
- var _a, _b;
6999
- const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
7000
- const isSafari = ((_b = adapter.browserDetails) === null || _b === void 0 ? void 0 : _b.browser) === "safari";
7001
- const parseResolution = (res) => res.split(/[^\d]/g).map((n) => parseInt(n, 10));
7002
- function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }) {
7003
- var _a, _b;
7004
- let HIGH_HEIGHT = 480;
7005
- let LOW_HEIGHT = 240;
7006
- if (hd) {
7007
- HIGH_HEIGHT = lax || isSafari ? 720 : { min: 360, ideal: 720 };
7008
- }
7009
- if (simulcast) {
7010
- if (hd === false) {
7011
- HIGH_HEIGHT = 360;
7012
- LOW_HEIGHT = 270;
7013
- }
7014
- else {
7015
- LOW_HEIGHT = 360;
7016
- }
7017
- }
7018
- const constraints = {
7019
- audio: Object.assign({}, (preferredDeviceIds.audioId && { deviceId: preferredDeviceIds.audioId })),
7020
- video: Object.assign(Object.assign({}, (preferredDeviceIds.videoId ? { deviceId: preferredDeviceIds.videoId } : { facingMode: "user" })), { height: lowDataMode ? LOW_HEIGHT : HIGH_HEIGHT, frameRate: lowDataMode && !simulcast ? 15 : 24 }),
7021
- };
7022
- if (lax) {
7023
- if (!((_a = constraints.audio) === null || _a === void 0 ? void 0 : _a.deviceId))
7024
- constraints.audio = true;
7025
- (_b = constraints.video) === null || _b === void 0 ? true : delete _b.facingMode;
7026
- return constraints;
7027
- }
7028
- if (resolution) {
7029
- const [w, h, fps] = parseResolution(resolution);
7030
- if (w)
7031
- constraints.video.width = { exact: w };
7032
- if (h)
7033
- constraints.video.height = { exact: h };
7034
- if (fps)
7035
- constraints.video.frameRate = { exact: fps };
7036
- delete constraints.video.facingMode;
7037
- }
7038
- else {
7039
- constraints.video.aspectRatio = widescreen ? 16 / 9 : 4 / 3;
7040
- }
7041
- if (disableAGC)
7042
- constraints.audio.autoGainControl = false;
7043
- if (disableAEC)
7044
- constraints.audio.echoCancellation = false;
7045
- return constraints;
7046
- }
7047
- function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
7048
- const audioDevices = devices.filter((d) => d.kind === "audioinput");
7049
- const videoDevices = devices.filter((d) => d.kind === "videoinput");
7050
- const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
7051
- const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
7052
- const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
7053
- audioId: useDefaultAudio ? null : { [type]: audioId },
7054
- videoId: useDefaultVideo ? null : { [type]: videoId },
7055
- } }, options));
7056
- if (audioId === false || !audioDevices.length) {
7057
- delete constraints.audio;
7058
- }
7059
- if (videoId === false || !videoDevices.length) {
7060
- delete constraints.video;
7061
- }
7062
- return constraints;
7063
- }
7064
-
7065
7065
  const logger = new Logger();
7066
7066
  const isMobile = /mobi/i.test(navigator.userAgent);
7067
7067
  class NoDevicesError extends Error {
@@ -7135,7 +7135,6 @@ function getSettingsFromTrack(kind, track, devices, lastUsedId) {
7135
7135
  if (settings.deviceId)
7136
7136
  return settings;
7137
7137
  settings.deviceId = (_c = track.getConstraints()) === null || _c === void 0 ? void 0 : _c.deviceId;
7138
- settings.broken = 1;
7139
7138
  return settings;
7140
7139
  }
7141
7140
  function getDeviceData({ audioTrack, videoTrack, devices, stoppedVideoTrack, lastAudioId, lastVideoId, }) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "7.0.1",
4
+ "version": "8.0.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {
@@ -61,10 +61,10 @@
61
61
  "prettier": "^3.5.3",
62
62
  "process": "^0.11.10",
63
63
  "typescript": "^5.8.3",
64
- "@whereby.com/eslint-config": "0.1.0",
65
64
  "@whereby.com/jest-config": "0.1.0",
66
65
  "@whereby.com/prettier-config": "0.1.0",
67
66
  "@whereby.com/rollup-config": "0.1.1",
67
+ "@whereby.com/eslint-config": "0.1.0",
68
68
  "@whereby.com/tsconfig": "0.1.0"
69
69
  },
70
70
  "engines": {