vani-meeting-client-native 0.4.6 → 0.4.7-beta2

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.
@@ -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
  }
@@ -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 (_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) {
@@ -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>;
@@ -162,11 +162,6 @@ var WebrtcHandler = /** @class */ (function (_super) {
162
162
  else if (realTrack.track.kind === 'video') {
163
163
  newTransceiver = peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, {
164
164
  direction: 'sendonly',
165
- sendEncodings: [{
166
- maxBitrate: 500000,
167
- priority: 'low',
168
- networkPriority: 'low',
169
- }]
170
165
  });
171
166
  }
172
167
  // newTransceiver = await peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, { direction: "sendrecv" })
@@ -257,6 +252,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
257
252
  // send offer to peer
258
253
  peerConnectionObject.remoteAnswer = undefined;
259
254
  this.loopSendOffer(peerConnectionObject, participant, mungedOffer);
255
+ this.printLogIfRequired("CheckIfCanSendOffer", peerConnectionObject, selfParticpant);
260
256
  _c.label = 5;
261
257
  case 5: return [2 /*return*/];
262
258
  }
@@ -266,10 +262,19 @@ var WebrtcHandler = /** @class */ (function (_super) {
266
262
  _this.loopSendOffer = function (peerConnectionObject, participant, mungedOffer, count) {
267
263
  if (count === void 0) { count = 0; }
268
264
  return __awaiter(_this, void 0, void 0, function () {
269
- var messageJson;
265
+ var selfParticpant, messageJson;
270
266
  var _this = this;
271
- return __generator(this, function (_a) {
272
- this.printLogIfRequired("Send Offer", mungedOffer);
267
+ var _a;
268
+ return __generator(this, function (_b) {
269
+ selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
270
+ if (!selfParticpant) {
271
+ return [2 /*return*/];
272
+ }
273
+ if (!selfParticpant.isPeerConnectionsViaUserIdPresent(participant.userId)) {
274
+ this.printLogIfRequired("loopSendOffer", "Not found", selfParticpant, participant);
275
+ return [2 /*return*/];
276
+ }
277
+ this.printLogIfRequired("Send Offer loop", mungedOffer, participant);
273
278
  messageJson = { to: participant.userId, type: WebrtcMessageType.SendOffer, data: mungedOffer };
274
279
  this.sendWebrtcMessage(messageJson);
275
280
  if (peerConnectionObject.remoteAnswer || count > 20) {
@@ -561,10 +566,13 @@ var WebrtcHandler = /** @class */ (function (_super) {
561
566
  }
562
567
  });
563
568
  rtcConnection.addEventListener('signalingstatechange', function (event) {
569
+ var _a;
564
570
  _this.printLogIfRequired("signalingstatechange", event, rtcConnection.signalingState);
565
- if (rtcConnection.signalingState === 'stable') {
566
- peerConnectionObject.isCreatingOffer = false;
567
- if (peerConnectionObject.isNegotiationNeeded) {
571
+ var selfParticpant = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
572
+ var innerPeerConnectionObject = selfParticpant === null || selfParticpant === void 0 ? void 0 : selfParticpant.isPeerConnectionsViaUserIdPresent(remoteParticipant.userId);
573
+ if (innerPeerConnectionObject && rtcConnection.signalingState === 'stable') {
574
+ innerPeerConnectionObject.isCreatingOffer = false;
575
+ if (innerPeerConnectionObject.isNegotiationNeeded) {
568
576
  _this.onNegotiationNeeded(remoteParticipant, false, 0, true);
569
577
  }
570
578
  }
@@ -579,13 +587,16 @@ var WebrtcHandler = /** @class */ (function (_super) {
579
587
  // }
580
588
  // })
581
589
  rtcConnection.addEventListener('negotiationneeded', function (event) {
582
- _this.printLogIfRequired("negotiationneeded", rtcConnection.signalingState, remoteParticipant);
583
- if (!peerConnectionObject.offer && !peerConnectionObject.answer) {
584
- _this.printLogIfRequired("negotiationneeded ignored", rtcConnection.signalingState, remoteParticipant);
590
+ var _a;
591
+ _this.printLogIfRequired("negotiationneeded", rtcConnection.signalingState, remoteParticipant, peerConnectionObject);
592
+ var selfParticpant = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
593
+ var innerPeerConnectionObject = selfParticpant === null || selfParticpant === void 0 ? void 0 : selfParticpant.isPeerConnectionsViaUserIdPresent(remoteParticipant.userId);
594
+ if (!innerPeerConnectionObject || (!innerPeerConnectionObject.offer && !innerPeerConnectionObject.answer)) {
595
+ _this.printLogIfRequired("negotiationneeded ignored", rtcConnection.signalingState, remoteParticipant, innerPeerConnectionObject, selfParticpant);
585
596
  return;
586
597
  }
587
- peerConnectionObject.isNegotiationNeeded = true;
588
- peerConnectionObject.negotiationId = new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
598
+ innerPeerConnectionObject.isNegotiationNeeded = true;
599
+ innerPeerConnectionObject.negotiationId = new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
589
600
  if (rtcConnection.signalingState === 'stable') {
590
601
  _this.onNegotiationNeeded(remoteParticipant, false, 0, true);
591
602
  }
@@ -710,11 +721,12 @@ var WebrtcHandler = /** @class */ (function (_super) {
710
721
  }); };
711
722
  _this.sendTrackToParticipant = function (track, participant) { return __awaiter(_this, void 0, void 0, function () {
712
723
  var selfParticpant, peerConnection;
713
- return __generator(this, function (_a) {
724
+ var _a;
725
+ return __generator(this, function (_b) {
714
726
  if (!track.track) {
715
727
  return [2 /*return*/];
716
728
  }
717
- selfParticpant = this.communicationHandler.getSelfParticipant();
729
+ selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
718
730
  if (selfParticpant) {
719
731
  peerConnection = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
720
732
  if (peerConnection && peerConnection.rtcPeerConnection && peerConnection.rtcPeerConnection.signalingState === 'stable') {
@@ -832,13 +844,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
832
844
  transceiver.sender.setParameters(params).catch(console.error);
833
845
  };
834
846
  _this.onNewTrack = function (track, receiver, transceiver, remoteParticipant) { return __awaiter(_this, void 0, void 0, function () {
835
- var kind, t;
836
- var _a;
837
- return __generator(this, function (_b) {
838
- this.printLogIfRequired('ontrack fired', track.kind, track.id);
847
+ var kind;
848
+ return __generator(this, function (_a) {
839
849
  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);
850
+ this.registerTrack(track, remoteParticipant, kind);
842
851
  return [2 /*return*/];
843
852
  });
844
853
  }); };
@@ -983,12 +992,13 @@ var WebrtcHandler = /** @class */ (function (_super) {
983
992
  // throw new Error("Method not implemented.");
984
993
  };
985
994
  WebrtcHandler.prototype.onAllParticipants = function (participants) {
995
+ var _a;
986
996
  return __awaiter(this, void 0, void 0, function () {
987
997
  var selfParticpant;
988
998
  var _this = this;
989
- return __generator(this, function (_a) {
990
- selfParticpant = this.communicationHandler.getSelfParticipant();
991
- if (selfParticpant.isStartMeetingCalled) {
999
+ return __generator(this, function (_b) {
1000
+ selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
1001
+ if (selfParticpant && selfParticpant.isStartMeetingCalled) {
992
1002
  participants.forEach(function (eachParticiapant) {
993
1003
  _this.onUserJoined(eachParticiapant);
994
1004
  });
@@ -997,6 +1007,28 @@ var WebrtcHandler = /** @class */ (function (_super) {
997
1007
  });
998
1008
  });
999
1009
  };
1010
+ WebrtcHandler.prototype.onUserLeft = function (participant) {
1011
+ var _a;
1012
+ return __awaiter(this, void 0, void 0, function () {
1013
+ var selfParticpant, peerConnection;
1014
+ return __generator(this, function (_b) {
1015
+ try {
1016
+ selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
1017
+ if (selfParticpant) {
1018
+ peerConnection = selfParticpant.isPeerConnectionsViaUserIdPresent(participant.userId);
1019
+ if (peerConnection) {
1020
+ peerConnection.rtcPeerConnection.close();
1021
+ selfParticpant.removePeerConnectionsViaUserId(participant.userId);
1022
+ this.printLogIfRequired("onUserLeft after", selfParticpant.getPeerConnections());
1023
+ }
1024
+ }
1025
+ }
1026
+ catch (err) {
1027
+ }
1028
+ return [2 /*return*/];
1029
+ });
1030
+ });
1031
+ };
1000
1032
  WebrtcHandler.prototype.onUserJoined = function (participant) {
1001
1033
  return __awaiter(this, void 0, void 0, function () {
1002
1034
  return __generator(this, function (_a) {
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-client-native",
3
- "version": "0.4.6",
3
+ "version": "0.4.7beta2",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",