@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/cjs/index.js CHANGED
@@ -8773,17 +8773,25 @@ function setMaxBandwidth(parsedSdp, maxBandwidth) {
8773
8773
  mline.bandwidth = new BandwidthLine('TIAS', maxBandwidth);
8774
8774
  });
8775
8775
  }
8776
- function setupBundle(parsedSdp, bundlePolicy) {
8776
+ function setupBundle(parsedSdp, bundlePolicy, midMap) {
8777
8777
  if (bundlePolicy === 'max-compat') {
8778
- const audioMids = parsedSdp.avMedia
8779
- .filter((m) => m.type === 'audio')
8780
- .map((m) => m.mid);
8781
- const videoMids = parsedSdp.avMedia
8782
- .filter((m) => m.type === 'video')
8783
- .map((m) => m.mid);
8778
+ const audioMainMids = midMap.get(MediaType.AudioMain);
8779
+ const videoMainMids = midMap.get(MediaType.VideoMain);
8780
+ const audioContentMids = midMap.get(MediaType.AudioSlides);
8781
+ const videoContentMids = midMap.get(MediaType.VideoSlides);
8784
8782
  parsedSdp.session.groups.splice(0, parsedSdp.session.groups.length);
8785
- parsedSdp.session.groups.push(new BundleGroupLine(audioMids));
8786
- parsedSdp.session.groups.push(new BundleGroupLine(videoMids));
8783
+ if (audioMainMids) {
8784
+ parsedSdp.session.groups.push(new BundleGroupLine(audioMainMids));
8785
+ }
8786
+ if (videoMainMids) {
8787
+ parsedSdp.session.groups.push(new BundleGroupLine(videoMainMids));
8788
+ }
8789
+ if (audioContentMids) {
8790
+ parsedSdp.session.groups.push(new BundleGroupLine(audioContentMids));
8791
+ }
8792
+ if (videoContentMids) {
8793
+ parsedSdp.session.groups.push(new BundleGroupLine(videoContentMids));
8794
+ }
8787
8795
  }
8788
8796
  }
8789
8797
  function filterRecvOnlyMlines(parsedSdp) {
@@ -9575,6 +9583,8 @@ class MultistreamConnection extends EventEmitter {
9575
9583
  this.pendingJmpTasks = [];
9576
9584
  this.metricsCallback = () => { };
9577
9585
  this.overuseUpdateCallback = () => { };
9586
+ this.midMap = new Map();
9587
+ this.currentMid = 0;
9578
9588
  this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
9579
9589
  logger.info(`Creating multistream connection with options ${JSON.stringify(this.options)}`);
9580
9590
  this.initializePeerConnection();
@@ -9593,10 +9603,23 @@ class MultistreamConnection extends EventEmitter {
9593
9603
  this.createSendTransceiver(MediaType.AudioSlides, contentSceneId);
9594
9604
  }
9595
9605
  }
9606
+ addMid(mediaType) {
9607
+ const mid = this.currentMid++;
9608
+ const mids = this.midMap.get(mediaType) || [];
9609
+ mids.push(`${mid}`);
9610
+ this.midMap.set(mediaType, mids);
9611
+ }
9612
+ clearMids() {
9613
+ this.midMap = new Map();
9614
+ this.currentMid = 0;
9615
+ }
9596
9616
  initializePeerConnection() {
9597
9617
  var _a;
9598
9618
  (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
9599
- this.pc = new PeerConnection({ iceServers: this.options.iceServers });
9619
+ this.pc = new PeerConnection({
9620
+ iceServers: this.options.iceServers,
9621
+ bundlePolicy: this.options.bundlePolicy,
9622
+ });
9600
9623
  this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => this.emit(exports.MultistreamConnectionEventNames.ConnectionStateUpdate, state));
9601
9624
  this.attachMetricsObserver();
9602
9625
  this.createDataChannel();
@@ -9618,6 +9641,7 @@ class MultistreamConnection extends EventEmitter {
9618
9641
  direction: 'sendrecv',
9619
9642
  sendEncodings: sendEncodingsOptions,
9620
9643
  });
9644
+ this.addMid(mediaType);
9621
9645
  const csi = generateCsi(getMediaFamily(mediaType), sceneId);
9622
9646
  this.sendTransceivers.set(mediaType, new SendOnlyTransceiver(rtcTransceiver, csi));
9623
9647
  this.createJmpSession(mediaType);
@@ -9897,6 +9921,7 @@ class MultistreamConnection extends EventEmitter {
9897
9921
  const rtcRtpTransceiver = this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
9898
9922
  direction: 'recvonly',
9899
9923
  });
9924
+ this.addMid(mediaType);
9900
9925
  const recvOnlyTransceiver = new ReceiveOnlyTransceiver(rtcRtpTransceiver, (mid) => {
9901
9926
  const ingressSignaler = this.streamSignalerManager.getIngressStreamSignaler(mid);
9902
9927
  if (!ingressSignaler) {
@@ -9960,6 +9985,9 @@ class MultistreamConnection extends EventEmitter {
9960
9985
  }
9961
9986
  createOffer() {
9962
9987
  return __awaiter(this, void 0, void 0, function* () {
9988
+ if (!this.pc.getLocalDescription()) {
9989
+ this.currentMid++;
9990
+ }
9963
9991
  return (this.pc
9964
9992
  .createOffer()
9965
9993
  .then((offer) => {
@@ -10019,7 +10047,7 @@ class MultistreamConnection extends EventEmitter {
10019
10047
  }
10020
10048
  });
10021
10049
  if (getBrowserDetails().name !== 'Firefox') {
10022
- setupBundle(parsed, this.options.bundlePolicy);
10050
+ setupBundle(parsed, this.options.bundlePolicy, this.midMap);
10023
10051
  }
10024
10052
  return parsed.toString();
10025
10053
  }
@@ -10054,7 +10082,7 @@ class MultistreamConnection extends EventEmitter {
10054
10082
  const parsedOffer = parse((_a = this.pc.getLocalDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
10055
10083
  matchMlinesInAnswer(parsedOffer, parsedAnswer, this.streamSignalerManager);
10056
10084
  if (getBrowserDetails().name === 'Firefox') {
10057
- setupBundle(parsedAnswer, this.options.bundlePolicy);
10085
+ setupBundle(parsedAnswer, this.options.bundlePolicy, this.midMap);
10058
10086
  }
10059
10087
  return parsedAnswer.toString();
10060
10088
  }
@@ -10096,11 +10124,13 @@ class MultistreamConnection extends EventEmitter {
10096
10124
  this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
10097
10125
  }
10098
10126
  logger.info(`Renewing multistream connection with options ${JSON.stringify(this.options)}`);
10127
+ this.clearMids();
10099
10128
  this.initializePeerConnection();
10100
10129
  this.streamSignalerManager = new StreamSignalerManager(this.options.streamSignalingMode);
10101
10130
  const mainSceneId = generateSceneId();
10102
10131
  this.sendTransceivers.forEach((transceiver, mediaType) => {
10103
10132
  var _a;
10133
+ this.addMid(mediaType);
10104
10134
  transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
10105
10135
  direction: 'sendrecv',
10106
10136
  sendEncodings: getMediaFamily(mediaType) === MediaFamily.Video
@@ -10116,6 +10146,7 @@ class MultistreamConnection extends EventEmitter {
10116
10146
  });
10117
10147
  this.recvTransceivers.forEach((transceivers, mediaType) => {
10118
10148
  transceivers.forEach((t) => {
10149
+ this.addMid(mediaType);
10119
10150
  t.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
10120
10151
  direction: 'recvonly',
10121
10152
  }));