vani-meeting-client 2.3.7 → 2.3.9
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/lib/inter-communication-handler/CommunicationHandler.js +2 -0
- package/lib/model/Participant.d.ts +2 -0
- package/lib/model/Participant.js +6 -0
- package/lib/video-call-handler/SFUHandler.js +9 -8
- package/lib/video-call-handler/WebrtcHandler.d.ts +1 -0
- package/lib/video-call-handler/WebrtcHandler.js +246 -115
- package/lib/websocket-handler/WebsocketHandler.js +2 -0
- package/package.json +1 -1
|
@@ -573,6 +573,8 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
573
573
|
CommunicationHandler.prototype.sendWebSocketMessage = function (type, data) {
|
|
574
574
|
var _a;
|
|
575
575
|
(_a = this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.sendSocketMessage(type, data);
|
|
576
|
+
// this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug &&
|
|
577
|
+
// console.log("sendSocketMessage",type,data)
|
|
576
578
|
};
|
|
577
579
|
// public sendWebSocketMessageForWebrtc(type: WebrtcMessageType, data: any, to : string) {
|
|
578
580
|
// this.websocketCallHandler?.sendSocketMessage(type, data)
|
|
@@ -16,6 +16,8 @@ export declare class Participant {
|
|
|
16
16
|
isRecordingUser: boolean;
|
|
17
17
|
private peerConnections;
|
|
18
18
|
getPeerConnections: () => Map<string, PeerConnection>;
|
|
19
|
+
isPeerConnectionsViaUserIdPresent: (userId: string) => PeerConnection;
|
|
20
|
+
removePeerConnectionsViaUserId: (userId: string) => boolean;
|
|
19
21
|
getPeerConnectionsViaUserId: (userId: string, meetingStartRequest: MeetingStartRequest) => PeerConnection;
|
|
20
22
|
constructor(_userId: string, _roomId: string, _userData?: any, _isAdmin?: boolean);
|
|
21
23
|
}
|
package/lib/model/Participant.js
CHANGED
|
@@ -22,6 +22,12 @@ var Participant = /** @class */ (function () {
|
|
|
22
22
|
}
|
|
23
23
|
return _this.peerConnections;
|
|
24
24
|
};
|
|
25
|
+
this.isPeerConnectionsViaUserIdPresent = function (userId) {
|
|
26
|
+
return _this.getPeerConnections().get(userId);
|
|
27
|
+
};
|
|
28
|
+
this.removePeerConnectionsViaUserId = function (userId) {
|
|
29
|
+
return _this.getPeerConnections().delete(userId);
|
|
30
|
+
};
|
|
25
31
|
this.getPeerConnectionsViaUserId = function (userId, meetingStartRequest) {
|
|
26
32
|
if (!_this.getPeerConnections().has(userId)) {
|
|
27
33
|
var peerConnection = new PeerConnection();
|
|
@@ -272,11 +272,11 @@ var SFUHandler = /** @class */ (function (_super) {
|
|
|
272
272
|
});
|
|
273
273
|
};
|
|
274
274
|
SFUHandler.prototype.onRestartIceCandidateResponse = function (data) {
|
|
275
|
-
var _a;
|
|
275
|
+
var _a, _b;
|
|
276
276
|
return __awaiter(this, void 0, void 0, function () {
|
|
277
277
|
var transportId, iceParameters;
|
|
278
|
-
return __generator(this, function (
|
|
279
|
-
switch (
|
|
278
|
+
return __generator(this, function (_c) {
|
|
279
|
+
switch (_c.label) {
|
|
280
280
|
case 0:
|
|
281
281
|
transportId = data.message.transportId;
|
|
282
282
|
iceParameters = data.message.iceParameters;
|
|
@@ -285,17 +285,17 @@ var SFUHandler = /** @class */ (function (_super) {
|
|
|
285
285
|
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("Restat Ice consumer");
|
|
286
286
|
return [4 /*yield*/, this.consumerTransport.restartIce({ iceParameters: iceParameters })];
|
|
287
287
|
case 1:
|
|
288
|
-
|
|
288
|
+
_c.sent();
|
|
289
289
|
return [3 /*break*/, 4];
|
|
290
290
|
case 2:
|
|
291
291
|
if (!(this.sendTransport && this.sendTransport.id === transportId)) return [3 /*break*/, 4];
|
|
292
292
|
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("Restat Ice sender");
|
|
293
293
|
return [4 /*yield*/, this.sendTransport.restartIce({ iceParameters: iceParameters })];
|
|
294
294
|
case 3:
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
_c.sent();
|
|
296
|
+
_c.label = 4;
|
|
297
297
|
case 4:
|
|
298
|
-
this.communicationHandler.onReconnect(false);
|
|
298
|
+
(_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.onReconnect(false);
|
|
299
299
|
return [2 /*return*/];
|
|
300
300
|
}
|
|
301
301
|
});
|
|
@@ -670,8 +670,9 @@ var SFUHandler = /** @class */ (function (_super) {
|
|
|
670
670
|
});
|
|
671
671
|
};
|
|
672
672
|
SFUHandler.prototype.onRouterRtpCapabilities = function (data) {
|
|
673
|
+
var _a;
|
|
673
674
|
try {
|
|
674
|
-
if (this.getDevice() && this.getDevice().loaded) {
|
|
675
|
+
if (this.getDevice() && ((_a = this.getDevice()) === null || _a === void 0 ? void 0 : _a.loaded)) {
|
|
675
676
|
return;
|
|
676
677
|
}
|
|
677
678
|
if (data && data.message && data.message.rtpCapabilities) {
|
|
@@ -42,6 +42,7 @@ export declare class WebrtcHandler extends BaseVideoCallHandler {
|
|
|
42
42
|
subToConnectionState: (remoteParticipant: Participant) => Promise<void>;
|
|
43
43
|
onNegotiationNeeded: (remoteParticipant: Participant, shouldRestartIce?: boolean, count?: number, shouldForceFullyCreateOffer?: boolean) => Promise<void>;
|
|
44
44
|
onAllParticipants(participants: Participant[]): Promise<void>;
|
|
45
|
+
onUserLeft(participant: Participant): Promise<void>;
|
|
45
46
|
onUserJoined(participant: Participant): Promise<void>;
|
|
46
47
|
startSendTrackToPartiipant: (participant: Participant) => Promise<void>;
|
|
47
48
|
sendTrackToParticipant: (track: Track, participant: Participant) => Promise<void>;
|
|
@@ -97,7 +97,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
97
97
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
98
98
|
};
|
|
99
99
|
import { Track, TrackKind } from "../model/Track";
|
|
100
|
-
import { WebrtcMessageType } from "../websocket-handler/WebsocketHandler";
|
|
100
|
+
import { WebrtcMessageType, } from "../websocket-handler/WebsocketHandler";
|
|
101
101
|
import { BaseVideoCallHandler } from "./BaseVideoCallHandler";
|
|
102
102
|
import { LogLevel } from "../model/MeetingStartRequest";
|
|
103
103
|
import { DynamicLibHelper } from "../utility/DynamicLibHelper";
|
|
@@ -107,14 +107,14 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
107
107
|
__extends(WebrtcHandler, _super);
|
|
108
108
|
function WebrtcHandler() {
|
|
109
109
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
110
|
-
_this.dynamicLibHelper =
|
|
110
|
+
_this.dynamicLibHelper = new DynamicLibHelper();
|
|
111
111
|
_this.rtcPeerConnections = [];
|
|
112
112
|
_this.adaptationManager = null;
|
|
113
113
|
_this.addTransceiverifRequired = function (peerConnection) { return __awaiter(_this, void 0, void 0, function () {
|
|
114
114
|
var kinds, kinds_1, kinds_1_1, eachKind;
|
|
115
115
|
var e_1, _a;
|
|
116
116
|
return __generator(this, function (_b) {
|
|
117
|
-
kinds = [
|
|
117
|
+
kinds = ["audio", "video"];
|
|
118
118
|
try {
|
|
119
119
|
for (kinds_1 = __values(kinds), kinds_1_1 = kinds_1.next(); !kinds_1_1.done; kinds_1_1 = kinds_1.next()) {
|
|
120
120
|
eachKind = kinds_1_1.value;
|
|
@@ -128,6 +128,12 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
128
128
|
}
|
|
129
129
|
finally { if (e_1) throw e_1.error; }
|
|
130
130
|
}
|
|
131
|
+
this.printLogIfRequired("no of transiver", peerConnection.rtcPeerConnection
|
|
132
|
+
.getTransceivers());
|
|
133
|
+
if (peerConnection.rtcPeerConnection
|
|
134
|
+
.getTransceivers().length === 0) {
|
|
135
|
+
peerConnection.rtcPeerConnection.createDataChannel("test");
|
|
136
|
+
}
|
|
131
137
|
return [2 /*return*/];
|
|
132
138
|
});
|
|
133
139
|
}); };
|
|
@@ -139,7 +145,9 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
139
145
|
return __generator(this, function (_c) {
|
|
140
146
|
switch (_c.label) {
|
|
141
147
|
case 0:
|
|
142
|
-
transceiver = peerConnection.rtcPeerConnection
|
|
148
|
+
transceiver = peerConnection.rtcPeerConnection
|
|
149
|
+
.getTransceivers()
|
|
150
|
+
.find(function (t) { var _a, _b; return ((_b = (_a = t === null || t === void 0 ? void 0 : t.sender) === null || _a === void 0 ? void 0 : _a.track) === null || _b === void 0 ? void 0 : _b.kind) === eachKind; });
|
|
143
151
|
if (!!transceiver) return [3 /*break*/, 1];
|
|
144
152
|
this.printLogIfRequired("addTransceiverifRequired", eachKind);
|
|
145
153
|
realTrack = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getAllSelfTracks().find(function (t) { var _a; return ((_a = t.track) === null || _a === void 0 ? void 0 : _a.kind) === eachKind; });
|
|
@@ -147,26 +155,21 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
147
155
|
if (realTrack && realTrack.track) {
|
|
148
156
|
this.printLogIfRequired("addTransceiverifRequired track real", eachKind, realTrack.track);
|
|
149
157
|
// newTransceiver = await peerConnection.rtcPeerConnection.addTrack(realTrack.track)
|
|
150
|
-
if (realTrack.track.kind ===
|
|
158
|
+
if (realTrack.track.kind === "audio") {
|
|
151
159
|
newTransceiver = peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, {
|
|
152
|
-
direction:
|
|
160
|
+
direction: "sendonly",
|
|
153
161
|
sendEncodings: [
|
|
154
162
|
{
|
|
155
163
|
maxBitrate: 32000,
|
|
156
|
-
priority:
|
|
157
|
-
networkPriority:
|
|
158
|
-
}
|
|
159
|
-
]
|
|
164
|
+
priority: "high",
|
|
165
|
+
networkPriority: "high",
|
|
166
|
+
},
|
|
167
|
+
],
|
|
160
168
|
});
|
|
161
169
|
}
|
|
162
|
-
else if (realTrack.track.kind ===
|
|
170
|
+
else if (realTrack.track.kind === "video") {
|
|
163
171
|
newTransceiver = peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, {
|
|
164
|
-
direction:
|
|
165
|
-
sendEncodings: [{
|
|
166
|
-
maxBitrate: 500000,
|
|
167
|
-
priority: 'low',
|
|
168
|
-
networkPriority: 'low',
|
|
169
|
-
}]
|
|
172
|
+
direction: "sendonly",
|
|
170
173
|
});
|
|
171
174
|
}
|
|
172
175
|
// newTransceiver = await peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, { direction: "sendrecv" })
|
|
@@ -176,8 +179,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
176
179
|
// this.printLogIfRequired("addTransceiverifRequired track fake",eachKind)
|
|
177
180
|
// newTransceiver = await peerConnection.rtcPeerConnection.addTransceiver(eachKind, { direction: "sendrecv" })
|
|
178
181
|
}
|
|
179
|
-
if (eachKind ===
|
|
180
|
-
transceiver = peerConnection.rtcPeerConnection
|
|
182
|
+
if (eachKind === "audio") {
|
|
183
|
+
transceiver = peerConnection.rtcPeerConnection
|
|
184
|
+
.getTransceivers()
|
|
185
|
+
.find(function (t) { var _a, _b; return ((_b = (_a = t === null || t === void 0 ? void 0 : t.sender) === null || _a === void 0 ? void 0 : _a.track) === null || _b === void 0 ? void 0 : _b.kind) === eachKind; });
|
|
181
186
|
if (transceiver) {
|
|
182
187
|
this.applyAudioPriority(transceiver);
|
|
183
188
|
}
|
|
@@ -192,7 +197,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
192
197
|
return [4 /*yield*/, transceiver.sender.replaceTrack(realTrack.track)];
|
|
193
198
|
case 2:
|
|
194
199
|
_c.sent();
|
|
195
|
-
if (eachKind ===
|
|
200
|
+
if (eachKind === "audio") {
|
|
196
201
|
this.applyAudioPriority(transceiver);
|
|
197
202
|
// this.setOpusParams(newTransceiver);
|
|
198
203
|
}
|
|
@@ -214,19 +219,26 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
214
219
|
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
215
220
|
this.printLogIfRequired("checkIfCanSendOffer", selfParticpant, (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.isStartAndSetupWithServerCalled);
|
|
216
221
|
this.printLogIfRequired("checkIfCanSendOffer REMOTE", participant);
|
|
217
|
-
if (!selfParticpant.isStartMeetingCalled &&
|
|
222
|
+
if (!selfParticpant.isStartMeetingCalled &&
|
|
223
|
+
!((_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.isStartAndSetupWithServerCalled)) {
|
|
218
224
|
return [2 /*return*/];
|
|
219
225
|
}
|
|
220
|
-
if (!(selfParticpant.userId !== participant.userId &&
|
|
226
|
+
if (!(selfParticpant.userId !== participant.userId &&
|
|
227
|
+
(negotiationId ||
|
|
228
|
+
!selfParticpant.getPeerConnections().has(participant.userId)))) return [3 /*break*/, 5];
|
|
221
229
|
isOfferInitParticipant = this.isOfferInitParticipant(participant);
|
|
222
230
|
this.printLogIfRequired("Check if Can Send Offer", isOfferInitParticipant, shouldForceFullyCreateOffer);
|
|
223
231
|
if (!(!isOfferInitParticipant || shouldForceFullyCreateOffer)) return [3 /*break*/, 5];
|
|
224
232
|
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
|
|
225
|
-
peerConnection = peerConnectionObject.rtcPeerConnection
|
|
233
|
+
peerConnection = peerConnectionObject.rtcPeerConnection
|
|
234
|
+
? peerConnectionObject.rtcPeerConnection
|
|
235
|
+
: this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
|
|
226
236
|
if (!peerConnection) return [3 /*break*/, 5];
|
|
227
237
|
this.rtcPeerConnections.push(peerConnection);
|
|
228
238
|
peerConnectionObject.isCreatingOffer = true;
|
|
229
|
-
if (negotiationId &&
|
|
239
|
+
if (negotiationId &&
|
|
240
|
+
peerConnectionObject.opertionalNegotiationId &&
|
|
241
|
+
peerConnectionObject.opertionalNegotiationId === negotiationId) {
|
|
230
242
|
return [2 /*return*/];
|
|
231
243
|
}
|
|
232
244
|
peerConnectionObject.opertionalNegotiationId = negotiationId;
|
|
@@ -242,7 +254,9 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
242
254
|
if (shouldRestartIce) {
|
|
243
255
|
peerConnection.restartIce();
|
|
244
256
|
}
|
|
245
|
-
return [4 /*yield*/, peerConnection.createOffer({
|
|
257
|
+
return [4 /*yield*/, peerConnection.createOffer({
|
|
258
|
+
iceRestart: shouldRestartIce,
|
|
259
|
+
})];
|
|
246
260
|
case 3:
|
|
247
261
|
offer = _c.sent();
|
|
248
262
|
mungedOffer = {
|
|
@@ -257,6 +271,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
257
271
|
// send offer to peer
|
|
258
272
|
peerConnectionObject.remoteAnswer = undefined;
|
|
259
273
|
this.loopSendOffer(peerConnectionObject, participant, mungedOffer);
|
|
274
|
+
this.printLogIfRequired("CheckIfCanSendOffer new", peerConnectionObject, __spreadArray([], __read(selfParticpant.getPeerConnections().entries()), false));
|
|
260
275
|
_c.label = 5;
|
|
261
276
|
case 5: return [2 /*return*/];
|
|
262
277
|
}
|
|
@@ -266,21 +281,35 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
266
281
|
_this.loopSendOffer = function (peerConnectionObject, participant, mungedOffer, count) {
|
|
267
282
|
if (count === void 0) { count = 0; }
|
|
268
283
|
return __awaiter(_this, void 0, void 0, function () {
|
|
269
|
-
var messageJson;
|
|
284
|
+
var selfParticpant, messageJson;
|
|
270
285
|
var _this = this;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
286
|
+
var _a;
|
|
287
|
+
return __generator(this, function (_b) {
|
|
288
|
+
selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
|
|
289
|
+
if (!selfParticpant) {
|
|
290
|
+
return [2 /*return*/];
|
|
291
|
+
}
|
|
292
|
+
if (!selfParticpant.isPeerConnectionsViaUserIdPresent(participant.userId)) {
|
|
293
|
+
this.printLogIfRequired("loopSendOffer", "Not found", selfParticpant, participant);
|
|
294
|
+
return [2 /*return*/];
|
|
295
|
+
}
|
|
296
|
+
this.printLogIfRequired("Send Offer loop", mungedOffer, participant);
|
|
297
|
+
messageJson = {
|
|
298
|
+
to: participant.userId,
|
|
299
|
+
type: WebrtcMessageType.SendOffer,
|
|
300
|
+
data: mungedOffer,
|
|
301
|
+
};
|
|
274
302
|
this.sendWebrtcMessage(messageJson);
|
|
275
303
|
if (peerConnectionObject.remoteAnswer || count > 20) {
|
|
276
304
|
return [2 /*return*/];
|
|
277
305
|
}
|
|
278
|
-
if (peerConnectionObject.rtcPeerConnection &&
|
|
306
|
+
if (peerConnectionObject.rtcPeerConnection &&
|
|
307
|
+
peerConnectionObject.rtcPeerConnection.connectionState === "closed") {
|
|
279
308
|
return [2 /*return*/];
|
|
280
309
|
}
|
|
281
310
|
setTimeout(function () {
|
|
282
311
|
_this.printLogIfRequired("loopSendOffer ");
|
|
283
|
-
_this.loopSendOffer(peerConnectionObject, participant, mungedOffer,
|
|
312
|
+
_this.loopSendOffer(peerConnectionObject, participant, mungedOffer, count + 1);
|
|
284
313
|
}, 3000);
|
|
285
314
|
return [2 /*return*/];
|
|
286
315
|
});
|
|
@@ -305,21 +334,32 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
305
334
|
if (peerConnectionObject) {
|
|
306
335
|
peerConnectionObject.remoteOffer = data.sdp;
|
|
307
336
|
}
|
|
308
|
-
peerConnection = peerConnectionObject.rtcPeerConnection
|
|
337
|
+
peerConnection = peerConnectionObject.rtcPeerConnection
|
|
338
|
+
? peerConnectionObject.rtcPeerConnection
|
|
339
|
+
: this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
|
|
309
340
|
if (!peerConnection) return [3 /*break*/, 6];
|
|
310
341
|
this.rtcPeerConnections.push(peerConnection);
|
|
311
342
|
peerConnectionObject.rtcPeerConnection = peerConnection;
|
|
312
|
-
if (peerConnectionObject.opertionalNegotiationId &&
|
|
343
|
+
if (peerConnectionObject.opertionalNegotiationId &&
|
|
344
|
+
peerConnectionObject.negotiationId &&
|
|
345
|
+
peerConnectionObject.opertionalNegotiationId ===
|
|
346
|
+
peerConnectionObject.negotiationId) {
|
|
313
347
|
peerConnectionObject.negotiationId = undefined;
|
|
314
348
|
peerConnectionObject.isNegotiationNeeded = false;
|
|
315
349
|
}
|
|
316
350
|
return [4 /*yield*/, this.subToConnectionState(participant)];
|
|
317
351
|
case 1:
|
|
318
352
|
_b.sent();
|
|
319
|
-
return [4 /*yield*/, peerConnection.setRemoteDescription({
|
|
353
|
+
return [4 /*yield*/, peerConnection.setRemoteDescription({
|
|
354
|
+
type: "offer",
|
|
355
|
+
sdp: peerConnectionObject.remoteOffer,
|
|
356
|
+
})];
|
|
320
357
|
case 2:
|
|
321
358
|
_b.sent();
|
|
322
|
-
this.printLogIfRequired("On New Offer setRemoteDescription", {
|
|
359
|
+
this.printLogIfRequired("On New Offer setRemoteDescription", {
|
|
360
|
+
type: "offer",
|
|
361
|
+
sdp: peerConnectionObject.remoteOffer,
|
|
362
|
+
});
|
|
323
363
|
this.printLogIfRequired("REMOTE SDP", (_a = peerConnection.remoteDescription) === null || _a === void 0 ? void 0 : _a.sdp);
|
|
324
364
|
return [4 /*yield*/, this.addTransceiverifRequired(peerConnectionObject)];
|
|
325
365
|
case 3:
|
|
@@ -338,7 +378,11 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
338
378
|
this.printLogIfRequired("On New Offer setLocalDescription", mungedAnswer);
|
|
339
379
|
peerConnectionObject.answer = mungedAnswer;
|
|
340
380
|
console.log("answer", mungedAnswer);
|
|
341
|
-
messageJson = {
|
|
381
|
+
messageJson = {
|
|
382
|
+
to: participant.userId,
|
|
383
|
+
type: WebrtcMessageType.SendAnswer,
|
|
384
|
+
data: mungedAnswer,
|
|
385
|
+
};
|
|
342
386
|
this.sendWebrtcMessage(messageJson);
|
|
343
387
|
peerConnectionObject.opertionalNegotiationId = undefined;
|
|
344
388
|
_b.label = 6;
|
|
@@ -357,7 +401,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
357
401
|
participant = data.sender;
|
|
358
402
|
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
|
|
359
403
|
this.printLogIfRequired("On New Answer peerConnectionObject", peerConnectionObject);
|
|
360
|
-
if (peerConnectionObject.opertionalNegotiationId &&
|
|
404
|
+
if (peerConnectionObject.opertionalNegotiationId &&
|
|
405
|
+
peerConnectionObject.negotiationId &&
|
|
406
|
+
peerConnectionObject.opertionalNegotiationId ===
|
|
407
|
+
peerConnectionObject.negotiationId) {
|
|
361
408
|
peerConnectionObject.negotiationId = undefined;
|
|
362
409
|
peerConnectionObject.opertionalNegotiationId = undefined;
|
|
363
410
|
peerConnectionObject.isNegotiationNeeded = false;
|
|
@@ -366,17 +413,25 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
366
413
|
if (peerConnectionObject) {
|
|
367
414
|
peerConnectionObject.remoteAnswer = data.sdp;
|
|
368
415
|
}
|
|
369
|
-
peerConnection = peerConnectionObject.rtcPeerConnection
|
|
416
|
+
peerConnection = peerConnectionObject.rtcPeerConnection
|
|
417
|
+
? peerConnectionObject.rtcPeerConnection
|
|
418
|
+
: this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
|
|
370
419
|
if (!peerConnection) return [3 /*break*/, 3];
|
|
371
|
-
if (!(peerConnection.signalingState ===
|
|
372
|
-
return [4 /*yield*/, peerConnection.setRemoteDescription({
|
|
420
|
+
if (!(peerConnection.signalingState === "have-local-offer")) return [3 /*break*/, 2];
|
|
421
|
+
return [4 /*yield*/, peerConnection.setRemoteDescription({
|
|
422
|
+
type: "answer",
|
|
423
|
+
sdp: peerConnectionObject.remoteAnswer,
|
|
424
|
+
})];
|
|
373
425
|
case 1:
|
|
374
426
|
_b.sent();
|
|
375
427
|
_b.label = 2;
|
|
376
428
|
case 2:
|
|
377
429
|
peerConnectionObject.isRtcRestartIceInProgess = false;
|
|
378
430
|
this.printLogIfRequired("REMOTE SDP", (_a = peerConnection.remoteDescription) === null || _a === void 0 ? void 0 : _a.sdp);
|
|
379
|
-
this.printLogIfRequired("On New Answer setRemoteDescription", {
|
|
431
|
+
this.printLogIfRequired("On New Answer setRemoteDescription", {
|
|
432
|
+
type: "answer",
|
|
433
|
+
sdp: peerConnectionObject.remoteAnswer,
|
|
434
|
+
});
|
|
380
435
|
_b.label = 3;
|
|
381
436
|
case 3: return [2 /*return*/];
|
|
382
437
|
}
|
|
@@ -472,19 +527,24 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
472
527
|
return [2 /*return*/];
|
|
473
528
|
}
|
|
474
529
|
rtcConnection = peerConnectionObject.rtcPeerConnection;
|
|
475
|
-
if (!rtcConnection ||
|
|
530
|
+
if (!rtcConnection ||
|
|
531
|
+
peerConnectionObject.isRtcRestartIceInProgess ||
|
|
532
|
+
count > 12 ||
|
|
533
|
+
(rtcConnection.connectionState !== "failed" &&
|
|
534
|
+
rtcConnection.connectionState !== "disconnected")) {
|
|
476
535
|
return [2 /*return*/];
|
|
477
536
|
}
|
|
478
537
|
if ((_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.isWebScoketConnected()) {
|
|
479
538
|
rtcConnection.restartIce();
|
|
480
539
|
peerConnectionObject.isRtcRestartIceInProgess = true;
|
|
481
540
|
peerConnectionObject.isNegotiationNeeded = true;
|
|
482
|
-
peerConnectionObject.negotiationId =
|
|
541
|
+
peerConnectionObject.negotiationId =
|
|
542
|
+
new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
|
|
483
543
|
this.onNegotiationNeeded(remoteParticipant, true);
|
|
484
544
|
}
|
|
485
545
|
else {
|
|
486
546
|
setTimeout(function () {
|
|
487
|
-
_this.onRTCConnectionChanged(remoteParticipant,
|
|
547
|
+
_this.onRTCConnectionChanged(remoteParticipant, count + 1);
|
|
488
548
|
}, 4000);
|
|
489
549
|
}
|
|
490
550
|
return [2 /*return*/];
|
|
@@ -502,23 +562,30 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
502
562
|
}
|
|
503
563
|
peerConnectionObject.isSubDone = true;
|
|
504
564
|
rtcConnection = peerConnectionObject.rtcPeerConnection;
|
|
505
|
-
rtcConnection.addEventListener(
|
|
565
|
+
rtcConnection.addEventListener("icecandidate", function (event) {
|
|
506
566
|
if (event.candidate && event.candidate !== null) {
|
|
507
567
|
_this.printLogIfRequired("icecandidate", event.candidate, remoteParticipant);
|
|
508
568
|
var sdpMid = event.candidate.sdpMid;
|
|
509
569
|
var sdpMLineIndex = event.candidate.sdpMLineIndex;
|
|
510
|
-
var messageJson = {
|
|
511
|
-
|
|
570
|
+
var messageJson = {
|
|
571
|
+
to: remoteParticipant.userId,
|
|
572
|
+
type: WebrtcMessageType.IceCandidate,
|
|
573
|
+
data: {
|
|
574
|
+
sdpMid: sdpMid,
|
|
575
|
+
sdpMLineIndex: sdpMLineIndex,
|
|
576
|
+
candidate: event.candidate,
|
|
577
|
+
},
|
|
578
|
+
};
|
|
512
579
|
_this.sendWebrtcMessage(messageJson);
|
|
513
580
|
}
|
|
514
581
|
});
|
|
515
|
-
rtcConnection.addEventListener(
|
|
582
|
+
rtcConnection.addEventListener("iceconnectionstatechange", function (event) {
|
|
516
583
|
_this.printLogIfRequired("iceconnectionstatechange", rtcConnection.iceConnectionState, event, remoteParticipant);
|
|
517
584
|
});
|
|
518
|
-
rtcConnection.addEventListener(
|
|
585
|
+
rtcConnection.addEventListener("connectionstatechange", function (event) {
|
|
519
586
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
520
587
|
_this.printLogIfRequired("connectionstatechange", peerConnectionObject.userId, rtcConnection.connectionState);
|
|
521
|
-
if (rtcConnection.connectionState ===
|
|
588
|
+
if (rtcConnection.connectionState === "connected") {
|
|
522
589
|
var participant = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.participantByUserId(peerConnectionObject.userId);
|
|
523
590
|
_this.printLogIfRequired("connected", participant, peerConnectionObject.userId);
|
|
524
591
|
if (participant) {
|
|
@@ -538,10 +605,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
538
605
|
// if(eachReciver && eachReciver.track){
|
|
539
606
|
// const streamTrack = eachReciver.track
|
|
540
607
|
// this.onNewTrack(streamTrack,remoteParticipant)
|
|
541
|
-
// }
|
|
608
|
+
// }
|
|
542
609
|
// })
|
|
543
610
|
}
|
|
544
|
-
else if (rtcConnection.connectionState ===
|
|
611
|
+
else if (rtcConnection.connectionState === "disconnected") {
|
|
545
612
|
var participant = (_e = _this.communicationHandler) === null || _e === void 0 ? void 0 : _e.participantByUserId(peerConnectionObject.userId);
|
|
546
613
|
_this.printLogIfRequired("disconnected", participant, peerConnectionObject.userId);
|
|
547
614
|
if (participant) {
|
|
@@ -551,7 +618,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
551
618
|
_this.onRTCConnectionChanged(remoteParticipant);
|
|
552
619
|
}, 4000);
|
|
553
620
|
}
|
|
554
|
-
else if (rtcConnection.connectionState ===
|
|
621
|
+
else if (rtcConnection.connectionState === "failed") {
|
|
555
622
|
var participant = (_g = _this.communicationHandler) === null || _g === void 0 ? void 0 : _g.participantByUserId(peerConnectionObject.userId);
|
|
556
623
|
_this.printLogIfRequired("failed", participant, peerConnectionObject.userId);
|
|
557
624
|
if (participant) {
|
|
@@ -560,11 +627,15 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
560
627
|
_this.onRTCConnectionChanged(remoteParticipant);
|
|
561
628
|
}
|
|
562
629
|
});
|
|
563
|
-
rtcConnection.addEventListener(
|
|
630
|
+
rtcConnection.addEventListener("signalingstatechange", function (event) {
|
|
631
|
+
var _a;
|
|
564
632
|
_this.printLogIfRequired("signalingstatechange", event, rtcConnection.signalingState);
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
633
|
+
var selfParticpant = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
|
|
634
|
+
var innerPeerConnectionObject = selfParticpant === null || selfParticpant === void 0 ? void 0 : selfParticpant.isPeerConnectionsViaUserIdPresent(remoteParticipant.userId);
|
|
635
|
+
if (innerPeerConnectionObject &&
|
|
636
|
+
rtcConnection.signalingState === "stable") {
|
|
637
|
+
innerPeerConnectionObject.isCreatingOffer = false;
|
|
638
|
+
if (innerPeerConnectionObject.isNegotiationNeeded) {
|
|
568
639
|
_this.onNegotiationNeeded(remoteParticipant, false, 0, true);
|
|
569
640
|
}
|
|
570
641
|
}
|
|
@@ -578,15 +649,23 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
578
649
|
// this.printLogIfRequired("New Remote Track",track)
|
|
579
650
|
// }
|
|
580
651
|
// })
|
|
581
|
-
rtcConnection.addEventListener(
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
652
|
+
rtcConnection.addEventListener("negotiationneeded", function (event) {
|
|
653
|
+
var _a, _b;
|
|
654
|
+
_this.printLogIfRequired("negotiationneeded", rtcConnection.signalingState, remoteParticipant, peerConnectionObject);
|
|
655
|
+
var selfParticpant = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
|
|
656
|
+
var innerPeerConnectionObject = selfParticpant === null || selfParticpant === void 0 ? void 0 : selfParticpant.isPeerConnectionsViaUserIdPresent(remoteParticipant.userId);
|
|
657
|
+
var remoteUser = (_b = _this.communicationHandler) === null || _b === void 0 ? void 0 : _b.participantByUserId(remoteParticipant.userId);
|
|
658
|
+
if (!remoteUser &&
|
|
659
|
+
(!innerPeerConnectionObject ||
|
|
660
|
+
(!innerPeerConnectionObject.offer &&
|
|
661
|
+
!innerPeerConnectionObject.answer))) {
|
|
662
|
+
_this.printLogIfRequired("negotiationneeded ignored", rtcConnection.signalingState, remoteParticipant, innerPeerConnectionObject, __spreadArray([], __read(selfParticpant.getPeerConnections().entries()), false));
|
|
585
663
|
return;
|
|
586
664
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
665
|
+
innerPeerConnectionObject.isNegotiationNeeded = true;
|
|
666
|
+
innerPeerConnectionObject.negotiationId =
|
|
667
|
+
new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
|
|
668
|
+
if (rtcConnection.signalingState === "stable") {
|
|
590
669
|
_this.onNegotiationNeeded(remoteParticipant, false, 0, true);
|
|
591
670
|
}
|
|
592
671
|
});
|
|
@@ -622,7 +701,11 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
622
701
|
isOfferInitParticipant = this.isOfferInitParticipant(remoteParticipant);
|
|
623
702
|
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
624
703
|
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(remoteParticipant.userId, this.meetingStartRequest);
|
|
625
|
-
if (peerConnectionObject &&
|
|
704
|
+
if (peerConnectionObject &&
|
|
705
|
+
shouldRestartIce &&
|
|
706
|
+
peerConnectionObject.rtcPeerConnection &&
|
|
707
|
+
peerConnectionObject.rtcPeerConnection.connectionState === "connected") {
|
|
708
|
+
this.printLogIfRequired("onNegotiationNeeded return", remoteParticipant, shouldRestartIce, peerConnectionObject);
|
|
626
709
|
return [2 /*return*/];
|
|
627
710
|
}
|
|
628
711
|
// if(shouldIgnoreAllOldOpetionalNego){
|
|
@@ -632,7 +715,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
632
715
|
// this.printLogIfRequired("shouldForceFullyCreateOffer ",peerConnectionObject,peerConnectionObject.isNegotiationNeeded,peerConnectionObject.opertionalNegotiationId,count)
|
|
633
716
|
// }
|
|
634
717
|
// else
|
|
635
|
-
if (!peerConnectionObject ||
|
|
718
|
+
if (!peerConnectionObject ||
|
|
719
|
+
!peerConnectionObject.isNegotiationNeeded ||
|
|
720
|
+
peerConnectionObject.opertionalNegotiationId ||
|
|
721
|
+
count > 15) {
|
|
636
722
|
this.printLogIfRequired("onNegotiationNeeded exit", peerConnectionObject, peerConnectionObject.isNegotiationNeeded, peerConnectionObject.opertionalNegotiationId, count);
|
|
637
723
|
return [2 /*return*/];
|
|
638
724
|
}
|
|
@@ -648,24 +734,38 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
648
734
|
case 2:
|
|
649
735
|
setTimeout(function () {
|
|
650
736
|
_this.printLogIfRequired("onNegotiationNeeded setTimeout 525");
|
|
651
|
-
_this.onNegotiationNeeded(remoteParticipant, shouldRestartIce,
|
|
737
|
+
_this.onNegotiationNeeded(remoteParticipant, shouldRestartIce, count + 1, shouldForceFullyCreateOffer);
|
|
652
738
|
}, 5000);
|
|
653
739
|
_d.label = 3;
|
|
654
740
|
case 3: return [3 /*break*/, 6];
|
|
655
741
|
case 4:
|
|
656
|
-
isVideoAdded = ((_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.getAllSelfTracks().find(function (eachTrack) {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
742
|
+
isVideoAdded = ((_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.getAllSelfTracks().find(function (eachTrack) {
|
|
743
|
+
return eachTrack.trackKind === TrackKind.Video && eachTrack.track;
|
|
744
|
+
}))
|
|
745
|
+
? true
|
|
746
|
+
: false;
|
|
747
|
+
isAudioAdded = ((_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.getAllSelfTracks().find(function (eachTrack) {
|
|
748
|
+
return eachTrack.trackKind === TrackKind.Audio && eachTrack.track;
|
|
749
|
+
}))
|
|
750
|
+
? true
|
|
751
|
+
: false;
|
|
752
|
+
messageJson = {
|
|
753
|
+
to: remoteParticipant.userId,
|
|
754
|
+
type: WebrtcMessageType.NegotiationNeeded,
|
|
755
|
+
data: {
|
|
756
|
+
negotiationId: peerConnectionObject.negotiationId,
|
|
757
|
+
shouldRestartIce: shouldRestartIce,
|
|
758
|
+
isVideoAdded: isVideoAdded,
|
|
759
|
+
isAudioAdded: isAudioAdded,
|
|
760
|
+
},
|
|
761
|
+
};
|
|
662
762
|
return [4 /*yield*/, this.sendWebrtcMessage(messageJson)];
|
|
663
763
|
case 5:
|
|
664
764
|
_d.sent();
|
|
665
765
|
this.printLogIfRequired("ask remote negogitation ", messageJson);
|
|
666
766
|
setTimeout(function () {
|
|
667
767
|
_this.printLogIfRequired("onNegotiationNeeded setTimeout 542");
|
|
668
|
-
_this.onNegotiationNeeded(remoteParticipant, shouldRestartIce,
|
|
768
|
+
_this.onNegotiationNeeded(remoteParticipant, shouldRestartIce, count + 1, shouldForceFullyCreateOffer);
|
|
669
769
|
}, 5000);
|
|
670
770
|
_d.label = 6;
|
|
671
771
|
case 6: return [2 /*return*/];
|
|
@@ -710,14 +810,17 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
710
810
|
}); };
|
|
711
811
|
_this.sendTrackToParticipant = function (track, participant) { return __awaiter(_this, void 0, void 0, function () {
|
|
712
812
|
var selfParticpant, peerConnection;
|
|
713
|
-
|
|
813
|
+
var _a;
|
|
814
|
+
return __generator(this, function (_b) {
|
|
714
815
|
if (!track.track) {
|
|
715
816
|
return [2 /*return*/];
|
|
716
817
|
}
|
|
717
|
-
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
818
|
+
selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
|
|
718
819
|
if (selfParticpant) {
|
|
719
820
|
peerConnection = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
|
|
720
|
-
if (peerConnection &&
|
|
821
|
+
if (peerConnection &&
|
|
822
|
+
peerConnection.rtcPeerConnection &&
|
|
823
|
+
peerConnection.rtcPeerConnection.signalingState === "stable") {
|
|
721
824
|
this.printLogIfRequired("Send Track", participant);
|
|
722
825
|
this.addTransceiverToEachTrackKind(track.track.kind, peerConnection, true);
|
|
723
826
|
// let transceiver = peerConnection.rtcPeerConnection.getTransceivers().find(t => t && t.sender && t.sender.track && t.sender.track.kind && t.sender.track.kind === track.track.kind)
|
|
@@ -765,15 +868,19 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
765
868
|
optionalParams[_i - 1] = arguments[_i];
|
|
766
869
|
}
|
|
767
870
|
if (optionalParams && optionalParams.length > 0) {
|
|
768
|
-
_this.meetingStartRequest &&
|
|
871
|
+
_this.meetingStartRequest &&
|
|
872
|
+
_this.meetingStartRequest.logLevel === LogLevel.Debug &&
|
|
873
|
+
console.log("Webrtc-" + message, optionalParams);
|
|
769
874
|
}
|
|
770
875
|
else {
|
|
771
|
-
_this.meetingStartRequest &&
|
|
876
|
+
_this.meetingStartRequest &&
|
|
877
|
+
_this.meetingStartRequest.logLevel === LogLevel.Debug &&
|
|
878
|
+
console.log("Webrtc-" + message);
|
|
772
879
|
}
|
|
773
880
|
};
|
|
774
881
|
_this.setOpusSdpParams = function (sdp) {
|
|
775
882
|
var _a;
|
|
776
|
-
var lines = sdp.split(
|
|
883
|
+
var lines = sdp.split("\r\n");
|
|
777
884
|
var opusLine = lines.find(function (l) { return /a=rtpmap:\d+ opus/i.test(l); });
|
|
778
885
|
if (!opusLine)
|
|
779
886
|
return sdp;
|
|
@@ -793,7 +900,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
793
900
|
lines.splice(rtpmapIdx + 1, 0, fmtpLine);
|
|
794
901
|
}
|
|
795
902
|
// a=mid injection removed — was corrupting SDP
|
|
796
|
-
return lines.join(
|
|
903
|
+
return lines.join("\r\n");
|
|
797
904
|
};
|
|
798
905
|
_this.setOpusParams = function (transceiver) {
|
|
799
906
|
if (transceiver === null || transceiver === void 0 ? void 0 : transceiver.sender) {
|
|
@@ -808,21 +915,17 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
808
915
|
if (!params.encodings || params.encodings.length === 0) {
|
|
809
916
|
params.encodings = [{}];
|
|
810
917
|
}
|
|
811
|
-
params.encodings[0] = __assign(__assign({}, params.encodings[0]), { maxBitrate: 32000, networkPriority:
|
|
918
|
+
params.encodings[0] = __assign(__assign({}, params.encodings[0]), { maxBitrate: 32000, networkPriority: "high", priority: "high" });
|
|
812
919
|
sender.setParameters(params).catch(console.error);
|
|
813
920
|
};
|
|
814
921
|
_this.applyAudioPriority = function (transceiver) {
|
|
815
922
|
var _a, _b;
|
|
816
923
|
// Codec preference — Opus first
|
|
817
|
-
var capabilities = (_a = RTCRtpSender.getCapabilities) === null || _a === void 0 ? void 0 : _a.call(RTCRtpSender,
|
|
924
|
+
var capabilities = (_a = RTCRtpSender.getCapabilities) === null || _a === void 0 ? void 0 : _a.call(RTCRtpSender, "audio");
|
|
818
925
|
if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities.codecs))
|
|
819
926
|
return;
|
|
820
|
-
var opus = capabilities.codecs.filter(function (c) {
|
|
821
|
-
|
|
822
|
-
});
|
|
823
|
-
var rest = capabilities.codecs.filter(function (c) {
|
|
824
|
-
return c.mimeType.toLowerCase() !== 'audio/opus';
|
|
825
|
-
});
|
|
927
|
+
var opus = capabilities.codecs.filter(function (c) { return c.mimeType.toLowerCase() === "audio/opus"; });
|
|
928
|
+
var rest = capabilities.codecs.filter(function (c) { return c.mimeType.toLowerCase() !== "audio/opus"; });
|
|
826
929
|
transceiver.setCodecPreferences(__spreadArray(__spreadArray([], __read(opus), false), __read(rest), false));
|
|
827
930
|
// maxBitrate only — priority/networkPriority already set at addTransceiver
|
|
828
931
|
var params = transceiver.sender.getParameters();
|
|
@@ -832,13 +935,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
832
935
|
transceiver.sender.setParameters(params).catch(console.error);
|
|
833
936
|
};
|
|
834
937
|
_this.onNewTrack = function (track, receiver, transceiver, remoteParticipant) { return __awaiter(_this, void 0, void 0, function () {
|
|
835
|
-
var kind
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
this.
|
|
839
|
-
kind = track.kind.toLowerCase() === 'audio' ? TrackKind.Audio : TrackKind.Video;
|
|
840
|
-
t = new Track(remoteParticipant, false, kind, track);
|
|
841
|
-
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.addUpdateRemoteTrack(t, remoteParticipant, true);
|
|
938
|
+
var kind;
|
|
939
|
+
return __generator(this, function (_a) {
|
|
940
|
+
kind = track.kind.toLowerCase() === "audio" ? TrackKind.Audio : TrackKind.Video;
|
|
941
|
+
this.registerTrack(track, remoteParticipant, kind);
|
|
842
942
|
return [2 /*return*/];
|
|
843
943
|
});
|
|
844
944
|
}); };
|
|
@@ -858,7 +958,11 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
858
958
|
}
|
|
859
959
|
track.onended = function () {
|
|
860
960
|
var _a, _b;
|
|
861
|
-
var existing = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getAllTracks().find(function (t) {
|
|
961
|
+
var existing = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getAllTracks().find(function (t) {
|
|
962
|
+
var _a, _b;
|
|
963
|
+
return ((_a = t.track) === null || _a === void 0 ? void 0 : _a.kind) === track.kind &&
|
|
964
|
+
((_b = t.participant) === null || _b === void 0 ? void 0 : _b.userId) === participant.userId;
|
|
965
|
+
});
|
|
862
966
|
if (existing)
|
|
863
967
|
(_b = _this.communicationHandler) === null || _b === void 0 ? void 0 : _b.removeTrack(existing);
|
|
864
968
|
};
|
|
@@ -875,7 +979,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
875
979
|
stillPhantom = _a.sent();
|
|
876
980
|
this.printLogIfRequired("stillPhantom", kind);
|
|
877
981
|
if (!stillPhantom) {
|
|
878
|
-
this.printLogIfRequired(
|
|
982
|
+
this.printLogIfRequired("Real track arrived for", kind);
|
|
879
983
|
this.registerTrack(transceiver.receiver.track, participant, kind);
|
|
880
984
|
}
|
|
881
985
|
else {
|
|
@@ -906,7 +1010,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
906
1010
|
try {
|
|
907
1011
|
for (_a = __values(stats.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
908
1012
|
report = _b.value;
|
|
909
|
-
if (report.type ===
|
|
1013
|
+
if (report.type === "inbound-rtp") {
|
|
910
1014
|
return [2 /*return*/, ((_d = report.bytesReceived) !== null && _d !== void 0 ? _d : 0) === 0];
|
|
911
1015
|
}
|
|
912
1016
|
}
|
|
@@ -983,12 +1087,13 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
983
1087
|
// throw new Error("Method not implemented.");
|
|
984
1088
|
};
|
|
985
1089
|
WebrtcHandler.prototype.onAllParticipants = function (participants) {
|
|
1090
|
+
var _a;
|
|
986
1091
|
return __awaiter(this, void 0, void 0, function () {
|
|
987
1092
|
var selfParticpant;
|
|
988
1093
|
var _this = this;
|
|
989
|
-
return __generator(this, function (
|
|
990
|
-
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
991
|
-
if (selfParticpant.isStartMeetingCalled) {
|
|
1094
|
+
return __generator(this, function (_b) {
|
|
1095
|
+
selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
|
|
1096
|
+
if (selfParticpant && selfParticpant.isStartMeetingCalled) {
|
|
992
1097
|
participants.forEach(function (eachParticiapant) {
|
|
993
1098
|
_this.onUserJoined(eachParticiapant);
|
|
994
1099
|
});
|
|
@@ -997,6 +1102,27 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
997
1102
|
});
|
|
998
1103
|
});
|
|
999
1104
|
};
|
|
1105
|
+
WebrtcHandler.prototype.onUserLeft = function (participant) {
|
|
1106
|
+
var _a;
|
|
1107
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1108
|
+
var selfParticpant, peerConnection;
|
|
1109
|
+
return __generator(this, function (_b) {
|
|
1110
|
+
try {
|
|
1111
|
+
selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
|
|
1112
|
+
if (selfParticpant) {
|
|
1113
|
+
peerConnection = selfParticpant.isPeerConnectionsViaUserIdPresent(participant.userId);
|
|
1114
|
+
if (peerConnection) {
|
|
1115
|
+
peerConnection.rtcPeerConnection.close();
|
|
1116
|
+
selfParticpant.removePeerConnectionsViaUserId(participant.userId);
|
|
1117
|
+
this.printLogIfRequired("onUserLeft after", selfParticpant.getPeerConnections());
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
catch (err) { }
|
|
1122
|
+
return [2 /*return*/];
|
|
1123
|
+
});
|
|
1124
|
+
});
|
|
1125
|
+
};
|
|
1000
1126
|
WebrtcHandler.prototype.onUserJoined = function (participant) {
|
|
1001
1127
|
return __awaiter(this, void 0, void 0, function () {
|
|
1002
1128
|
return __generator(this, function (_a) {
|
|
@@ -1026,19 +1152,24 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
1026
1152
|
var _a, _b;
|
|
1027
1153
|
return (_b = (_a = _this.communicationHandler
|
|
1028
1154
|
.getAllSelfTracks()
|
|
1029
|
-
.find(function (t) { var _a; return ((_a = t.track) === null || _a === void 0 ? void 0 : _a.kind) ===
|
|
1155
|
+
.find(function (t) { var _a; return ((_a = t.track) === null || _a === void 0 ? void 0 : _a.kind) === "video"; })) === null || _a === void 0 ? void 0 : _a.track) !== null && _b !== void 0 ? _b : null;
|
|
1030
1156
|
}, function (profile) {
|
|
1031
|
-
_this.printLogIfRequired(
|
|
1157
|
+
_this.printLogIfRequired("Network profile", profile);
|
|
1032
1158
|
// Show UI banner: 'poor connection' / 'video paused' etc.
|
|
1033
1159
|
}, (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.deviceTier);
|
|
1034
1160
|
this.adaptationManager.start();
|
|
1035
1161
|
}
|
|
1036
1162
|
}
|
|
1037
|
-
catch (err) {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
this.
|
|
1163
|
+
catch (err) { }
|
|
1164
|
+
this.meetingStartRequest &&
|
|
1165
|
+
this.meetingStartRequest.logLevel === LogLevel.Debug &&
|
|
1166
|
+
this.printLogIfRequired(" Init", this.communicationHandler.getAllParticipants());
|
|
1167
|
+
this.meetingStartRequest &&
|
|
1168
|
+
this.meetingStartRequest.logLevel === LogLevel.Debug &&
|
|
1169
|
+
this.printLogIfRequired("Webrtc Init");
|
|
1170
|
+
this.communicationHandler
|
|
1171
|
+
.getAllParticipants()
|
|
1172
|
+
.forEach(function (eachParticiapant) {
|
|
1042
1173
|
_this.onUserJoined(eachParticiapant);
|
|
1043
1174
|
});
|
|
1044
1175
|
return [2 /*return*/];
|
|
@@ -1094,11 +1225,9 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
1094
1225
|
}
|
|
1095
1226
|
};
|
|
1096
1227
|
WebrtcHandler.prototype.createDataChannel = function () {
|
|
1097
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1098
|
-
return
|
|
1099
|
-
|
|
1100
|
-
});
|
|
1101
|
-
});
|
|
1228
|
+
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
1229
|
+
return [2 /*return*/];
|
|
1230
|
+
}); });
|
|
1102
1231
|
};
|
|
1103
1232
|
WebrtcHandler.prototype.sendMessageViaDataChannel = function (messagePayload) {
|
|
1104
1233
|
// throw new Error('Method not implemented.');
|
|
@@ -1144,7 +1273,9 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
1144
1273
|
var selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
1145
1274
|
var peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(remoteUserId, this.meetingStartRequest);
|
|
1146
1275
|
if (peerConnectionObject && peerConnectionObject.rtcPeerConnection) {
|
|
1147
|
-
peerConnectionObject.rtcPeerConnection
|
|
1276
|
+
peerConnectionObject.rtcPeerConnection
|
|
1277
|
+
.getTransceivers()
|
|
1278
|
+
.forEach(function (transceiver) {
|
|
1148
1279
|
var _a;
|
|
1149
1280
|
if ((_a = transceiver.receiver) === null || _a === void 0 ? void 0 : _a.track) {
|
|
1150
1281
|
_this.onNewTrack(transceiver.receiver.track, transceiver.receiver, transceiver, participant);
|
|
@@ -373,6 +373,8 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
373
373
|
if (this.isWebScoketConnectedWithoutSetup()) {
|
|
374
374
|
var paylod = { type: type, data: data };
|
|
375
375
|
(_a = this.wss) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(paylod));
|
|
376
|
+
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug &&
|
|
377
|
+
console.log("sendSocketMessage", type, JSON.stringify(paylod));
|
|
376
378
|
// console.log("sendSocketMessage",type,data)
|
|
377
379
|
}
|
|
378
380
|
};
|