vani-meeting-client-native 0.4.8 → 0.4.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.
@@ -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 = {
@@ -275,17 +294,22 @@ var WebrtcHandler = /** @class */ (function (_super) {
275
294
  return [2 /*return*/];
276
295
  }
277
296
  this.printLogIfRequired("Send Offer loop", mungedOffer, participant);
278
- messageJson = { to: participant.userId, type: WebrtcMessageType.SendOffer, data: mungedOffer };
297
+ messageJson = {
298
+ to: participant.userId,
299
+ type: WebrtcMessageType.SendOffer,
300
+ data: mungedOffer,
301
+ };
279
302
  this.sendWebrtcMessage(messageJson);
280
303
  if (peerConnectionObject.remoteAnswer || count > 20) {
281
304
  return [2 /*return*/];
282
305
  }
283
- if (peerConnectionObject.rtcPeerConnection && peerConnectionObject.rtcPeerConnection.connectionState === 'closed') {
306
+ if (peerConnectionObject.rtcPeerConnection &&
307
+ peerConnectionObject.rtcPeerConnection.connectionState === "closed") {
284
308
  return [2 /*return*/];
285
309
  }
286
310
  setTimeout(function () {
287
311
  _this.printLogIfRequired("loopSendOffer ");
288
- _this.loopSendOffer(peerConnectionObject, participant, mungedOffer, (count + 1));
312
+ _this.loopSendOffer(peerConnectionObject, participant, mungedOffer, count + 1);
289
313
  }, 3000);
290
314
  return [2 /*return*/];
291
315
  });
@@ -310,21 +334,32 @@ var WebrtcHandler = /** @class */ (function (_super) {
310
334
  if (peerConnectionObject) {
311
335
  peerConnectionObject.remoteOffer = data.sdp;
312
336
  }
313
- peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
337
+ peerConnection = peerConnectionObject.rtcPeerConnection
338
+ ? peerConnectionObject.rtcPeerConnection
339
+ : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
314
340
  if (!peerConnection) return [3 /*break*/, 6];
315
341
  this.rtcPeerConnections.push(peerConnection);
316
342
  peerConnectionObject.rtcPeerConnection = peerConnection;
317
- if (peerConnectionObject.opertionalNegotiationId && peerConnectionObject.negotiationId && peerConnectionObject.opertionalNegotiationId === peerConnectionObject.negotiationId) {
343
+ if (peerConnectionObject.opertionalNegotiationId &&
344
+ peerConnectionObject.negotiationId &&
345
+ peerConnectionObject.opertionalNegotiationId ===
346
+ peerConnectionObject.negotiationId) {
318
347
  peerConnectionObject.negotiationId = undefined;
319
348
  peerConnectionObject.isNegotiationNeeded = false;
320
349
  }
321
350
  return [4 /*yield*/, this.subToConnectionState(participant)];
322
351
  case 1:
323
352
  _b.sent();
324
- return [4 /*yield*/, peerConnection.setRemoteDescription({ type: 'offer', sdp: peerConnectionObject.remoteOffer })];
353
+ return [4 /*yield*/, peerConnection.setRemoteDescription({
354
+ type: "offer",
355
+ sdp: peerConnectionObject.remoteOffer,
356
+ })];
325
357
  case 2:
326
358
  _b.sent();
327
- 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
+ });
328
363
  this.printLogIfRequired("REMOTE SDP", (_a = peerConnection.remoteDescription) === null || _a === void 0 ? void 0 : _a.sdp);
329
364
  return [4 /*yield*/, this.addTransceiverifRequired(peerConnectionObject)];
330
365
  case 3:
@@ -343,7 +378,11 @@ var WebrtcHandler = /** @class */ (function (_super) {
343
378
  this.printLogIfRequired("On New Offer setLocalDescription", mungedAnswer);
344
379
  peerConnectionObject.answer = mungedAnswer;
345
380
  console.log("answer", mungedAnswer);
346
- messageJson = { to: participant.userId, type: WebrtcMessageType.SendAnswer, data: mungedAnswer };
381
+ messageJson = {
382
+ to: participant.userId,
383
+ type: WebrtcMessageType.SendAnswer,
384
+ data: mungedAnswer,
385
+ };
347
386
  this.sendWebrtcMessage(messageJson);
348
387
  peerConnectionObject.opertionalNegotiationId = undefined;
349
388
  _b.label = 6;
@@ -362,7 +401,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
362
401
  participant = data.sender;
363
402
  peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
364
403
  this.printLogIfRequired("On New Answer peerConnectionObject", peerConnectionObject);
365
- if (peerConnectionObject.opertionalNegotiationId && peerConnectionObject.negotiationId && peerConnectionObject.opertionalNegotiationId === peerConnectionObject.negotiationId) {
404
+ if (peerConnectionObject.opertionalNegotiationId &&
405
+ peerConnectionObject.negotiationId &&
406
+ peerConnectionObject.opertionalNegotiationId ===
407
+ peerConnectionObject.negotiationId) {
366
408
  peerConnectionObject.negotiationId = undefined;
367
409
  peerConnectionObject.opertionalNegotiationId = undefined;
368
410
  peerConnectionObject.isNegotiationNeeded = false;
@@ -371,17 +413,25 @@ var WebrtcHandler = /** @class */ (function (_super) {
371
413
  if (peerConnectionObject) {
372
414
  peerConnectionObject.remoteAnswer = data.sdp;
373
415
  }
374
- peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
416
+ peerConnection = peerConnectionObject.rtcPeerConnection
417
+ ? peerConnectionObject.rtcPeerConnection
418
+ : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
375
419
  if (!peerConnection) return [3 /*break*/, 3];
376
- if (!(peerConnection.signalingState === 'have-local-offer')) return [3 /*break*/, 2];
377
- 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
+ })];
378
425
  case 1:
379
426
  _b.sent();
380
427
  _b.label = 2;
381
428
  case 2:
382
429
  peerConnectionObject.isRtcRestartIceInProgess = false;
383
430
  this.printLogIfRequired("REMOTE SDP", (_a = peerConnection.remoteDescription) === null || _a === void 0 ? void 0 : _a.sdp);
384
- 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
+ });
385
435
  _b.label = 3;
386
436
  case 3: return [2 /*return*/];
387
437
  }
@@ -477,19 +527,24 @@ var WebrtcHandler = /** @class */ (function (_super) {
477
527
  return [2 /*return*/];
478
528
  }
479
529
  rtcConnection = peerConnectionObject.rtcPeerConnection;
480
- 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")) {
481
535
  return [2 /*return*/];
482
536
  }
483
537
  if ((_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.isWebScoketConnected()) {
484
538
  rtcConnection.restartIce();
485
539
  peerConnectionObject.isRtcRestartIceInProgess = true;
486
540
  peerConnectionObject.isNegotiationNeeded = true;
487
- peerConnectionObject.negotiationId = new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
541
+ peerConnectionObject.negotiationId =
542
+ new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
488
543
  this.onNegotiationNeeded(remoteParticipant, true);
489
544
  }
490
545
  else {
491
546
  setTimeout(function () {
492
- _this.onRTCConnectionChanged(remoteParticipant, (count + 1));
547
+ _this.onRTCConnectionChanged(remoteParticipant, count + 1);
493
548
  }, 4000);
494
549
  }
495
550
  return [2 /*return*/];
@@ -507,23 +562,30 @@ var WebrtcHandler = /** @class */ (function (_super) {
507
562
  }
508
563
  peerConnectionObject.isSubDone = true;
509
564
  rtcConnection = peerConnectionObject.rtcPeerConnection;
510
- rtcConnection.addEventListener('icecandidate', function (event) {
565
+ rtcConnection.addEventListener("icecandidate", function (event) {
511
566
  if (event.candidate && event.candidate !== null) {
512
567
  _this.printLogIfRequired("icecandidate", event.candidate, remoteParticipant);
513
568
  var sdpMid = event.candidate.sdpMid;
514
569
  var sdpMLineIndex = event.candidate.sdpMLineIndex;
515
- var messageJson = { to: remoteParticipant.userId, type: WebrtcMessageType.IceCandidate,
516
- 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
+ };
517
579
  _this.sendWebrtcMessage(messageJson);
518
580
  }
519
581
  });
520
- rtcConnection.addEventListener('iceconnectionstatechange', function (event) {
582
+ rtcConnection.addEventListener("iceconnectionstatechange", function (event) {
521
583
  _this.printLogIfRequired("iceconnectionstatechange", rtcConnection.iceConnectionState, event, remoteParticipant);
522
584
  });
523
- rtcConnection.addEventListener('connectionstatechange', function (event) {
585
+ rtcConnection.addEventListener("connectionstatechange", function (event) {
524
586
  var _a, _b, _c, _d, _e, _f, _g, _h;
525
587
  _this.printLogIfRequired("connectionstatechange", peerConnectionObject.userId, rtcConnection.connectionState);
526
- if (rtcConnection.connectionState === 'connected') {
588
+ if (rtcConnection.connectionState === "connected") {
527
589
  var participant = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.participantByUserId(peerConnectionObject.userId);
528
590
  _this.printLogIfRequired("connected", participant, peerConnectionObject.userId);
529
591
  if (participant) {
@@ -543,10 +605,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
543
605
  // if(eachReciver && eachReciver.track){
544
606
  // const streamTrack = eachReciver.track
545
607
  // this.onNewTrack(streamTrack,remoteParticipant)
546
- // }
608
+ // }
547
609
  // })
548
610
  }
549
- else if (rtcConnection.connectionState === 'disconnected') {
611
+ else if (rtcConnection.connectionState === "disconnected") {
550
612
  var participant = (_e = _this.communicationHandler) === null || _e === void 0 ? void 0 : _e.participantByUserId(peerConnectionObject.userId);
551
613
  _this.printLogIfRequired("disconnected", participant, peerConnectionObject.userId);
552
614
  if (participant) {
@@ -556,7 +618,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
556
618
  _this.onRTCConnectionChanged(remoteParticipant);
557
619
  }, 4000);
558
620
  }
559
- else if (rtcConnection.connectionState === 'failed') {
621
+ else if (rtcConnection.connectionState === "failed") {
560
622
  var participant = (_g = _this.communicationHandler) === null || _g === void 0 ? void 0 : _g.participantByUserId(peerConnectionObject.userId);
561
623
  _this.printLogIfRequired("failed", participant, peerConnectionObject.userId);
562
624
  if (participant) {
@@ -565,12 +627,13 @@ var WebrtcHandler = /** @class */ (function (_super) {
565
627
  _this.onRTCConnectionChanged(remoteParticipant);
566
628
  }
567
629
  });
568
- rtcConnection.addEventListener('signalingstatechange', function (event) {
630
+ rtcConnection.addEventListener("signalingstatechange", function (event) {
569
631
  var _a;
570
632
  _this.printLogIfRequired("signalingstatechange", event, rtcConnection.signalingState);
571
633
  var selfParticpant = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
572
634
  var innerPeerConnectionObject = selfParticpant === null || selfParticpant === void 0 ? void 0 : selfParticpant.isPeerConnectionsViaUserIdPresent(remoteParticipant.userId);
573
- if (innerPeerConnectionObject && rtcConnection.signalingState === 'stable') {
635
+ if (innerPeerConnectionObject &&
636
+ rtcConnection.signalingState === "stable") {
574
637
  innerPeerConnectionObject.isCreatingOffer = false;
575
638
  if (innerPeerConnectionObject.isNegotiationNeeded) {
576
639
  _this.onNegotiationNeeded(remoteParticipant, false, 0, true);
@@ -586,19 +649,23 @@ var WebrtcHandler = /** @class */ (function (_super) {
586
649
  // this.printLogIfRequired("New Remote Track",track)
587
650
  // }
588
651
  // })
589
- rtcConnection.addEventListener('negotiationneeded', function (event) {
652
+ rtcConnection.addEventListener("negotiationneeded", function (event) {
590
653
  var _a, _b;
591
654
  _this.printLogIfRequired("negotiationneeded", rtcConnection.signalingState, remoteParticipant, peerConnectionObject);
592
655
  var selfParticpant = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
593
656
  var innerPeerConnectionObject = selfParticpant === null || selfParticpant === void 0 ? void 0 : selfParticpant.isPeerConnectionsViaUserIdPresent(remoteParticipant.userId);
594
657
  var remoteUser = (_b = _this.communicationHandler) === null || _b === void 0 ? void 0 : _b.participantByUserId(remoteParticipant.userId);
595
- if (!remoteUser && (!innerPeerConnectionObject || (!innerPeerConnectionObject.offer && !innerPeerConnectionObject.answer))) {
658
+ if (!remoteUser &&
659
+ (!innerPeerConnectionObject ||
660
+ (!innerPeerConnectionObject.offer &&
661
+ !innerPeerConnectionObject.answer))) {
596
662
  _this.printLogIfRequired("negotiationneeded ignored", rtcConnection.signalingState, remoteParticipant, innerPeerConnectionObject, __spreadArray([], __read(selfParticpant.getPeerConnections().entries()), false));
597
663
  return;
598
664
  }
599
665
  innerPeerConnectionObject.isNegotiationNeeded = true;
600
- innerPeerConnectionObject.negotiationId = new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
601
- if (rtcConnection.signalingState === 'stable') {
666
+ innerPeerConnectionObject.negotiationId =
667
+ new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
668
+ if (rtcConnection.signalingState === "stable") {
602
669
  _this.onNegotiationNeeded(remoteParticipant, false, 0, true);
603
670
  }
604
671
  });
@@ -634,7 +701,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
634
701
  isOfferInitParticipant = this.isOfferInitParticipant(remoteParticipant);
635
702
  selfParticpant = this.communicationHandler.getSelfParticipant();
636
703
  peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(remoteParticipant.userId, this.meetingStartRequest);
637
- if (peerConnectionObject && shouldRestartIce && peerConnectionObject.rtcPeerConnection && peerConnectionObject.rtcPeerConnection.connectionState === 'connected') {
704
+ if (peerConnectionObject &&
705
+ shouldRestartIce &&
706
+ peerConnectionObject.rtcPeerConnection &&
707
+ peerConnectionObject.rtcPeerConnection.connectionState === "connected") {
638
708
  this.printLogIfRequired("onNegotiationNeeded return", remoteParticipant, shouldRestartIce, peerConnectionObject);
639
709
  return [2 /*return*/];
640
710
  }
@@ -645,7 +715,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
645
715
  // this.printLogIfRequired("shouldForceFullyCreateOffer ",peerConnectionObject,peerConnectionObject.isNegotiationNeeded,peerConnectionObject.opertionalNegotiationId,count)
646
716
  // }
647
717
  // else
648
- if (!peerConnectionObject || !peerConnectionObject.isNegotiationNeeded || peerConnectionObject.opertionalNegotiationId || count > 15) {
718
+ if (!peerConnectionObject ||
719
+ !peerConnectionObject.isNegotiationNeeded ||
720
+ peerConnectionObject.opertionalNegotiationId ||
721
+ count > 15) {
649
722
  this.printLogIfRequired("onNegotiationNeeded exit", peerConnectionObject, peerConnectionObject.isNegotiationNeeded, peerConnectionObject.opertionalNegotiationId, count);
650
723
  return [2 /*return*/];
651
724
  }
@@ -661,24 +734,38 @@ var WebrtcHandler = /** @class */ (function (_super) {
661
734
  case 2:
662
735
  setTimeout(function () {
663
736
  _this.printLogIfRequired("onNegotiationNeeded setTimeout 525");
664
- _this.onNegotiationNeeded(remoteParticipant, shouldRestartIce, (count + 1), shouldForceFullyCreateOffer);
737
+ _this.onNegotiationNeeded(remoteParticipant, shouldRestartIce, count + 1, shouldForceFullyCreateOffer);
665
738
  }, 5000);
666
739
  _d.label = 3;
667
740
  case 3: return [3 /*break*/, 6];
668
741
  case 4:
669
- isVideoAdded = ((_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.getAllSelfTracks().find(function (eachTrack) { return eachTrack.trackKind === TrackKind.Video && eachTrack.track; })) ? true : false;
670
- isAudioAdded = ((_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.getAllSelfTracks().find(function (eachTrack) { return eachTrack.trackKind === TrackKind.Audio && eachTrack.track; })) ? true : false;
671
- messageJson = { to: remoteParticipant.userId, type: WebrtcMessageType.NegotiationNeeded,
672
- data: { negotiationId: peerConnectionObject.negotiationId, shouldRestartIce: shouldRestartIce,
673
- isVideoAdded: isVideoAdded, isAudioAdded: isAudioAdded
674
- } };
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
+ };
675
762
  return [4 /*yield*/, this.sendWebrtcMessage(messageJson)];
676
763
  case 5:
677
764
  _d.sent();
678
765
  this.printLogIfRequired("ask remote negogitation ", messageJson);
679
766
  setTimeout(function () {
680
767
  _this.printLogIfRequired("onNegotiationNeeded setTimeout 542");
681
- _this.onNegotiationNeeded(remoteParticipant, shouldRestartIce, (count + 1), shouldForceFullyCreateOffer);
768
+ _this.onNegotiationNeeded(remoteParticipant, shouldRestartIce, count + 1, shouldForceFullyCreateOffer);
682
769
  }, 5000);
683
770
  _d.label = 6;
684
771
  case 6: return [2 /*return*/];
@@ -731,7 +818,9 @@ var WebrtcHandler = /** @class */ (function (_super) {
731
818
  selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
732
819
  if (selfParticpant) {
733
820
  peerConnection = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
734
- if (peerConnection && peerConnection.rtcPeerConnection && peerConnection.rtcPeerConnection.signalingState === 'stable') {
821
+ if (peerConnection &&
822
+ peerConnection.rtcPeerConnection &&
823
+ peerConnection.rtcPeerConnection.signalingState === "stable") {
735
824
  this.printLogIfRequired("Send Track", participant);
736
825
  this.addTransceiverToEachTrackKind(track.track.kind, peerConnection, true);
737
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)
@@ -779,15 +868,19 @@ var WebrtcHandler = /** @class */ (function (_super) {
779
868
  optionalParams[_i - 1] = arguments[_i];
780
869
  }
781
870
  if (optionalParams && optionalParams.length > 0) {
782
- _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);
783
874
  }
784
875
  else {
785
- _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);
786
879
  }
787
880
  };
788
881
  _this.setOpusSdpParams = function (sdp) {
789
882
  var _a;
790
- var lines = sdp.split('\r\n');
883
+ var lines = sdp.split("\r\n");
791
884
  var opusLine = lines.find(function (l) { return /a=rtpmap:\d+ opus/i.test(l); });
792
885
  if (!opusLine)
793
886
  return sdp;
@@ -807,7 +900,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
807
900
  lines.splice(rtpmapIdx + 1, 0, fmtpLine);
808
901
  }
809
902
  // a=mid injection removed — was corrupting SDP
810
- return lines.join('\r\n');
903
+ return lines.join("\r\n");
811
904
  };
812
905
  _this.setOpusParams = function (transceiver) {
813
906
  if (transceiver === null || transceiver === void 0 ? void 0 : transceiver.sender) {
@@ -822,21 +915,17 @@ var WebrtcHandler = /** @class */ (function (_super) {
822
915
  if (!params.encodings || params.encodings.length === 0) {
823
916
  params.encodings = [{}];
824
917
  }
825
- 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" });
826
919
  sender.setParameters(params).catch(console.error);
827
920
  };
828
921
  _this.applyAudioPriority = function (transceiver) {
829
922
  var _a, _b;
830
923
  // Codec preference — Opus first
831
- 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");
832
925
  if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities.codecs))
833
926
  return;
834
- var opus = capabilities.codecs.filter(function (c) {
835
- return c.mimeType.toLowerCase() === 'audio/opus';
836
- });
837
- var rest = capabilities.codecs.filter(function (c) {
838
- return c.mimeType.toLowerCase() !== 'audio/opus';
839
- });
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"; });
840
929
  transceiver.setCodecPreferences(__spreadArray(__spreadArray([], __read(opus), false), __read(rest), false));
841
930
  // maxBitrate only — priority/networkPriority already set at addTransceiver
842
931
  var params = transceiver.sender.getParameters();
@@ -848,7 +937,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
848
937
  _this.onNewTrack = function (track, receiver, transceiver, remoteParticipant) { return __awaiter(_this, void 0, void 0, function () {
849
938
  var kind;
850
939
  return __generator(this, function (_a) {
851
- kind = track.kind.toLowerCase() === 'audio' ? TrackKind.Audio : TrackKind.Video;
940
+ kind = track.kind.toLowerCase() === "audio" ? TrackKind.Audio : TrackKind.Video;
852
941
  this.registerTrack(track, remoteParticipant, kind);
853
942
  return [2 /*return*/];
854
943
  });
@@ -869,7 +958,11 @@ var WebrtcHandler = /** @class */ (function (_super) {
869
958
  }
870
959
  track.onended = function () {
871
960
  var _a, _b;
872
- 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
+ });
873
966
  if (existing)
874
967
  (_b = _this.communicationHandler) === null || _b === void 0 ? void 0 : _b.removeTrack(existing);
875
968
  };
@@ -886,7 +979,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
886
979
  stillPhantom = _a.sent();
887
980
  this.printLogIfRequired("stillPhantom", kind);
888
981
  if (!stillPhantom) {
889
- this.printLogIfRequired('Real track arrived for', kind);
982
+ this.printLogIfRequired("Real track arrived for", kind);
890
983
  this.registerTrack(transceiver.receiver.track, participant, kind);
891
984
  }
892
985
  else {
@@ -917,7 +1010,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
917
1010
  try {
918
1011
  for (_a = __values(stats.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
919
1012
  report = _b.value;
920
- if (report.type === 'inbound-rtp') {
1013
+ if (report.type === "inbound-rtp") {
921
1014
  return [2 /*return*/, ((_d = report.bytesReceived) !== null && _d !== void 0 ? _d : 0) === 0];
922
1015
  }
923
1016
  }
@@ -1025,8 +1118,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
1025
1118
  }
1026
1119
  }
1027
1120
  }
1028
- catch (err) {
1029
- }
1121
+ catch (err) { }
1030
1122
  return [2 /*return*/];
1031
1123
  });
1032
1124
  });
@@ -1060,19 +1152,24 @@ var WebrtcHandler = /** @class */ (function (_super) {
1060
1152
  var _a, _b;
1061
1153
  return (_b = (_a = _this.communicationHandler
1062
1154
  .getAllSelfTracks()
1063
- .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;
1064
1156
  }, function (profile) {
1065
- _this.printLogIfRequired('Network profile', profile);
1157
+ _this.printLogIfRequired("Network profile", profile);
1066
1158
  // Show UI banner: 'poor connection' / 'video paused' etc.
1067
1159
  }, (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.deviceTier);
1068
1160
  this.adaptationManager.start();
1069
1161
  }
1070
1162
  }
1071
- catch (err) {
1072
- }
1073
- this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && this.printLogIfRequired(" Init", this.communicationHandler.getAllParticipants());
1074
- this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && this.printLogIfRequired("Webrtc Init");
1075
- 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) {
1076
1173
  _this.onUserJoined(eachParticiapant);
1077
1174
  });
1078
1175
  return [2 /*return*/];
@@ -1128,11 +1225,9 @@ var WebrtcHandler = /** @class */ (function (_super) {
1128
1225
  }
1129
1226
  };
1130
1227
  WebrtcHandler.prototype.createDataChannel = function () {
1131
- return __awaiter(this, void 0, void 0, function () {
1132
- return __generator(this, function (_a) {
1133
- return [2 /*return*/];
1134
- });
1135
- });
1228
+ return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
1229
+ return [2 /*return*/];
1230
+ }); });
1136
1231
  };
1137
1232
  WebrtcHandler.prototype.sendMessageViaDataChannel = function (messagePayload) {
1138
1233
  // throw new Error('Method not implemented.');
@@ -1178,7 +1273,9 @@ var WebrtcHandler = /** @class */ (function (_super) {
1178
1273
  var selfParticpant = this.communicationHandler.getSelfParticipant();
1179
1274
  var peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(remoteUserId, this.meetingStartRequest);
1180
1275
  if (peerConnectionObject && peerConnectionObject.rtcPeerConnection) {
1181
- peerConnectionObject.rtcPeerConnection.getTransceivers().forEach(function (transceiver) {
1276
+ peerConnectionObject.rtcPeerConnection
1277
+ .getTransceivers()
1278
+ .forEach(function (transceiver) {
1182
1279
  var _a;
1183
1280
  if ((_a = transceiver.receiver) === null || _a === void 0 ? void 0 : _a.track) {
1184
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-native",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",