@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.mjs
CHANGED
|
@@ -224,6 +224,7 @@ class Logger {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
const logger$b = new Logger();
|
|
227
228
|
const AUDIO_SETTINGS = {
|
|
228
229
|
codecOptions: {
|
|
229
230
|
opusDtx: true,
|
|
@@ -398,7 +399,14 @@ function getIsCodecDecodingPowerEfficient(codec) {
|
|
|
398
399
|
}
|
|
399
400
|
function sortCodecsByPowerEfficiency(codecs) {
|
|
400
401
|
return __awaiter(this, void 0, void 0, function* () {
|
|
401
|
-
|
|
402
|
+
let codecPowerEfficiencyEntries;
|
|
403
|
+
try {
|
|
404
|
+
codecPowerEfficiencyEntries = yield Promise.all(codecs.map(({ mimeType }) => getIsCodecDecodingPowerEfficient(mimeType).then((val) => [mimeType, val])));
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
logger$b.error(error);
|
|
408
|
+
return codecs;
|
|
409
|
+
}
|
|
402
410
|
const codecPowerEfficiencies = Object.fromEntries(codecPowerEfficiencyEntries);
|
|
403
411
|
const sorted = codecs.sort((a, b) => {
|
|
404
412
|
const aPowerEfficient = codecPowerEfficiencies[a.mimeType];
|
|
@@ -2505,11 +2513,78 @@ var rtcManagerEvents = {
|
|
|
2505
2513
|
|
|
2506
2514
|
var _a$2, _b$1;
|
|
2507
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;
|
|
2508
2583
|
const logger$6 = new Logger();
|
|
2509
2584
|
const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
|
|
2510
2585
|
const ICE_RESTART_DELAY = 2 * 1000;
|
|
2511
|
-
const browserName$1 = (_b
|
|
2512
|
-
const browserVersion = adapter$
|
|
2586
|
+
const browserName$1 = (_b = adapter$1.browserDetails) === null || _b === void 0 ? void 0 : _b.browser;
|
|
2587
|
+
const browserVersion = adapter$1.browserDetails.version;
|
|
2513
2588
|
let unloading$1 = false;
|
|
2514
2589
|
if (browserName$1 === "chrome") {
|
|
2515
2590
|
window.document.addEventListener("beforeunload", () => {
|
|
@@ -2532,6 +2607,9 @@ class P2pRtcManager {
|
|
|
2532
2607
|
this._features = features || {};
|
|
2533
2608
|
this._isAudioOnlyMode = false;
|
|
2534
2609
|
this._closed = false;
|
|
2610
|
+
this._fetchMediaServersTimer = null;
|
|
2611
|
+
this._stopCameraTimeout = null;
|
|
2612
|
+
this._icePublicIPGatheringTimeoutID = null;
|
|
2535
2613
|
this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
|
|
2536
2614
|
this._audioTrackOnEnded = () => {
|
|
2537
2615
|
rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
|
|
@@ -2733,6 +2811,7 @@ class P2pRtcManager {
|
|
|
2733
2811
|
message: answer,
|
|
2734
2812
|
});
|
|
2735
2813
|
})).catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
|
|
2814
|
+
logger$6.error(e);
|
|
2736
2815
|
this.analytics.numPcOnOfferFailure++;
|
|
2737
2816
|
});
|
|
2738
2817
|
}),
|
|
@@ -3140,11 +3219,12 @@ class P2pRtcManager {
|
|
|
3140
3219
|
return session;
|
|
3141
3220
|
}
|
|
3142
3221
|
_maybeRestartIce(clientId, session) {
|
|
3222
|
+
var _a;
|
|
3143
3223
|
const pc = session.pc;
|
|
3144
3224
|
if (!(pc.iceConnectionState === "disconnected" || pc.iceConnectionState === "failed")) {
|
|
3145
3225
|
return;
|
|
3146
3226
|
}
|
|
3147
|
-
if (pc.localDescription.type === "offer") {
|
|
3227
|
+
if (((_a = pc.localDescription) === null || _a === void 0 ? void 0 : _a.type) === "offer") {
|
|
3148
3228
|
session.wasEverConnected = false;
|
|
3149
3229
|
session.relayCandidateSeen = false;
|
|
3150
3230
|
session.serverReflexiveCandidateSeen = false;
|
|
@@ -3223,7 +3303,7 @@ class P2pRtcManager {
|
|
|
3223
3303
|
}
|
|
3224
3304
|
if (rtpAbsCaptureTimeOn)
|
|
3225
3305
|
offer.sdp = addAbsCaptureTimeExtMap(offer.sdp);
|
|
3226
|
-
if (browserName$1 === "firefox") {
|
|
3306
|
+
if (browserName$1 === "firefox" && browserVersion < 128) {
|
|
3227
3307
|
offer.sdp = setCodecPreferenceSDP({
|
|
3228
3308
|
sdp: offer.sdp,
|
|
3229
3309
|
redOn,
|
|
@@ -3313,9 +3393,9 @@ class P2pRtcManager {
|
|
|
3313
3393
|
const connection = event.target;
|
|
3314
3394
|
switch (connection.iceGatheringState) {
|
|
3315
3395
|
case "gathering":
|
|
3316
|
-
if (this.
|
|
3317
|
-
clearTimeout(this.
|
|
3318
|
-
this.
|
|
3396
|
+
if (this._icePublicIPGatheringTimeoutID)
|
|
3397
|
+
clearTimeout(this._icePublicIPGatheringTimeoutID);
|
|
3398
|
+
this._icePublicIPGatheringTimeoutID = setTimeout(() => {
|
|
3319
3399
|
if (!session.publicHostCandidateSeen &&
|
|
3320
3400
|
!session.relayCandidateSeen &&
|
|
3321
3401
|
!session.serverReflexiveCandidateSeen) {
|
|
@@ -3325,9 +3405,9 @@ class P2pRtcManager {
|
|
|
3325
3405
|
}, ICE_PUBLIC_IP_GATHERING_TIMEOUT);
|
|
3326
3406
|
break;
|
|
3327
3407
|
case "complete":
|
|
3328
|
-
if (this.
|
|
3329
|
-
clearTimeout(this.
|
|
3330
|
-
this.
|
|
3408
|
+
if (this._icePublicIPGatheringTimeoutID)
|
|
3409
|
+
clearTimeout(this._icePublicIPGatheringTimeoutID);
|
|
3410
|
+
this._icePublicIPGatheringTimeoutID = null;
|
|
3331
3411
|
break;
|
|
3332
3412
|
}
|
|
3333
3413
|
};
|
|
@@ -3476,9 +3556,13 @@ class P2pRtcManager {
|
|
|
3476
3556
|
if (!["chrome", "safari"].includes(browserName$1)) {
|
|
3477
3557
|
return;
|
|
3478
3558
|
}
|
|
3559
|
+
if (this._stopCameraTimeout) {
|
|
3560
|
+
clearTimeout(this._stopCameraTimeout);
|
|
3561
|
+
this._stopCameraTimeout = null;
|
|
3562
|
+
}
|
|
3479
3563
|
if (enable === false) {
|
|
3480
3564
|
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
|
|
3481
|
-
setTimeout(() => {
|
|
3565
|
+
this._stopCameraTimeout = setTimeout(() => {
|
|
3482
3566
|
localStream.getVideoTracks().forEach((track) => {
|
|
3483
3567
|
if (track.enabled === false) {
|
|
3484
3568
|
track.stop();
|
|
@@ -3494,7 +3578,7 @@ class P2pRtcManager {
|
|
|
3494
3578
|
}
|
|
3495
3579
|
else {
|
|
3496
3580
|
if (localStream.getVideoTracks().length === 0) {
|
|
3497
|
-
const constraints = this._webrtcProvider.
|
|
3581
|
+
const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
|
|
3498
3582
|
if (!constraints) {
|
|
3499
3583
|
return;
|
|
3500
3584
|
}
|
|
@@ -4363,10 +4447,10 @@ const STREAM_TYPES = {
|
|
|
4363
4447
|
screenshare: "screenshare",
|
|
4364
4448
|
};
|
|
4365
4449
|
|
|
4366
|
-
var _a
|
|
4367
|
-
const adapter
|
|
4450
|
+
var _a;
|
|
4451
|
+
const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
|
|
4368
4452
|
const logger$2 = new Logger();
|
|
4369
|
-
const browserName = adapter
|
|
4453
|
+
const browserName = adapter.browserDetails.browser;
|
|
4370
4454
|
let unloading = false;
|
|
4371
4455
|
const RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS = 3500;
|
|
4372
4456
|
const RESTARTICE_ERROR_MAX_RETRY_COUNT = 5;
|
|
@@ -5432,8 +5516,11 @@ class VegaRtcManager {
|
|
|
5432
5516
|
if (!["chrome", "safari"].includes(browserName)) {
|
|
5433
5517
|
return;
|
|
5434
5518
|
}
|
|
5435
|
-
if (
|
|
5519
|
+
if (this._stopCameraTimeout) {
|
|
5436
5520
|
clearTimeout(this._stopCameraTimeout);
|
|
5521
|
+
this._stopCameraTimeout = null;
|
|
5522
|
+
}
|
|
5523
|
+
if (!enable) {
|
|
5437
5524
|
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
|
|
5438
5525
|
this._stopCameraTimeout = setTimeout(() => {
|
|
5439
5526
|
localStream.getVideoTracks().forEach((track) => {
|
|
@@ -5450,7 +5537,7 @@ class VegaRtcManager {
|
|
|
5450
5537
|
}, stopCameraDelay);
|
|
5451
5538
|
}
|
|
5452
5539
|
else if (localStream.getVideoTracks().length === 0) {
|
|
5453
|
-
const constraints = this._webrtcProvider.
|
|
5540
|
+
const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
|
|
5454
5541
|
navigator.mediaDevices
|
|
5455
5542
|
.getUserMedia({ video: constraints })
|
|
5456
5543
|
.then((stream) => {
|
|
@@ -6975,73 +7062,6 @@ class BandwidthTester extends EventEmitter {
|
|
|
6975
7062
|
}
|
|
6976
7063
|
}
|
|
6977
7064
|
|
|
6978
|
-
var _a, _b;
|
|
6979
|
-
const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
|
|
6980
|
-
const isSafari = ((_b = adapter.browserDetails) === null || _b === void 0 ? void 0 : _b.browser) === "safari";
|
|
6981
|
-
const parseResolution = (res) => res.split(/[^\d]/g).map((n) => parseInt(n, 10));
|
|
6982
|
-
function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }) {
|
|
6983
|
-
var _a, _b;
|
|
6984
|
-
let HIGH_HEIGHT = 480;
|
|
6985
|
-
let LOW_HEIGHT = 240;
|
|
6986
|
-
if (hd) {
|
|
6987
|
-
HIGH_HEIGHT = lax || isSafari ? 720 : { min: 360, ideal: 720 };
|
|
6988
|
-
}
|
|
6989
|
-
if (simulcast) {
|
|
6990
|
-
if (hd === false) {
|
|
6991
|
-
HIGH_HEIGHT = 360;
|
|
6992
|
-
LOW_HEIGHT = 270;
|
|
6993
|
-
}
|
|
6994
|
-
else {
|
|
6995
|
-
LOW_HEIGHT = 360;
|
|
6996
|
-
}
|
|
6997
|
-
}
|
|
6998
|
-
const constraints = {
|
|
6999
|
-
audio: Object.assign({}, (preferredDeviceIds.audioId && { deviceId: preferredDeviceIds.audioId })),
|
|
7000
|
-
video: Object.assign(Object.assign({}, (preferredDeviceIds.videoId ? { deviceId: preferredDeviceIds.videoId } : { facingMode: "user" })), { height: lowDataMode ? LOW_HEIGHT : HIGH_HEIGHT, frameRate: lowDataMode && !simulcast ? 15 : 24 }),
|
|
7001
|
-
};
|
|
7002
|
-
if (lax) {
|
|
7003
|
-
if (!((_a = constraints.audio) === null || _a === void 0 ? void 0 : _a.deviceId))
|
|
7004
|
-
constraints.audio = true;
|
|
7005
|
-
(_b = constraints.video) === null || _b === void 0 ? true : delete _b.facingMode;
|
|
7006
|
-
return constraints;
|
|
7007
|
-
}
|
|
7008
|
-
if (resolution) {
|
|
7009
|
-
const [w, h, fps] = parseResolution(resolution);
|
|
7010
|
-
if (w)
|
|
7011
|
-
constraints.video.width = { exact: w };
|
|
7012
|
-
if (h)
|
|
7013
|
-
constraints.video.height = { exact: h };
|
|
7014
|
-
if (fps)
|
|
7015
|
-
constraints.video.frameRate = { exact: fps };
|
|
7016
|
-
delete constraints.video.facingMode;
|
|
7017
|
-
}
|
|
7018
|
-
else {
|
|
7019
|
-
constraints.video.aspectRatio = widescreen ? 16 / 9 : 4 / 3;
|
|
7020
|
-
}
|
|
7021
|
-
if (disableAGC)
|
|
7022
|
-
constraints.audio.autoGainControl = false;
|
|
7023
|
-
if (disableAEC)
|
|
7024
|
-
constraints.audio.echoCancellation = false;
|
|
7025
|
-
return constraints;
|
|
7026
|
-
}
|
|
7027
|
-
function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
|
|
7028
|
-
const audioDevices = devices.filter((d) => d.kind === "audioinput");
|
|
7029
|
-
const videoDevices = devices.filter((d) => d.kind === "videoinput");
|
|
7030
|
-
const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
|
|
7031
|
-
const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
|
|
7032
|
-
const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
|
|
7033
|
-
audioId: useDefaultAudio ? null : { [type]: audioId },
|
|
7034
|
-
videoId: useDefaultVideo ? null : { [type]: videoId },
|
|
7035
|
-
} }, options));
|
|
7036
|
-
if (audioId === false || !audioDevices.length) {
|
|
7037
|
-
delete constraints.audio;
|
|
7038
|
-
}
|
|
7039
|
-
if (videoId === false || !videoDevices.length) {
|
|
7040
|
-
delete constraints.video;
|
|
7041
|
-
}
|
|
7042
|
-
return constraints;
|
|
7043
|
-
}
|
|
7044
|
-
|
|
7045
7065
|
const logger = new Logger();
|
|
7046
7066
|
const isMobile = /mobi/i.test(navigator.userAgent);
|
|
7047
7067
|
class NoDevicesError extends Error {
|
|
@@ -7115,7 +7135,6 @@ function getSettingsFromTrack(kind, track, devices, lastUsedId) {
|
|
|
7115
7135
|
if (settings.deviceId)
|
|
7116
7136
|
return settings;
|
|
7117
7137
|
settings.deviceId = (_c = track.getConstraints()) === null || _c === void 0 ? void 0 : _c.deviceId;
|
|
7118
|
-
settings.broken = 1;
|
|
7119
7138
|
return settings;
|
|
7120
7139
|
}
|
|
7121
7140
|
function getDeviceData({ audioTrack, videoTrack, devices, stoppedVideoTrack, lastAudioId, lastVideoId, }) {
|
package/dist/legacy-esm.js
CHANGED
|
@@ -224,6 +224,7 @@ class Logger {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
const logger$b = new Logger();
|
|
227
228
|
const AUDIO_SETTINGS = {
|
|
228
229
|
codecOptions: {
|
|
229
230
|
opusDtx: true,
|
|
@@ -398,7 +399,14 @@ function getIsCodecDecodingPowerEfficient(codec) {
|
|
|
398
399
|
}
|
|
399
400
|
function sortCodecsByPowerEfficiency(codecs) {
|
|
400
401
|
return __awaiter(this, void 0, void 0, function* () {
|
|
401
|
-
|
|
402
|
+
let codecPowerEfficiencyEntries;
|
|
403
|
+
try {
|
|
404
|
+
codecPowerEfficiencyEntries = yield Promise.all(codecs.map(({ mimeType }) => getIsCodecDecodingPowerEfficient(mimeType).then((val) => [mimeType, val])));
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
logger$b.error(error);
|
|
408
|
+
return codecs;
|
|
409
|
+
}
|
|
402
410
|
const codecPowerEfficiencies = Object.fromEntries(codecPowerEfficiencyEntries);
|
|
403
411
|
const sorted = codecs.sort((a, b) => {
|
|
404
412
|
const aPowerEfficient = codecPowerEfficiencies[a.mimeType];
|
|
@@ -2505,11 +2513,78 @@ var rtcManagerEvents = {
|
|
|
2505
2513
|
|
|
2506
2514
|
var _a$2, _b$1;
|
|
2507
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;
|
|
2508
2583
|
const logger$6 = new Logger();
|
|
2509
2584
|
const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
|
|
2510
2585
|
const ICE_RESTART_DELAY = 2 * 1000;
|
|
2511
|
-
const browserName$1 = (_b
|
|
2512
|
-
const browserVersion = adapter$
|
|
2586
|
+
const browserName$1 = (_b = adapter$1.browserDetails) === null || _b === void 0 ? void 0 : _b.browser;
|
|
2587
|
+
const browserVersion = adapter$1.browserDetails.version;
|
|
2513
2588
|
let unloading$1 = false;
|
|
2514
2589
|
if (browserName$1 === "chrome") {
|
|
2515
2590
|
window.document.addEventListener("beforeunload", () => {
|
|
@@ -2532,6 +2607,9 @@ class P2pRtcManager {
|
|
|
2532
2607
|
this._features = features || {};
|
|
2533
2608
|
this._isAudioOnlyMode = false;
|
|
2534
2609
|
this._closed = false;
|
|
2610
|
+
this._fetchMediaServersTimer = null;
|
|
2611
|
+
this._stopCameraTimeout = null;
|
|
2612
|
+
this._icePublicIPGatheringTimeoutID = null;
|
|
2535
2613
|
this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
|
|
2536
2614
|
this._audioTrackOnEnded = () => {
|
|
2537
2615
|
rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
|
|
@@ -2733,6 +2811,7 @@ class P2pRtcManager {
|
|
|
2733
2811
|
message: answer,
|
|
2734
2812
|
});
|
|
2735
2813
|
})).catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
|
|
2814
|
+
logger$6.error(e);
|
|
2736
2815
|
this.analytics.numPcOnOfferFailure++;
|
|
2737
2816
|
});
|
|
2738
2817
|
}),
|
|
@@ -3140,11 +3219,12 @@ class P2pRtcManager {
|
|
|
3140
3219
|
return session;
|
|
3141
3220
|
}
|
|
3142
3221
|
_maybeRestartIce(clientId, session) {
|
|
3222
|
+
var _a;
|
|
3143
3223
|
const pc = session.pc;
|
|
3144
3224
|
if (!(pc.iceConnectionState === "disconnected" || pc.iceConnectionState === "failed")) {
|
|
3145
3225
|
return;
|
|
3146
3226
|
}
|
|
3147
|
-
if (pc.localDescription.type === "offer") {
|
|
3227
|
+
if (((_a = pc.localDescription) === null || _a === void 0 ? void 0 : _a.type) === "offer") {
|
|
3148
3228
|
session.wasEverConnected = false;
|
|
3149
3229
|
session.relayCandidateSeen = false;
|
|
3150
3230
|
session.serverReflexiveCandidateSeen = false;
|
|
@@ -3223,7 +3303,7 @@ class P2pRtcManager {
|
|
|
3223
3303
|
}
|
|
3224
3304
|
if (rtpAbsCaptureTimeOn)
|
|
3225
3305
|
offer.sdp = addAbsCaptureTimeExtMap(offer.sdp);
|
|
3226
|
-
if (browserName$1 === "firefox") {
|
|
3306
|
+
if (browserName$1 === "firefox" && browserVersion < 128) {
|
|
3227
3307
|
offer.sdp = setCodecPreferenceSDP({
|
|
3228
3308
|
sdp: offer.sdp,
|
|
3229
3309
|
redOn,
|
|
@@ -3313,9 +3393,9 @@ class P2pRtcManager {
|
|
|
3313
3393
|
const connection = event.target;
|
|
3314
3394
|
switch (connection.iceGatheringState) {
|
|
3315
3395
|
case "gathering":
|
|
3316
|
-
if (this.
|
|
3317
|
-
clearTimeout(this.
|
|
3318
|
-
this.
|
|
3396
|
+
if (this._icePublicIPGatheringTimeoutID)
|
|
3397
|
+
clearTimeout(this._icePublicIPGatheringTimeoutID);
|
|
3398
|
+
this._icePublicIPGatheringTimeoutID = setTimeout(() => {
|
|
3319
3399
|
if (!session.publicHostCandidateSeen &&
|
|
3320
3400
|
!session.relayCandidateSeen &&
|
|
3321
3401
|
!session.serverReflexiveCandidateSeen) {
|
|
@@ -3325,9 +3405,9 @@ class P2pRtcManager {
|
|
|
3325
3405
|
}, ICE_PUBLIC_IP_GATHERING_TIMEOUT);
|
|
3326
3406
|
break;
|
|
3327
3407
|
case "complete":
|
|
3328
|
-
if (this.
|
|
3329
|
-
clearTimeout(this.
|
|
3330
|
-
this.
|
|
3408
|
+
if (this._icePublicIPGatheringTimeoutID)
|
|
3409
|
+
clearTimeout(this._icePublicIPGatheringTimeoutID);
|
|
3410
|
+
this._icePublicIPGatheringTimeoutID = null;
|
|
3331
3411
|
break;
|
|
3332
3412
|
}
|
|
3333
3413
|
};
|
|
@@ -3476,9 +3556,13 @@ class P2pRtcManager {
|
|
|
3476
3556
|
if (!["chrome", "safari"].includes(browserName$1)) {
|
|
3477
3557
|
return;
|
|
3478
3558
|
}
|
|
3559
|
+
if (this._stopCameraTimeout) {
|
|
3560
|
+
clearTimeout(this._stopCameraTimeout);
|
|
3561
|
+
this._stopCameraTimeout = null;
|
|
3562
|
+
}
|
|
3479
3563
|
if (enable === false) {
|
|
3480
3564
|
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
|
|
3481
|
-
setTimeout(() => {
|
|
3565
|
+
this._stopCameraTimeout = setTimeout(() => {
|
|
3482
3566
|
localStream.getVideoTracks().forEach((track) => {
|
|
3483
3567
|
if (track.enabled === false) {
|
|
3484
3568
|
track.stop();
|
|
@@ -3494,7 +3578,7 @@ class P2pRtcManager {
|
|
|
3494
3578
|
}
|
|
3495
3579
|
else {
|
|
3496
3580
|
if (localStream.getVideoTracks().length === 0) {
|
|
3497
|
-
const constraints = this._webrtcProvider.
|
|
3581
|
+
const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
|
|
3498
3582
|
if (!constraints) {
|
|
3499
3583
|
return;
|
|
3500
3584
|
}
|
|
@@ -4363,10 +4447,10 @@ const STREAM_TYPES = {
|
|
|
4363
4447
|
screenshare: "screenshare",
|
|
4364
4448
|
};
|
|
4365
4449
|
|
|
4366
|
-
var _a
|
|
4367
|
-
const adapter
|
|
4450
|
+
var _a;
|
|
4451
|
+
const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
|
|
4368
4452
|
const logger$2 = new Logger();
|
|
4369
|
-
const browserName = adapter
|
|
4453
|
+
const browserName = adapter.browserDetails.browser;
|
|
4370
4454
|
let unloading = false;
|
|
4371
4455
|
const RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS = 3500;
|
|
4372
4456
|
const RESTARTICE_ERROR_MAX_RETRY_COUNT = 5;
|
|
@@ -5432,8 +5516,11 @@ class VegaRtcManager {
|
|
|
5432
5516
|
if (!["chrome", "safari"].includes(browserName)) {
|
|
5433
5517
|
return;
|
|
5434
5518
|
}
|
|
5435
|
-
if (
|
|
5519
|
+
if (this._stopCameraTimeout) {
|
|
5436
5520
|
clearTimeout(this._stopCameraTimeout);
|
|
5521
|
+
this._stopCameraTimeout = null;
|
|
5522
|
+
}
|
|
5523
|
+
if (!enable) {
|
|
5437
5524
|
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
|
|
5438
5525
|
this._stopCameraTimeout = setTimeout(() => {
|
|
5439
5526
|
localStream.getVideoTracks().forEach((track) => {
|
|
@@ -5450,7 +5537,7 @@ class VegaRtcManager {
|
|
|
5450
5537
|
}, stopCameraDelay);
|
|
5451
5538
|
}
|
|
5452
5539
|
else if (localStream.getVideoTracks().length === 0) {
|
|
5453
|
-
const constraints = this._webrtcProvider.
|
|
5540
|
+
const constraints = getConstraints(this._webrtcProvider.getMediaOptions()).video;
|
|
5454
5541
|
navigator.mediaDevices
|
|
5455
5542
|
.getUserMedia({ video: constraints })
|
|
5456
5543
|
.then((stream) => {
|
|
@@ -6975,73 +7062,6 @@ class BandwidthTester extends EventEmitter {
|
|
|
6975
7062
|
}
|
|
6976
7063
|
}
|
|
6977
7064
|
|
|
6978
|
-
var _a, _b;
|
|
6979
|
-
const adapter = (_a = adapterRaw.default) !== null && _a !== void 0 ? _a : adapterRaw;
|
|
6980
|
-
const isSafari = ((_b = adapter.browserDetails) === null || _b === void 0 ? void 0 : _b.browser) === "safari";
|
|
6981
|
-
const parseResolution = (res) => res.split(/[^\d]/g).map((n) => parseInt(n, 10));
|
|
6982
|
-
function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, preferredDeviceIds, resolution, simulcast, widescreen, }) {
|
|
6983
|
-
var _a, _b;
|
|
6984
|
-
let HIGH_HEIGHT = 480;
|
|
6985
|
-
let LOW_HEIGHT = 240;
|
|
6986
|
-
if (hd) {
|
|
6987
|
-
HIGH_HEIGHT = lax || isSafari ? 720 : { min: 360, ideal: 720 };
|
|
6988
|
-
}
|
|
6989
|
-
if (simulcast) {
|
|
6990
|
-
if (hd === false) {
|
|
6991
|
-
HIGH_HEIGHT = 360;
|
|
6992
|
-
LOW_HEIGHT = 270;
|
|
6993
|
-
}
|
|
6994
|
-
else {
|
|
6995
|
-
LOW_HEIGHT = 360;
|
|
6996
|
-
}
|
|
6997
|
-
}
|
|
6998
|
-
const constraints = {
|
|
6999
|
-
audio: Object.assign({}, (preferredDeviceIds.audioId && { deviceId: preferredDeviceIds.audioId })),
|
|
7000
|
-
video: Object.assign(Object.assign({}, (preferredDeviceIds.videoId ? { deviceId: preferredDeviceIds.videoId } : { facingMode: "user" })), { height: lowDataMode ? LOW_HEIGHT : HIGH_HEIGHT, frameRate: lowDataMode && !simulcast ? 15 : 24 }),
|
|
7001
|
-
};
|
|
7002
|
-
if (lax) {
|
|
7003
|
-
if (!((_a = constraints.audio) === null || _a === void 0 ? void 0 : _a.deviceId))
|
|
7004
|
-
constraints.audio = true;
|
|
7005
|
-
(_b = constraints.video) === null || _b === void 0 ? true : delete _b.facingMode;
|
|
7006
|
-
return constraints;
|
|
7007
|
-
}
|
|
7008
|
-
if (resolution) {
|
|
7009
|
-
const [w, h, fps] = parseResolution(resolution);
|
|
7010
|
-
if (w)
|
|
7011
|
-
constraints.video.width = { exact: w };
|
|
7012
|
-
if (h)
|
|
7013
|
-
constraints.video.height = { exact: h };
|
|
7014
|
-
if (fps)
|
|
7015
|
-
constraints.video.frameRate = { exact: fps };
|
|
7016
|
-
delete constraints.video.facingMode;
|
|
7017
|
-
}
|
|
7018
|
-
else {
|
|
7019
|
-
constraints.video.aspectRatio = widescreen ? 16 / 9 : 4 / 3;
|
|
7020
|
-
}
|
|
7021
|
-
if (disableAGC)
|
|
7022
|
-
constraints.audio.autoGainControl = false;
|
|
7023
|
-
if (disableAEC)
|
|
7024
|
-
constraints.audio.echoCancellation = false;
|
|
7025
|
-
return constraints;
|
|
7026
|
-
}
|
|
7027
|
-
function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
|
|
7028
|
-
const audioDevices = devices.filter((d) => d.kind === "audioinput");
|
|
7029
|
-
const videoDevices = devices.filter((d) => d.kind === "videoinput");
|
|
7030
|
-
const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
|
|
7031
|
-
const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
|
|
7032
|
-
const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
|
|
7033
|
-
audioId: useDefaultAudio ? null : { [type]: audioId },
|
|
7034
|
-
videoId: useDefaultVideo ? null : { [type]: videoId },
|
|
7035
|
-
} }, options));
|
|
7036
|
-
if (audioId === false || !audioDevices.length) {
|
|
7037
|
-
delete constraints.audio;
|
|
7038
|
-
}
|
|
7039
|
-
if (videoId === false || !videoDevices.length) {
|
|
7040
|
-
delete constraints.video;
|
|
7041
|
-
}
|
|
7042
|
-
return constraints;
|
|
7043
|
-
}
|
|
7044
|
-
|
|
7045
7065
|
const logger = new Logger();
|
|
7046
7066
|
const isMobile = /mobi/i.test(navigator.userAgent);
|
|
7047
7067
|
class NoDevicesError extends Error {
|
|
@@ -7115,7 +7135,6 @@ function getSettingsFromTrack(kind, track, devices, lastUsedId) {
|
|
|
7115
7135
|
if (settings.deviceId)
|
|
7116
7136
|
return settings;
|
|
7117
7137
|
settings.deviceId = (_c = track.getConstraints()) === null || _c === void 0 ? void 0 : _c.deviceId;
|
|
7118
|
-
settings.broken = 1;
|
|
7119
7138
|
return settings;
|
|
7120
7139
|
}
|
|
7121
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": "
|
|
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": {
|