@webex/web-client-media-engine 3.29.3 → 3.30.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/cjs/index.js CHANGED
@@ -7603,7 +7603,10 @@ function getFrameHeightByMaxFs(sourceAspectRatio, requestedMaxFs) {
7603
7603
  const _gcd = gcd(sourceAspectRatio[0], sourceAspectRatio[1]);
7604
7604
  const minNumberRatiosForWidth = sourceAspectRatio[0] / _gcd;
7605
7605
  const minNumberRatiosForHeight = sourceAspectRatio[1] / _gcd;
7606
- return (Math.floor(Math.sqrt((requestedMaxFs * 16 * 16) / (minNumberRatiosForWidth * minNumberRatiosForHeight))) * minNumberRatiosForHeight);
7606
+ const macroBlockSize = 16 * 16;
7607
+ const minRatioNumberByMaxFs = Math.sqrt((requestedMaxFs * macroBlockSize) / (minNumberRatiosForWidth * minNumberRatiosForHeight));
7608
+ const roundedMinRatioNumberByMaxFs = Math.max(Math.floor(minRatioNumberByMaxFs), 1.0);
7609
+ return roundedMinRatioNumberByMaxFs * minNumberRatiosForHeight;
7607
7610
  }
7608
7611
  function getScaleDownRatio(sourceWidth, sourceHeight, maxFs, maxWidth, maxHeight) {
7609
7612
  if (!sourceWidth || !sourceHeight || !maxFs) {
@@ -14504,6 +14507,7 @@ class SendOnlyTransceiver extends Transceiver {
14504
14507
  this.rtxEnabled = false;
14505
14508
  this.streamMuteStateChange = new TypedEvent();
14506
14509
  this.streamPublishStateChange = new TypedEvent();
14510
+ this.streamEnded = new TypedEvent();
14507
14511
  this.negotiationNeeded = new TypedEvent();
14508
14512
  this.namedMediaGroupsChange = new TypedEvent();
14509
14513
  this.requestedIdEncodingParamsMap = new Map();
@@ -14516,6 +14520,7 @@ class SendOnlyTransceiver extends Transceiver {
14516
14520
  this.handleTrackChange = this.handleTrackChange.bind(this);
14517
14521
  this.handleStreamConstraintsChange = this.handleStreamConstraintsChange.bind(this);
14518
14522
  this.handleStreamMuteStateChange = this.handleStreamMuteStateChange.bind(this);
14523
+ this.handleStreamEnded = this.handleStreamEnded.bind(this);
14519
14524
  }
14520
14525
  replaceSenderSource(stream) {
14521
14526
  var _a, _b;
@@ -14547,6 +14552,9 @@ class SendOnlyTransceiver extends Transceiver {
14547
14552
  handleStreamMuteStateChange() {
14548
14553
  this.streamMuteStateChange.emit();
14549
14554
  }
14555
+ handleStreamEnded() {
14556
+ this.streamEnded.emit();
14557
+ }
14550
14558
  get requested() {
14551
14559
  return this.requestedIdEncodingParamsMap.size > 0;
14552
14560
  }
@@ -14569,6 +14577,7 @@ class SendOnlyTransceiver extends Transceiver {
14569
14577
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.LocalStreamEventNames.ConstraintsChange, this.handleStreamConstraintsChange);
14570
14578
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.LocalStreamEventNames.UserMuteStateChange, this.handleStreamMuteStateChange);
14571
14579
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.LocalStreamEventNames.SystemMuteStateChange, this.handleStreamMuteStateChange);
14580
+ oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.StreamEventNames.Ended, this.handleStreamEnded);
14572
14581
  if (this.requested) {
14573
14582
  yield this.replaceSenderSource(newStream);
14574
14583
  }
@@ -14577,6 +14586,7 @@ class SendOnlyTransceiver extends Transceiver {
14577
14586
  newStream === null || newStream === void 0 ? void 0 : newStream.on(exports.LocalStreamEventNames.ConstraintsChange, this.handleStreamConstraintsChange);
14578
14587
  newStream === null || newStream === void 0 ? void 0 : newStream.on(exports.LocalStreamEventNames.UserMuteStateChange, this.handleStreamMuteStateChange);
14579
14588
  newStream === null || newStream === void 0 ? void 0 : newStream.on(exports.LocalStreamEventNames.SystemMuteStateChange, this.handleStreamMuteStateChange);
14589
+ newStream === null || newStream === void 0 ? void 0 : newStream.on(exports.StreamEventNames.Ended, this.handleStreamEnded);
14580
14590
  if ((!oldStream && newStream && !newStream.muted) ||
14581
14591
  (oldStream && !newStream && !oldStream.muted)) {
14582
14592
  this.streamPublishStateChange.emit();
@@ -15058,6 +15068,10 @@ class MultistreamConnection extends EventEmitter$2 {
15058
15068
  this.sendSourceAdvertisement(mediaType);
15059
15069
  this.sendMediaRequestStatus(mediaType);
15060
15070
  });
15071
+ transceiver.streamEnded.on(() => {
15072
+ this.sendSourceAdvertisement(mediaType);
15073
+ this.sendMediaRequestStatus(mediaType);
15074
+ });
15061
15075
  transceiver.negotiationNeeded.on((offerAnswerType) => {
15062
15076
  if (offerAnswerType === OfferAnswerType.Remote) {
15063
15077
  this.emit(exports.MultistreamConnectionEventNames.NegotiationNeeded);
@@ -15287,9 +15301,12 @@ SCTP Max Message Size: ${maxMessageSize}`);
15287
15301
  }
15288
15302
  }
15289
15303
  sendSourceAdvertisement(mediaType) {
15290
- var _a, _b;
15304
+ var _a, _b, _c;
15291
15305
  const transceiver = this.getSendTransceiverOrThrow(mediaType);
15292
- const numLiveSources = ((_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.muted) === false ? 1 : 0;
15306
+ const numLiveSources = ((_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.muted) === false &&
15307
+ ((_b = transceiver.publishedStream) === null || _b === void 0 ? void 0 : _b.readyState) === 'live'
15308
+ ? 1
15309
+ : 0;
15293
15310
  let task;
15294
15311
  if (getMediaFamily(mediaType) === exports.MediaFamily.Video) {
15295
15312
  const sources = this.getVideoStreamStates(mediaType);
@@ -15313,7 +15330,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
15313
15330
  .get(mediaType)) === null || _a === void 0 ? void 0 : _a.sendSourceAdvertisement(1, numLiveSources, mediaType === exports.MediaType.AudioMain ? transceiver.namedMediaGroups : []);
15314
15331
  };
15315
15332
  }
15316
- if (((_b = this.dataChannel) === null || _b === void 0 ? void 0 : _b.readyState) === 'open') {
15333
+ if (((_c = this.dataChannel) === null || _c === void 0 ? void 0 : _c.readyState) === 'open') {
15317
15334
  task();
15318
15335
  }
15319
15336
  else {