@webex/web-client-media-engine 3.12.0 → 3.13.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.
package/dist/cjs/index.js CHANGED
@@ -9422,6 +9422,8 @@ function deepCopy(source) {
9422
9422
  : source;
9423
9423
  }
9424
9424
 
9425
+ const ipv4Regex = /(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.)(\d{1,3}\b)/g;
9426
+ const ipv6Regex = /(\b[\da-fA-F]{1,4}(:[\da-fA-F]{1,4}){7}\b)/g;
9425
9427
  function matchMediaDescriptionsInAnswer(parsedOffer, parsedAnswer) {
9426
9428
  parsedAnswer.session.groups = parsedOffer.session.groups;
9427
9429
  parsedAnswer.media = parsedOffer.media.map((offerMediaDescription) => {
@@ -9509,6 +9511,15 @@ function injectDummyCandidates(mediaDescription) {
9509
9511
  mediaDescription.addLine(new CandidateLine('dummy2', 1, 'tcp', 2, '0.0.0.0', 9, 'host'));
9510
9512
  mediaDescription.addLine(new CandidateLine('dummy3', 1, 'udp', 1, '0.0.0.0', 9, 'relay'));
9511
9513
  }
9514
+ function maskIp(sdp) {
9515
+ let maskedSdp = sdp.replace(ipv4Regex, (match, firstOctets) => {
9516
+ return `${firstOctets}0`;
9517
+ });
9518
+ maskedSdp = maskedSdp.replace(ipv6Regex, (match) => {
9519
+ return match.replace(/:[\da-fA-F]{1,4}$/, ':0');
9520
+ });
9521
+ return maskedSdp;
9522
+ }
9512
9523
  function removeMidRidExtensions(mediaDescription) {
9513
9524
  mediaDescription.extMaps.forEach((extMapLine, extId, extMap) => {
9514
9525
  if (/^urn:ietf:params:rtp-hdrext:sdes:(?:mid|rtp-stream-id|repaired-rtp-stream-id)$/.test(extMapLine.uri)) {
@@ -14217,6 +14228,22 @@ class SendOnlyTransceiver extends Transceiver {
14217
14228
  }));
14218
14229
  });
14219
14230
  }
14231
+ getRequestedBitrate(ssrc) {
14232
+ const index = this.senderIds.findIndex((streamId) => streamId.ssrc === ssrc);
14233
+ if (this.requestedIdEncodingParamsMap.has(index)) {
14234
+ const encodingParams = this.requestedIdEncodingParamsMap.get(index);
14235
+ return encodingParams === null || encodingParams === void 0 ? void 0 : encodingParams.maxPayloadBitsPerSecond;
14236
+ }
14237
+ return undefined;
14238
+ }
14239
+ getRequestedFrameSize(ssrc) {
14240
+ const index = this.senderIds.findIndex((streamId) => streamId.ssrc === ssrc);
14241
+ if (this.requestedIdEncodingParamsMap.has(index)) {
14242
+ const encodingParams = this.requestedIdEncodingParamsMap.get(index);
14243
+ return encodingParams === null || encodingParams === void 0 ? void 0 : encodingParams.maxFs;
14244
+ }
14245
+ return undefined;
14246
+ }
14220
14247
  isSimulcastEnabled() {
14221
14248
  const params = this.sender.getParameters();
14222
14249
  return params.encodings.length > 1;
@@ -14846,7 +14873,15 @@ class MultistreamConnection extends EventEmitter$2 {
14846
14873
  logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
14847
14874
  }
14848
14875
  offer.sdp = this.preProcessLocalOffer(offer.sdp);
14849
- yield this.pc.setLocalDescription(offer);
14876
+ yield this.pc
14877
+ .setLocalDescription(offer)
14878
+ .then(() => __awaiter$1(this, void 0, void 0, function* () {
14879
+ logger.info('this.pc.setLocalDescription() resolved');
14880
+ }))
14881
+ .catch((error) => {
14882
+ var _a;
14883
+ logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp((_a = offer.sdp) !== null && _a !== void 0 ? _a : '')}`);
14884
+ });
14850
14885
  const sdpToSend = this.prepareLocalOfferForRemoteServer((_a = this.pc.getLocalDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
14851
14886
  createOfferResolve({ type: 'offer', sdp: sdpToSend });
14852
14887
  if (this.currentCreateOfferId > createOfferId) {
@@ -14872,7 +14907,9 @@ class MultistreamConnection extends EventEmitter$2 {
14872
14907
  logErrorAndThrow(exports.WcmeErrorType.SET_ANSWER_FAILED, `Call to setAnswer without having previously called createOffer.`);
14873
14908
  }
14874
14909
  logger.info('calling this.pc.setRemoteDescription()');
14875
- return this.pc.setRemoteDescription({ type: 'answer', sdp }).then(() => __awaiter$1(this, void 0, void 0, function* () {
14910
+ return this.pc
14911
+ .setRemoteDescription({ type: 'answer', sdp })
14912
+ .then(() => __awaiter$1(this, void 0, void 0, function* () {
14876
14913
  logger.info('this.pc.setRemoteDescription() resolved');
14877
14914
  if (this.setAnswerResolve) {
14878
14915
  this.setAnswerResolve();
@@ -14881,7 +14918,10 @@ class MultistreamConnection extends EventEmitter$2 {
14881
14918
  else {
14882
14919
  logger.debug(`setAnswerResolve function was cleared between setAnswer and result of setRemoteDescription`);
14883
14920
  }
14884
- }));
14921
+ }))
14922
+ .catch((error) => {
14923
+ logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp(answer)}`);
14924
+ });
14885
14925
  });
14886
14926
  }
14887
14927
  doLocalOfferAnswer() {
@@ -14892,9 +14932,24 @@ class MultistreamConnection extends EventEmitter$2 {
14892
14932
  logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
14893
14933
  }
14894
14934
  offer.sdp = this.preProcessLocalOffer(offer.sdp);
14895
- yield this.pc.setLocalDescription(offer);
14935
+ yield this.pc
14936
+ .setLocalDescription(offer)
14937
+ .then(() => __awaiter$1(this, void 0, void 0, function* () {
14938
+ logger.info('this.pc.setLocalDescription() resolved');
14939
+ }))
14940
+ .catch((error) => {
14941
+ var _a;
14942
+ logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp((_a = offer.sdp) !== null && _a !== void 0 ? _a : '')}`);
14943
+ });
14896
14944
  const answer = this.preProcessRemoteAnswer((_a = this.pc.getRemoteDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
14897
- return this.pc.setRemoteDescription({ type: 'answer', sdp: answer });
14945
+ return this.pc
14946
+ .setRemoteDescription({ type: 'answer', sdp: answer })
14947
+ .then(() => __awaiter$1(this, void 0, void 0, function* () {
14948
+ logger.info('this.pc.setRemoteDescription() resolved');
14949
+ }))
14950
+ .catch((error) => {
14951
+ logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, `Error ${error}. SDP: ${maskIp(answer)}`);
14952
+ });
14898
14953
  });
14899
14954
  }
14900
14955
  queueLocalOfferAnswer() {
@@ -15024,6 +15079,17 @@ class MultistreamConnection extends EventEmitter$2 {
15024
15079
  }
15025
15080
  });
15026
15081
  jmpSession.sendRequests(streamRequests.map((sr) => sr._toJmpStreamRequest()));
15082
+ streamRequests.forEach((sr) => {
15083
+ var _a;
15084
+ const isAffectedInStreamRequest = (t) => sr.receiveSlots.some((rs) => rs.id && compareStreamIds(rs.id, t.receiverId));
15085
+ const affectedTransceivers = (_a = this.recvTransceivers
15086
+ .get(mediaType)) === null || _a === void 0 ? void 0 : _a.filter(isAffectedInStreamRequest);
15087
+ affectedTransceivers === null || affectedTransceivers === void 0 ? void 0 : affectedTransceivers.forEach((t) => {
15088
+ var _a, _b;
15089
+ t.requestedBitrate = sr.maxPayloadBitsPerSecond;
15090
+ t.requestedFrameSize = (_b = (_a = sr.codecInfos[0]) === null || _a === void 0 ? void 0 : _a.h264) === null || _b === void 0 ? void 0 : _b.maxFs;
15091
+ });
15092
+ });
15027
15093
  };
15028
15094
  if (((_a = this.dataChannel) === null || _a === void 0 ? void 0 : _a.readyState) === 'open') {
15029
15095
  task();
@@ -15096,6 +15162,8 @@ class MultistreamConnection extends EventEmitter$2 {
15096
15162
  statsToModify.mid = transceiver.mid;
15097
15163
  statsToModify.csi = transceiver.csi;
15098
15164
  statsToModify.calliopeMediaType = mediaType;
15165
+ statsToModify.requestedBitrate = transceiver.getRequestedBitrate(senderStats.ssrc);
15166
+ statsToModify.requestedFrameSize = transceiver.getRequestedFrameSize(senderStats.ssrc);
15099
15167
  const trackSettings = (_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.getSettings();
15100
15168
  if (trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate) {
15101
15169
  statsToModify.targetFrameRate = trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate;
@@ -15118,6 +15186,8 @@ class MultistreamConnection extends EventEmitter$2 {
15118
15186
  statsToModify.mid = (_a = transceiver.receiveSlot.id) === null || _a === void 0 ? void 0 : _a.mid;
15119
15187
  statsToModify.csi = transceiver.receiveSlot.currentRxCsi;
15120
15188
  statsToModify.calliopeMediaType = mediaType;
15189
+ statsToModify.requestedBitrate = transceiver.requestedBitrate;
15190
+ statsToModify.requestedFrameSize = transceiver.requestedFrameSize;
15121
15191
  Object.assign(statsToModify, transceiver.receiverId);
15122
15192
  stats.set(receiverStats.id, statsToModify);
15123
15193
  }