@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/esm/index.js CHANGED
@@ -9418,6 +9418,8 @@ function deepCopy(source) {
9418
9418
  : source;
9419
9419
  }
9420
9420
 
9421
+ const ipv4Regex = /(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.)(\d{1,3}\b)/g;
9422
+ const ipv6Regex = /(\b[\da-fA-F]{1,4}(:[\da-fA-F]{1,4}){7}\b)/g;
9421
9423
  function matchMediaDescriptionsInAnswer(parsedOffer, parsedAnswer) {
9422
9424
  parsedAnswer.session.groups = parsedOffer.session.groups;
9423
9425
  parsedAnswer.media = parsedOffer.media.map((offerMediaDescription) => {
@@ -9505,6 +9507,15 @@ function injectDummyCandidates(mediaDescription) {
9505
9507
  mediaDescription.addLine(new CandidateLine('dummy2', 1, 'tcp', 2, '0.0.0.0', 9, 'host'));
9506
9508
  mediaDescription.addLine(new CandidateLine('dummy3', 1, 'udp', 1, '0.0.0.0', 9, 'relay'));
9507
9509
  }
9510
+ function maskIp(sdp) {
9511
+ let maskedSdp = sdp.replace(ipv4Regex, (match, firstOctets) => {
9512
+ return `${firstOctets}0`;
9513
+ });
9514
+ maskedSdp = maskedSdp.replace(ipv6Regex, (match) => {
9515
+ return match.replace(/:[\da-fA-F]{1,4}$/, ':0');
9516
+ });
9517
+ return maskedSdp;
9518
+ }
9508
9519
  function removeMidRidExtensions(mediaDescription) {
9509
9520
  mediaDescription.extMaps.forEach((extMapLine, extId, extMap) => {
9510
9521
  if (/^urn:ietf:params:rtp-hdrext:sdes:(?:mid|rtp-stream-id|repaired-rtp-stream-id)$/.test(extMapLine.uri)) {
@@ -14213,6 +14224,22 @@ class SendOnlyTransceiver extends Transceiver {
14213
14224
  }));
14214
14225
  });
14215
14226
  }
14227
+ getRequestedBitrate(ssrc) {
14228
+ const index = this.senderIds.findIndex((streamId) => streamId.ssrc === ssrc);
14229
+ if (this.requestedIdEncodingParamsMap.has(index)) {
14230
+ const encodingParams = this.requestedIdEncodingParamsMap.get(index);
14231
+ return encodingParams === null || encodingParams === void 0 ? void 0 : encodingParams.maxPayloadBitsPerSecond;
14232
+ }
14233
+ return undefined;
14234
+ }
14235
+ getRequestedFrameSize(ssrc) {
14236
+ const index = this.senderIds.findIndex((streamId) => streamId.ssrc === ssrc);
14237
+ if (this.requestedIdEncodingParamsMap.has(index)) {
14238
+ const encodingParams = this.requestedIdEncodingParamsMap.get(index);
14239
+ return encodingParams === null || encodingParams === void 0 ? void 0 : encodingParams.maxFs;
14240
+ }
14241
+ return undefined;
14242
+ }
14216
14243
  isSimulcastEnabled() {
14217
14244
  const params = this.sender.getParameters();
14218
14245
  return params.encodings.length > 1;
@@ -14842,7 +14869,15 @@ class MultistreamConnection extends EventEmitter$2 {
14842
14869
  logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
14843
14870
  }
14844
14871
  offer.sdp = this.preProcessLocalOffer(offer.sdp);
14845
- yield this.pc.setLocalDescription(offer);
14872
+ yield this.pc
14873
+ .setLocalDescription(offer)
14874
+ .then(() => __awaiter$1(this, void 0, void 0, function* () {
14875
+ logger.info('this.pc.setLocalDescription() resolved');
14876
+ }))
14877
+ .catch((error) => {
14878
+ var _a;
14879
+ logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp((_a = offer.sdp) !== null && _a !== void 0 ? _a : '')}`);
14880
+ });
14846
14881
  const sdpToSend = this.prepareLocalOfferForRemoteServer((_a = this.pc.getLocalDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
14847
14882
  createOfferResolve({ type: 'offer', sdp: sdpToSend });
14848
14883
  if (this.currentCreateOfferId > createOfferId) {
@@ -14868,7 +14903,9 @@ class MultistreamConnection extends EventEmitter$2 {
14868
14903
  logErrorAndThrow(WcmeErrorType.SET_ANSWER_FAILED, `Call to setAnswer without having previously called createOffer.`);
14869
14904
  }
14870
14905
  logger.info('calling this.pc.setRemoteDescription()');
14871
- return this.pc.setRemoteDescription({ type: 'answer', sdp }).then(() => __awaiter$1(this, void 0, void 0, function* () {
14906
+ return this.pc
14907
+ .setRemoteDescription({ type: 'answer', sdp })
14908
+ .then(() => __awaiter$1(this, void 0, void 0, function* () {
14872
14909
  logger.info('this.pc.setRemoteDescription() resolved');
14873
14910
  if (this.setAnswerResolve) {
14874
14911
  this.setAnswerResolve();
@@ -14877,7 +14914,10 @@ class MultistreamConnection extends EventEmitter$2 {
14877
14914
  else {
14878
14915
  logger.debug(`setAnswerResolve function was cleared between setAnswer and result of setRemoteDescription`);
14879
14916
  }
14880
- }));
14917
+ }))
14918
+ .catch((error) => {
14919
+ logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp(answer)}`);
14920
+ });
14881
14921
  });
14882
14922
  }
14883
14923
  doLocalOfferAnswer() {
@@ -14888,9 +14928,24 @@ class MultistreamConnection extends EventEmitter$2 {
14888
14928
  logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
14889
14929
  }
14890
14930
  offer.sdp = this.preProcessLocalOffer(offer.sdp);
14891
- yield this.pc.setLocalDescription(offer);
14931
+ yield this.pc
14932
+ .setLocalDescription(offer)
14933
+ .then(() => __awaiter$1(this, void 0, void 0, function* () {
14934
+ logger.info('this.pc.setLocalDescription() resolved');
14935
+ }))
14936
+ .catch((error) => {
14937
+ var _a;
14938
+ logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp((_a = offer.sdp) !== null && _a !== void 0 ? _a : '')}`);
14939
+ });
14892
14940
  const answer = this.preProcessRemoteAnswer((_a = this.pc.getRemoteDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
14893
- return this.pc.setRemoteDescription({ type: 'answer', sdp: answer });
14941
+ return this.pc
14942
+ .setRemoteDescription({ type: 'answer', sdp: answer })
14943
+ .then(() => __awaiter$1(this, void 0, void 0, function* () {
14944
+ logger.info('this.pc.setRemoteDescription() resolved');
14945
+ }))
14946
+ .catch((error) => {
14947
+ logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, `Error ${error}. SDP: ${maskIp(answer)}`);
14948
+ });
14894
14949
  });
14895
14950
  }
14896
14951
  queueLocalOfferAnswer() {
@@ -15020,6 +15075,17 @@ class MultistreamConnection extends EventEmitter$2 {
15020
15075
  }
15021
15076
  });
15022
15077
  jmpSession.sendRequests(streamRequests.map((sr) => sr._toJmpStreamRequest()));
15078
+ streamRequests.forEach((sr) => {
15079
+ var _a;
15080
+ const isAffectedInStreamRequest = (t) => sr.receiveSlots.some((rs) => rs.id && compareStreamIds(rs.id, t.receiverId));
15081
+ const affectedTransceivers = (_a = this.recvTransceivers
15082
+ .get(mediaType)) === null || _a === void 0 ? void 0 : _a.filter(isAffectedInStreamRequest);
15083
+ affectedTransceivers === null || affectedTransceivers === void 0 ? void 0 : affectedTransceivers.forEach((t) => {
15084
+ var _a, _b;
15085
+ t.requestedBitrate = sr.maxPayloadBitsPerSecond;
15086
+ t.requestedFrameSize = (_b = (_a = sr.codecInfos[0]) === null || _a === void 0 ? void 0 : _a.h264) === null || _b === void 0 ? void 0 : _b.maxFs;
15087
+ });
15088
+ });
15023
15089
  };
15024
15090
  if (((_a = this.dataChannel) === null || _a === void 0 ? void 0 : _a.readyState) === 'open') {
15025
15091
  task();
@@ -15092,6 +15158,8 @@ class MultistreamConnection extends EventEmitter$2 {
15092
15158
  statsToModify.mid = transceiver.mid;
15093
15159
  statsToModify.csi = transceiver.csi;
15094
15160
  statsToModify.calliopeMediaType = mediaType;
15161
+ statsToModify.requestedBitrate = transceiver.getRequestedBitrate(senderStats.ssrc);
15162
+ statsToModify.requestedFrameSize = transceiver.getRequestedFrameSize(senderStats.ssrc);
15095
15163
  const trackSettings = (_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.getSettings();
15096
15164
  if (trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate) {
15097
15165
  statsToModify.targetFrameRate = trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate;
@@ -15114,6 +15182,8 @@ class MultistreamConnection extends EventEmitter$2 {
15114
15182
  statsToModify.mid = (_a = transceiver.receiveSlot.id) === null || _a === void 0 ? void 0 : _a.mid;
15115
15183
  statsToModify.csi = transceiver.receiveSlot.currentRxCsi;
15116
15184
  statsToModify.calliopeMediaType = mediaType;
15185
+ statsToModify.requestedBitrate = transceiver.requestedBitrate;
15186
+ statsToModify.requestedFrameSize = transceiver.requestedFrameSize;
15117
15187
  Object.assign(statsToModify, transceiver.receiverId);
15118
15188
  stats.set(receiverStats.id, statsToModify);
15119
15189
  }