@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/esm/index.js CHANGED
@@ -7599,7 +7599,10 @@ function getFrameHeightByMaxFs(sourceAspectRatio, requestedMaxFs) {
7599
7599
  const _gcd = gcd(sourceAspectRatio[0], sourceAspectRatio[1]);
7600
7600
  const minNumberRatiosForWidth = sourceAspectRatio[0] / _gcd;
7601
7601
  const minNumberRatiosForHeight = sourceAspectRatio[1] / _gcd;
7602
- return (Math.floor(Math.sqrt((requestedMaxFs * 16 * 16) / (minNumberRatiosForWidth * minNumberRatiosForHeight))) * minNumberRatiosForHeight);
7602
+ const macroBlockSize = 16 * 16;
7603
+ const minRatioNumberByMaxFs = Math.sqrt((requestedMaxFs * macroBlockSize) / (minNumberRatiosForWidth * minNumberRatiosForHeight));
7604
+ const roundedMinRatioNumberByMaxFs = Math.max(Math.floor(minRatioNumberByMaxFs), 1.0);
7605
+ return roundedMinRatioNumberByMaxFs * minNumberRatiosForHeight;
7603
7606
  }
7604
7607
  function getScaleDownRatio(sourceWidth, sourceHeight, maxFs, maxWidth, maxHeight) {
7605
7608
  if (!sourceWidth || !sourceHeight || !maxFs) {
@@ -14500,6 +14503,7 @@ class SendOnlyTransceiver extends Transceiver {
14500
14503
  this.rtxEnabled = false;
14501
14504
  this.streamMuteStateChange = new TypedEvent();
14502
14505
  this.streamPublishStateChange = new TypedEvent();
14506
+ this.streamEnded = new TypedEvent();
14503
14507
  this.negotiationNeeded = new TypedEvent();
14504
14508
  this.namedMediaGroupsChange = new TypedEvent();
14505
14509
  this.requestedIdEncodingParamsMap = new Map();
@@ -14512,6 +14516,7 @@ class SendOnlyTransceiver extends Transceiver {
14512
14516
  this.handleTrackChange = this.handleTrackChange.bind(this);
14513
14517
  this.handleStreamConstraintsChange = this.handleStreamConstraintsChange.bind(this);
14514
14518
  this.handleStreamMuteStateChange = this.handleStreamMuteStateChange.bind(this);
14519
+ this.handleStreamEnded = this.handleStreamEnded.bind(this);
14515
14520
  }
14516
14521
  replaceSenderSource(stream) {
14517
14522
  var _a, _b;
@@ -14543,6 +14548,9 @@ class SendOnlyTransceiver extends Transceiver {
14543
14548
  handleStreamMuteStateChange() {
14544
14549
  this.streamMuteStateChange.emit();
14545
14550
  }
14551
+ handleStreamEnded() {
14552
+ this.streamEnded.emit();
14553
+ }
14546
14554
  get requested() {
14547
14555
  return this.requestedIdEncodingParamsMap.size > 0;
14548
14556
  }
@@ -14565,6 +14573,7 @@ class SendOnlyTransceiver extends Transceiver {
14565
14573
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(LocalStreamEventNames.ConstraintsChange, this.handleStreamConstraintsChange);
14566
14574
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(LocalStreamEventNames.UserMuteStateChange, this.handleStreamMuteStateChange);
14567
14575
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(LocalStreamEventNames.SystemMuteStateChange, this.handleStreamMuteStateChange);
14576
+ oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(StreamEventNames.Ended, this.handleStreamEnded);
14568
14577
  if (this.requested) {
14569
14578
  yield this.replaceSenderSource(newStream);
14570
14579
  }
@@ -14573,6 +14582,7 @@ class SendOnlyTransceiver extends Transceiver {
14573
14582
  newStream === null || newStream === void 0 ? void 0 : newStream.on(LocalStreamEventNames.ConstraintsChange, this.handleStreamConstraintsChange);
14574
14583
  newStream === null || newStream === void 0 ? void 0 : newStream.on(LocalStreamEventNames.UserMuteStateChange, this.handleStreamMuteStateChange);
14575
14584
  newStream === null || newStream === void 0 ? void 0 : newStream.on(LocalStreamEventNames.SystemMuteStateChange, this.handleStreamMuteStateChange);
14585
+ newStream === null || newStream === void 0 ? void 0 : newStream.on(StreamEventNames.Ended, this.handleStreamEnded);
14576
14586
  if ((!oldStream && newStream && !newStream.muted) ||
14577
14587
  (oldStream && !newStream && !oldStream.muted)) {
14578
14588
  this.streamPublishStateChange.emit();
@@ -15054,6 +15064,10 @@ class MultistreamConnection extends EventEmitter$2 {
15054
15064
  this.sendSourceAdvertisement(mediaType);
15055
15065
  this.sendMediaRequestStatus(mediaType);
15056
15066
  });
15067
+ transceiver.streamEnded.on(() => {
15068
+ this.sendSourceAdvertisement(mediaType);
15069
+ this.sendMediaRequestStatus(mediaType);
15070
+ });
15057
15071
  transceiver.negotiationNeeded.on((offerAnswerType) => {
15058
15072
  if (offerAnswerType === OfferAnswerType.Remote) {
15059
15073
  this.emit(MultistreamConnectionEventNames.NegotiationNeeded);
@@ -15283,9 +15297,12 @@ SCTP Max Message Size: ${maxMessageSize}`);
15283
15297
  }
15284
15298
  }
15285
15299
  sendSourceAdvertisement(mediaType) {
15286
- var _a, _b;
15300
+ var _a, _b, _c;
15287
15301
  const transceiver = this.getSendTransceiverOrThrow(mediaType);
15288
- const numLiveSources = ((_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.muted) === false ? 1 : 0;
15302
+ const numLiveSources = ((_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.muted) === false &&
15303
+ ((_b = transceiver.publishedStream) === null || _b === void 0 ? void 0 : _b.readyState) === 'live'
15304
+ ? 1
15305
+ : 0;
15289
15306
  let task;
15290
15307
  if (getMediaFamily(mediaType) === MediaFamily.Video) {
15291
15308
  const sources = this.getVideoStreamStates(mediaType);
@@ -15309,7 +15326,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
15309
15326
  .get(mediaType)) === null || _a === void 0 ? void 0 : _a.sendSourceAdvertisement(1, numLiveSources, mediaType === MediaType.AudioMain ? transceiver.namedMediaGroups : []);
15310
15327
  };
15311
15328
  }
15312
- if (((_b = this.dataChannel) === null || _b === void 0 ? void 0 : _b.readyState) === 'open') {
15329
+ if (((_c = this.dataChannel) === null || _c === void 0 ? void 0 : _c.readyState) === 'open') {
15313
15330
  task();
15314
15331
  }
15315
15332
  else {