@whereby.com/media 2.6.2 → 2.6.3
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 +60 -19
- package/dist/index.d.cts +18 -6
- package/dist/index.d.mts +18 -6
- package/dist/index.d.ts +18 -6
- package/dist/index.mjs +60 -19
- package/dist/legacy-esm.js +60 -19
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4548,6 +4548,14 @@ class VegaRtcManager {
|
|
|
4548
4548
|
});
|
|
4549
4549
|
this._networkIsDetectedUpBySignal = false;
|
|
4550
4550
|
this._cpuOveruseDetected = false;
|
|
4551
|
+
this.analytics = {
|
|
4552
|
+
vegaJoinFailed: 0,
|
|
4553
|
+
vegaJoinWithoutVegaConnection: 0,
|
|
4554
|
+
vegaCreateTransportWithoutVegaConnection: 0,
|
|
4555
|
+
vegaIceRestarts: 0,
|
|
4556
|
+
vegaIceRestartMissingTransport: 0,
|
|
4557
|
+
vegaIceRestartWrongTransportId: 0,
|
|
4558
|
+
};
|
|
4551
4559
|
}
|
|
4552
4560
|
_updateAndScheduleMediaServersRefresh({ iceServers, turnServers, sfuServer, sfuServers, mediaserverConfigTtlSeconds, }) {
|
|
4553
4561
|
var _a, _b, _c;
|
|
@@ -4691,10 +4699,16 @@ class VegaRtcManager {
|
|
|
4691
4699
|
_join() {
|
|
4692
4700
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4693
4701
|
var _a, _b;
|
|
4694
|
-
logger$2.info("
|
|
4702
|
+
logger$2.info("_join()");
|
|
4695
4703
|
this._emitToPWA(rtcManagerEvents.SFU_CONNECTION_OPEN);
|
|
4696
4704
|
try {
|
|
4697
|
-
|
|
4705
|
+
if (!this._vegaConnection) {
|
|
4706
|
+
logger$2.error("_join() No VegaConnection found");
|
|
4707
|
+
this.analytics.vegaJoinWithoutVegaConnection++;
|
|
4708
|
+
rtcStats.sendEvent("JoinWithoutVegaConnection", {});
|
|
4709
|
+
throw new Error("No VegaConnection found");
|
|
4710
|
+
}
|
|
4711
|
+
const { routerRtpCapabilities } = (yield this._vegaConnection.request("getCapabilities"));
|
|
4698
4712
|
if (!this._routerRtpCapabilities) {
|
|
4699
4713
|
const modifiedCapabilities = modifyMediaCapabilities(routerRtpCapabilities, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }));
|
|
4700
4714
|
this._routerRtpCapabilities = modifiedCapabilities;
|
|
@@ -4719,14 +4733,22 @@ class VegaRtcManager {
|
|
|
4719
4733
|
}
|
|
4720
4734
|
catch (error) {
|
|
4721
4735
|
logger$2.error("_join() [error:%o]", error);
|
|
4736
|
+
this.analytics.vegaJoinFailed++;
|
|
4737
|
+
rtcStats.sendEvent("VegaJoinFailed", { error });
|
|
4722
4738
|
}
|
|
4723
4739
|
});
|
|
4724
4740
|
}
|
|
4725
4741
|
_createTransport(send) {
|
|
4726
4742
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4727
4743
|
var _a;
|
|
4744
|
+
if (!this._vegaConnection) {
|
|
4745
|
+
logger$2.error("_createTransport() No VegaConnection found");
|
|
4746
|
+
this.analytics.vegaCreateTransportWithoutVegaConnection++;
|
|
4747
|
+
rtcStats.sendEvent("CreateTransportWithoutVegaConnection", {});
|
|
4748
|
+
throw new Error("No VegaConnection found");
|
|
4749
|
+
}
|
|
4728
4750
|
const creator = send ? "createSendTransport" : "createRecvTransport";
|
|
4729
|
-
const
|
|
4751
|
+
const optionsFromSfu = (yield this._vegaConnection.request("createTransport", {
|
|
4730
4752
|
producing: send,
|
|
4731
4753
|
consuming: !send,
|
|
4732
4754
|
enableTcp: true,
|
|
@@ -4741,7 +4763,8 @@ class VegaRtcManager {
|
|
|
4741
4763
|
maxSctpMessageSize: 262144,
|
|
4742
4764
|
sctpSendBufferSize: 262144,
|
|
4743
4765
|
},
|
|
4744
|
-
});
|
|
4766
|
+
}));
|
|
4767
|
+
const transportOptions = Object.assign({}, optionsFromSfu);
|
|
4745
4768
|
transportOptions.iceServers = turnServerOverride(this._features.turnServersOn ? this._turnServers : this._iceServers, this._features.turnServerOverrideHost);
|
|
4746
4769
|
maybeTurnOnly(transportOptions, this._features);
|
|
4747
4770
|
const transport = (_a = (yield this._mediasoupDeviceInitializedAsync)) === null || _a === void 0 ? void 0 : _a[creator](transportOptions);
|
|
@@ -4751,18 +4774,22 @@ class VegaRtcManager {
|
|
|
4751
4774
|
return;
|
|
4752
4775
|
}
|
|
4753
4776
|
if (send) {
|
|
4754
|
-
if (this._sndTransportIceRestartPromise) {
|
|
4777
|
+
if (this._sndTransportIceRestartPromise || !(transport === null || transport === void 0 ? void 0 : transport.id)) {
|
|
4755
4778
|
return;
|
|
4756
4779
|
}
|
|
4757
|
-
this._sndTransportIceRestartPromise = this._restartIce(transport
|
|
4780
|
+
this._sndTransportIceRestartPromise = this._restartIce("send", transport.id)
|
|
4781
|
+
.catch((e) => logger$2.error(e))
|
|
4782
|
+
.finally(() => {
|
|
4758
4783
|
this._sndTransportIceRestartPromise = null;
|
|
4759
4784
|
});
|
|
4760
4785
|
}
|
|
4761
4786
|
else {
|
|
4762
|
-
if (this._rcvTransportIceRestartPromise) {
|
|
4787
|
+
if (this._rcvTransportIceRestartPromise || !(transport === null || transport === void 0 ? void 0 : transport.id)) {
|
|
4763
4788
|
return;
|
|
4764
4789
|
}
|
|
4765
|
-
this._rcvTransportIceRestartPromise = this._restartIce(transport
|
|
4790
|
+
this._rcvTransportIceRestartPromise = this._restartIce("recv", transport.id)
|
|
4791
|
+
.catch((e) => logger$2.error(e))
|
|
4792
|
+
.finally(() => {
|
|
4766
4793
|
this._rcvTransportIceRestartPromise = null;
|
|
4767
4794
|
});
|
|
4768
4795
|
}
|
|
@@ -4783,13 +4810,13 @@ class VegaRtcManager {
|
|
|
4783
4810
|
var _b;
|
|
4784
4811
|
try {
|
|
4785
4812
|
const { paused } = appData;
|
|
4786
|
-
const { id } = yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produce", {
|
|
4813
|
+
const { id } = (yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produce", {
|
|
4787
4814
|
transportId: transport.id,
|
|
4788
4815
|
kind,
|
|
4789
4816
|
rtpParameters,
|
|
4790
4817
|
paused,
|
|
4791
4818
|
appData,
|
|
4792
|
-
}));
|
|
4819
|
+
})));
|
|
4793
4820
|
callback({ id });
|
|
4794
4821
|
}
|
|
4795
4822
|
catch (error) {
|
|
@@ -4799,11 +4826,11 @@ class VegaRtcManager {
|
|
|
4799
4826
|
transport === null || transport === void 0 ? void 0 : transport.on("producedata", (_a, callback_1, errback_1) => __awaiter(this, [_a, callback_1, errback_1], void 0, function* ({ appData, sctpStreamParameters, }, callback, errback) {
|
|
4800
4827
|
var _b;
|
|
4801
4828
|
try {
|
|
4802
|
-
const { id } = yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produceData", {
|
|
4829
|
+
const { id } = (yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produceData", {
|
|
4803
4830
|
transportId: transport.id,
|
|
4804
4831
|
sctpStreamParameters,
|
|
4805
4832
|
appData,
|
|
4806
|
-
}));
|
|
4833
|
+
})));
|
|
4807
4834
|
callback({ id });
|
|
4808
4835
|
}
|
|
4809
4836
|
catch (error) {
|
|
@@ -4817,10 +4844,22 @@ class VegaRtcManager {
|
|
|
4817
4844
|
}
|
|
4818
4845
|
});
|
|
4819
4846
|
}
|
|
4820
|
-
_restartIce(
|
|
4821
|
-
return __awaiter(this, arguments, void 0, function* (
|
|
4822
|
-
|
|
4823
|
-
|
|
4847
|
+
_restartIce(direction_1, transportId_1) {
|
|
4848
|
+
return __awaiter(this, arguments, void 0, function* (direction, transportId, retried = 0) {
|
|
4849
|
+
this.analytics.vegaIceRestarts++;
|
|
4850
|
+
const transport = direction === "send" ? this._sendTransport : this._receiveTransport;
|
|
4851
|
+
if (!transport) {
|
|
4852
|
+
logger$2.info(`_restartIce: No transport found with id ${transportId}`);
|
|
4853
|
+
this.analytics.vegaIceRestartMissingTransport++;
|
|
4854
|
+
return;
|
|
4855
|
+
}
|
|
4856
|
+
if (transport.id !== transportId) {
|
|
4857
|
+
logger$2.info(`_restartIce: Transport ids does not match [expected: ${transportId}, actual: ${transport.id}]`);
|
|
4858
|
+
this.analytics.vegaIceRestartWrongTransportId++;
|
|
4859
|
+
return;
|
|
4860
|
+
}
|
|
4861
|
+
if (!("closed" in transport) || !("connectionState" in transport)) {
|
|
4862
|
+
logger$2.info("_restartIce: Transport is missing closed or connectionState property");
|
|
4824
4863
|
return;
|
|
4825
4864
|
}
|
|
4826
4865
|
if (transport.closed) {
|
|
@@ -4845,7 +4884,9 @@ class VegaRtcManager {
|
|
|
4845
4884
|
logger$2.info(`_restartIce: Connection is undefined`);
|
|
4846
4885
|
return;
|
|
4847
4886
|
}
|
|
4848
|
-
const { iceParameters } = yield this._vegaConnection.request("restartIce", {
|
|
4887
|
+
const { iceParameters } = (yield this._vegaConnection.request("restartIce", {
|
|
4888
|
+
transportId: transport.id,
|
|
4889
|
+
}));
|
|
4849
4890
|
logger$2.info("_restartIce: ICE restart iceParameters received from SFU: ", iceParameters);
|
|
4850
4891
|
const error = yield transport
|
|
4851
4892
|
.restartIce({ iceParameters })
|
|
@@ -4863,7 +4904,7 @@ class VegaRtcManager {
|
|
|
4863
4904
|
resolve(undefined);
|
|
4864
4905
|
}, Math.min(RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS * Math.pow(2, retried), 60000));
|
|
4865
4906
|
});
|
|
4866
|
-
yield this._restartIce(
|
|
4907
|
+
yield this._restartIce(direction, transportId, retried + 1);
|
|
4867
4908
|
break;
|
|
4868
4909
|
}
|
|
4869
4910
|
return;
|
|
@@ -4874,7 +4915,7 @@ class VegaRtcManager {
|
|
|
4874
4915
|
}, 60000 * Math.min(8, retried + 1));
|
|
4875
4916
|
});
|
|
4876
4917
|
if (transport.connectionState === "failed" || transport.connectionState === "disconnected") {
|
|
4877
|
-
yield this._restartIce(
|
|
4918
|
+
yield this._restartIce(direction, transportId, retried + 1);
|
|
4878
4919
|
return;
|
|
4879
4920
|
}
|
|
4880
4921
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1483,19 +1483,30 @@ declare function createVegaConnectionManager(config: {
|
|
|
1483
1483
|
networkIsPossiblyDown: () => void;
|
|
1484
1484
|
};
|
|
1485
1485
|
|
|
1486
|
-
type
|
|
1487
|
-
|
|
1486
|
+
type VegaTransportDirection = "send" | "recv";
|
|
1487
|
+
|
|
1488
|
+
type VegaAnalytics = {
|
|
1489
|
+
vegaJoinFailed: number;
|
|
1490
|
+
vegaJoinWithoutVegaConnection: number;
|
|
1491
|
+
vegaCreateTransportWithoutVegaConnection: number;
|
|
1492
|
+
vegaIceRestarts: number;
|
|
1493
|
+
vegaIceRestartMissingTransport: number;
|
|
1494
|
+
vegaIceRestartWrongTransportId: number;
|
|
1488
1495
|
};
|
|
1496
|
+
|
|
1497
|
+
type MediaStreamWhichMayHaveInboundId = MediaStream & { inboundId?: string };
|
|
1498
|
+
|
|
1489
1499
|
type ClientState = {
|
|
1490
1500
|
hasAcceptedWebcamStream: Boolean;
|
|
1491
1501
|
hasAcceptedScreenStream: Boolean;
|
|
1492
1502
|
hasEmittedWebcamStream: Boolean;
|
|
1493
1503
|
hasEmittedScreenStream: Boolean;
|
|
1494
|
-
webcamStream?:
|
|
1495
|
-
screenStream?:
|
|
1504
|
+
webcamStream?: MediaStreamWhichMayHaveInboundId;
|
|
1505
|
+
screenStream?: MediaStreamWhichMayHaveInboundId;
|
|
1496
1506
|
screenShareStreamId?: string;
|
|
1497
1507
|
camStreamId?: string;
|
|
1498
1508
|
};
|
|
1509
|
+
|
|
1499
1510
|
declare class VegaRtcManager implements RtcManager {
|
|
1500
1511
|
_selfId: any;
|
|
1501
1512
|
_room: any;
|
|
@@ -1505,7 +1516,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1505
1516
|
_webrtcProvider: any;
|
|
1506
1517
|
_features: any;
|
|
1507
1518
|
_eventClaim?: any;
|
|
1508
|
-
_vegaConnection:
|
|
1519
|
+
_vegaConnection: VegaConnection | null;
|
|
1509
1520
|
_micAnalyser: any;
|
|
1510
1521
|
_micAnalyserDebugger: any;
|
|
1511
1522
|
_mediasoupDeviceInitializedAsync: Promise<Device | null>;
|
|
@@ -1559,6 +1570,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1559
1570
|
_vegaConnectionManager?: ReturnType<typeof createVegaConnectionManager>;
|
|
1560
1571
|
_networkIsDetectedUpBySignal: boolean;
|
|
1561
1572
|
_cpuOveruseDetected: boolean;
|
|
1573
|
+
analytics: VegaAnalytics;
|
|
1562
1574
|
constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, eventClaim, }: {
|
|
1563
1575
|
selfId: any;
|
|
1564
1576
|
room: any;
|
|
@@ -1584,7 +1596,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1584
1596
|
_onClose(): void;
|
|
1585
1597
|
_join(): Promise<void>;
|
|
1586
1598
|
_createTransport(send: any): Promise<void>;
|
|
1587
|
-
_restartIce(
|
|
1599
|
+
_restartIce(direction: VegaTransportDirection, transportId: string, retried?: number): Promise<void>;
|
|
1588
1600
|
_internalSendMic(): Promise<void>;
|
|
1589
1601
|
_internalSetupMicScore(): Promise<void>;
|
|
1590
1602
|
_stopMicScoreProducer(): void;
|
package/dist/index.d.mts
CHANGED
|
@@ -1483,19 +1483,30 @@ declare function createVegaConnectionManager(config: {
|
|
|
1483
1483
|
networkIsPossiblyDown: () => void;
|
|
1484
1484
|
};
|
|
1485
1485
|
|
|
1486
|
-
type
|
|
1487
|
-
|
|
1486
|
+
type VegaTransportDirection = "send" | "recv";
|
|
1487
|
+
|
|
1488
|
+
type VegaAnalytics = {
|
|
1489
|
+
vegaJoinFailed: number;
|
|
1490
|
+
vegaJoinWithoutVegaConnection: number;
|
|
1491
|
+
vegaCreateTransportWithoutVegaConnection: number;
|
|
1492
|
+
vegaIceRestarts: number;
|
|
1493
|
+
vegaIceRestartMissingTransport: number;
|
|
1494
|
+
vegaIceRestartWrongTransportId: number;
|
|
1488
1495
|
};
|
|
1496
|
+
|
|
1497
|
+
type MediaStreamWhichMayHaveInboundId = MediaStream & { inboundId?: string };
|
|
1498
|
+
|
|
1489
1499
|
type ClientState = {
|
|
1490
1500
|
hasAcceptedWebcamStream: Boolean;
|
|
1491
1501
|
hasAcceptedScreenStream: Boolean;
|
|
1492
1502
|
hasEmittedWebcamStream: Boolean;
|
|
1493
1503
|
hasEmittedScreenStream: Boolean;
|
|
1494
|
-
webcamStream?:
|
|
1495
|
-
screenStream?:
|
|
1504
|
+
webcamStream?: MediaStreamWhichMayHaveInboundId;
|
|
1505
|
+
screenStream?: MediaStreamWhichMayHaveInboundId;
|
|
1496
1506
|
screenShareStreamId?: string;
|
|
1497
1507
|
camStreamId?: string;
|
|
1498
1508
|
};
|
|
1509
|
+
|
|
1499
1510
|
declare class VegaRtcManager implements RtcManager {
|
|
1500
1511
|
_selfId: any;
|
|
1501
1512
|
_room: any;
|
|
@@ -1505,7 +1516,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1505
1516
|
_webrtcProvider: any;
|
|
1506
1517
|
_features: any;
|
|
1507
1518
|
_eventClaim?: any;
|
|
1508
|
-
_vegaConnection:
|
|
1519
|
+
_vegaConnection: VegaConnection | null;
|
|
1509
1520
|
_micAnalyser: any;
|
|
1510
1521
|
_micAnalyserDebugger: any;
|
|
1511
1522
|
_mediasoupDeviceInitializedAsync: Promise<Device | null>;
|
|
@@ -1559,6 +1570,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1559
1570
|
_vegaConnectionManager?: ReturnType<typeof createVegaConnectionManager>;
|
|
1560
1571
|
_networkIsDetectedUpBySignal: boolean;
|
|
1561
1572
|
_cpuOveruseDetected: boolean;
|
|
1573
|
+
analytics: VegaAnalytics;
|
|
1562
1574
|
constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, eventClaim, }: {
|
|
1563
1575
|
selfId: any;
|
|
1564
1576
|
room: any;
|
|
@@ -1584,7 +1596,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1584
1596
|
_onClose(): void;
|
|
1585
1597
|
_join(): Promise<void>;
|
|
1586
1598
|
_createTransport(send: any): Promise<void>;
|
|
1587
|
-
_restartIce(
|
|
1599
|
+
_restartIce(direction: VegaTransportDirection, transportId: string, retried?: number): Promise<void>;
|
|
1588
1600
|
_internalSendMic(): Promise<void>;
|
|
1589
1601
|
_internalSetupMicScore(): Promise<void>;
|
|
1590
1602
|
_stopMicScoreProducer(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1483,19 +1483,30 @@ declare function createVegaConnectionManager(config: {
|
|
|
1483
1483
|
networkIsPossiblyDown: () => void;
|
|
1484
1484
|
};
|
|
1485
1485
|
|
|
1486
|
-
type
|
|
1487
|
-
|
|
1486
|
+
type VegaTransportDirection = "send" | "recv";
|
|
1487
|
+
|
|
1488
|
+
type VegaAnalytics = {
|
|
1489
|
+
vegaJoinFailed: number;
|
|
1490
|
+
vegaJoinWithoutVegaConnection: number;
|
|
1491
|
+
vegaCreateTransportWithoutVegaConnection: number;
|
|
1492
|
+
vegaIceRestarts: number;
|
|
1493
|
+
vegaIceRestartMissingTransport: number;
|
|
1494
|
+
vegaIceRestartWrongTransportId: number;
|
|
1488
1495
|
};
|
|
1496
|
+
|
|
1497
|
+
type MediaStreamWhichMayHaveInboundId = MediaStream & { inboundId?: string };
|
|
1498
|
+
|
|
1489
1499
|
type ClientState = {
|
|
1490
1500
|
hasAcceptedWebcamStream: Boolean;
|
|
1491
1501
|
hasAcceptedScreenStream: Boolean;
|
|
1492
1502
|
hasEmittedWebcamStream: Boolean;
|
|
1493
1503
|
hasEmittedScreenStream: Boolean;
|
|
1494
|
-
webcamStream?:
|
|
1495
|
-
screenStream?:
|
|
1504
|
+
webcamStream?: MediaStreamWhichMayHaveInboundId;
|
|
1505
|
+
screenStream?: MediaStreamWhichMayHaveInboundId;
|
|
1496
1506
|
screenShareStreamId?: string;
|
|
1497
1507
|
camStreamId?: string;
|
|
1498
1508
|
};
|
|
1509
|
+
|
|
1499
1510
|
declare class VegaRtcManager implements RtcManager {
|
|
1500
1511
|
_selfId: any;
|
|
1501
1512
|
_room: any;
|
|
@@ -1505,7 +1516,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1505
1516
|
_webrtcProvider: any;
|
|
1506
1517
|
_features: any;
|
|
1507
1518
|
_eventClaim?: any;
|
|
1508
|
-
_vegaConnection:
|
|
1519
|
+
_vegaConnection: VegaConnection | null;
|
|
1509
1520
|
_micAnalyser: any;
|
|
1510
1521
|
_micAnalyserDebugger: any;
|
|
1511
1522
|
_mediasoupDeviceInitializedAsync: Promise<Device | null>;
|
|
@@ -1559,6 +1570,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1559
1570
|
_vegaConnectionManager?: ReturnType<typeof createVegaConnectionManager>;
|
|
1560
1571
|
_networkIsDetectedUpBySignal: boolean;
|
|
1561
1572
|
_cpuOveruseDetected: boolean;
|
|
1573
|
+
analytics: VegaAnalytics;
|
|
1562
1574
|
constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, eventClaim, }: {
|
|
1563
1575
|
selfId: any;
|
|
1564
1576
|
room: any;
|
|
@@ -1584,7 +1596,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1584
1596
|
_onClose(): void;
|
|
1585
1597
|
_join(): Promise<void>;
|
|
1586
1598
|
_createTransport(send: any): Promise<void>;
|
|
1587
|
-
_restartIce(
|
|
1599
|
+
_restartIce(direction: VegaTransportDirection, transportId: string, retried?: number): Promise<void>;
|
|
1588
1600
|
_internalSendMic(): Promise<void>;
|
|
1589
1601
|
_internalSetupMicScore(): Promise<void>;
|
|
1590
1602
|
_stopMicScoreProducer(): void;
|
package/dist/index.mjs
CHANGED
|
@@ -4527,6 +4527,14 @@ class VegaRtcManager {
|
|
|
4527
4527
|
});
|
|
4528
4528
|
this._networkIsDetectedUpBySignal = false;
|
|
4529
4529
|
this._cpuOveruseDetected = false;
|
|
4530
|
+
this.analytics = {
|
|
4531
|
+
vegaJoinFailed: 0,
|
|
4532
|
+
vegaJoinWithoutVegaConnection: 0,
|
|
4533
|
+
vegaCreateTransportWithoutVegaConnection: 0,
|
|
4534
|
+
vegaIceRestarts: 0,
|
|
4535
|
+
vegaIceRestartMissingTransport: 0,
|
|
4536
|
+
vegaIceRestartWrongTransportId: 0,
|
|
4537
|
+
};
|
|
4530
4538
|
}
|
|
4531
4539
|
_updateAndScheduleMediaServersRefresh({ iceServers, turnServers, sfuServer, sfuServers, mediaserverConfigTtlSeconds, }) {
|
|
4532
4540
|
var _a, _b, _c;
|
|
@@ -4670,10 +4678,16 @@ class VegaRtcManager {
|
|
|
4670
4678
|
_join() {
|
|
4671
4679
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4672
4680
|
var _a, _b;
|
|
4673
|
-
logger$2.info("
|
|
4681
|
+
logger$2.info("_join()");
|
|
4674
4682
|
this._emitToPWA(rtcManagerEvents.SFU_CONNECTION_OPEN);
|
|
4675
4683
|
try {
|
|
4676
|
-
|
|
4684
|
+
if (!this._vegaConnection) {
|
|
4685
|
+
logger$2.error("_join() No VegaConnection found");
|
|
4686
|
+
this.analytics.vegaJoinWithoutVegaConnection++;
|
|
4687
|
+
rtcStats.sendEvent("JoinWithoutVegaConnection", {});
|
|
4688
|
+
throw new Error("No VegaConnection found");
|
|
4689
|
+
}
|
|
4690
|
+
const { routerRtpCapabilities } = (yield this._vegaConnection.request("getCapabilities"));
|
|
4677
4691
|
if (!this._routerRtpCapabilities) {
|
|
4678
4692
|
const modifiedCapabilities = modifyMediaCapabilities(routerRtpCapabilities, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }));
|
|
4679
4693
|
this._routerRtpCapabilities = modifiedCapabilities;
|
|
@@ -4698,14 +4712,22 @@ class VegaRtcManager {
|
|
|
4698
4712
|
}
|
|
4699
4713
|
catch (error) {
|
|
4700
4714
|
logger$2.error("_join() [error:%o]", error);
|
|
4715
|
+
this.analytics.vegaJoinFailed++;
|
|
4716
|
+
rtcStats.sendEvent("VegaJoinFailed", { error });
|
|
4701
4717
|
}
|
|
4702
4718
|
});
|
|
4703
4719
|
}
|
|
4704
4720
|
_createTransport(send) {
|
|
4705
4721
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4706
4722
|
var _a;
|
|
4723
|
+
if (!this._vegaConnection) {
|
|
4724
|
+
logger$2.error("_createTransport() No VegaConnection found");
|
|
4725
|
+
this.analytics.vegaCreateTransportWithoutVegaConnection++;
|
|
4726
|
+
rtcStats.sendEvent("CreateTransportWithoutVegaConnection", {});
|
|
4727
|
+
throw new Error("No VegaConnection found");
|
|
4728
|
+
}
|
|
4707
4729
|
const creator = send ? "createSendTransport" : "createRecvTransport";
|
|
4708
|
-
const
|
|
4730
|
+
const optionsFromSfu = (yield this._vegaConnection.request("createTransport", {
|
|
4709
4731
|
producing: send,
|
|
4710
4732
|
consuming: !send,
|
|
4711
4733
|
enableTcp: true,
|
|
@@ -4720,7 +4742,8 @@ class VegaRtcManager {
|
|
|
4720
4742
|
maxSctpMessageSize: 262144,
|
|
4721
4743
|
sctpSendBufferSize: 262144,
|
|
4722
4744
|
},
|
|
4723
|
-
});
|
|
4745
|
+
}));
|
|
4746
|
+
const transportOptions = Object.assign({}, optionsFromSfu);
|
|
4724
4747
|
transportOptions.iceServers = turnServerOverride(this._features.turnServersOn ? this._turnServers : this._iceServers, this._features.turnServerOverrideHost);
|
|
4725
4748
|
maybeTurnOnly(transportOptions, this._features);
|
|
4726
4749
|
const transport = (_a = (yield this._mediasoupDeviceInitializedAsync)) === null || _a === void 0 ? void 0 : _a[creator](transportOptions);
|
|
@@ -4730,18 +4753,22 @@ class VegaRtcManager {
|
|
|
4730
4753
|
return;
|
|
4731
4754
|
}
|
|
4732
4755
|
if (send) {
|
|
4733
|
-
if (this._sndTransportIceRestartPromise) {
|
|
4756
|
+
if (this._sndTransportIceRestartPromise || !(transport === null || transport === void 0 ? void 0 : transport.id)) {
|
|
4734
4757
|
return;
|
|
4735
4758
|
}
|
|
4736
|
-
this._sndTransportIceRestartPromise = this._restartIce(transport
|
|
4759
|
+
this._sndTransportIceRestartPromise = this._restartIce("send", transport.id)
|
|
4760
|
+
.catch((e) => logger$2.error(e))
|
|
4761
|
+
.finally(() => {
|
|
4737
4762
|
this._sndTransportIceRestartPromise = null;
|
|
4738
4763
|
});
|
|
4739
4764
|
}
|
|
4740
4765
|
else {
|
|
4741
|
-
if (this._rcvTransportIceRestartPromise) {
|
|
4766
|
+
if (this._rcvTransportIceRestartPromise || !(transport === null || transport === void 0 ? void 0 : transport.id)) {
|
|
4742
4767
|
return;
|
|
4743
4768
|
}
|
|
4744
|
-
this._rcvTransportIceRestartPromise = this._restartIce(transport
|
|
4769
|
+
this._rcvTransportIceRestartPromise = this._restartIce("recv", transport.id)
|
|
4770
|
+
.catch((e) => logger$2.error(e))
|
|
4771
|
+
.finally(() => {
|
|
4745
4772
|
this._rcvTransportIceRestartPromise = null;
|
|
4746
4773
|
});
|
|
4747
4774
|
}
|
|
@@ -4762,13 +4789,13 @@ class VegaRtcManager {
|
|
|
4762
4789
|
var _b;
|
|
4763
4790
|
try {
|
|
4764
4791
|
const { paused } = appData;
|
|
4765
|
-
const { id } = yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produce", {
|
|
4792
|
+
const { id } = (yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produce", {
|
|
4766
4793
|
transportId: transport.id,
|
|
4767
4794
|
kind,
|
|
4768
4795
|
rtpParameters,
|
|
4769
4796
|
paused,
|
|
4770
4797
|
appData,
|
|
4771
|
-
}));
|
|
4798
|
+
})));
|
|
4772
4799
|
callback({ id });
|
|
4773
4800
|
}
|
|
4774
4801
|
catch (error) {
|
|
@@ -4778,11 +4805,11 @@ class VegaRtcManager {
|
|
|
4778
4805
|
transport === null || transport === void 0 ? void 0 : transport.on("producedata", (_a, callback_1, errback_1) => __awaiter(this, [_a, callback_1, errback_1], void 0, function* ({ appData, sctpStreamParameters, }, callback, errback) {
|
|
4779
4806
|
var _b;
|
|
4780
4807
|
try {
|
|
4781
|
-
const { id } = yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produceData", {
|
|
4808
|
+
const { id } = (yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produceData", {
|
|
4782
4809
|
transportId: transport.id,
|
|
4783
4810
|
sctpStreamParameters,
|
|
4784
4811
|
appData,
|
|
4785
|
-
}));
|
|
4812
|
+
})));
|
|
4786
4813
|
callback({ id });
|
|
4787
4814
|
}
|
|
4788
4815
|
catch (error) {
|
|
@@ -4796,10 +4823,22 @@ class VegaRtcManager {
|
|
|
4796
4823
|
}
|
|
4797
4824
|
});
|
|
4798
4825
|
}
|
|
4799
|
-
_restartIce(
|
|
4800
|
-
return __awaiter(this, arguments, void 0, function* (
|
|
4801
|
-
|
|
4802
|
-
|
|
4826
|
+
_restartIce(direction_1, transportId_1) {
|
|
4827
|
+
return __awaiter(this, arguments, void 0, function* (direction, transportId, retried = 0) {
|
|
4828
|
+
this.analytics.vegaIceRestarts++;
|
|
4829
|
+
const transport = direction === "send" ? this._sendTransport : this._receiveTransport;
|
|
4830
|
+
if (!transport) {
|
|
4831
|
+
logger$2.info(`_restartIce: No transport found with id ${transportId}`);
|
|
4832
|
+
this.analytics.vegaIceRestartMissingTransport++;
|
|
4833
|
+
return;
|
|
4834
|
+
}
|
|
4835
|
+
if (transport.id !== transportId) {
|
|
4836
|
+
logger$2.info(`_restartIce: Transport ids does not match [expected: ${transportId}, actual: ${transport.id}]`);
|
|
4837
|
+
this.analytics.vegaIceRestartWrongTransportId++;
|
|
4838
|
+
return;
|
|
4839
|
+
}
|
|
4840
|
+
if (!("closed" in transport) || !("connectionState" in transport)) {
|
|
4841
|
+
logger$2.info("_restartIce: Transport is missing closed or connectionState property");
|
|
4803
4842
|
return;
|
|
4804
4843
|
}
|
|
4805
4844
|
if (transport.closed) {
|
|
@@ -4824,7 +4863,9 @@ class VegaRtcManager {
|
|
|
4824
4863
|
logger$2.info(`_restartIce: Connection is undefined`);
|
|
4825
4864
|
return;
|
|
4826
4865
|
}
|
|
4827
|
-
const { iceParameters } = yield this._vegaConnection.request("restartIce", {
|
|
4866
|
+
const { iceParameters } = (yield this._vegaConnection.request("restartIce", {
|
|
4867
|
+
transportId: transport.id,
|
|
4868
|
+
}));
|
|
4828
4869
|
logger$2.info("_restartIce: ICE restart iceParameters received from SFU: ", iceParameters);
|
|
4829
4870
|
const error = yield transport
|
|
4830
4871
|
.restartIce({ iceParameters })
|
|
@@ -4842,7 +4883,7 @@ class VegaRtcManager {
|
|
|
4842
4883
|
resolve(undefined);
|
|
4843
4884
|
}, Math.min(RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS * Math.pow(2, retried), 60000));
|
|
4844
4885
|
});
|
|
4845
|
-
yield this._restartIce(
|
|
4886
|
+
yield this._restartIce(direction, transportId, retried + 1);
|
|
4846
4887
|
break;
|
|
4847
4888
|
}
|
|
4848
4889
|
return;
|
|
@@ -4853,7 +4894,7 @@ class VegaRtcManager {
|
|
|
4853
4894
|
}, 60000 * Math.min(8, retried + 1));
|
|
4854
4895
|
});
|
|
4855
4896
|
if (transport.connectionState === "failed" || transport.connectionState === "disconnected") {
|
|
4856
|
-
yield this._restartIce(
|
|
4897
|
+
yield this._restartIce(direction, transportId, retried + 1);
|
|
4857
4898
|
return;
|
|
4858
4899
|
}
|
|
4859
4900
|
});
|
package/dist/legacy-esm.js
CHANGED
|
@@ -4527,6 +4527,14 @@ class VegaRtcManager {
|
|
|
4527
4527
|
});
|
|
4528
4528
|
this._networkIsDetectedUpBySignal = false;
|
|
4529
4529
|
this._cpuOveruseDetected = false;
|
|
4530
|
+
this.analytics = {
|
|
4531
|
+
vegaJoinFailed: 0,
|
|
4532
|
+
vegaJoinWithoutVegaConnection: 0,
|
|
4533
|
+
vegaCreateTransportWithoutVegaConnection: 0,
|
|
4534
|
+
vegaIceRestarts: 0,
|
|
4535
|
+
vegaIceRestartMissingTransport: 0,
|
|
4536
|
+
vegaIceRestartWrongTransportId: 0,
|
|
4537
|
+
};
|
|
4530
4538
|
}
|
|
4531
4539
|
_updateAndScheduleMediaServersRefresh({ iceServers, turnServers, sfuServer, sfuServers, mediaserverConfigTtlSeconds, }) {
|
|
4532
4540
|
var _a, _b, _c;
|
|
@@ -4670,10 +4678,16 @@ class VegaRtcManager {
|
|
|
4670
4678
|
_join() {
|
|
4671
4679
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4672
4680
|
var _a, _b;
|
|
4673
|
-
logger$2.info("
|
|
4681
|
+
logger$2.info("_join()");
|
|
4674
4682
|
this._emitToPWA(rtcManagerEvents.SFU_CONNECTION_OPEN);
|
|
4675
4683
|
try {
|
|
4676
|
-
|
|
4684
|
+
if (!this._vegaConnection) {
|
|
4685
|
+
logger$2.error("_join() No VegaConnection found");
|
|
4686
|
+
this.analytics.vegaJoinWithoutVegaConnection++;
|
|
4687
|
+
rtcStats.sendEvent("JoinWithoutVegaConnection", {});
|
|
4688
|
+
throw new Error("No VegaConnection found");
|
|
4689
|
+
}
|
|
4690
|
+
const { routerRtpCapabilities } = (yield this._vegaConnection.request("getCapabilities"));
|
|
4677
4691
|
if (!this._routerRtpCapabilities) {
|
|
4678
4692
|
const modifiedCapabilities = modifyMediaCapabilities(routerRtpCapabilities, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }));
|
|
4679
4693
|
this._routerRtpCapabilities = modifiedCapabilities;
|
|
@@ -4698,14 +4712,22 @@ class VegaRtcManager {
|
|
|
4698
4712
|
}
|
|
4699
4713
|
catch (error) {
|
|
4700
4714
|
logger$2.error("_join() [error:%o]", error);
|
|
4715
|
+
this.analytics.vegaJoinFailed++;
|
|
4716
|
+
rtcStats.sendEvent("VegaJoinFailed", { error });
|
|
4701
4717
|
}
|
|
4702
4718
|
});
|
|
4703
4719
|
}
|
|
4704
4720
|
_createTransport(send) {
|
|
4705
4721
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4706
4722
|
var _a;
|
|
4723
|
+
if (!this._vegaConnection) {
|
|
4724
|
+
logger$2.error("_createTransport() No VegaConnection found");
|
|
4725
|
+
this.analytics.vegaCreateTransportWithoutVegaConnection++;
|
|
4726
|
+
rtcStats.sendEvent("CreateTransportWithoutVegaConnection", {});
|
|
4727
|
+
throw new Error("No VegaConnection found");
|
|
4728
|
+
}
|
|
4707
4729
|
const creator = send ? "createSendTransport" : "createRecvTransport";
|
|
4708
|
-
const
|
|
4730
|
+
const optionsFromSfu = (yield this._vegaConnection.request("createTransport", {
|
|
4709
4731
|
producing: send,
|
|
4710
4732
|
consuming: !send,
|
|
4711
4733
|
enableTcp: true,
|
|
@@ -4720,7 +4742,8 @@ class VegaRtcManager {
|
|
|
4720
4742
|
maxSctpMessageSize: 262144,
|
|
4721
4743
|
sctpSendBufferSize: 262144,
|
|
4722
4744
|
},
|
|
4723
|
-
});
|
|
4745
|
+
}));
|
|
4746
|
+
const transportOptions = Object.assign({}, optionsFromSfu);
|
|
4724
4747
|
transportOptions.iceServers = turnServerOverride(this._features.turnServersOn ? this._turnServers : this._iceServers, this._features.turnServerOverrideHost);
|
|
4725
4748
|
maybeTurnOnly(transportOptions, this._features);
|
|
4726
4749
|
const transport = (_a = (yield this._mediasoupDeviceInitializedAsync)) === null || _a === void 0 ? void 0 : _a[creator](transportOptions);
|
|
@@ -4730,18 +4753,22 @@ class VegaRtcManager {
|
|
|
4730
4753
|
return;
|
|
4731
4754
|
}
|
|
4732
4755
|
if (send) {
|
|
4733
|
-
if (this._sndTransportIceRestartPromise) {
|
|
4756
|
+
if (this._sndTransportIceRestartPromise || !(transport === null || transport === void 0 ? void 0 : transport.id)) {
|
|
4734
4757
|
return;
|
|
4735
4758
|
}
|
|
4736
|
-
this._sndTransportIceRestartPromise = this._restartIce(transport
|
|
4759
|
+
this._sndTransportIceRestartPromise = this._restartIce("send", transport.id)
|
|
4760
|
+
.catch((e) => logger$2.error(e))
|
|
4761
|
+
.finally(() => {
|
|
4737
4762
|
this._sndTransportIceRestartPromise = null;
|
|
4738
4763
|
});
|
|
4739
4764
|
}
|
|
4740
4765
|
else {
|
|
4741
|
-
if (this._rcvTransportIceRestartPromise) {
|
|
4766
|
+
if (this._rcvTransportIceRestartPromise || !(transport === null || transport === void 0 ? void 0 : transport.id)) {
|
|
4742
4767
|
return;
|
|
4743
4768
|
}
|
|
4744
|
-
this._rcvTransportIceRestartPromise = this._restartIce(transport
|
|
4769
|
+
this._rcvTransportIceRestartPromise = this._restartIce("recv", transport.id)
|
|
4770
|
+
.catch((e) => logger$2.error(e))
|
|
4771
|
+
.finally(() => {
|
|
4745
4772
|
this._rcvTransportIceRestartPromise = null;
|
|
4746
4773
|
});
|
|
4747
4774
|
}
|
|
@@ -4762,13 +4789,13 @@ class VegaRtcManager {
|
|
|
4762
4789
|
var _b;
|
|
4763
4790
|
try {
|
|
4764
4791
|
const { paused } = appData;
|
|
4765
|
-
const { id } = yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produce", {
|
|
4792
|
+
const { id } = (yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produce", {
|
|
4766
4793
|
transportId: transport.id,
|
|
4767
4794
|
kind,
|
|
4768
4795
|
rtpParameters,
|
|
4769
4796
|
paused,
|
|
4770
4797
|
appData,
|
|
4771
|
-
}));
|
|
4798
|
+
})));
|
|
4772
4799
|
callback({ id });
|
|
4773
4800
|
}
|
|
4774
4801
|
catch (error) {
|
|
@@ -4778,11 +4805,11 @@ class VegaRtcManager {
|
|
|
4778
4805
|
transport === null || transport === void 0 ? void 0 : transport.on("producedata", (_a, callback_1, errback_1) => __awaiter(this, [_a, callback_1, errback_1], void 0, function* ({ appData, sctpStreamParameters, }, callback, errback) {
|
|
4779
4806
|
var _b;
|
|
4780
4807
|
try {
|
|
4781
|
-
const { id } = yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produceData", {
|
|
4808
|
+
const { id } = (yield ((_b = this._vegaConnection) === null || _b === void 0 ? void 0 : _b.request("produceData", {
|
|
4782
4809
|
transportId: transport.id,
|
|
4783
4810
|
sctpStreamParameters,
|
|
4784
4811
|
appData,
|
|
4785
|
-
}));
|
|
4812
|
+
})));
|
|
4786
4813
|
callback({ id });
|
|
4787
4814
|
}
|
|
4788
4815
|
catch (error) {
|
|
@@ -4796,10 +4823,22 @@ class VegaRtcManager {
|
|
|
4796
4823
|
}
|
|
4797
4824
|
});
|
|
4798
4825
|
}
|
|
4799
|
-
_restartIce(
|
|
4800
|
-
return __awaiter(this, arguments, void 0, function* (
|
|
4801
|
-
|
|
4802
|
-
|
|
4826
|
+
_restartIce(direction_1, transportId_1) {
|
|
4827
|
+
return __awaiter(this, arguments, void 0, function* (direction, transportId, retried = 0) {
|
|
4828
|
+
this.analytics.vegaIceRestarts++;
|
|
4829
|
+
const transport = direction === "send" ? this._sendTransport : this._receiveTransport;
|
|
4830
|
+
if (!transport) {
|
|
4831
|
+
logger$2.info(`_restartIce: No transport found with id ${transportId}`);
|
|
4832
|
+
this.analytics.vegaIceRestartMissingTransport++;
|
|
4833
|
+
return;
|
|
4834
|
+
}
|
|
4835
|
+
if (transport.id !== transportId) {
|
|
4836
|
+
logger$2.info(`_restartIce: Transport ids does not match [expected: ${transportId}, actual: ${transport.id}]`);
|
|
4837
|
+
this.analytics.vegaIceRestartWrongTransportId++;
|
|
4838
|
+
return;
|
|
4839
|
+
}
|
|
4840
|
+
if (!("closed" in transport) || !("connectionState" in transport)) {
|
|
4841
|
+
logger$2.info("_restartIce: Transport is missing closed or connectionState property");
|
|
4803
4842
|
return;
|
|
4804
4843
|
}
|
|
4805
4844
|
if (transport.closed) {
|
|
@@ -4824,7 +4863,9 @@ class VegaRtcManager {
|
|
|
4824
4863
|
logger$2.info(`_restartIce: Connection is undefined`);
|
|
4825
4864
|
return;
|
|
4826
4865
|
}
|
|
4827
|
-
const { iceParameters } = yield this._vegaConnection.request("restartIce", {
|
|
4866
|
+
const { iceParameters } = (yield this._vegaConnection.request("restartIce", {
|
|
4867
|
+
transportId: transport.id,
|
|
4868
|
+
}));
|
|
4828
4869
|
logger$2.info("_restartIce: ICE restart iceParameters received from SFU: ", iceParameters);
|
|
4829
4870
|
const error = yield transport
|
|
4830
4871
|
.restartIce({ iceParameters })
|
|
@@ -4842,7 +4883,7 @@ class VegaRtcManager {
|
|
|
4842
4883
|
resolve(undefined);
|
|
4843
4884
|
}, Math.min(RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS * Math.pow(2, retried), 60000));
|
|
4844
4885
|
});
|
|
4845
|
-
yield this._restartIce(
|
|
4886
|
+
yield this._restartIce(direction, transportId, retried + 1);
|
|
4846
4887
|
break;
|
|
4847
4888
|
}
|
|
4848
4889
|
return;
|
|
@@ -4853,7 +4894,7 @@ class VegaRtcManager {
|
|
|
4853
4894
|
}, 60000 * Math.min(8, retried + 1));
|
|
4854
4895
|
});
|
|
4855
4896
|
if (transport.connectionState === "failed" || transport.connectionState === "disconnected") {
|
|
4856
|
-
yield this._restartIce(
|
|
4897
|
+
yield this._restartIce(direction, transportId, retried + 1);
|
|
4857
4898
|
return;
|
|
4858
4899
|
}
|
|
4859
4900
|
});
|