@webex/web-client-media-engine 1.34.5 → 1.35.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
@@ -4751,10 +4751,11 @@ adapterFactory({window: typeof window === 'undefined' ? undefined : window});
4751
4751
  /**
4752
4752
  * Creates an RTCPeerConnection.
4753
4753
  *
4754
+ * @param configuration - Config to the RTCPeerConnection constructor.
4754
4755
  * @returns An RTCPeerConnection instance.
4755
4756
  */
4756
- function createRTCPeerConnection() {
4757
- return new RTCPeerConnection();
4757
+ function createRTCPeerConnection(configuration) {
4758
+ return new RTCPeerConnection(configuration);
4758
4759
  }
4759
4760
 
4760
4761
  /**
@@ -4776,11 +4777,13 @@ var PeerConnectionEvents;
4776
4777
  class PeerConnection extends EventEmitter$2 {
4777
4778
  /**
4778
4779
  * Creates an instance of the RTCPeerConnection.
4780
+ *
4781
+ * @param configuration - Config to the RTCPeerConnection constructor.
4779
4782
  */
4780
- constructor() {
4783
+ constructor(configuration) {
4781
4784
  super();
4782
4785
  logger$3.log('PeerConnection init');
4783
- this.pc = createRTCPeerConnection();
4786
+ this.pc = createRTCPeerConnection(configuration);
4784
4787
  this.connectionStateHandler = new ConnectionStateHandler(() => {
4785
4788
  return {
4786
4789
  connectionState: this.pc.connectionState,
@@ -5773,7 +5776,7 @@ class JmpSession extends EventEmitter$3 {
5773
5776
  }
5774
5777
 
5775
5778
  class MediaRequest {
5776
- constructor(policy, policySpecificInfo, receiveSlots, maxPayloadBitsPerSecond, codecInfos) {
5779
+ constructor(policy, policySpecificInfo, receiveSlots, maxPayloadBitsPerSecond, codecInfos = []) {
5777
5780
  this.policy = policy;
5778
5781
  this.policySpecificInfo = policySpecificInfo;
5779
5782
  this.receiveSlots = receiveSlots;
@@ -6855,6 +6858,22 @@ class FingerprintLine extends Line {
6855
6858
  }
6856
6859
  FingerprintLine.regex = new RegExp(`^fingerprint:(${REST})`);
6857
6860
 
6861
+ function parseFmtpParams(fmtpParams) {
6862
+ fmtpParams = fmtpParams.replace(/^a=fmtp:\d+\x20/, '');
6863
+ const fmtpObj = new Map();
6864
+ if (/^\d+([/-]\d+)+$/.test(fmtpParams)) {
6865
+ fmtpObj.set(fmtpParams, undefined);
6866
+ return fmtpObj;
6867
+ }
6868
+ fmtpParams.split(';').forEach((param) => {
6869
+ const paramArr = param && param.split('=');
6870
+ if (paramArr.length !== 2 || !paramArr[0] || !paramArr[1]) {
6871
+ throw new Error(`Fmtp params is invalid with ${fmtpParams}`);
6872
+ }
6873
+ fmtpObj.set(paramArr[0], paramArr[1]);
6874
+ });
6875
+ return fmtpObj;
6876
+ }
6858
6877
  class FmtpLine extends Line {
6859
6878
  constructor(payloadType, params) {
6860
6879
  super();
@@ -6868,10 +6887,18 @@ class FmtpLine extends Line {
6868
6887
  const tokens = line.match(FmtpLine.regex);
6869
6888
  const payloadType = parseInt(tokens[1], 10);
6870
6889
  const params = tokens[2];
6871
- return new FmtpLine(payloadType, params);
6890
+ return new FmtpLine(payloadType, parseFmtpParams(params));
6872
6891
  }
6873
6892
  toSdpLine() {
6874
- return `a=fmtp:${this.payloadType} ${this.params}`;
6893
+ const fmtParams = Array.from(this.params.keys())
6894
+ .map((key) => {
6895
+ if (this.params.get(key) !== undefined) {
6896
+ return `${key}=${this.params.get(key)}`;
6897
+ }
6898
+ return `${key}`;
6899
+ })
6900
+ .join(';');
6901
+ return `a=fmtp:${this.payloadType} ${fmtParams}`;
6875
6902
  }
6876
6903
  }
6877
6904
  FmtpLine.regex = new RegExp(`^fmtp:(${NUM}) (${REST})`);
@@ -7558,7 +7585,7 @@ class ApplicationMediaDescription extends MediaDescription {
7558
7585
 
7559
7586
  class CodecInfo {
7560
7587
  constructor(pt) {
7561
- this.fmtParams = [];
7588
+ this.fmtParams = new Map();
7562
7589
  this.feedback = [];
7563
7590
  this.pt = pt;
7564
7591
  }
@@ -7570,9 +7597,12 @@ class CodecInfo {
7570
7597
  return true;
7571
7598
  }
7572
7599
  if (line instanceof FmtpLine) {
7573
- this.fmtParams.push(line.params);
7574
- if (line.params.indexOf('apt') !== -1) {
7575
- const apt = line.params.split('=')[1];
7600
+ this.fmtParams = new Map([
7601
+ ...Array.from(this.fmtParams.entries()),
7602
+ ...Array.from(line.params.entries()),
7603
+ ]);
7604
+ if (line.params.has('apt')) {
7605
+ const apt = line.params.get('apt');
7576
7606
  this.primaryCodecPt = parseInt(apt, 10);
7577
7607
  }
7578
7608
  return true;
@@ -7589,9 +7619,9 @@ class CodecInfo {
7589
7619
  this.feedback.forEach((fb) => {
7590
7620
  lines.push(new RtcpFbLine(this.pt, fb));
7591
7621
  });
7592
- this.fmtParams.forEach((fmt) => {
7593
- lines.push(new FmtpLine(this.pt, fmt));
7594
- });
7622
+ if (this.fmtParams.size > 0) {
7623
+ lines.push(new FmtpLine(this.pt, this.fmtParams));
7624
+ }
7595
7625
  return lines;
7596
7626
  }
7597
7627
  }
@@ -7937,18 +7967,6 @@ const maxFrameSizeToMaxBitrateMap = new Map([
7937
7967
  [3600, 2500000],
7938
7968
  [8160, 4000000],
7939
7969
  ]);
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
7970
  function areProfileLevelIdsCompatible(senderProfileLevelId, receiverProfileLevelId, levelAsymmetryAllowed) {
7953
7971
  const senderProfile = Number.parseInt(`0x${senderProfileLevelId}`, 16);
7954
7972
  const recvProfile = Number.parseInt(`0x${receiverProfileLevelId}`, 16);
@@ -7976,8 +7994,8 @@ function areCodecsCompatible(senderCodec, receiverCodec) {
7976
7994
  return true;
7977
7995
  }
7978
7996
  if (key === 'sdpFmtpLine') {
7979
- const fmtpForSender = parseFmtpParams(senderCodec[key]);
7980
- const fmtpForReceiver = parseFmtpParams(receiverCodec[key]);
7997
+ const fmtpForSender = Object.fromEntries(parseFmtpParams(senderCodec[key]));
7998
+ const fmtpForReceiver = Object.fromEntries(parseFmtpParams(receiverCodec[key]));
7981
7999
  const levelAsymmetryAllowed = Object.keys(fmtpForSender).some((senderFmtpParamKey) => {
7982
8000
  return (senderFmtpParamKey === 'level-asymmetry-allowed' &&
7983
8001
  fmtpForReceiver[senderFmtpParamKey] === '1' &&
@@ -8791,7 +8809,7 @@ function matchMlinesInAnswer(parsedOffer, parsedAnswer, streamSignalerManager) {
8791
8809
  if (answerMline) {
8792
8810
  if (answerMline instanceof AvMediaDescription) {
8793
8811
  [...answerMline.codecs.values()].forEach((ci) => {
8794
- ci.fmtParams.push('x-google-start-bitrate=60000');
8812
+ ci.fmtParams.set('x-google-start-bitrate', '60000');
8795
8813
  });
8796
8814
  }
8797
8815
  return answerMline;
@@ -9501,6 +9519,7 @@ const defaultMultistreamConnectionOptions = {
9501
9519
  disableSimulcast: false,
9502
9520
  streamSignalingMode: 'SSRC',
9503
9521
  bundlePolicy: 'compat',
9522
+ iceServers: undefined,
9504
9523
  };
9505
9524
  class MultistreamConnection extends EventEmitter {
9506
9525
  constructor(userOptions = {}) {
@@ -9532,7 +9551,7 @@ class MultistreamConnection extends EventEmitter {
9532
9551
  initializePeerConnection() {
9533
9552
  var _a;
9534
9553
  (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
9535
- this.pc = new PeerConnection();
9554
+ this.pc = new PeerConnection({ iceServers: this.options.iceServers });
9536
9555
  this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => this.emit(MultistreamConnectionEventNames.ConnectionStateUpdate, state));
9537
9556
  this.attachMetricsObserver();
9538
9557
  this.createDataChannel();
@@ -9925,8 +9944,8 @@ class MultistreamConnection extends EventEmitter {
9925
9944
  [...av.codecs.values()]
9926
9945
  .filter((ci) => ci.name === 'H264')
9927
9946
  .forEach((ci) => {
9928
- ci.fmtParams.push(`max-mbps=${defaultMaxVideoEncodeMbps}`);
9929
- ci.fmtParams.push(`max-fs=${defaultMaxVideoEncodeFrameSize}`);
9947
+ ci.fmtParams.set('max-mbps', `${defaultMaxVideoEncodeMbps}`);
9948
+ ci.fmtParams.set('max-fs', `${defaultMaxVideoEncodeFrameSize}`);
9930
9949
  });
9931
9950
  }
9932
9951
  });