vani-meeting-client-native 0.3.7 → 0.4.0

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.
@@ -29,6 +29,7 @@ export declare class MeetingHandler {
29
29
  muteUser(userId?: string): Promise<TaskResponse>;
30
30
  getClientStats: () => Promise<TrackStats[] | undefined>;
31
31
  resumeCamera(userId?: string): Promise<TaskResponse>;
32
+ refetchTrackForParticipant: (participant: Participant) => Promise<void>;
32
33
  unmute(userId?: string): Promise<TaskResponse>;
33
34
  resumeStreamWithoutAdding(streamKind: TrackKind): TaskResponse | undefined;
34
35
  pauseStreamWithoutStopping(streamKind: TrackKind): TaskResponse | undefined;
@@ -42,12 +43,13 @@ export declare class MeetingHandler {
42
43
  getConsumerForTrack(track: Track): void;
43
44
  participantByUserId(userId: string): Participant | undefined;
44
45
  updateParticipantData(participant: Participant): Participant | undefined;
46
+ updateParticipantUserData(participant: Participant): Participant | undefined;
45
47
  getUpdatedParticipantsListFromServer(): void;
46
48
  getAllParticipants(): Participant[];
47
49
  getAllTracks(): Track[];
48
50
  getTracksByParticipantId(participantId: string): Track[];
49
51
  isWebScoketConnected(): boolean;
50
- isStartMeetingCalled: () => void;
52
+ isStartMeetingCalled: () => boolean;
51
53
  sendMessage(message: MessagePayload): TaskResponse;
52
54
  getOldMessages(): Promise<void>;
53
55
  onOldMessages(data: any): Promise<void>;
@@ -103,9 +103,16 @@ var MeetingHandler = /** @class */ (function () {
103
103
  }
104
104
  });
105
105
  }); };
106
+ this.refetchTrackForParticipant = function (participant) { return __awaiter(_this, void 0, void 0, function () {
107
+ var _a;
108
+ return __generator(this, function (_b) {
109
+ (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.refetchTrackForParticipant(participant);
110
+ return [2 /*return*/];
111
+ });
112
+ }); };
106
113
  this.isStartMeetingCalled = function () {
107
114
  var _a;
108
- (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.isStartAndSetupWithServerCalled;
115
+ return (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.isStartAndSetupWithServerCalled;
109
116
  };
110
117
  this.restartTransport = function () { return __awaiter(_this, void 0, void 0, function () {
111
118
  var _a;
@@ -194,22 +201,29 @@ var MeetingHandler = /** @class */ (function () {
194
201
  if (shouldAddTrackImmediately === void 0) { shouldAddTrackImmediately = true; }
195
202
  return __awaiter(this, void 0, void 0, function () {
196
203
  return __generator(this, function (_c) {
197
- if (!this.meetingStartRequest) {
198
- log.error("meetingStartRequestObject not found");
199
- return [2 /*return*/, false];
200
- }
201
- if ((((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.isMobileApp) && !this.reactNativeWebrtcPlugin) || ((_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.isReady()) === false) {
202
- log.error("Init method not called");
203
- return [2 /*return*/];
204
- }
205
- if (!this.userMediaHandler) {
206
- this.userMediaHandler = new UserMediaHandler(this.meetingStartRequest, this.communicationHandler);
207
- }
208
- if (isVideoRequired === false && isAudioRequired === false) {
209
- return [2 /*return*/];
204
+ switch (_c.label) {
205
+ case 0:
206
+ if (!this.meetingStartRequest) {
207
+ log.error("meetingStartRequestObject not found");
208
+ return [2 /*return*/, false];
209
+ }
210
+ if ((((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.isMobileApp) && !this.reactNativeWebrtcPlugin) || ((_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.isReady()) === false) {
211
+ log.error("Init method not called");
212
+ return [2 /*return*/];
213
+ }
214
+ if (!this.userMediaHandler) {
215
+ this.userMediaHandler = new UserMediaHandler(this.meetingStartRequest, this.communicationHandler);
216
+ }
217
+ if (isVideoRequired === false && isAudioRequired === false) {
218
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("startLocalStream return");
219
+ return [2 /*return*/];
220
+ }
221
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("startLocalStream starting");
222
+ return [4 /*yield*/, this.userMediaHandler.startLocalStream(isVideoRequired, isAudioRequired, shouldAddTrackImmediately, userMediaPayload)];
223
+ case 1:
224
+ _c.sent();
225
+ return [2 /*return*/, true];
210
226
  }
211
- this.userMediaHandler.startLocalStream(isVideoRequired, isAudioRequired, shouldAddTrackImmediately, userMediaPayload);
212
- return [2 /*return*/, true];
213
227
  });
214
228
  });
215
229
  };
@@ -400,8 +414,22 @@ var MeetingHandler = /** @class */ (function () {
400
414
  }
401
415
  return oldParticipant;
402
416
  };
417
+ MeetingHandler.prototype.updateParticipantUserData = function (participant) {
418
+ var _a, _b;
419
+ if (this.meetingStartRequest && participant.userId === ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId)) {
420
+ this.meetingStartRequest.userData = participant.userData;
421
+ }
422
+ var oldParticipant = this.participantByUserId(participant.userId);
423
+ if (oldParticipant) {
424
+ oldParticipant.userData = participant.userData;
425
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("updateParticipantUserData", oldParticipant);
426
+ (_b = this.websocketCallHandler) === null || _b === void 0 ? void 0 : _b.sendSocketMessage(WebSocketBasicEvents.UpdateParticipantData, oldParticipant);
427
+ }
428
+ return oldParticipant;
429
+ };
403
430
  MeetingHandler.prototype.getUpdatedParticipantsListFromServer = function () {
404
431
  var _a;
432
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("getUpdatedParticipantsListFromServer", this.communicationHandler);
405
433
  (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.downloadParticipantsData();
406
434
  };
407
435
  MeetingHandler.prototype.getAllParticipants = function () {
@@ -17,6 +17,7 @@ export declare class CommunicationHandler {
17
17
  private meetingHandler?;
18
18
  private internetReachbilityTimeout?;
19
19
  private isReachable;
20
+ private isServerVerifiedIfStartMeetingCalled;
20
21
  constructor(meetingHandler: MeetingHandler);
21
22
  setMeetingStartRequest(_meetingStartRequest: MeetingStartRequest): void;
22
23
  setWebsocketCallHandler(_websocketCallHandler: WebsocketHandler): void;
@@ -25,11 +26,13 @@ export declare class CommunicationHandler {
25
26
  emitMessageToSource(emitType: VaniEvent, payload: any): Promise<void>;
26
27
  getEventEmitter(): VaniEventListener;
27
28
  onAudioVideoStatusUpdated(data: any): void;
29
+ refetchTrackForParticipant: (participant: Participant) => Promise<void>;
28
30
  restartTransport: () => Promise<void>;
29
31
  updateSelfParticipantUserId(): void;
30
32
  getSelfParticipant(): Participant | undefined;
31
33
  downloadParticipantsData(): void;
32
34
  onServerParticipants(data: any): void;
35
+ isWebScoketConnected(): boolean;
33
36
  getAllParticipants(): Participant[];
34
37
  participantByUserId(userId: string): Participant | undefined;
35
38
  onStartParticipantMeetingCalled: (participantData: any) => Promise<void>;
@@ -55,7 +58,8 @@ export declare class CommunicationHandler {
55
58
  sendWebSocketMessage(type: WebSocketEvents, data: any): void;
56
59
  onVideoCallWebSocketMessage(websocketMessage: WebSocketMessageBody): Promise<void>;
57
60
  onReconnect(shouldInfromVideoCallHandler?: boolean): Promise<void>;
58
- onStartMeeingCalled(): boolean;
61
+ onStartMeeingCalled(isForceFully?: boolean): boolean;
62
+ checkIfStartMeetingUpdatedOnServer: () => Promise<void>;
59
63
  onAudioBlocked(data: any): void;
60
64
  onAudioUnblocked(data: any): void;
61
65
  onVideoBlocked(data: any): void;
@@ -64,6 +68,7 @@ export declare class CommunicationHandler {
64
68
  onIceCandidateDisconnected(): void;
65
69
  checkIfInternetReachable: (count: number) => void;
66
70
  private onApiResponded;
71
+ onPing: () => Promise<void>;
67
72
  restartSFU: () => Promise<void>;
68
73
  onSFUInitDone: () => Promise<void>;
69
74
  private reloadSFUCleanUpDone;
@@ -34,6 +34,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
35
  }
36
36
  };
37
+ var __read = (this && this.__read) || function (o, n) {
38
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
39
+ if (!m) return o;
40
+ var i = m.call(o), r, ar = [], e;
41
+ try {
42
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
43
+ }
44
+ catch (error) { e = { error: error }; }
45
+ finally {
46
+ try {
47
+ if (r && !r.done && (m = i["return"])) m.call(i);
48
+ }
49
+ finally { if (e) throw e.error; }
50
+ }
51
+ return ar;
52
+ };
37
53
  import { VaniEvent, MessagePayload, LogLevel } from "..";
38
54
  import { Participant } from "../model/Participant";
39
55
  import * as log from 'loglevel';
@@ -51,6 +67,14 @@ var CommunicationHandler = /** @class */ (function () {
51
67
  this.allTracks = [];
52
68
  this.allSelfTracksForRestartSFU = undefined;
53
69
  this.isReachable = true;
70
+ this.isServerVerifiedIfStartMeetingCalled = false;
71
+ this.refetchTrackForParticipant = function (participant) { return __awaiter(_this, void 0, void 0, function () {
72
+ var _a;
73
+ return __generator(this, function (_b) {
74
+ (_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.participantAudioVideoStatusUpdated(participant);
75
+ return [2 /*return*/];
76
+ });
77
+ }); };
54
78
  this.restartTransport = function () { return __awaiter(_this, void 0, void 0, function () {
55
79
  var _a;
56
80
  return __generator(this, function (_b) {
@@ -63,9 +87,15 @@ var CommunicationHandler = /** @class */ (function () {
63
87
  var _a;
64
88
  return __generator(this, function (_b) {
65
89
  if (participantData && participantData.userId && participantData.userId !== this.getSelfParticipant().userId) {
66
- participant = this.addParticipantIfNotExist(participantData, true);
90
+ participant = this.participantByUserId(participantData.userId);
91
+ if (!participant) {
92
+ participant = this.addParticipantIfNotExist(participantData, true);
93
+ }
67
94
  participant.isStartMeetingCalled = true;
68
- this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("onStartParticipantMeetingCalled", participant);
95
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug
96
+ && console.log(" webrtc onStartParticipantMeetingCalled", participant);
97
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug
98
+ && console.log(" webrtc isStartMeetingCalled onStartParticipantMeetingCalled", participant.isStartMeetingCalled);
69
99
  (_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.onParticipantStartMeetingCalled(participant);
70
100
  }
71
101
  return [2 /*return*/];
@@ -78,6 +108,29 @@ var CommunicationHandler = /** @class */ (function () {
78
108
  return [2 /*return*/];
79
109
  });
80
110
  }); };
111
+ this.checkIfStartMeetingUpdatedOnServer = function () { return __awaiter(_this, void 0, void 0, function () {
112
+ var _this = this;
113
+ var _a;
114
+ return __generator(this, function (_b) {
115
+ if (this.isServerVerifiedIfStartMeetingCalled) {
116
+ (_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.init();
117
+ return [2 /*return*/];
118
+ }
119
+ this.downloadParticipantsData();
120
+ setTimeout(function () {
121
+ var _a;
122
+ if (_this.isServerVerifiedIfStartMeetingCalled) {
123
+ (_a = _this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.init();
124
+ return;
125
+ }
126
+ _this.onStartMeeingCalled(true);
127
+ _this.meetingStartRequest &&
128
+ _this.meetingStartRequest.logLevel === LogLevel.Debug &&
129
+ console.log("checkIfStartMeetingUpdatedOnServer", _this.isServerVerifiedIfStartMeetingCalled);
130
+ }, 1000);
131
+ return [2 /*return*/];
132
+ });
133
+ }); };
81
134
  //Connection Recheck
82
135
  this.destoryRoomForcefully = function () {
83
136
  var _a;
@@ -122,6 +175,14 @@ var CommunicationHandler = /** @class */ (function () {
122
175
  });
123
176
  ;
124
177
  };
178
+ this.onPing = function () { return __awaiter(_this, void 0, void 0, function () {
179
+ var _a;
180
+ return __generator(this, function (_b) {
181
+ this === null || this === void 0 ? void 0 : this.emitMessageToSource(VaniEvent.OnNewPingFromServer, {});
182
+ (_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.onPing();
183
+ return [2 /*return*/];
184
+ });
185
+ }); };
125
186
  this.restartSFU = function () { return __awaiter(_this, void 0, void 0, function () {
126
187
  var messageJson;
127
188
  var _a;
@@ -203,6 +264,7 @@ var CommunicationHandler = /** @class */ (function () {
203
264
  if (participant) {
204
265
  participant.isVideoEnable = data.message.participant.isVideoEnable;
205
266
  participant.isAudioEnable = data.message.participant.isAudioEnable;
267
+ // this.refetchTrackForParticipant(participant)
206
268
  this.emitMessageToSource(VaniEvent.OnAudioVideoStatusUpdated, participant);
207
269
  }
208
270
  }
@@ -238,19 +300,25 @@ var CommunicationHandler = /** @class */ (function () {
238
300
  };
239
301
  CommunicationHandler.prototype.downloadParticipantsData = function () {
240
302
  var _a;
303
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("downloadParticipantsData");
241
304
  var obj = { type: WebSocketBasicEvents.GetAllParticipant, message: "" };
242
305
  (_a = this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.sendSocketMessage(WebSocketBasicEvents.GetAllParticipant, obj);
243
306
  };
244
307
  CommunicationHandler.prototype.onServerParticipants = function (data) {
245
308
  var _this = this;
246
309
  var _a;
247
- this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log(data);
310
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("onServerParticipants", data);
248
311
  if (data && data.message) {
249
- var userIds = "";
312
+ // var userIds = "";
250
313
  Object.entries(data.message).forEach(function (_a) {
251
- var userId = _a[0], participant = _a[1];
252
- userIds = userIds + " " + userId;
314
+ var _b;
315
+ var _c = __read(_a, 2), userId = _c[0], participant = _c[1];
316
+ // userIds = userIds + " " + userId
253
317
  _this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("addParticipantIfNotExist from onServerParticipants", data);
318
+ var localParticipant = participant;
319
+ if (localParticipant && localParticipant.userId === ((_b = _this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.userId) && localParticipant.isStartMeetingCalled) {
320
+ _this.isServerVerifiedIfStartMeetingCalled = true;
321
+ }
254
322
  _this.addParticipantIfNotExist(participant, false);
255
323
  });
256
324
  // const allParticiapntsToBeRemove = this.allParticipants.filter(participant => (userIds.includes(participant.userId) === false))
@@ -261,6 +329,13 @@ var CommunicationHandler = /** @class */ (function () {
261
329
  this.emitMessageToSource(VaniEvent.OnAllParticipants, this.allParticipants);
262
330
  }
263
331
  };
332
+ CommunicationHandler.prototype.isWebScoketConnected = function () {
333
+ var _a;
334
+ if (this.websocketCallHandler) {
335
+ return (_a = this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.isWebScoketConnected();
336
+ }
337
+ return false;
338
+ };
264
339
  CommunicationHandler.prototype.getAllParticipants = function () {
265
340
  return this.allParticipants;
266
341
  };
@@ -282,8 +357,9 @@ var CommunicationHandler = /** @class */ (function () {
282
357
  this.emitMessageToSource(VaniEvent.OnParticipantDataUpdated, oldParticipant);
283
358
  }
284
359
  this.updateParticipantAudioVideoDataAccordingToTrack(oldParticipant);
360
+ (_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.onParticipantUpdated();
285
361
  try {
286
- if (oldParticipant.userId === ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId)) {
362
+ if (oldParticipant.userId === ((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.userId)) {
287
363
  this.meetingStartRequest.userData = oldParticipant.userData;
288
364
  }
289
365
  }
@@ -295,18 +371,17 @@ var CommunicationHandler = /** @class */ (function () {
295
371
  participant = Object.assign(new Participant(participant.userId, participant.roomId, participant.userData, participant.isAdmin), participant);
296
372
  this.updateParticipantAudioVideoDataAccordingToTrack(participant);
297
373
  try {
298
- if (participant.userId === ((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.userId)) {
374
+ if (participant.userId === ((_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.userId)) {
299
375
  this.meetingStartRequest.userData = participant.userData;
300
376
  }
301
377
  }
302
378
  catch (err) {
303
379
  }
304
380
  this.allParticipants.push(participant);
305
- (_c = this.videoCallHandler) === null || _c === void 0 ? void 0 : _c.onUserJoined(participant);
381
+ (_d = this.videoCallHandler) === null || _d === void 0 ? void 0 : _d.onUserJoined(participant);
306
382
  if (shouldInfrom) {
307
383
  this.emitMessageToSource(VaniEvent.OnUserJoined, participant);
308
384
  }
309
- (_d = this.videoCallHandler) === null || _d === void 0 ? void 0 : _d.onParticipantUpdated();
310
385
  return participant;
311
386
  }
312
387
  };
@@ -529,24 +604,27 @@ var CommunicationHandler = /** @class */ (function () {
529
604
  });
530
605
  });
531
606
  };
532
- CommunicationHandler.prototype.onStartMeeingCalled = function () {
607
+ CommunicationHandler.prototype.onStartMeeingCalled = function (isForceFully) {
533
608
  var _a, _b, _c, _d;
534
- if (this.isStartAndSetupWithServerCalled) {
609
+ if (isForceFully === void 0) { isForceFully = false; }
610
+ if (this.isStartAndSetupWithServerCalled && !isForceFully) {
535
611
  return;
536
612
  }
537
613
  if (!this.meetingStartRequest) {
538
- log.warn("meetingStartRequestObject not found onStartMeeingCalled");
614
+ log.warn("meetingStartRequestObject not found onStartMeeingCalled", isForceFully);
539
615
  return false;
540
616
  }
541
617
  if (!this.websocketCallHandler) {
542
- log.warn("Init method not called onStartMeeingCalled");
618
+ this.checkIfStartMeetingUpdatedOnServer();
619
+ log.warn("Init method not called onStartMeeingCalled", isForceFully);
543
620
  return false;
544
621
  }
545
622
  if (!this.websocketCallHandler.isWebScoketConnected()) {
546
- log.warn("WEB SOCKET NOT CONNECTED");
623
+ this.checkIfStartMeetingUpdatedOnServer();
624
+ log.warn("WEB SOCKET NOT CONNECTED", isForceFully);
547
625
  return false;
548
626
  }
549
- this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("onStartAndSetupWithServerCalled");
627
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("webrtc onStartAndSetupWithServerCalled client");
550
628
  this.isStartAndSetupWithServerCalled = true;
551
629
  var data = { user: (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId };
552
630
  var startMeetingCalled = { message: data, type: WebSocketBasicEvents.OnStartMeetingCalled, to: (_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.roomId };
@@ -556,6 +634,7 @@ var CommunicationHandler = /** @class */ (function () {
556
634
  selfParticpant.isStartMeetingCalled = true;
557
635
  }
558
636
  (_d = this.videoCallHandler) === null || _d === void 0 ? void 0 : _d.init();
637
+ this.checkIfStartMeetingUpdatedOnServer();
559
638
  };
560
639
  CommunicationHandler.prototype.onAudioBlocked = function (data) {
561
640
  var _a, _b, _c;
@@ -638,12 +717,32 @@ var CommunicationHandler = /** @class */ (function () {
638
717
  }
639
718
  };
640
719
  CommunicationHandler.prototype.cleanup = function () {
720
+ var _a;
641
721
  return __awaiter(this, void 0, void 0, function () {
722
+ var participant;
642
723
  var _this = this;
643
- return __generator(this, function (_a) {
644
- this.selfTracks.forEach(function (eachTrack) {
645
- _this.removeTrack(eachTrack, false);
646
- });
724
+ return __generator(this, function (_b) {
725
+ try {
726
+ if (this.meetingStartRequest) {
727
+ participant = this.participantByUserId((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId);
728
+ if (participant) {
729
+ participant.getPeerConnections().forEach(function (peerConnection, eachUserId) {
730
+ try {
731
+ if (peerConnection && peerConnection.rtcPeerConnection) {
732
+ peerConnection.rtcPeerConnection.close();
733
+ }
734
+ }
735
+ catch (err) { }
736
+ });
737
+ }
738
+ }
739
+ }
740
+ catch (err) {
741
+ }
742
+ if (this.getSelfParticipant())
743
+ this.selfTracks.forEach(function (eachTrack) {
744
+ _this.removeTrack(eachTrack, false);
745
+ });
647
746
  this.allSelfTracksForRestartSFU = undefined;
648
747
  this.eventEmitter.removeAllListeners();
649
748
  this.videoCallHandler = undefined;
@@ -33,6 +33,8 @@ export declare enum VaniEvent {
33
33
  OnNotReachable = "notReachable",
34
34
  OnReconectionTimeout = "reconectionTimeout",
35
35
  OnReconecting = "reconecting",
36
+ WebrtcReconecting = "WebrtcReconecting",
37
+ WebrtcReconected = "WebrtcReconected",
36
38
  OnUserOnFoundWhileReconnect = "onUserOnFoundWhileReconnect",
37
39
  OnNewPingFromServer = "OnNewPingFromServer",
38
40
  OnConsumerScoreChange = "OnConsumerScoreChange",
@@ -61,6 +63,8 @@ interface VaniConnectionEvents {
61
63
  [VaniEvent.OnParticipantDataUpdated]: (participants: Participant) => any;
62
64
  [VaniEvent.OnMeetingStartTime]: (time: string) => any;
63
65
  [VaniEvent.OnNewPingFromServer]: () => any;
66
+ [VaniEvent.WebrtcReconected]: (participant: Participant) => any;
67
+ [VaniEvent.WebrtcReconecting]: (participant: Participant) => any;
64
68
  [VaniEvent.OnOldMessages]: (messages: MessagePayload[]) => any;
65
69
  [VaniEvent.OnNewChatMessageReceived]: (message: MessagePayload) => any;
66
70
  [VaniEvent.OnSpeakerChanged]: (participant: Participant) => any;
@@ -31,6 +31,8 @@ export var VaniEvent;
31
31
  VaniEvent["OnNotReachable"] = "notReachable";
32
32
  VaniEvent["OnReconectionTimeout"] = "reconectionTimeout";
33
33
  VaniEvent["OnReconecting"] = "reconecting";
34
+ VaniEvent["WebrtcReconecting"] = "WebrtcReconecting";
35
+ VaniEvent["WebrtcReconected"] = "WebrtcReconected";
34
36
  VaniEvent["OnUserOnFoundWhileReconnect"] = "onUserOnFoundWhileReconnect";
35
37
  VaniEvent["OnNewPingFromServer"] = "OnNewPingFromServer";
36
38
  VaniEvent["OnConsumerScoreChange"] = "OnConsumerScoreChange";
@@ -15,6 +15,11 @@ export declare enum LogLevel {
15
15
  None = "none",
16
16
  Debug = "Debug"
17
17
  }
18
+ export declare enum DeviceTier {
19
+ low = "low",
20
+ mid = "mid",
21
+ high = "high"
22
+ }
18
23
  export declare class MeetingStartRequest {
19
24
  roomId: string;
20
25
  userId: string;
@@ -35,6 +40,7 @@ export declare class MeetingStartRequest {
35
40
  maxBitRateConfig: number;
36
41
  renewUserIdOnEveryReconnection: boolean;
37
42
  maxAudioBitrateConfig: number;
43
+ deviceTier: DeviceTier;
38
44
  logLevel: LogLevel;
39
45
  dynamicWebSocketFetchBaseUrl?: string;
40
46
  isRecordingUser: boolean;
@@ -19,6 +19,12 @@ export var LogLevel;
19
19
  LogLevel["None"] = "none";
20
20
  LogLevel["Debug"] = "Debug";
21
21
  })(LogLevel || (LogLevel = {}));
22
+ export var DeviceTier;
23
+ (function (DeviceTier) {
24
+ DeviceTier["low"] = "low";
25
+ DeviceTier["mid"] = "mid";
26
+ DeviceTier["high"] = "high";
27
+ })(DeviceTier || (DeviceTier = {}));
22
28
  var MeetingStartRequest = /** @class */ (function () {
23
29
  function MeetingStartRequest(_roomId, _userId, _appId, _wssUrl, _shouldIgnoreCaseForRoomId) {
24
30
  if (_shouldIgnoreCaseForRoomId === void 0) { _shouldIgnoreCaseForRoomId = false; }
@@ -35,6 +41,7 @@ var MeetingStartRequest = /** @class */ (function () {
35
41
  this.maxBitRateConfig = 620000;
36
42
  this.renewUserIdOnEveryReconnection = false;
37
43
  this.maxAudioBitrateConfig = -1;
44
+ this.deviceTier = DeviceTier.mid;
38
45
  this.logLevel = LogLevel.None;
39
46
  this.isRecordingUser = false;
40
47
  this.meetingType = MeetingType.SFU;
@@ -25,6 +25,7 @@ var Participant = /** @class */ (function () {
25
25
  this.getPeerConnectionsViaUserId = function (userId, meetingStartRequest) {
26
26
  if (!_this.getPeerConnections().has(userId)) {
27
27
  var peerConnection = new PeerConnection();
28
+ peerConnection.userId = userId;
28
29
  if (!peerConnection.rtcPeerConnection) {
29
30
  peerConnection.rtcPeerConnection = new DynamicLibHelper().getRTCPeerConnection(meetingStartRequest);
30
31
  }
@@ -1,8 +1,14 @@
1
1
  export declare class PeerConnection {
2
2
  rtcPeerConnection: any;
3
3
  offer: any;
4
+ isCreatingOffer: boolean;
4
5
  remoteOffer: any;
5
6
  answer: any;
6
7
  remoteAnswer: any;
7
8
  userId: string;
9
+ isNegotiationNeeded: boolean;
10
+ negotiationId?: string;
11
+ opertionalNegotiationId?: string;
12
+ isSubDone: boolean;
13
+ isRtcRestartIceInProgess: boolean;
8
14
  }
@@ -49,6 +49,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
49
49
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
50
  }
51
51
  };
52
+ var __values = (this && this.__values) || function(o) {
53
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
54
+ if (m) return m.call(o);
55
+ if (o && typeof o.length === "number") return {
56
+ next: function () {
57
+ if (o && i >= o.length) o = void 0;
58
+ return { value: o && o[i++], done: !o };
59
+ }
60
+ };
61
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
62
+ };
52
63
  import log from 'loglevel';
53
64
  import { CameraFacingMode, LogLevel, VaniEvent } from "..";
54
65
  import { Base } from "../base/Base";
@@ -97,14 +108,18 @@ var UserMediaHandler = /** @class */ (function (_super) {
97
108
  this.meetingStartRequest.audioInDevice = undefined;
98
109
  }
99
110
  }
100
- canFetchAudioIn = true;
111
+ if (oldTrack) {
112
+ canFetchAudioIn = true;
113
+ }
101
114
  _f.label = 2;
102
115
  case 2:
103
116
  oldVideoTrack = (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.getSelfTrackByType(TrackKind.Video);
104
117
  isCameraDeviceFound = false;
105
118
  canFetchVideoIn = false;
106
119
  if (!(oldVideoTrack || (!oldVideoTrack && ((_d = this.meetingStartRequest) === null || _d === void 0 ? void 0 : _d.cameraDevice)))) return [3 /*break*/, 4];
107
- canFetchVideoIn = true;
120
+ if (oldVideoTrack) {
121
+ canFetchVideoIn = true;
122
+ }
108
123
  return [4 /*yield*/, this.getDevice(GetDevicesType.VideoIn)];
109
124
  case 3:
110
125
  cameraDevices = _f.sent();
@@ -199,6 +214,7 @@ var UserMediaHandler = /** @class */ (function (_super) {
199
214
  return __generator(this, function (_b) {
200
215
  switch (_b.label) {
201
216
  case 0:
217
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("startLocalStream ", isVideoRequired, isAudioRequired);
202
218
  if (isVideoRequired === false && isAudioRequired === false) {
203
219
  this.isVideoAudioFetchInProgress = false;
204
220
  (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.emitMessageToSource(VaniEvent.OnPermissionApproved, {});
@@ -209,6 +225,7 @@ var UserMediaHandler = /** @class */ (function (_super) {
209
225
  }
210
226
  this.userMediaPayload = userMediaPayload;
211
227
  if (this.isVideoAudioFetchInProgress) {
228
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("Already fetching stream. So request ignored", isVideoRequired, isVideoRequired);
212
229
  log.log("Already fetching stream. So request ignored");
213
230
  return [2 /*return*/];
214
231
  }
@@ -234,6 +251,7 @@ var UserMediaHandler = /** @class */ (function (_super) {
234
251
  // isAudioRequired = false;
235
252
  // }
236
253
  // }
254
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("startLocalStream startCapturingStream calling", isVideoRequired, isVideoRequired);
237
255
  this.startCapturingStream(isVideoRequired, isAudioRequired, shouldAddTrackImmediately, userMediaPayload);
238
256
  return [2 /*return*/];
239
257
  }
@@ -265,6 +283,8 @@ var UserMediaHandler = /** @class */ (function (_super) {
265
283
  UserMediaHandler.prototype.startCapturingStream = function (isVideoRequired, isAudioRequired, shouldAddTrackImmediately, userMediaPayload) {
266
284
  var _this = this;
267
285
  var _a, _b, _c, _d, _e;
286
+ this.isVideoAudioFetchInProgress = true;
287
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("startCapturingStream called", isVideoRequired, isAudioRequired);
268
288
  if (!userMediaPayload) {
269
289
  userMediaPayload = {};
270
290
  }
@@ -291,6 +311,9 @@ var UserMediaHandler = /** @class */ (function (_super) {
291
311
  userMediaPayload.video.facingMode = this.cameraFacingMode;
292
312
  }
293
313
  }
314
+ else {
315
+ userMediaPayload.video = undefined;
316
+ }
294
317
  if (isAudioRequired) {
295
318
  var oldTrack = (_d = this.communicationHandler) === null || _d === void 0 ? void 0 : _d.getSelfTrackByType(TrackKind.Audio);
296
319
  if (oldTrack && oldTrack.track) {
@@ -308,7 +331,10 @@ var UserMediaHandler = /** @class */ (function (_super) {
308
331
  }
309
332
  }
310
333
  }
311
- this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log(userMediaPayload);
334
+ else {
335
+ userMediaPayload.audio = undefined;
336
+ }
337
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("userMediaPayload", userMediaPayload);
312
338
  (new DynamicLibHelper()).getMediaDevicesVariable(this.meetingStartRequest).getUserMedia(userMediaPayload)
313
339
  .then(function (stream) {
314
340
  _this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("On Got Stream", stream);
@@ -339,6 +365,7 @@ var UserMediaHandler = /** @class */ (function (_super) {
339
365
  var permissionApprovedFor, data, audioPause, data, audioPause;
340
366
  var _this = this;
341
367
  return __generator(this, function (_f) {
368
+ this.isVideoAudioFetchInProgress = false;
342
369
  try {
343
370
  if (stream && stream.getVideoTracks()) {
344
371
  stream.getVideoTracks().forEach(function (eachMediaTrack) {
@@ -479,18 +506,28 @@ var UserMediaHandler = /** @class */ (function (_super) {
479
506
  };
480
507
  UserMediaHandler.prototype.getDevice = function (type) {
481
508
  return __awaiter(this, void 0, void 0, function () {
482
- var deviceInfos, devices, _i, deviceInfos_1, deviceInfo;
483
- return __generator(this, function (_a) {
484
- switch (_a.label) {
509
+ var deviceInfos, devices, deviceInfos_1, deviceInfos_1_1, deviceInfo;
510
+ var e_1, _a;
511
+ return __generator(this, function (_b) {
512
+ switch (_b.label) {
485
513
  case 0: return [4 /*yield*/, navigator.mediaDevices.enumerateDevices()];
486
514
  case 1:
487
- deviceInfos = _a.sent();
515
+ deviceInfos = _b.sent();
488
516
  devices = [];
489
- for (_i = 0, deviceInfos_1 = deviceInfos; _i < deviceInfos_1.length; _i++) {
490
- deviceInfo = deviceInfos_1[_i];
491
- if (deviceInfo.kind === type) {
492
- devices.push({ id: deviceInfo.deviceId, label: deviceInfo.label });
517
+ try {
518
+ for (deviceInfos_1 = __values(deviceInfos), deviceInfos_1_1 = deviceInfos_1.next(); !deviceInfos_1_1.done; deviceInfos_1_1 = deviceInfos_1.next()) {
519
+ deviceInfo = deviceInfos_1_1.value;
520
+ if (deviceInfo.kind === type) {
521
+ devices.push({ id: deviceInfo.deviceId, label: deviceInfo.label });
522
+ }
523
+ }
524
+ }
525
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
526
+ finally {
527
+ try {
528
+ if (deviceInfos_1_1 && !deviceInfos_1_1.done && (_a = deviceInfos_1.return)) _a.call(deviceInfos_1);
493
529
  }
530
+ finally { if (e_1) throw e_1.error; }
494
531
  }
495
532
  return [2 /*return*/, devices];
496
533
  }