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

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" })
@@ -266,10 +261,19 @@ var WebrtcHandler = /** @class */ (function (_super) {
266
261
  _this.loopSendOffer = function (peerConnectionObject, participant, mungedOffer, count) {
267
262
  if (count === void 0) { count = 0; }
268
263
  return __awaiter(_this, void 0, void 0, function () {
269
- var messageJson;
264
+ var selfParticpant, messageJson;
270
265
  var _this = this;
271
- return __generator(this, function (_a) {
272
- this.printLogIfRequired("Send Offer", mungedOffer);
266
+ var _a;
267
+ return __generator(this, function (_b) {
268
+ selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
269
+ if (!selfParticpant) {
270
+ return [2 /*return*/];
271
+ }
272
+ if (!selfParticpant.isPeerConnectionsViaUserIdPresent(participant.userId)) {
273
+ this.printLogIfRequired("loopSendOffer", "Not found", selfParticpant, participant);
274
+ return [2 /*return*/];
275
+ }
276
+ this.printLogIfRequired("Send Offer loop", mungedOffer, participant);
273
277
  messageJson = { to: participant.userId, type: WebrtcMessageType.SendOffer, data: mungedOffer };
274
278
  this.sendWebrtcMessage(messageJson);
275
279
  if (peerConnectionObject.remoteAnswer || count > 20) {
@@ -561,10 +565,13 @@ var WebrtcHandler = /** @class */ (function (_super) {
561
565
  }
562
566
  });
563
567
  rtcConnection.addEventListener('signalingstatechange', function (event) {
568
+ var _a;
564
569
  _this.printLogIfRequired("signalingstatechange", event, rtcConnection.signalingState);
565
- if (rtcConnection.signalingState === 'stable') {
566
- peerConnectionObject.isCreatingOffer = false;
567
- if (peerConnectionObject.isNegotiationNeeded) {
570
+ var selfParticpant = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
571
+ var innerPeerConnectionObject = selfParticpant === null || selfParticpant === void 0 ? void 0 : selfParticpant.isPeerConnectionsViaUserIdPresent(remoteParticipant.userId);
572
+ if (innerPeerConnectionObject && rtcConnection.signalingState === 'stable') {
573
+ innerPeerConnectionObject.isCreatingOffer = false;
574
+ if (innerPeerConnectionObject.isNegotiationNeeded) {
568
575
  _this.onNegotiationNeeded(remoteParticipant, false, 0, true);
569
576
  }
570
577
  }
@@ -579,13 +586,16 @@ var WebrtcHandler = /** @class */ (function (_super) {
579
586
  // }
580
587
  // })
581
588
  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);
589
+ var _a;
590
+ _this.printLogIfRequired("negotiationneeded", rtcConnection.signalingState, remoteParticipant, peerConnectionObject);
591
+ var selfParticpant = (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
592
+ var innerPeerConnectionObject = selfParticpant === null || selfParticpant === void 0 ? void 0 : selfParticpant.isPeerConnectionsViaUserIdPresent(remoteParticipant.userId);
593
+ if (!innerPeerConnectionObject || (!innerPeerConnectionObject.offer && !innerPeerConnectionObject.answer)) {
594
+ _this.printLogIfRequired("negotiationneeded ignored", rtcConnection.signalingState, remoteParticipant, peerConnectionObject);
585
595
  return;
586
596
  }
587
- peerConnectionObject.isNegotiationNeeded = true;
588
- peerConnectionObject.negotiationId = new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
597
+ innerPeerConnectionObject.isNegotiationNeeded = true;
598
+ innerPeerConnectionObject.negotiationId = new Date().getTime() + "_" + (Math.floor(Math.random() * 100) + 1);
589
599
  if (rtcConnection.signalingState === 'stable') {
590
600
  _this.onNegotiationNeeded(remoteParticipant, false, 0, true);
591
601
  }
@@ -710,11 +720,12 @@ var WebrtcHandler = /** @class */ (function (_super) {
710
720
  }); };
711
721
  _this.sendTrackToParticipant = function (track, participant) { return __awaiter(_this, void 0, void 0, function () {
712
722
  var selfParticpant, peerConnection;
713
- return __generator(this, function (_a) {
723
+ var _a;
724
+ return __generator(this, function (_b) {
714
725
  if (!track.track) {
715
726
  return [2 /*return*/];
716
727
  }
717
- selfParticpant = this.communicationHandler.getSelfParticipant();
728
+ selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
718
729
  if (selfParticpant) {
719
730
  peerConnection = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
720
731
  if (peerConnection && peerConnection.rtcPeerConnection && peerConnection.rtcPeerConnection.signalingState === 'stable') {
@@ -832,13 +843,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
832
843
  transceiver.sender.setParameters(params).catch(console.error);
833
844
  };
834
845
  _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);
846
+ var kind;
847
+ return __generator(this, function (_a) {
839
848
  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);
849
+ this.registerTrack(track, remoteParticipant, kind);
842
850
  return [2 /*return*/];
843
851
  });
844
852
  }); };
@@ -983,12 +991,13 @@ var WebrtcHandler = /** @class */ (function (_super) {
983
991
  // throw new Error("Method not implemented.");
984
992
  };
985
993
  WebrtcHandler.prototype.onAllParticipants = function (participants) {
994
+ var _a;
986
995
  return __awaiter(this, void 0, void 0, function () {
987
996
  var selfParticpant;
988
997
  var _this = this;
989
- return __generator(this, function (_a) {
990
- selfParticpant = this.communicationHandler.getSelfParticipant();
991
- if (selfParticpant.isStartMeetingCalled) {
998
+ return __generator(this, function (_b) {
999
+ selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
1000
+ if (selfParticpant && selfParticpant.isStartMeetingCalled) {
992
1001
  participants.forEach(function (eachParticiapant) {
993
1002
  _this.onUserJoined(eachParticiapant);
994
1003
  });
@@ -997,6 +1006,28 @@ var WebrtcHandler = /** @class */ (function (_super) {
997
1006
  });
998
1007
  });
999
1008
  };
1009
+ WebrtcHandler.prototype.onUserLeft = function (participant) {
1010
+ var _a;
1011
+ return __awaiter(this, void 0, void 0, function () {
1012
+ var selfParticpant, peerConnection;
1013
+ return __generator(this, function (_b) {
1014
+ try {
1015
+ selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
1016
+ if (selfParticpant) {
1017
+ peerConnection = selfParticpant.isPeerConnectionsViaUserIdPresent(participant.userId);
1018
+ if (peerConnection) {
1019
+ peerConnection.rtcPeerConnection.close();
1020
+ selfParticpant.removePeerConnectionsViaUserId(participant.userId);
1021
+ this.printLogIfRequired("onUserLeft after", selfParticpant.getPeerConnections());
1022
+ }
1023
+ }
1024
+ }
1025
+ catch (err) {
1026
+ }
1027
+ return [2 /*return*/];
1028
+ });
1029
+ });
1030
+ };
1000
1031
  WebrtcHandler.prototype.onUserJoined = function (participant) {
1001
1032
  return __awaiter(this, void 0, void 0, function () {
1002
1033
  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.7beta1",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",