@whereby.com/media 7.0.0 → 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 +105 -86
- package/dist/index.d.cts +250 -249
- package/dist/index.d.mts +250 -249
- package/dist/index.d.ts +250 -249
- package/dist/index.mjs +105 -86
- package/dist/legacy-esm.js +105 -86
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -245,6 +245,7 @@ class Logger {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
const logger$b = new Logger();
|
|
248
249
|
const AUDIO_SETTINGS = {
|
|
249
250
|
codecOptions: {
|
|
250
251
|
opusDtx: true,
|
|
@@ -419,7 +420,14 @@ function getIsCodecDecodingPowerEfficient(codec) {
|
|
|
419
420
|
}
|
|
420
421
|
function sortCodecsByPowerEfficiency(codecs) {
|
|
421
422
|
return __awaiter(this, void 0, void 0, function* () {
|
|
422
|
-
|
|
423
|
+
let codecPowerEfficiencyEntries;
|
|
424
|
+
try {
|
|
425
|
+
codecPowerEfficiencyEntries = yield Promise.all(codecs.map(({ mimeType }) => getIsCodecDecodingPowerEfficient(mimeType).then((val) => [mimeType, val])));
|
|
426
|
+
}
|
|
427
|
+
catch (error) {
|
|
428
|
+
logger$b.error(error);
|
|
429
|
+
return codecs;
|
|
430
|
+
}
|
|
423
431
|
const codecPowerEfficiencies = Object.fromEntries(codecPowerEfficiencyEntries);
|
|
424
432
|
const sorted = codecs.sort((a, b) => {
|
|
425
433
|
const aPowerEfficient = codecPowerEfficiencies[a.mimeType];
|
|
@@ -2526,11 +2534,78 @@ var rtcManagerEvents = {
|
|
|
2526
2534
|
|
|
2527
2535
|
var _a$2, _b$1;
|
|
2528
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;
|
|
2529
2604
|
const logger$6 = new Logger();
|
|
2530
2605
|
const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
|
|
2531
2606
|
const ICE_RESTART_DELAY = 2 * 1000;
|
|
2532
|
-
const browserName$1 = (_b
|
|
2533
|
-
const browserVersion = adapter$
|
|
2607
|
+
const browserName$1 = (_b = adapter$1.browserDetails) === null || _b === void 0 ? void 0 : _b.browser;
|
|
2608
|
+
const browserVersion = adapter$1.browserDetails.version;
|
|
2534
2609
|
let unloading$1 = false;
|
|
2535
2610
|
if (browserName$1 === "chrome") {
|
|
2536
2611
|
window.document.addEventListener("beforeunload", () => {
|
|
@@ -2553,6 +2628,9 @@ class P2pRtcManager {
|
|
|
2553
2628
|
this._features = features || {};
|
|
2554
2629
|
this._isAudioOnlyMode = false;
|
|
2555
2630
|
this._closed = false;
|
|
2631
|
+
this._fetchMediaServersTimer = null;
|
|
2632
|
+
this._stopCameraTimeout = null;
|
|
2633
|
+
this._icePublicIPGatheringTimeoutID = null;
|
|
2556
2634
|
this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
|
|
2557
2635
|
this._audioTrackOnEnded = () => {
|
|
2558
2636
|
rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
|
|
@@ -2754,6 +2832,7 @@ class P2pRtcManager {
|
|
|
2754
2832
|
message: answer,
|
|
2755
2833
|
});
|
|
2756
2834
|
})).catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
|
|
2835
|
+
logger$6.error(e);
|
|
2757
2836
|
this.analytics.numPcOnOfferFailure++;
|
|
2758
2837
|
});
|
|
2759
2838
|
}),
|
|
@@ -3161,11 +3240,12 @@ class P2pRtcManager {
|
|
|
3161
3240
|
return session;
|
|
3162
3241
|
}
|
|
3163
3242
|
_maybeRestartIce(clientId, session) {
|
|
3243
|
+
var _a;
|
|
3164
3244
|
const pc = session.pc;
|
|
3165
3245
|
if (!(pc.iceConnectionState === "disconnected" || pc.iceConnectionState === "failed")) {
|
|
3166
3246
|
return;
|
|
3167
3247
|
}
|
|
3168
|
-
if (pc.localDescription.type === "offer") {
|
|
3248
|
+
if (((_a = pc.localDescription) === null || _a === void 0 ? void 0 : _a.type) === "offer") {
|
|
3169
3249
|
session.wasEverConnected = false;
|
|
3170
3250
|
session.relayCandidateSeen = false;
|
|
3171
3251
|
session.serverReflexiveCandidateSeen = false;
|
|
@@ -3244,7 +3324,7 @@ class P2pRtcManager {
|
|
|
3244
3324
|
}
|
|
3245
3325
|
if (rtpAbsCaptureTimeOn)
|
|
3246
3326
|
offer.sdp = addAbsCaptureTimeExtMap(offer.sdp);
|
|
3247
|
-
if (browserName$1 === "firefox") {
|
|
3327
|
+
if (browserName$1 === "firefox" && browserVersion < 128) {
|
|
3248
3328
|
offer.sdp = setCodecPreferenceSDP({
|
|
3249
3329
|
sdp: offer.sdp,
|
|
3250
3330
|
redOn,
|
|
@@ -3334,9 +3414,9 @@ class P2pRtcManager {
|
|
|
3334
3414
|
const connection = event.target;
|
|
3335
3415
|
switch (connection.iceGatheringState) {
|
|
3336
3416
|
case "gathering":
|
|
3337
|
-
if (this.
|
|
3338
|
-
clearTimeout(this.
|
|
3339
|
-
this.
|
|
3417
|
+
if (this._icePublicIPGatheringTimeoutID)
|
|
3418
|
+
clearTimeout(this._icePublicIPGatheringTimeoutID);
|
|
3419
|
+
this._icePublicIPGatheringTimeoutID = setTimeout(() => {
|
|
3340
3420
|
if (!session.publicHostCandidateSeen &&
|
|
3341
3421
|
!session.relayCandidateSeen &&
|
|
3342
3422
|
!session.serverReflexiveCandidateSeen) {
|
|
@@ -3346,9 +3426,9 @@ class P2pRtcManager {
|
|
|
3346
3426
|
}, ICE_PUBLIC_IP_GATHERING_TIMEOUT);
|
|
3347
3427
|
break;
|
|
3348
3428
|
case "complete":
|
|
3349
|
-
if (this.
|
|
3350
|
-
clearTimeout(this.
|
|
3351
|
-
this.
|
|
3429
|
+
if (this._icePublicIPGatheringTimeoutID)
|
|
3430
|
+
clearTimeout(this._icePublicIPGatheringTimeoutID);
|
|
3431
|
+
this._icePublicIPGatheringTimeoutID = null;
|
|
3352
3432
|
break;
|
|
3353
3433
|
}
|
|
3354
3434
|
};
|
|
@@ -3497,9 +3577,13 @@ class P2pRtcManager {
|
|
|
3497
3577
|
if (!["chrome", "safari"].includes(browserName$1)) {
|
|
3498
3578
|
return;
|
|
3499
3579
|
}
|
|
3580
|
+
if (this._stopCameraTimeout) {
|
|
3581
|
+
clearTimeout(this._stopCameraTimeout);
|
|
3582
|
+
this._stopCameraTimeout = null;
|
|
3583
|
+
}
|
|
3500
3584
|
if (enable === false) {
|
|
3501
3585
|
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
|
|
3502
|
-
setTimeout(() => {
|
|
3586
|
+
this._stopCameraTimeout = setTimeout(() => {
|
|
3503
3587
|
localStream.getVideoTracks().forEach((track) => {
|
|
3504
3588
|
if (track.enabled === false) {
|
|
3505
3589
|
track.stop();
|
|
@@ -3515,7 +3599,7 @@ class P2pRtcManager {
|
|
|
3515
3599
|
}
|
|
3516
3600
|
else {
|
|
3517
3601
|
if (localStream.getVideoTracks().length === 0) {
|
|
3518
|
-
const constraints = this._webrtcProvider.
|
|
3602
|
+
const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
|
|
3519
3603
|
if (!constraints) {
|
|
3520
3604
|
return;
|
|
3521
3605
|
}
|
|
@@ -4384,10 +4468,10 @@ const STREAM_TYPES = {
|
|
|
4384
4468
|
screenshare: "screenshare",
|
|
4385
4469
|
};
|
|
4386
4470
|
|
|
4387
|
-
var _a
|
|
4388
|
-
const adapter
|
|
4471
|
+
var _a;
|
|
4472
|
+
const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
|
|
4389
4473
|
const logger$2 = new Logger();
|
|
4390
|
-
const browserName = adapter
|
|
4474
|
+
const browserName = adapter.browserDetails.browser;
|
|
4391
4475
|
let unloading = false;
|
|
4392
4476
|
const RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS = 3500;
|
|
4393
4477
|
const RESTARTICE_ERROR_MAX_RETRY_COUNT = 5;
|
|
@@ -5453,8 +5537,11 @@ class VegaRtcManager {
|
|
|
5453
5537
|
if (!["chrome", "safari"].includes(browserName)) {
|
|
5454
5538
|
return;
|
|
5455
5539
|
}
|
|
5456
|
-
if (
|
|
5540
|
+
if (this._stopCameraTimeout) {
|
|
5457
5541
|
clearTimeout(this._stopCameraTimeout);
|
|
5542
|
+
this._stopCameraTimeout = null;
|
|
5543
|
+
}
|
|
5544
|
+
if (!enable) {
|
|
5458
5545
|
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
|
|
5459
5546
|
this._stopCameraTimeout = setTimeout(() => {
|
|
5460
5547
|
localStream.getVideoTracks().forEach((track) => {
|
|
@@ -5471,7 +5558,7 @@ class VegaRtcManager {
|
|
|
5471
5558
|
}, stopCameraDelay);
|
|
5472
5559
|
}
|
|
5473
5560
|
else if (localStream.getVideoTracks().length === 0) {
|
|
5474
|
-
const constraints = this._webrtcProvider.
|
|
5561
|
+
const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
|
|
5475
5562
|
navigator.mediaDevices
|
|
5476
5563
|
.getUserMedia({ video: constraints })
|
|
5477
5564
|
.then((stream) => {
|
|
@@ -6996,73 +7083,6 @@ class BandwidthTester extends EventEmitter {
|
|
|
6996
7083
|
}
|
|
6997
7084
|
}
|
|
6998
7085
|
|
|
6999
|
-
var _a, _b;
|
|
7000
|
-
const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
|
|
7001
|
-
const isSafari = ((_b = adapter.browserDetails) === null || _b === void 0 ? void 0 : _b.browser) === "safari";
|
|
7002
|
-
const parseResolution = (res) => res.split(/[^\d]/g).map((n) => parseInt(n, 10));
|
|
7003
|
-
function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }) {
|
|
7004
|
-
var _a, _b;
|
|
7005
|
-
let HIGH_HEIGHT = 480;
|
|
7006
|
-
let LOW_HEIGHT = 240;
|
|
7007
|
-
if (hd) {
|
|
7008
|
-
HIGH_HEIGHT = lax || isSafari ? 720 : { min: 360, ideal: 720 };
|
|
7009
|
-
}
|
|
7010
|
-
if (simulcast) {
|
|
7011
|
-
if (hd === false) {
|
|
7012
|
-
HIGH_HEIGHT = 360;
|
|
7013
|
-
LOW_HEIGHT = 270;
|
|
7014
|
-
}
|
|
7015
|
-
else {
|
|
7016
|
-
LOW_HEIGHT = 360;
|
|
7017
|
-
}
|
|
7018
|
-
}
|
|
7019
|
-
const constraints = {
|
|
7020
|
-
audio: Object.assign({}, (preferredDeviceIds.audioId && { deviceId: preferredDeviceIds.audioId })),
|
|
7021
|
-
video: Object.assign(Object.assign({}, (preferredDeviceIds.videoId ? { deviceId: preferredDeviceIds.videoId } : { facingMode: "user" })), { height: lowDataMode ? LOW_HEIGHT : HIGH_HEIGHT, frameRate: lowDataMode && !simulcast ? 15 : 24 }),
|
|
7022
|
-
};
|
|
7023
|
-
if (lax) {
|
|
7024
|
-
if (!((_a = constraints.audio) === null || _a === void 0 ? void 0 : _a.deviceId))
|
|
7025
|
-
constraints.audio = true;
|
|
7026
|
-
(_b = constraints.video) === null || _b === void 0 ? true : delete _b.facingMode;
|
|
7027
|
-
return constraints;
|
|
7028
|
-
}
|
|
7029
|
-
if (resolution) {
|
|
7030
|
-
const [w, h, fps] = parseResolution(resolution);
|
|
7031
|
-
if (w)
|
|
7032
|
-
constraints.video.width = { exact: w };
|
|
7033
|
-
if (h)
|
|
7034
|
-
constraints.video.height = { exact: h };
|
|
7035
|
-
if (fps)
|
|
7036
|
-
constraints.video.frameRate = { exact: fps };
|
|
7037
|
-
delete constraints.video.facingMode;
|
|
7038
|
-
}
|
|
7039
|
-
else {
|
|
7040
|
-
constraints.video.aspectRatio = widescreen ? 16 / 9 : 4 / 3;
|
|
7041
|
-
}
|
|
7042
|
-
if (disableAGC)
|
|
7043
|
-
constraints.audio.autoGainControl = false;
|
|
7044
|
-
if (disableAEC)
|
|
7045
|
-
constraints.audio.echoCancellation = false;
|
|
7046
|
-
return constraints;
|
|
7047
|
-
}
|
|
7048
|
-
function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
|
|
7049
|
-
const audioDevices = devices.filter((d) => d.kind === "audioinput");
|
|
7050
|
-
const videoDevices = devices.filter((d) => d.kind === "videoinput");
|
|
7051
|
-
const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
|
|
7052
|
-
const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
|
|
7053
|
-
const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
|
|
7054
|
-
audioId: useDefaultAudio ? null : { [type]: audioId },
|
|
7055
|
-
videoId: useDefaultVideo ? null : { [type]: videoId },
|
|
7056
|
-
} }, options));
|
|
7057
|
-
if (audioId === false || !audioDevices.length) {
|
|
7058
|
-
delete constraints.audio;
|
|
7059
|
-
}
|
|
7060
|
-
if (videoId === false || !videoDevices.length) {
|
|
7061
|
-
delete constraints.video;
|
|
7062
|
-
}
|
|
7063
|
-
return constraints;
|
|
7064
|
-
}
|
|
7065
|
-
|
|
7066
7086
|
const logger = new Logger();
|
|
7067
7087
|
const isMobile = /mobi/i.test(navigator.userAgent);
|
|
7068
7088
|
class NoDevicesError extends Error {
|
|
@@ -7136,7 +7156,6 @@ function getSettingsFromTrack(kind, track, devices, lastUsedId) {
|
|
|
7136
7156
|
if (settings.deviceId)
|
|
7137
7157
|
return settings;
|
|
7138
7158
|
settings.deviceId = (_c = track.getConstraints()) === null || _c === void 0 ? void 0 : _c.deviceId;
|
|
7139
|
-
settings.broken = 1;
|
|
7140
7159
|
return settings;
|
|
7141
7160
|
}
|
|
7142
7161
|
function getDeviceData({ audioTrack, videoTrack, devices, stoppedVideoTrack, lastAudioId, lastVideoId, }) {
|