@webex/web-client-media-engine 1.37.0 → 1.37.2

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
@@ -8769,17 +8769,25 @@ function setMaxBandwidth(parsedSdp, maxBandwidth) {
8769
8769
  mline.bandwidth = new BandwidthLine('TIAS', maxBandwidth);
8770
8770
  });
8771
8771
  }
8772
- function setupBundle(parsedSdp, bundlePolicy) {
8772
+ function setupBundle(parsedSdp, bundlePolicy, midMap) {
8773
8773
  if (bundlePolicy === 'max-compat') {
8774
- const audioMids = parsedSdp.avMedia
8775
- .filter((m) => m.type === 'audio')
8776
- .map((m) => m.mid);
8777
- const videoMids = parsedSdp.avMedia
8778
- .filter((m) => m.type === 'video')
8779
- .map((m) => m.mid);
8774
+ const audioMainMids = midMap.get(MediaType.AudioMain);
8775
+ const videoMainMids = midMap.get(MediaType.VideoMain);
8776
+ const audioContentMids = midMap.get(MediaType.AudioSlides);
8777
+ const videoContentMids = midMap.get(MediaType.VideoSlides);
8780
8778
  parsedSdp.session.groups.splice(0, parsedSdp.session.groups.length);
8781
- parsedSdp.session.groups.push(new BundleGroupLine(audioMids));
8782
- parsedSdp.session.groups.push(new BundleGroupLine(videoMids));
8779
+ if (audioMainMids) {
8780
+ parsedSdp.session.groups.push(new BundleGroupLine(audioMainMids));
8781
+ }
8782
+ if (videoMainMids) {
8783
+ parsedSdp.session.groups.push(new BundleGroupLine(videoMainMids));
8784
+ }
8785
+ if (audioContentMids) {
8786
+ parsedSdp.session.groups.push(new BundleGroupLine(audioContentMids));
8787
+ }
8788
+ if (videoContentMids) {
8789
+ parsedSdp.session.groups.push(new BundleGroupLine(videoContentMids));
8790
+ }
8783
8791
  }
8784
8792
  }
8785
8793
  function filterRecvOnlyMlines(parsedSdp) {
@@ -9571,6 +9579,8 @@ class MultistreamConnection extends EventEmitter {
9571
9579
  this.pendingJmpTasks = [];
9572
9580
  this.metricsCallback = () => { };
9573
9581
  this.overuseUpdateCallback = () => { };
9582
+ this.midMap = new Map();
9583
+ this.currentMid = 0;
9574
9584
  this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
9575
9585
  logger.info(`Creating multistream connection with options ${JSON.stringify(this.options)}`);
9576
9586
  this.initializePeerConnection();
@@ -9589,10 +9599,23 @@ class MultistreamConnection extends EventEmitter {
9589
9599
  this.createSendTransceiver(MediaType.AudioSlides, contentSceneId);
9590
9600
  }
9591
9601
  }
9602
+ addMid(mediaType) {
9603
+ const mid = this.currentMid++;
9604
+ const mids = this.midMap.get(mediaType) || [];
9605
+ mids.push(`${mid}`);
9606
+ this.midMap.set(mediaType, mids);
9607
+ }
9608
+ clearMids() {
9609
+ this.midMap = new Map();
9610
+ this.currentMid = 0;
9611
+ }
9592
9612
  initializePeerConnection() {
9593
9613
  var _a;
9594
9614
  (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
9595
- this.pc = new PeerConnection({ iceServers: this.options.iceServers });
9615
+ this.pc = new PeerConnection({
9616
+ iceServers: this.options.iceServers,
9617
+ bundlePolicy: this.options.bundlePolicy,
9618
+ });
9596
9619
  this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => this.emit(MultistreamConnectionEventNames.ConnectionStateUpdate, state));
9597
9620
  this.attachMetricsObserver();
9598
9621
  this.createDataChannel();
@@ -9614,6 +9637,7 @@ class MultistreamConnection extends EventEmitter {
9614
9637
  direction: 'sendrecv',
9615
9638
  sendEncodings: sendEncodingsOptions,
9616
9639
  });
9640
+ this.addMid(mediaType);
9617
9641
  const csi = generateCsi(getMediaFamily(mediaType), sceneId);
9618
9642
  this.sendTransceivers.set(mediaType, new SendOnlyTransceiver(rtcTransceiver, csi));
9619
9643
  this.createJmpSession(mediaType);
@@ -9893,6 +9917,7 @@ class MultistreamConnection extends EventEmitter {
9893
9917
  const rtcRtpTransceiver = this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
9894
9918
  direction: 'recvonly',
9895
9919
  });
9920
+ this.addMid(mediaType);
9896
9921
  const recvOnlyTransceiver = new ReceiveOnlyTransceiver(rtcRtpTransceiver, (mid) => {
9897
9922
  const ingressSignaler = this.streamSignalerManager.getIngressStreamSignaler(mid);
9898
9923
  if (!ingressSignaler) {
@@ -9956,6 +9981,9 @@ class MultistreamConnection extends EventEmitter {
9956
9981
  }
9957
9982
  createOffer() {
9958
9983
  return __awaiter(this, void 0, void 0, function* () {
9984
+ if (!this.pc.getLocalDescription()) {
9985
+ this.currentMid++;
9986
+ }
9959
9987
  return (this.pc
9960
9988
  .createOffer()
9961
9989
  .then((offer) => {
@@ -10015,7 +10043,7 @@ class MultistreamConnection extends EventEmitter {
10015
10043
  }
10016
10044
  });
10017
10045
  if (getBrowserDetails().name !== 'Firefox') {
10018
- setupBundle(parsed, this.options.bundlePolicy);
10046
+ setupBundle(parsed, this.options.bundlePolicy, this.midMap);
10019
10047
  }
10020
10048
  return parsed.toString();
10021
10049
  }
@@ -10050,7 +10078,7 @@ class MultistreamConnection extends EventEmitter {
10050
10078
  const parsedOffer = parse((_a = this.pc.getLocalDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
10051
10079
  matchMlinesInAnswer(parsedOffer, parsedAnswer, this.streamSignalerManager);
10052
10080
  if (getBrowserDetails().name === 'Firefox') {
10053
- setupBundle(parsedAnswer, this.options.bundlePolicy);
10081
+ setupBundle(parsedAnswer, this.options.bundlePolicy, this.midMap);
10054
10082
  }
10055
10083
  return parsedAnswer.toString();
10056
10084
  }
@@ -10092,11 +10120,13 @@ class MultistreamConnection extends EventEmitter {
10092
10120
  this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
10093
10121
  }
10094
10122
  logger.info(`Renewing multistream connection with options ${JSON.stringify(this.options)}`);
10123
+ this.clearMids();
10095
10124
  this.initializePeerConnection();
10096
10125
  this.streamSignalerManager = new StreamSignalerManager(this.options.streamSignalingMode);
10097
10126
  const mainSceneId = generateSceneId();
10098
10127
  this.sendTransceivers.forEach((transceiver, mediaType) => {
10099
10128
  var _a;
10129
+ this.addMid(mediaType);
10100
10130
  transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
10101
10131
  direction: 'sendrecv',
10102
10132
  sendEncodings: getMediaFamily(mediaType) === MediaFamily.Video
@@ -10112,6 +10142,7 @@ class MultistreamConnection extends EventEmitter {
10112
10142
  });
10113
10143
  this.recvTransceivers.forEach((transceivers, mediaType) => {
10114
10144
  transceivers.forEach((t) => {
10145
+ this.addMid(mediaType);
10115
10146
  t.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
10116
10147
  direction: 'recvonly',
10117
10148
  }));