vani-meeting-client 2.3.8 → 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.
@@ -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 (_b) {
279
- switch (_b.label) {
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
- _b.sent();
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
- _b.sent();
296
- _b.label = 4;
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) {
@@ -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 = (new 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 = ['audio', 'video'];
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.getTransceivers().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; });
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,21 +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 === 'audio') {
158
+ if (realTrack.track.kind === "audio") {
151
159
  newTransceiver = peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, {
152
- direction: 'sendonly',
160
+ direction: "sendonly",
153
161
  sendEncodings: [
154
162
  {
155
163
  maxBitrate: 32000,
156
- priority: 'high',
157
- networkPriority: 'high',
158
- }
159
- ]
164
+ priority: "high",
165
+ networkPriority: "high",
166
+ },
167
+ ],
160
168
  });
161
169
  }
162
- else if (realTrack.track.kind === 'video') {
170
+ else if (realTrack.track.kind === "video") {
163
171
  newTransceiver = peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, {
164
- direction: 'sendonly',
172
+ direction: "sendonly",
165
173
  });
166
174
  }
167
175
  // newTransceiver = await peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, { direction: "sendrecv" })
@@ -171,8 +179,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
171
179
  // this.printLogIfRequired("addTransceiverifRequired track fake",eachKind)
172
180
  // newTransceiver = await peerConnection.rtcPeerConnection.addTransceiver(eachKind, { direction: "sendrecv" })
173
181
  }
174
- if (eachKind === 'audio') {
175
- transceiver = peerConnection.rtcPeerConnection.getTransceivers().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; });
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; });
176
186
  if (transceiver) {
177
187
  this.applyAudioPriority(transceiver);
178
188
  }
@@ -187,7 +197,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
187
197
  return [4 /*yield*/, transceiver.sender.replaceTrack(realTrack.track)];
188
198
  case 2:
189
199
  _c.sent();
190
- if (eachKind === 'audio') {
200
+ if (eachKind === "audio") {
191
201
  this.applyAudioPriority(transceiver);
192
202
  // this.setOpusParams(newTransceiver);
193
203
  }
@@ -209,19 +219,26 @@ var WebrtcHandler = /** @class */ (function (_super) {
209
219
  selfParticpant = this.communicationHandler.getSelfParticipant();
210
220
  this.printLogIfRequired("checkIfCanSendOffer", selfParticpant, (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.isStartAndSetupWithServerCalled);
211
221
  this.printLogIfRequired("checkIfCanSendOffer REMOTE", participant);
212
- if (!selfParticpant.isStartMeetingCalled && !((_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.isStartAndSetupWithServerCalled)) {
222
+ if (!selfParticpant.isStartMeetingCalled &&
223
+ !((_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.isStartAndSetupWithServerCalled)) {
213
224
  return [2 /*return*/];
214
225
  }
215
- if (!(selfParticpant.userId !== participant.userId && (negotiationId || !selfParticpant.getPeerConnections().has(participant.userId)))) return [3 /*break*/, 5];
226
+ if (!(selfParticpant.userId !== participant.userId &&
227
+ (negotiationId ||
228
+ !selfParticpant.getPeerConnections().has(participant.userId)))) return [3 /*break*/, 5];
216
229
  isOfferInitParticipant = this.isOfferInitParticipant(participant);
217
230
  this.printLogIfRequired("Check if Can Send Offer", isOfferInitParticipant, shouldForceFullyCreateOffer);
218
231
  if (!(!isOfferInitParticipant || shouldForceFullyCreateOffer)) return [3 /*break*/, 5];
219
232
  peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
220
- peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
233
+ peerConnection = peerConnectionObject.rtcPeerConnection
234
+ ? peerConnectionObject.rtcPeerConnection
235
+ : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
221
236
  if (!peerConnection) return [3 /*break*/, 5];
222
237
  this.rtcPeerConnections.push(peerConnection);
223
238
  peerConnectionObject.isCreatingOffer = true;
224
- if (negotiationId && peerConnectionObject.opertionalNegotiationId && peerConnectionObject.opertionalNegotiationId === negotiationId) {
239
+ if (negotiationId &&
240
+ peerConnectionObject.opertionalNegotiationId &&
241
+ peerConnectionObject.opertionalNegotiationId === negotiationId) {
225
242
  return [2 /*return*/];
226
243
  }
227
244
  peerConnectionObject.opertionalNegotiationId = negotiationId;
@@ -237,7 +254,9 @@ var WebrtcHandler = /** @class */ (function (_super) {
237
254
  if (shouldRestartIce) {
238
255
  peerConnection.restartIce();
239
256
  }
240
- return [4 /*yield*/, peerConnection.createOffer({ iceRestart: shouldRestartIce })];
257
+ return [4 /*yield*/, peerConnection.createOffer({
258
+ iceRestart: shouldRestartIce,
259
+ })];
241
260
  case 3:
242
261
  offer = _c.sent();
243
262
  mungedOffer = {
@@ -252,6 +271,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
252
271
  // send offer to peer
253
272
  peerConnectionObject.remoteAnswer = undefined;
254
273
  this.loopSendOffer(peerConnectionObject, participant, mungedOffer);
274
+ this.printLogIfRequired("CheckIfCanSendOffer new", peerConnectionObject, __spreadArray([], __read(selfParticpant.getPeerConnections().entries()), false));
255
275
  _c.label = 5;
256
276
  case 5: return [2 /*return*/];
257
277
  }
@@ -274,17 +294,22 @@ var WebrtcHandler = /** @class */ (function (_super) {
274
294
  return [2 /*return*/];
275
295
  }
276
296
  this.printLogIfRequired("Send Offer loop", mungedOffer, participant);
277
- messageJson = { to: participant.userId, type: WebrtcMessageType.SendOffer, data: mungedOffer };
297
+ messageJson = {
298
+ to: participant.userId,
299
+ type: WebrtcMessageType.SendOffer,
300
+ data: mungedOffer,
301
+ };
278
302
  this.sendWebrtcMessage(messageJson);
279
303
  if (peerConnectionObject.remoteAnswer || count > 20) {
280
304
  return [2 /*return*/];
281
305
  }
282
- if (peerConnectionObject.rtcPeerConnection && peerConnectionObject.rtcPeerConnection.connectionState === 'closed') {
306
+ if (peerConnectionObject.rtcPeerConnection &&
307
+ peerConnectionObject.rtcPeerConnection.connectionState === "closed") {
283
308
  return [2 /*return*/];
284
309
  }
285
310
  setTimeout(function () {
286
311
  _this.printLogIfRequired("loopSendOffer ");
287
- _this.loopSendOffer(peerConnectionObject, participant, mungedOffer, (count + 1));
312
+ _this.loopSendOffer(peerConnectionObject, participant, mungedOffer, count + 1);
288
313
  }, 3000);
289
314
  return [2 /*return*/];
290
315
  });
@@ -309,21 +334,32 @@ var WebrtcHandler = /** @class */ (function (_super) {
309
334
  if (peerConnectionObject) {
310
335
  peerConnectionObject.remoteOffer = data.sdp;
311
336
  }
312
- peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
337
+ peerConnection = peerConnectionObject.rtcPeerConnection
338
+ ? peerConnectionObject.rtcPeerConnection
339
+ : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
313
340
  if (!peerConnection) return [3 /*break*/, 6];
314
341
  this.rtcPeerConnections.push(peerConnection);
315
342
  peerConnectionObject.rtcPeerConnection = peerConnection;
316
- if (peerConnectionObject.opertionalNegotiationId && peerConnectionObject.negotiationId && peerConnectionObject.opertionalNegotiationId === peerConnectionObject.negotiationId) {
343
+ if (peerConnectionObject.opertionalNegotiationId &&
344
+ peerConnectionObject.negotiationId &&
345
+ peerConnectionObject.opertionalNegotiationId ===
346
+ peerConnectionObject.negotiationId) {
317
347
  peerConnectionObject.negotiationId = undefined;
318
348
  peerConnectionObject.isNegotiationNeeded = false;
319
349
  }
320
350
  return [4 /*yield*/, this.subToConnectionState(participant)];
321
351
  case 1:
322
352
  _b.sent();
323
- return [4 /*yield*/, peerConnection.setRemoteDescription({ type: 'offer', sdp: peerConnectionObject.remoteOffer })];
353
+ return [4 /*yield*/, peerConnection.setRemoteDescription({
354
+ type: "offer",
355
+ sdp: peerConnectionObject.remoteOffer,
356
+ })];
324
357
  case 2:
325
358
  _b.sent();
326
- this.printLogIfRequired("On New Offer setRemoteDescription", { type: 'offer', sdp: peerConnectionObject.remoteOffer });
359
+ this.printLogIfRequired("On New Offer setRemoteDescription", {
360
+ type: "offer",
361
+ sdp: peerConnectionObject.remoteOffer,
362
+ });
327
363
  this.printLogIfRequired("REMOTE SDP", (_a = peerConnection.remoteDescription) === null || _a === void 0 ? void 0 : _a.sdp);
328
364
  return [4 /*yield*/, this.addTransceiverifRequired(peerConnectionObject)];
329
365
  case 3:
@@ -342,7 +378,11 @@ var WebrtcHandler = /** @class */ (function (_super) {
342
378
  this.printLogIfRequired("On New Offer setLocalDescription", mungedAnswer);
343
379
  peerConnectionObject.answer = mungedAnswer;
344
380
  console.log("answer", mungedAnswer);
345
- messageJson = { to: participant.userId, type: WebrtcMessageType.SendAnswer, data: mungedAnswer };
381
+ messageJson = {
382
+ to: participant.userId,
383
+ type: WebrtcMessageType.SendAnswer,
384
+ data: mungedAnswer,
385
+ };
346
386
  this.sendWebrtcMessage(messageJson);
347
387
  peerConnectionObject.opertionalNegotiationId = undefined;
348
388
  _b.label = 6;
@@ -361,7 +401,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
361
401
  participant = data.sender;
362
402
  peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
363
403
  this.printLogIfRequired("On New Answer peerConnectionObject", peerConnectionObject);
364
- if (peerConnectionObject.opertionalNegotiationId && peerConnectionObject.negotiationId && peerConnectionObject.opertionalNegotiationId === peerConnectionObject.negotiationId) {
404
+ if (peerConnectionObject.opertionalNegotiationId &&
405
+ peerConnectionObject.negotiationId &&
406
+ peerConnectionObject.opertionalNegotiationId ===
407
+ peerConnectionObject.negotiationId) {
365
408
  peerConnectionObject.negotiationId = undefined;
366
409
  peerConnectionObject.opertionalNegotiationId = undefined;
367
410
  peerConnectionObject.isNegotiationNeeded = false;
@@ -370,17 +413,25 @@ var WebrtcHandler = /** @class */ (function (_super) {
370
413
  if (peerConnectionObject) {
371
414
  peerConnectionObject.remoteAnswer = data.sdp;
372
415
  }
373
- peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
416
+ peerConnection = peerConnectionObject.rtcPeerConnection
417
+ ? peerConnectionObject.rtcPeerConnection
418
+ : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
374
419
  if (!peerConnection) return [3 /*break*/, 3];
375
- if (!(peerConnection.signalingState === 'have-local-offer')) return [3 /*break*/, 2];
376
- return [4 /*yield*/, peerConnection.setRemoteDescription({ type: 'answer', sdp: peerConnectionObject.remoteAnswer })];
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
+ })];
377
425
  case 1:
378
426
  _b.sent();
379
427
  _b.label = 2;
380
428
  case 2:
381
429
  peerConnectionObject.isRtcRestartIceInProgess = false;
382
430
  this.printLogIfRequired("REMOTE SDP", (_a = peerConnection.remoteDescription) === null || _a === void 0 ? void 0 : _a.sdp);
383
- this.printLogIfRequired("On New Answer setRemoteDescription", { type: 'answer', sdp: peerConnectionObject.remoteAnswer });
431
+ this.printLogIfRequired("On New Answer setRemoteDescription", {
432
+ type: "answer",
433
+ sdp: peerConnectionObject.remoteAnswer,
434
+ });
384
435
  _b.label = 3;
385
436
  case 3: return [2 /*return*/];
386
437
  }
@@ -476,19 +527,24 @@ var WebrtcHandler = /** @class */ (function (_super) {
476
527
  return [2 /*return*/];
477
528
  }
478
529
  rtcConnection = peerConnectionObject.rtcPeerConnection;
479
- if (!rtcConnection || peerConnectionObject.isRtcRestartIceInProgess || count > 12 || (rtcConnection.connectionState !== 'failed' && rtcConnection.connectionState !== 'disconnected')) {
530
+ if (!rtcConnection ||
531
+ peerConnectionObject.isRtcRestartIceInProgess ||
532
+ count > 12 ||
533
+ (rtcConnection.connectionState !== "failed" &&
534
+ rtcConnection.connectionState !== "disconnected")) {
480
535
  return [2 /*return*/];
481
536
  }
482
537
  if ((_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.isWebScoketConnected()) {
483
538
  rtcConnection.restartIce();
484
539
  peerConnectionObject.isRtcRestartIceInProgess = true;
485
540
  peerConnectionObject.isNegotiationNeeded = true;
486
- peerConnectionObject.negotiationId = new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
541
+ peerConnectionObject.negotiationId =
542
+ new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
487
543
  this.onNegotiationNeeded(remoteParticipant, true);
488
544
  }
489
545
  else {
490
546
  setTimeout(function () {
491
- _this.onRTCConnectionChanged(remoteParticipant, (count + 1));
547
+ _this.onRTCConnectionChanged(remoteParticipant, count + 1);
492
548
  }, 4000);
493
549
  }
494
550
  return [2 /*return*/];
@@ -506,23 +562,30 @@ var WebrtcHandler = /** @class */ (function (_super) {
506
562
  }
507
563
  peerConnectionObject.isSubDone = true;
508
564
  rtcConnection = peerConnectionObject.rtcPeerConnection;
509
- rtcConnection.addEventListener('icecandidate', function (event) {
565
+ rtcConnection.addEventListener("icecandidate", function (event) {
510
566
  if (event.candidate && event.candidate !== null) {
511
567
  _this.printLogIfRequired("icecandidate", event.candidate, remoteParticipant);
512
568
  var sdpMid = event.candidate.sdpMid;
513
569
  var sdpMLineIndex = event.candidate.sdpMLineIndex;
514
- var messageJson = { to: remoteParticipant.userId, type: WebrtcMessageType.IceCandidate,
515
- data: { sdpMid: sdpMid, sdpMLineIndex: sdpMLineIndex, candidate: event.candidate } };
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
+ };
516
579
  _this.sendWebrtcMessage(messageJson);
517
580
  }
518
581
  });
519
- rtcConnection.addEventListener('iceconnectionstatechange', function (event) {
582
+ rtcConnection.addEventListener("iceconnectionstatechange", function (event) {
520
583
  _this.printLogIfRequired("iceconnectionstatechange", rtcConnection.iceConnectionState, event, remoteParticipant);
521
584
  });
522
- rtcConnection.addEventListener('connectionstatechange', function (event) {
585
+ rtcConnection.addEventListener("connectionstatechange", function (event) {
523
586
  var _a, _b, _c, _d, _e, _f, _g, _h;
524
587
  _this.printLogIfRequired("connectionstatechange", peerConnectionObject.userId, rtcConnection.connectionState);
525
- if (rtcConnection.connectionState === 'connected') {
588
+ if (rtcConnection.connectionState === "connected") {
526
589
  var participant = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.participantByUserId(peerConnectionObject.userId);
527
590
  _this.printLogIfRequired("connected", participant, peerConnectionObject.userId);
528
591
  if (participant) {
@@ -542,10 +605,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
542
605
  // if(eachReciver && eachReciver.track){
543
606
  // const streamTrack = eachReciver.track
544
607
  // this.onNewTrack(streamTrack,remoteParticipant)
545
- // }
608
+ // }
546
609
  // })
547
610
  }
548
- else if (rtcConnection.connectionState === 'disconnected') {
611
+ else if (rtcConnection.connectionState === "disconnected") {
549
612
  var participant = (_e = _this.communicationHandler) === null || _e === void 0 ? void 0 : _e.participantByUserId(peerConnectionObject.userId);
550
613
  _this.printLogIfRequired("disconnected", participant, peerConnectionObject.userId);
551
614
  if (participant) {
@@ -555,7 +618,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
555
618
  _this.onRTCConnectionChanged(remoteParticipant);
556
619
  }, 4000);
557
620
  }
558
- else if (rtcConnection.connectionState === 'failed') {
621
+ else if (rtcConnection.connectionState === "failed") {
559
622
  var participant = (_g = _this.communicationHandler) === null || _g === void 0 ? void 0 : _g.participantByUserId(peerConnectionObject.userId);
560
623
  _this.printLogIfRequired("failed", participant, peerConnectionObject.userId);
561
624
  if (participant) {
@@ -564,11 +627,15 @@ var WebrtcHandler = /** @class */ (function (_super) {
564
627
  _this.onRTCConnectionChanged(remoteParticipant);
565
628
  }
566
629
  });
567
- rtcConnection.addEventListener('signalingstatechange', function (event) {
630
+ rtcConnection.addEventListener("signalingstatechange", function (event) {
631
+ var _a;
568
632
  _this.printLogIfRequired("signalingstatechange", event, rtcConnection.signalingState);
569
- if (rtcConnection.signalingState === 'stable') {
570
- peerConnectionObject.isCreatingOffer = false;
571
- if (peerConnectionObject.isNegotiationNeeded) {
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) {
572
639
  _this.onNegotiationNeeded(remoteParticipant, false, 0, true);
573
640
  }
574
641
  }
@@ -582,15 +649,23 @@ var WebrtcHandler = /** @class */ (function (_super) {
582
649
  // this.printLogIfRequired("New Remote Track",track)
583
650
  // }
584
651
  // })
585
- rtcConnection.addEventListener('negotiationneeded', function (event) {
586
- _this.printLogIfRequired("negotiationneeded", rtcConnection.signalingState, remoteParticipant);
587
- if (!peerConnectionObject.offer && !peerConnectionObject.answer) {
588
- _this.printLogIfRequired("negotiationneeded ignored", rtcConnection.signalingState, remoteParticipant);
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));
589
663
  return;
590
664
  }
591
- peerConnectionObject.isNegotiationNeeded = true;
592
- peerConnectionObject.negotiationId = new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
593
- if (rtcConnection.signalingState === 'stable') {
665
+ innerPeerConnectionObject.isNegotiationNeeded = true;
666
+ innerPeerConnectionObject.negotiationId =
667
+ new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
668
+ if (rtcConnection.signalingState === "stable") {
594
669
  _this.onNegotiationNeeded(remoteParticipant, false, 0, true);
595
670
  }
596
671
  });
@@ -626,7 +701,11 @@ var WebrtcHandler = /** @class */ (function (_super) {
626
701
  isOfferInitParticipant = this.isOfferInitParticipant(remoteParticipant);
627
702
  selfParticpant = this.communicationHandler.getSelfParticipant();
628
703
  peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(remoteParticipant.userId, this.meetingStartRequest);
629
- if (peerConnectionObject && shouldRestartIce && peerConnectionObject.rtcPeerConnection && peerConnectionObject.rtcPeerConnection.connectionState === 'connected') {
704
+ if (peerConnectionObject &&
705
+ shouldRestartIce &&
706
+ peerConnectionObject.rtcPeerConnection &&
707
+ peerConnectionObject.rtcPeerConnection.connectionState === "connected") {
708
+ this.printLogIfRequired("onNegotiationNeeded return", remoteParticipant, shouldRestartIce, peerConnectionObject);
630
709
  return [2 /*return*/];
631
710
  }
632
711
  // if(shouldIgnoreAllOldOpetionalNego){
@@ -636,7 +715,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
636
715
  // this.printLogIfRequired("shouldForceFullyCreateOffer ",peerConnectionObject,peerConnectionObject.isNegotiationNeeded,peerConnectionObject.opertionalNegotiationId,count)
637
716
  // }
638
717
  // else
639
- if (!peerConnectionObject || !peerConnectionObject.isNegotiationNeeded || peerConnectionObject.opertionalNegotiationId || count > 15) {
718
+ if (!peerConnectionObject ||
719
+ !peerConnectionObject.isNegotiationNeeded ||
720
+ peerConnectionObject.opertionalNegotiationId ||
721
+ count > 15) {
640
722
  this.printLogIfRequired("onNegotiationNeeded exit", peerConnectionObject, peerConnectionObject.isNegotiationNeeded, peerConnectionObject.opertionalNegotiationId, count);
641
723
  return [2 /*return*/];
642
724
  }
@@ -652,24 +734,38 @@ var WebrtcHandler = /** @class */ (function (_super) {
652
734
  case 2:
653
735
  setTimeout(function () {
654
736
  _this.printLogIfRequired("onNegotiationNeeded setTimeout 525");
655
- _this.onNegotiationNeeded(remoteParticipant, shouldRestartIce, (count + 1), shouldForceFullyCreateOffer);
737
+ _this.onNegotiationNeeded(remoteParticipant, shouldRestartIce, count + 1, shouldForceFullyCreateOffer);
656
738
  }, 5000);
657
739
  _d.label = 3;
658
740
  case 3: return [3 /*break*/, 6];
659
741
  case 4:
660
- isVideoAdded = ((_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.getAllSelfTracks().find(function (eachTrack) { return eachTrack.trackKind === TrackKind.Video && eachTrack.track; })) ? true : false;
661
- isAudioAdded = ((_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.getAllSelfTracks().find(function (eachTrack) { return eachTrack.trackKind === TrackKind.Audio && eachTrack.track; })) ? true : false;
662
- messageJson = { to: remoteParticipant.userId, type: WebrtcMessageType.NegotiationNeeded,
663
- data: { negotiationId: peerConnectionObject.negotiationId, shouldRestartIce: shouldRestartIce,
664
- isVideoAdded: isVideoAdded, isAudioAdded: isAudioAdded
665
- } };
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
+ };
666
762
  return [4 /*yield*/, this.sendWebrtcMessage(messageJson)];
667
763
  case 5:
668
764
  _d.sent();
669
765
  this.printLogIfRequired("ask remote negogitation ", messageJson);
670
766
  setTimeout(function () {
671
767
  _this.printLogIfRequired("onNegotiationNeeded setTimeout 542");
672
- _this.onNegotiationNeeded(remoteParticipant, shouldRestartIce, (count + 1), shouldForceFullyCreateOffer);
768
+ _this.onNegotiationNeeded(remoteParticipant, shouldRestartIce, count + 1, shouldForceFullyCreateOffer);
673
769
  }, 5000);
674
770
  _d.label = 6;
675
771
  case 6: return [2 /*return*/];
@@ -722,7 +818,9 @@ var WebrtcHandler = /** @class */ (function (_super) {
722
818
  selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
723
819
  if (selfParticpant) {
724
820
  peerConnection = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
725
- if (peerConnection && peerConnection.rtcPeerConnection && peerConnection.rtcPeerConnection.signalingState === 'stable') {
821
+ if (peerConnection &&
822
+ peerConnection.rtcPeerConnection &&
823
+ peerConnection.rtcPeerConnection.signalingState === "stable") {
726
824
  this.printLogIfRequired("Send Track", participant);
727
825
  this.addTransceiverToEachTrackKind(track.track.kind, peerConnection, true);
728
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)
@@ -770,15 +868,19 @@ var WebrtcHandler = /** @class */ (function (_super) {
770
868
  optionalParams[_i - 1] = arguments[_i];
771
869
  }
772
870
  if (optionalParams && optionalParams.length > 0) {
773
- _this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("Webrtc-" + message, optionalParams);
871
+ _this.meetingStartRequest &&
872
+ _this.meetingStartRequest.logLevel === LogLevel.Debug &&
873
+ console.log("Webrtc-" + message, optionalParams);
774
874
  }
775
875
  else {
776
- _this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("Webrtc-" + message);
876
+ _this.meetingStartRequest &&
877
+ _this.meetingStartRequest.logLevel === LogLevel.Debug &&
878
+ console.log("Webrtc-" + message);
777
879
  }
778
880
  };
779
881
  _this.setOpusSdpParams = function (sdp) {
780
882
  var _a;
781
- var lines = sdp.split('\r\n');
883
+ var lines = sdp.split("\r\n");
782
884
  var opusLine = lines.find(function (l) { return /a=rtpmap:\d+ opus/i.test(l); });
783
885
  if (!opusLine)
784
886
  return sdp;
@@ -798,7 +900,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
798
900
  lines.splice(rtpmapIdx + 1, 0, fmtpLine);
799
901
  }
800
902
  // a=mid injection removed — was corrupting SDP
801
- return lines.join('\r\n');
903
+ return lines.join("\r\n");
802
904
  };
803
905
  _this.setOpusParams = function (transceiver) {
804
906
  if (transceiver === null || transceiver === void 0 ? void 0 : transceiver.sender) {
@@ -813,21 +915,17 @@ var WebrtcHandler = /** @class */ (function (_super) {
813
915
  if (!params.encodings || params.encodings.length === 0) {
814
916
  params.encodings = [{}];
815
917
  }
816
- params.encodings[0] = __assign(__assign({}, params.encodings[0]), { maxBitrate: 32000, networkPriority: 'high', priority: 'high' });
918
+ params.encodings[0] = __assign(__assign({}, params.encodings[0]), { maxBitrate: 32000, networkPriority: "high", priority: "high" });
817
919
  sender.setParameters(params).catch(console.error);
818
920
  };
819
921
  _this.applyAudioPriority = function (transceiver) {
820
922
  var _a, _b;
821
923
  // Codec preference — Opus first
822
- var capabilities = (_a = RTCRtpSender.getCapabilities) === null || _a === void 0 ? void 0 : _a.call(RTCRtpSender, 'audio');
924
+ var capabilities = (_a = RTCRtpSender.getCapabilities) === null || _a === void 0 ? void 0 : _a.call(RTCRtpSender, "audio");
823
925
  if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities.codecs))
824
926
  return;
825
- var opus = capabilities.codecs.filter(function (c) {
826
- return c.mimeType.toLowerCase() === 'audio/opus';
827
- });
828
- var rest = capabilities.codecs.filter(function (c) {
829
- return c.mimeType.toLowerCase() !== 'audio/opus';
830
- });
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"; });
831
929
  transceiver.setCodecPreferences(__spreadArray(__spreadArray([], __read(opus), false), __read(rest), false));
832
930
  // maxBitrate only — priority/networkPriority already set at addTransceiver
833
931
  var params = transceiver.sender.getParameters();
@@ -839,7 +937,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
839
937
  _this.onNewTrack = function (track, receiver, transceiver, remoteParticipant) { return __awaiter(_this, void 0, void 0, function () {
840
938
  var kind;
841
939
  return __generator(this, function (_a) {
842
- kind = track.kind.toLowerCase() === 'audio' ? TrackKind.Audio : TrackKind.Video;
940
+ kind = track.kind.toLowerCase() === "audio" ? TrackKind.Audio : TrackKind.Video;
843
941
  this.registerTrack(track, remoteParticipant, kind);
844
942
  return [2 /*return*/];
845
943
  });
@@ -860,7 +958,11 @@ var WebrtcHandler = /** @class */ (function (_super) {
860
958
  }
861
959
  track.onended = function () {
862
960
  var _a, _b;
863
- var existing = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getAllTracks().find(function (t) { var _a, _b; return ((_a = t.track) === null || _a === void 0 ? void 0 : _a.kind) === track.kind && ((_b = t.participant) === null || _b === void 0 ? void 0 : _b.userId) === participant.userId; });
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
+ });
864
966
  if (existing)
865
967
  (_b = _this.communicationHandler) === null || _b === void 0 ? void 0 : _b.removeTrack(existing);
866
968
  };
@@ -877,7 +979,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
877
979
  stillPhantom = _a.sent();
878
980
  this.printLogIfRequired("stillPhantom", kind);
879
981
  if (!stillPhantom) {
880
- this.printLogIfRequired('Real track arrived for', kind);
982
+ this.printLogIfRequired("Real track arrived for", kind);
881
983
  this.registerTrack(transceiver.receiver.track, participant, kind);
882
984
  }
883
985
  else {
@@ -908,7 +1010,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
908
1010
  try {
909
1011
  for (_a = __values(stats.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
910
1012
  report = _b.value;
911
- if (report.type === 'inbound-rtp') {
1013
+ if (report.type === "inbound-rtp") {
912
1014
  return [2 /*return*/, ((_d = report.bytesReceived) !== null && _d !== void 0 ? _d : 0) === 0];
913
1015
  }
914
1016
  }
@@ -1016,8 +1118,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
1016
1118
  }
1017
1119
  }
1018
1120
  }
1019
- catch (err) {
1020
- }
1121
+ catch (err) { }
1021
1122
  return [2 /*return*/];
1022
1123
  });
1023
1124
  });
@@ -1051,19 +1152,24 @@ var WebrtcHandler = /** @class */ (function (_super) {
1051
1152
  var _a, _b;
1052
1153
  return (_b = (_a = _this.communicationHandler
1053
1154
  .getAllSelfTracks()
1054
- .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;
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;
1055
1156
  }, function (profile) {
1056
- _this.printLogIfRequired('Network profile', profile);
1157
+ _this.printLogIfRequired("Network profile", profile);
1057
1158
  // Show UI banner: 'poor connection' / 'video paused' etc.
1058
1159
  }, (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.deviceTier);
1059
1160
  this.adaptationManager.start();
1060
1161
  }
1061
1162
  }
1062
- catch (err) {
1063
- }
1064
- this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && this.printLogIfRequired(" Init", this.communicationHandler.getAllParticipants());
1065
- this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && this.printLogIfRequired("Webrtc Init");
1066
- this.communicationHandler.getAllParticipants().forEach(function (eachParticiapant) {
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) {
1067
1173
  _this.onUserJoined(eachParticiapant);
1068
1174
  });
1069
1175
  return [2 /*return*/];
@@ -1119,11 +1225,9 @@ var WebrtcHandler = /** @class */ (function (_super) {
1119
1225
  }
1120
1226
  };
1121
1227
  WebrtcHandler.prototype.createDataChannel = function () {
1122
- return __awaiter(this, void 0, void 0, function () {
1123
- return __generator(this, function (_a) {
1124
- return [2 /*return*/];
1125
- });
1126
- });
1228
+ return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
1229
+ return [2 /*return*/];
1230
+ }); });
1127
1231
  };
1128
1232
  WebrtcHandler.prototype.sendMessageViaDataChannel = function (messagePayload) {
1129
1233
  // throw new Error('Method not implemented.');
@@ -1169,7 +1273,9 @@ var WebrtcHandler = /** @class */ (function (_super) {
1169
1273
  var selfParticpant = this.communicationHandler.getSelfParticipant();
1170
1274
  var peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(remoteUserId, this.meetingStartRequest);
1171
1275
  if (peerConnectionObject && peerConnectionObject.rtcPeerConnection) {
1172
- peerConnectionObject.rtcPeerConnection.getTransceivers().forEach(function (transceiver) {
1276
+ peerConnectionObject.rtcPeerConnection
1277
+ .getTransceivers()
1278
+ .forEach(function (transceiver) {
1173
1279
  var _a;
1174
1280
  if ((_a = transceiver.receiver) === null || _a === void 0 ? void 0 : _a.track) {
1175
1281
  _this.onNewTrack(transceiver.receiver.track, transceiver.receiver, transceiver, participant);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-client",
3
- "version": "2.3.8",
3
+ "version": "2.3.9",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",