@webex/web-client-media-engine 1.34.4 → 1.34.6

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
@@ -5773,7 +5773,7 @@ class JmpSession extends EventEmitter$3 {
5773
5773
  }
5774
5774
 
5775
5775
  class MediaRequest {
5776
- constructor(policy, policySpecificInfo, receiveSlots, maxPayloadBitsPerSecond, codecInfos) {
5776
+ constructor(policy, policySpecificInfo, receiveSlots, maxPayloadBitsPerSecond, codecInfos = []) {
5777
5777
  this.policy = policy;
5778
5778
  this.policySpecificInfo = policySpecificInfo;
5779
5779
  this.receiveSlots = receiveSlots;
@@ -6855,6 +6855,22 @@ class FingerprintLine extends Line {
6855
6855
  }
6856
6856
  FingerprintLine.regex = new RegExp(`^fingerprint:(${REST})`);
6857
6857
 
6858
+ function parseFmtpParams(fmtpParams) {
6859
+ fmtpParams = fmtpParams.replace(/^a=fmtp:\d+\x20/, '');
6860
+ const fmtpObj = new Map();
6861
+ if (/^\d+([/-]\d+)+$/.test(fmtpParams)) {
6862
+ fmtpObj.set(fmtpParams, undefined);
6863
+ return fmtpObj;
6864
+ }
6865
+ fmtpParams.split(';').forEach((param) => {
6866
+ const paramArr = param && param.split('=');
6867
+ if (paramArr.length !== 2 || !paramArr[0] || !paramArr[1]) {
6868
+ throw new Error(`Fmtp params is invalid with ${fmtpParams}`);
6869
+ }
6870
+ fmtpObj.set(paramArr[0], paramArr[1]);
6871
+ });
6872
+ return fmtpObj;
6873
+ }
6858
6874
  class FmtpLine extends Line {
6859
6875
  constructor(payloadType, params) {
6860
6876
  super();
@@ -6868,10 +6884,18 @@ class FmtpLine extends Line {
6868
6884
  const tokens = line.match(FmtpLine.regex);
6869
6885
  const payloadType = parseInt(tokens[1], 10);
6870
6886
  const params = tokens[2];
6871
- return new FmtpLine(payloadType, params);
6887
+ return new FmtpLine(payloadType, parseFmtpParams(params));
6872
6888
  }
6873
6889
  toSdpLine() {
6874
- return `a=fmtp:${this.payloadType} ${this.params}`;
6890
+ const fmtParams = Array.from(this.params.keys())
6891
+ .map((key) => {
6892
+ if (this.params.get(key) !== undefined) {
6893
+ return `${key}=${this.params.get(key)}`;
6894
+ }
6895
+ return `${key}`;
6896
+ })
6897
+ .join(';');
6898
+ return `a=fmtp:${this.payloadType} ${fmtParams}`;
6875
6899
  }
6876
6900
  }
6877
6901
  FmtpLine.regex = new RegExp(`^fmtp:(${NUM}) (${REST})`);
@@ -7558,7 +7582,7 @@ class ApplicationMediaDescription extends MediaDescription {
7558
7582
 
7559
7583
  class CodecInfo {
7560
7584
  constructor(pt) {
7561
- this.fmtParams = [];
7585
+ this.fmtParams = new Map();
7562
7586
  this.feedback = [];
7563
7587
  this.pt = pt;
7564
7588
  }
@@ -7570,9 +7594,12 @@ class CodecInfo {
7570
7594
  return true;
7571
7595
  }
7572
7596
  if (line instanceof FmtpLine) {
7573
- this.fmtParams.push(line.params);
7574
- if (line.params.indexOf('apt') !== -1) {
7575
- const apt = line.params.split('=')[1];
7597
+ this.fmtParams = new Map([
7598
+ ...Array.from(this.fmtParams.entries()),
7599
+ ...Array.from(line.params.entries()),
7600
+ ]);
7601
+ if (line.params.has('apt')) {
7602
+ const apt = line.params.get('apt');
7576
7603
  this.primaryCodecPt = parseInt(apt, 10);
7577
7604
  }
7578
7605
  return true;
@@ -7589,9 +7616,9 @@ class CodecInfo {
7589
7616
  this.feedback.forEach((fb) => {
7590
7617
  lines.push(new RtcpFbLine(this.pt, fb));
7591
7618
  });
7592
- this.fmtParams.forEach((fmt) => {
7593
- lines.push(new FmtpLine(this.pt, fmt));
7594
- });
7619
+ if (this.fmtParams.size > 0) {
7620
+ lines.push(new FmtpLine(this.pt, this.fmtParams));
7621
+ }
7595
7622
  return lines;
7596
7623
  }
7597
7624
  }
@@ -7937,18 +7964,6 @@ const maxFrameSizeToMaxBitrateMap = new Map([
7937
7964
  [3600, 2500000],
7938
7965
  [8160, 4000000],
7939
7966
  ]);
7940
- function parseFmtpParams(fmtpParams) {
7941
- fmtpParams = fmtpParams.replace(/^a=fmtp:\d+\x20/, '');
7942
- const fmtpObj = {};
7943
- fmtpParams.split(';').forEach((param) => {
7944
- const paramArr = param && param.split('=');
7945
- if (paramArr.length !== 2 || !paramArr[0] || !paramArr[1]) {
7946
- throw new Error(`Fmtp params is invalid with ${fmtpParams}`);
7947
- }
7948
- fmtpObj[paramArr[0]] = paramArr[1];
7949
- });
7950
- return fmtpObj;
7951
- }
7952
7967
  function areProfileLevelIdsCompatible(senderProfileLevelId, receiverProfileLevelId, levelAsymmetryAllowed) {
7953
7968
  const senderProfile = Number.parseInt(`0x${senderProfileLevelId}`, 16);
7954
7969
  const recvProfile = Number.parseInt(`0x${receiverProfileLevelId}`, 16);
@@ -7976,8 +7991,8 @@ function areCodecsCompatible(senderCodec, receiverCodec) {
7976
7991
  return true;
7977
7992
  }
7978
7993
  if (key === 'sdpFmtpLine') {
7979
- const fmtpForSender = parseFmtpParams(senderCodec[key]);
7980
- const fmtpForReceiver = parseFmtpParams(receiverCodec[key]);
7994
+ const fmtpForSender = Object.fromEntries(parseFmtpParams(senderCodec[key]));
7995
+ const fmtpForReceiver = Object.fromEntries(parseFmtpParams(receiverCodec[key]));
7981
7996
  const levelAsymmetryAllowed = Object.keys(fmtpForSender).some((senderFmtpParamKey) => {
7982
7997
  return (senderFmtpParamKey === 'level-asymmetry-allowed' &&
7983
7998
  fmtpForReceiver[senderFmtpParamKey] === '1' &&
@@ -8791,7 +8806,7 @@ function matchMlinesInAnswer(parsedOffer, parsedAnswer, streamSignalerManager) {
8791
8806
  if (answerMline) {
8792
8807
  if (answerMline instanceof AvMediaDescription) {
8793
8808
  [...answerMline.codecs.values()].forEach((ci) => {
8794
- ci.fmtParams.push('x-google-start-bitrate=60000');
8809
+ ci.fmtParams.set('x-google-start-bitrate', '60000');
8795
8810
  });
8796
8811
  }
8797
8812
  return answerMline;
@@ -9045,7 +9060,7 @@ class RidEgressStreamSignaler {
9045
9060
  }
9046
9061
 
9047
9062
  function generateSsrc() {
9048
- return Math.floor(Math.random() * 0xffffffff);
9063
+ return Math.floor(Math.random() * 0xffffffff) + 1;
9049
9064
  }
9050
9065
 
9051
9066
  class SsrcIngressStreamSignaler {
@@ -9925,8 +9940,8 @@ class MultistreamConnection extends EventEmitter {
9925
9940
  [...av.codecs.values()]
9926
9941
  .filter((ci) => ci.name === 'H264')
9927
9942
  .forEach((ci) => {
9928
- ci.fmtParams.push(`max-mbps=${defaultMaxVideoEncodeMbps}`);
9929
- ci.fmtParams.push(`max-fs=${defaultMaxVideoEncodeFrameSize}`);
9943
+ ci.fmtParams.set('max-mbps', `${defaultMaxVideoEncodeMbps}`);
9944
+ ci.fmtParams.set('max-fs', `${defaultMaxVideoEncodeFrameSize}`);
9930
9945
  });
9931
9946
  }
9932
9947
  });