vani-meeting-client 1.1.5 → 1.1.7

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.
@@ -15,6 +15,7 @@ export declare class SFUHandler extends BaseVideoCallHandler {
15
15
  private dataProducers;
16
16
  private dataConsumer;
17
17
  constructor(_meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler);
18
+ reconnectedWithoutPing(): void;
18
19
  onReconnect(): Promise<void>;
19
20
  private onRestartIceCandidateResponse;
20
21
  stopTrack(track: Track): void;
@@ -90,6 +90,9 @@ var SFUHandler = /** @class */ (function (_super) {
90
90
  }
91
91
  return _this;
92
92
  }
93
+ SFUHandler.prototype.reconnectedWithoutPing = function () {
94
+ this.onReconnect();
95
+ };
93
96
  SFUHandler.prototype.onReconnect = function () {
94
97
  return __awaiter(this, void 0, void 0, function () {
95
98
  var data, data;
@@ -110,22 +113,44 @@ var SFUHandler = /** @class */ (function (_super) {
110
113
  });
111
114
  };
112
115
  SFUHandler.prototype.onRestartIceCandidateResponse = function (data) {
113
- var _a;
116
+ var _a, _b, _c;
114
117
  return __awaiter(this, void 0, void 0, function () {
115
- var transportId, iceParameters, messageJson;
116
- return __generator(this, function (_b) {
117
- transportId = data.message.transportId;
118
- iceParameters = data.message.iceParameters;
119
- if (this.consumerTransport && this.consumerTransport.id === transportId) {
120
- this.consumerTransport.restartIce({ iceParameters: iceParameters });
121
- }
122
- else if (this.sendTransport && this.sendTransport.id === transportId) {
123
- this.sendTransport.restartIce({ iceParameters: iceParameters });
118
+ var transportId, iceParameters, _i, _d, consumer, messageJson;
119
+ var _this = this;
120
+ return __generator(this, function (_e) {
121
+ switch (_e.label) {
122
+ case 0:
123
+ transportId = data.message.transportId;
124
+ iceParameters = data.message.iceParameters;
125
+ (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.downloadParticipantsData();
126
+ if (!(this.consumerTransport && this.consumerTransport.id === transportId)) return [3 /*break*/, 2];
127
+ return [4 /*yield*/, this.consumerTransport.restartIce({ iceParameters: iceParameters })];
128
+ case 1:
129
+ _e.sent();
130
+ for (_i = 0, _d = this.consumers; _i < _d.length; _i++) {
131
+ consumer = _d[_i];
132
+ if (consumer) {
133
+ consumer.close();
134
+ }
135
+ }
136
+ this.consumers = [];
137
+ messageJson = { to: "self", type: SFUMessageType.GetAllProducers, message: {} };
138
+ this.sendSFUMessageToSocket(messageJson);
139
+ return [3 /*break*/, 4];
140
+ case 2:
141
+ if (!(this.sendTransport && this.sendTransport.id === transportId)) return [3 /*break*/, 4];
142
+ return [4 /*yield*/, this.sendTransport.restartIce({ iceParameters: iceParameters })];
143
+ case 3:
144
+ _e.sent();
145
+ (_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.getAllSelfTracks().forEach(function (eachSelfTrack) {
146
+ _this.stopTrack(eachSelfTrack);
147
+ });
148
+ (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.getAllSelfTracks().forEach(function (eachSelfTrack) {
149
+ _this.sendTrack(eachSelfTrack);
150
+ });
151
+ _e.label = 4;
152
+ case 4: return [2 /*return*/];
124
153
  }
125
- messageJson = { to: "self", type: SFUMessageType.GetAllProducers, message: {} };
126
- this.sendSFUMessageToSocket(messageJson);
127
- (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.downloadParticipantsData();
128
- return [2 /*return*/];
129
154
  });
130
155
  });
131
156
  };
@@ -196,22 +221,25 @@ var SFUHandler = /** @class */ (function (_super) {
196
221
  });
197
222
  };
198
223
  SFUHandler.prototype.sendTrack = function (track) {
199
- var _a, _b, _c;
224
+ var _a, _b, _c, _d, _e;
200
225
  return __awaiter(this, void 0, void 0, function () {
201
226
  var producer, appData, producerData, webcamProducer;
202
- return __generator(this, function (_d) {
203
- switch (_d.label) {
227
+ return __generator(this, function (_f) {
228
+ switch (_f.label) {
204
229
  case 0:
205
230
  if (!(track && track.track)) return [3 /*break*/, 4];
206
231
  producer = this.producers.find(function (producer) { return producer.appData.trackId === track.trackId; });
207
- if (!(producer && producer.closed === false)) return [3 /*break*/, 2];
232
+ if (producer && producer.closed === false && ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.isMobileApp)) {
233
+ this.stopTrack(track);
234
+ }
235
+ if (!(producer && producer.closed === false && ((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.isMobileApp) === false)) return [3 /*break*/, 2];
208
236
  return [4 /*yield*/, producer.replaceTrack({ track: track.track })];
209
237
  case 1:
210
- _d.sent();
238
+ _f.sent();
211
239
  this.resumeTrack(track);
212
240
  return [3 /*break*/, 4];
213
241
  case 2:
214
- appData = __assign({}, (_a = this.sendTransport) === null || _a === void 0 ? void 0 : _a.appData);
242
+ appData = __assign({}, (_c = this.sendTransport) === null || _c === void 0 ? void 0 : _c.appData);
215
243
  appData.trackKind = track.trackKind;
216
244
  appData.trackId = track.trackId;
217
245
  producerData = { track: track.track, appData: appData, disableTrackOnPause: false, zeroRtpOnPause: true };
@@ -221,13 +249,13 @@ var SFUHandler = /** @class */ (function (_super) {
221
249
  if (track.track.kind === "audio") {
222
250
  producerData.codecOptions = { opusStereo: true, opusFec: true };
223
251
  if (this.meetingStartRequest.maxAudioBitrateConfig > 0) {
224
- producerData.codecOptions.opusMaxAverageBitrate = (_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.maxAudioBitrateConfig;
252
+ producerData.codecOptions.opusMaxAverageBitrate = (_d = this.meetingStartRequest) === null || _d === void 0 ? void 0 : _d.maxAudioBitrateConfig;
225
253
  }
226
254
  }
227
255
  log.info(producerData);
228
- return [4 /*yield*/, ((_c = this.sendTransport) === null || _c === void 0 ? void 0 : _c.produce(producerData))];
256
+ return [4 /*yield*/, ((_e = this.sendTransport) === null || _e === void 0 ? void 0 : _e.produce(producerData))];
229
257
  case 3:
230
- webcamProducer = _d.sent();
258
+ webcamProducer = _f.sent();
231
259
  if (webcamProducer) {
232
260
  console.log("On webcamProducer");
233
261
  this.producers.push(webcamProducer);
@@ -237,7 +265,7 @@ var SFUHandler = /** @class */ (function (_super) {
237
265
  else {
238
266
  console.log("On webcamProducer not created");
239
267
  }
240
- _d.label = 4;
268
+ _f.label = 4;
241
269
  case 4: return [2 /*return*/];
242
270
  }
243
271
  });
@@ -298,8 +326,30 @@ var SFUHandler = /** @class */ (function (_super) {
298
326
  };
299
327
  SFUHandler.prototype.onTransportNotFound = function (data) {
300
328
  return __awaiter(this, void 0, void 0, function () {
301
- var messageJson;
302
- return __generator(this, function (_a) {
329
+ var _i, _a, producer, _b, _c, consumer, messageJson;
330
+ return __generator(this, function (_d) {
331
+ for (_i = 0, _a = this.producers; _i < _a.length; _i++) {
332
+ producer = _a[_i];
333
+ if (producer) {
334
+ producer.close();
335
+ }
336
+ }
337
+ for (_b = 0, _c = this.consumers; _b < _c.length; _b++) {
338
+ consumer = _c[_b];
339
+ if (consumer) {
340
+ consumer.close();
341
+ }
342
+ }
343
+ this.producers = [];
344
+ this.consumers = [];
345
+ if (this.consumerTransport) {
346
+ this.consumerTransport.close();
347
+ this.consumerTransport = undefined;
348
+ }
349
+ if (this.sendTransport) {
350
+ this.sendTransport.close();
351
+ this.sendTransport = undefined;
352
+ }
303
353
  messageJson = { to: "self", type: SFUMessageType.OnCreateTransports, message: SFUMessageType.OnCreateTransports };
304
354
  this.sendSFUMessageToSocket(messageJson);
305
355
  return [2 /*return*/];
@@ -336,7 +386,11 @@ var SFUHandler = /** @class */ (function (_super) {
336
386
  allProducers.forEach(function (eachProducer) {
337
387
  var producerId = eachProducer.id;
338
388
  var consumedProducer = _this.consumers.find(function (eachConsumer) { return eachConsumer.producerId === producerId; });
339
- if (!consumedProducer) {
389
+ if (!consumedProducer || consumedProducer.closed) {
390
+ if (consumedProducer) {
391
+ consumedProducer.close();
392
+ _this.consumers = _this.consumers.filter(function (eachConsumer) { return eachConsumer.producerId !== producerId; });
393
+ }
340
394
  _this.onNewProducer({ data: { message: { producer: eachProducer } } });
341
395
  }
342
396
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-client",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",