@whereby.com/media 7.0.0 → 7.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 +31 -11
- package/dist/index.d.cts +251 -249
- package/dist/index.d.mts +251 -249
- package/dist/index.d.ts +251 -249
- package/dist/index.mjs +31 -11
- package/dist/legacy-esm.js +31 -11
- package/package.json +1 -1
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];
|
|
@@ -2532,6 +2540,9 @@ class P2pRtcManager {
|
|
|
2532
2540
|
this._features = features || {};
|
|
2533
2541
|
this._isAudioOnlyMode = false;
|
|
2534
2542
|
this._closed = false;
|
|
2543
|
+
this._fetchMediaServersTimer = null;
|
|
2544
|
+
this._stopCameraTimeout = null;
|
|
2545
|
+
this._icePublicIPGatheringTimeoutID = null;
|
|
2535
2546
|
this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
|
|
2536
2547
|
this._audioTrackOnEnded = () => {
|
|
2537
2548
|
rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
|
|
@@ -2733,6 +2744,7 @@ class P2pRtcManager {
|
|
|
2733
2744
|
message: answer,
|
|
2734
2745
|
});
|
|
2735
2746
|
})).catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
|
|
2747
|
+
logger$6.error(e);
|
|
2736
2748
|
this.analytics.numPcOnOfferFailure++;
|
|
2737
2749
|
});
|
|
2738
2750
|
}),
|
|
@@ -3140,11 +3152,12 @@ class P2pRtcManager {
|
|
|
3140
3152
|
return session;
|
|
3141
3153
|
}
|
|
3142
3154
|
_maybeRestartIce(clientId, session) {
|
|
3155
|
+
var _a;
|
|
3143
3156
|
const pc = session.pc;
|
|
3144
3157
|
if (!(pc.iceConnectionState === "disconnected" || pc.iceConnectionState === "failed")) {
|
|
3145
3158
|
return;
|
|
3146
3159
|
}
|
|
3147
|
-
if (pc.localDescription.type === "offer") {
|
|
3160
|
+
if (((_a = pc.localDescription) === null || _a === void 0 ? void 0 : _a.type) === "offer") {
|
|
3148
3161
|
session.wasEverConnected = false;
|
|
3149
3162
|
session.relayCandidateSeen = false;
|
|
3150
3163
|
session.serverReflexiveCandidateSeen = false;
|
|
@@ -3223,7 +3236,7 @@ class P2pRtcManager {
|
|
|
3223
3236
|
}
|
|
3224
3237
|
if (rtpAbsCaptureTimeOn)
|
|
3225
3238
|
offer.sdp = addAbsCaptureTimeExtMap(offer.sdp);
|
|
3226
|
-
if (browserName$1 === "firefox") {
|
|
3239
|
+
if (browserName$1 === "firefox" && browserVersion < 128) {
|
|
3227
3240
|
offer.sdp = setCodecPreferenceSDP({
|
|
3228
3241
|
sdp: offer.sdp,
|
|
3229
3242
|
redOn,
|
|
@@ -3313,9 +3326,9 @@ class P2pRtcManager {
|
|
|
3313
3326
|
const connection = event.target;
|
|
3314
3327
|
switch (connection.iceGatheringState) {
|
|
3315
3328
|
case "gathering":
|
|
3316
|
-
if (this.
|
|
3317
|
-
clearTimeout(this.
|
|
3318
|
-
this.
|
|
3329
|
+
if (this._icePublicIPGatheringTimeoutID)
|
|
3330
|
+
clearTimeout(this._icePublicIPGatheringTimeoutID);
|
|
3331
|
+
this._icePublicIPGatheringTimeoutID = setTimeout(() => {
|
|
3319
3332
|
if (!session.publicHostCandidateSeen &&
|
|
3320
3333
|
!session.relayCandidateSeen &&
|
|
3321
3334
|
!session.serverReflexiveCandidateSeen) {
|
|
@@ -3325,9 +3338,9 @@ class P2pRtcManager {
|
|
|
3325
3338
|
}, ICE_PUBLIC_IP_GATHERING_TIMEOUT);
|
|
3326
3339
|
break;
|
|
3327
3340
|
case "complete":
|
|
3328
|
-
if (this.
|
|
3329
|
-
clearTimeout(this.
|
|
3330
|
-
this.
|
|
3341
|
+
if (this._icePublicIPGatheringTimeoutID)
|
|
3342
|
+
clearTimeout(this._icePublicIPGatheringTimeoutID);
|
|
3343
|
+
this._icePublicIPGatheringTimeoutID = null;
|
|
3331
3344
|
break;
|
|
3332
3345
|
}
|
|
3333
3346
|
};
|
|
@@ -3476,9 +3489,13 @@ class P2pRtcManager {
|
|
|
3476
3489
|
if (!["chrome", "safari"].includes(browserName$1)) {
|
|
3477
3490
|
return;
|
|
3478
3491
|
}
|
|
3492
|
+
if (this._stopCameraTimeout) {
|
|
3493
|
+
clearTimeout(this._stopCameraTimeout);
|
|
3494
|
+
this._stopCameraTimeout = null;
|
|
3495
|
+
}
|
|
3479
3496
|
if (enable === false) {
|
|
3480
3497
|
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
|
|
3481
|
-
setTimeout(() => {
|
|
3498
|
+
this._stopCameraTimeout = setTimeout(() => {
|
|
3482
3499
|
localStream.getVideoTracks().forEach((track) => {
|
|
3483
3500
|
if (track.enabled === false) {
|
|
3484
3501
|
track.stop();
|
|
@@ -5432,8 +5449,11 @@ class VegaRtcManager {
|
|
|
5432
5449
|
if (!["chrome", "safari"].includes(browserName)) {
|
|
5433
5450
|
return;
|
|
5434
5451
|
}
|
|
5435
|
-
if (
|
|
5452
|
+
if (this._stopCameraTimeout) {
|
|
5436
5453
|
clearTimeout(this._stopCameraTimeout);
|
|
5454
|
+
this._stopCameraTimeout = null;
|
|
5455
|
+
}
|
|
5456
|
+
if (!enable) {
|
|
5437
5457
|
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
|
|
5438
5458
|
this._stopCameraTimeout = setTimeout(() => {
|
|
5439
5459
|
localStream.getVideoTracks().forEach((track) => {
|
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];
|
|
@@ -2532,6 +2540,9 @@ class P2pRtcManager {
|
|
|
2532
2540
|
this._features = features || {};
|
|
2533
2541
|
this._isAudioOnlyMode = false;
|
|
2534
2542
|
this._closed = false;
|
|
2543
|
+
this._fetchMediaServersTimer = null;
|
|
2544
|
+
this._stopCameraTimeout = null;
|
|
2545
|
+
this._icePublicIPGatheringTimeoutID = null;
|
|
2535
2546
|
this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
|
|
2536
2547
|
this._audioTrackOnEnded = () => {
|
|
2537
2548
|
rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
|
|
@@ -2733,6 +2744,7 @@ class P2pRtcManager {
|
|
|
2733
2744
|
message: answer,
|
|
2734
2745
|
});
|
|
2735
2746
|
})).catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
|
|
2747
|
+
logger$6.error(e);
|
|
2736
2748
|
this.analytics.numPcOnOfferFailure++;
|
|
2737
2749
|
});
|
|
2738
2750
|
}),
|
|
@@ -3140,11 +3152,12 @@ class P2pRtcManager {
|
|
|
3140
3152
|
return session;
|
|
3141
3153
|
}
|
|
3142
3154
|
_maybeRestartIce(clientId, session) {
|
|
3155
|
+
var _a;
|
|
3143
3156
|
const pc = session.pc;
|
|
3144
3157
|
if (!(pc.iceConnectionState === "disconnected" || pc.iceConnectionState === "failed")) {
|
|
3145
3158
|
return;
|
|
3146
3159
|
}
|
|
3147
|
-
if (pc.localDescription.type === "offer") {
|
|
3160
|
+
if (((_a = pc.localDescription) === null || _a === void 0 ? void 0 : _a.type) === "offer") {
|
|
3148
3161
|
session.wasEverConnected = false;
|
|
3149
3162
|
session.relayCandidateSeen = false;
|
|
3150
3163
|
session.serverReflexiveCandidateSeen = false;
|
|
@@ -3223,7 +3236,7 @@ class P2pRtcManager {
|
|
|
3223
3236
|
}
|
|
3224
3237
|
if (rtpAbsCaptureTimeOn)
|
|
3225
3238
|
offer.sdp = addAbsCaptureTimeExtMap(offer.sdp);
|
|
3226
|
-
if (browserName$1 === "firefox") {
|
|
3239
|
+
if (browserName$1 === "firefox" && browserVersion < 128) {
|
|
3227
3240
|
offer.sdp = setCodecPreferenceSDP({
|
|
3228
3241
|
sdp: offer.sdp,
|
|
3229
3242
|
redOn,
|
|
@@ -3313,9 +3326,9 @@ class P2pRtcManager {
|
|
|
3313
3326
|
const connection = event.target;
|
|
3314
3327
|
switch (connection.iceGatheringState) {
|
|
3315
3328
|
case "gathering":
|
|
3316
|
-
if (this.
|
|
3317
|
-
clearTimeout(this.
|
|
3318
|
-
this.
|
|
3329
|
+
if (this._icePublicIPGatheringTimeoutID)
|
|
3330
|
+
clearTimeout(this._icePublicIPGatheringTimeoutID);
|
|
3331
|
+
this._icePublicIPGatheringTimeoutID = setTimeout(() => {
|
|
3319
3332
|
if (!session.publicHostCandidateSeen &&
|
|
3320
3333
|
!session.relayCandidateSeen &&
|
|
3321
3334
|
!session.serverReflexiveCandidateSeen) {
|
|
@@ -3325,9 +3338,9 @@ class P2pRtcManager {
|
|
|
3325
3338
|
}, ICE_PUBLIC_IP_GATHERING_TIMEOUT);
|
|
3326
3339
|
break;
|
|
3327
3340
|
case "complete":
|
|
3328
|
-
if (this.
|
|
3329
|
-
clearTimeout(this.
|
|
3330
|
-
this.
|
|
3341
|
+
if (this._icePublicIPGatheringTimeoutID)
|
|
3342
|
+
clearTimeout(this._icePublicIPGatheringTimeoutID);
|
|
3343
|
+
this._icePublicIPGatheringTimeoutID = null;
|
|
3331
3344
|
break;
|
|
3332
3345
|
}
|
|
3333
3346
|
};
|
|
@@ -3476,9 +3489,13 @@ class P2pRtcManager {
|
|
|
3476
3489
|
if (!["chrome", "safari"].includes(browserName$1)) {
|
|
3477
3490
|
return;
|
|
3478
3491
|
}
|
|
3492
|
+
if (this._stopCameraTimeout) {
|
|
3493
|
+
clearTimeout(this._stopCameraTimeout);
|
|
3494
|
+
this._stopCameraTimeout = null;
|
|
3495
|
+
}
|
|
3479
3496
|
if (enable === false) {
|
|
3480
3497
|
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
|
|
3481
|
-
setTimeout(() => {
|
|
3498
|
+
this._stopCameraTimeout = setTimeout(() => {
|
|
3482
3499
|
localStream.getVideoTracks().forEach((track) => {
|
|
3483
3500
|
if (track.enabled === false) {
|
|
3484
3501
|
track.stop();
|
|
@@ -5432,8 +5449,11 @@ class VegaRtcManager {
|
|
|
5432
5449
|
if (!["chrome", "safari"].includes(browserName)) {
|
|
5433
5450
|
return;
|
|
5434
5451
|
}
|
|
5435
|
-
if (
|
|
5452
|
+
if (this._stopCameraTimeout) {
|
|
5436
5453
|
clearTimeout(this._stopCameraTimeout);
|
|
5454
|
+
this._stopCameraTimeout = null;
|
|
5455
|
+
}
|
|
5456
|
+
if (!enable) {
|
|
5437
5457
|
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
|
|
5438
5458
|
this._stopCameraTimeout = setTimeout(() => {
|
|
5439
5459
|
localStream.getVideoTracks().forEach((track) => {
|