vani-meeting-client 2.3.6 → 2.3.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.
@@ -140,21 +140,42 @@ var WebrtcHandler = /** @class */ (function (_super) {
140
140
  switch (_c.label) {
141
141
  case 0:
142
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; });
143
- if (!!transceiver) return [3 /*break*/, 3];
143
+ if (!!transceiver) return [3 /*break*/, 1];
144
144
  this.printLogIfRequired("addTransceiverifRequired", eachKind);
145
145
  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; });
146
146
  newTransceiver = void 0;
147
- if (!(realTrack && realTrack.track)) return [3 /*break*/, 2];
148
- this.printLogIfRequired("addTransceiverifRequired track real", eachKind, realTrack.track);
149
- return [4 /*yield*/, peerConnection.rtcPeerConnection.addTrack(realTrack.track)
147
+ if (realTrack && realTrack.track) {
148
+ this.printLogIfRequired("addTransceiverifRequired track real", eachKind, realTrack.track);
149
+ // newTransceiver = await peerConnection.rtcPeerConnection.addTrack(realTrack.track)
150
+ if (realTrack.track.kind === 'audio') {
151
+ newTransceiver = peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, {
152
+ direction: 'sendonly',
153
+ sendEncodings: [
154
+ {
155
+ maxBitrate: 32000,
156
+ priority: 'high',
157
+ networkPriority: 'high',
158
+ }
159
+ ]
160
+ });
161
+ }
162
+ else if (realTrack.track.kind === 'video') {
163
+ newTransceiver = peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, {
164
+ direction: 'sendonly',
165
+ sendEncodings: [{
166
+ maxBitrate: 500000,
167
+ priority: 'low',
168
+ networkPriority: 'low',
169
+ }]
170
+ });
171
+ }
150
172
  // newTransceiver = await peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, { direction: "sendrecv" })
151
- ];
152
- case 1:
153
- newTransceiver = _c.sent();
154
- // newTransceiver = await peerConnection.rtcPeerConnection.addTransceiver(realTrack.track, { direction: "sendrecv" })
155
- this.printLogIfRequired("addTransceiverifRequired track real end", eachKind, realTrack.track);
156
- return [3 /*break*/, 2];
157
- case 2:
173
+ this.printLogIfRequired("addTransceiverifRequired track real end", eachKind, realTrack.track);
174
+ }
175
+ else {
176
+ // this.printLogIfRequired("addTransceiverifRequired track fake",eachKind)
177
+ // newTransceiver = await peerConnection.rtcPeerConnection.addTransceiver(eachKind, { direction: "sendrecv" })
178
+ }
158
179
  if (eachKind === 'audio') {
159
180
  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; });
160
181
  if (transceiver) {
@@ -162,21 +183,21 @@ var WebrtcHandler = /** @class */ (function (_super) {
162
183
  }
163
184
  // this.setOpusParams(newTransceiver);
164
185
  }
165
- return [3 /*break*/, 5];
166
- case 3:
167
- if (!shouldReplaceIfExist) return [3 /*break*/, 5];
186
+ return [3 /*break*/, 3];
187
+ case 1:
188
+ if (!shouldReplaceIfExist) return [3 /*break*/, 3];
168
189
  realTrack = (_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.getAllSelfTracks().find(function (t) { var _a; return ((_a = t.track) === null || _a === void 0 ? void 0 : _a.kind) === eachKind; });
169
- if (!(realTrack && realTrack.track)) return [3 /*break*/, 5];
190
+ if (!(realTrack && realTrack.track)) return [3 /*break*/, 3];
170
191
  this.printLogIfRequired("transceiver.sender.", transceiver.sender, eachKind);
171
192
  return [4 /*yield*/, transceiver.sender.replaceTrack(realTrack.track)];
172
- case 4:
193
+ case 2:
173
194
  _c.sent();
174
195
  if (eachKind === 'audio') {
175
196
  this.applyAudioPriority(transceiver);
176
197
  // this.setOpusParams(newTransceiver);
177
198
  }
178
- _c.label = 5;
179
- case 5: return [2 /*return*/];
199
+ _c.label = 3;
200
+ case 3: return [2 /*return*/];
180
201
  }
181
202
  });
182
203
  });
@@ -346,15 +367,18 @@ var WebrtcHandler = /** @class */ (function (_super) {
346
367
  peerConnectionObject.remoteAnswer = data.sdp;
347
368
  }
348
369
  peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
349
- if (!peerConnection) return [3 /*break*/, 2];
370
+ if (!peerConnection) return [3 /*break*/, 3];
371
+ if (!(peerConnection.signalingState === 'have-local-offer')) return [3 /*break*/, 2];
350
372
  return [4 /*yield*/, peerConnection.setRemoteDescription({ type: 'answer', sdp: peerConnectionObject.remoteAnswer })];
351
373
  case 1:
352
374
  _b.sent();
375
+ _b.label = 2;
376
+ case 2:
353
377
  peerConnectionObject.isRtcRestartIceInProgess = false;
354
378
  this.printLogIfRequired("REMOTE SDP", (_a = peerConnection.remoteDescription) === null || _a === void 0 ? void 0 : _a.sdp);
355
379
  this.printLogIfRequired("On New Answer setRemoteDescription", { type: 'answer', sdp: peerConnectionObject.remoteAnswer });
356
- _b.label = 2;
357
- case 2: return [2 /*return*/];
380
+ _b.label = 3;
381
+ case 3: return [2 /*return*/];
358
382
  }
359
383
  });
360
384
  }); };
@@ -789,23 +813,22 @@ var WebrtcHandler = /** @class */ (function (_super) {
789
813
  };
790
814
  _this.applyAudioPriority = function (transceiver) {
791
815
  var _a, _b;
792
- // return;
793
- // ✅ 1. Codec preference — Opus first
816
+ // Codec preference — Opus first
794
817
  var capabilities = (_a = RTCRtpSender.getCapabilities) === null || _a === void 0 ? void 0 : _a.call(RTCRtpSender, 'audio');
795
- if (capabilities === null || capabilities === void 0 ? void 0 : capabilities.codecs) {
796
- var opus = capabilities.codecs.filter(function (c) {
797
- return c.mimeType.toLowerCase() === 'audio/opus';
798
- });
799
- var rest = capabilities.codecs.filter(function (c) {
800
- return c.mimeType.toLowerCase() !== 'audio/opus';
801
- });
802
- transceiver.setCodecPreferences(__spreadArray(__spreadArray([], __read(opus), false), __read(rest), false));
803
- }
804
- // 2. Encoding params bitrate + priority
818
+ if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities.codecs))
819
+ return;
820
+ var opus = capabilities.codecs.filter(function (c) {
821
+ return c.mimeType.toLowerCase() === 'audio/opus';
822
+ });
823
+ var rest = capabilities.codecs.filter(function (c) {
824
+ return c.mimeType.toLowerCase() !== 'audio/opus';
825
+ });
826
+ transceiver.setCodecPreferences(__spreadArray(__spreadArray([], __read(opus), false), __read(rest), false));
827
+ // maxBitrate only priority/networkPriority already set at addTransceiver
805
828
  var params = transceiver.sender.getParameters();
806
829
  if (!((_b = params.encodings) === null || _b === void 0 ? void 0 : _b.length))
807
- params.encodings = [{}];
808
- params.encodings[0] = __assign(__assign({}, params.encodings[0]), { maxBitrate: 32000, priority: 'high', networkPriority: 'high' });
830
+ return; // nothing to update, encoding slot not ready
831
+ params.encodings[0] = __assign(__assign({}, params.encodings[0]), { maxBitrate: 32000 });
809
832
  transceiver.sender.setParameters(params).catch(console.error);
810
833
  };
811
834
  _this.onNewTrack = function (track, receiver, transceiver, remoteParticipant) { return __awaiter(_this, void 0, void 0, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-client",
3
- "version": "2.3.6",
3
+ "version": "2.3.7",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",