@webex/web-client-media-engine 3.35.0 → 3.35.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
@@ -7158,6 +7158,29 @@ function isValidActiveSpeakerNotificationMsg(msg) {
7158
7158
  const maybeActiveSpeakerNotificationMsg = msg;
7159
7159
  return Boolean(maybeActiveSpeakerNotificationMsg.seqNum && maybeActiveSpeakerNotificationMsg.csis);
7160
7160
  }
7161
+ function isValidAV1Codec(msg) {
7162
+ if (typeof msg !== 'object' || msg === null) {
7163
+ return false;
7164
+ }
7165
+ const maybeAV1Codec = msg;
7166
+ return (maybeAV1Codec.levelIdx >= 0 &&
7167
+ maybeAV1Codec.tier >= 0 &&
7168
+ Boolean(maybeAV1Codec.maxWidth) &&
7169
+ Boolean(maybeAV1Codec.maxHeight) &&
7170
+ Boolean(maybeAV1Codec.maxPicSize) &&
7171
+ Boolean(maybeAV1Codec.maxDecodeRate));
7172
+ }
7173
+ function areAV1CodecsEqual(left, right) {
7174
+ if (left === undefined || right === undefined) {
7175
+ return left === right;
7176
+ }
7177
+ return (left.levelIdx === right.levelIdx &&
7178
+ left.tier === right.tier &&
7179
+ left.maxWidth === right.maxWidth &&
7180
+ left.maxHeight === right.maxHeight &&
7181
+ left.maxPicSize === right.maxPicSize &&
7182
+ left.maxDecodeRate === right.maxDecodeRate);
7183
+ }
7161
7184
 
7162
7185
  class H264Codec {
7163
7186
  constructor(maxFs, maxFps, maxMbps, maxWidth, maxHeight) {
@@ -7168,6 +7191,13 @@ class H264Codec {
7168
7191
  this.maxHeight = maxHeight;
7169
7192
  }
7170
7193
  }
7194
+ function isValidH264Codec(msg) {
7195
+ if (typeof msg !== 'object' || msg === null) {
7196
+ return false;
7197
+ }
7198
+ const maybeH264Codec = msg;
7199
+ return Boolean(maybeH264Codec.maxFs && maybeH264Codec.maxFps && maybeH264Codec.maxMbps);
7200
+ }
7171
7201
  function areH264CodecsEqual(left, right) {
7172
7202
  if (left === undefined || right === undefined) {
7173
7203
  return left === right;
@@ -7180,13 +7210,31 @@ function areH264CodecsEqual(left, right) {
7180
7210
  }
7181
7211
 
7182
7212
  class CodecInfo$1 {
7183
- constructor(payloadType, h264) {
7213
+ constructor(payloadType, codec) {
7184
7214
  this.payloadType = payloadType;
7185
- this.h264 = h264;
7215
+ if (isValidAV1Codec(codec))
7216
+ this.av1 = codec;
7217
+ if (isValidH264Codec(codec))
7218
+ this.h264 = codec;
7219
+ }
7220
+ static fromH264(payloadType, h264) {
7221
+ return new CodecInfo$1(payloadType, h264);
7222
+ }
7223
+ static fromAv1(payloadType, av1) {
7224
+ return new CodecInfo$1(payloadType, av1);
7186
7225
  }
7187
7226
  }
7188
7227
  function areCodecInfosEqual(left, right) {
7189
- return left.payloadType === right.payloadType && areH264CodecsEqual(left.h264, right.h264);
7228
+ if (left.payloadType !== right.payloadType) {
7229
+ return false;
7230
+ }
7231
+ if (isValidH264Codec(left.h264) && isValidH264Codec(right.h264)) {
7232
+ return areH264CodecsEqual(left.h264, right.h264);
7233
+ }
7234
+ if (isValidAV1Codec(left.av1) && isValidAV1Codec(right.av1)) {
7235
+ return areAV1CodecsEqual(left.av1, right.av1);
7236
+ }
7237
+ return false;
7190
7238
  }
7191
7239
 
7192
7240
  var JmpMsgType;
@@ -16167,6 +16215,9 @@ SCTP Max Message Size: ${maxMessageSize}`);
16167
16215
  csi: sendTransceiver.csi,
16168
16216
  }));
16169
16217
  }
16218
+ static getEncodedTransformId(mediaType, mid) {
16219
+ return `INBOUND-${mediaType}-${mid}`;
16220
+ }
16170
16221
  createReceiveTransceiver(mediaType) {
16171
16222
  const rtcRtpTransceiver = this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
16172
16223
  direction: 'recvonly',
@@ -16181,20 +16232,19 @@ SCTP Max Message Size: ${maxMessageSize}`);
16181
16232
  munger,
16182
16233
  });
16183
16234
  if (doAudioLevelMonitoring) {
16184
- const encodedTransformId = `INBOUND-${mediaType}-${mid}`;
16185
16235
  try {
16186
- this.setupEncodedTransform(rtcRtpTransceiver.receiver, encodedTransformId, EncodedTransformType.AudioLevelMonitor);
16236
+ this.setupEncodedTransform(rtcRtpTransceiver.receiver, MultistreamConnection.getEncodedTransformId(mediaType, recvOnlyTransceiver.mid), EncodedTransformType.AudioLevelMonitor);
16187
16237
  recvOnlyTransceiver.setEncodedStreamMetadataCallback(() => __awaiter(this, void 0, void 0, function* () {
16188
16238
  return getWorkerManager().sendRequestToWorker({
16189
16239
  type: MainMsgType.GetMetadata,
16190
16240
  mediaType,
16191
- encodedTransformId,
16241
+ encodedTransformId: MultistreamConnection.getEncodedTransformId(mediaType, recvOnlyTransceiver.mid),
16192
16242
  multistreamConnectionId: this.id,
16193
16243
  });
16194
16244
  }));
16195
16245
  }
16196
16246
  catch (e) {
16197
- logger.warn(`Failed to setup encoded transform for ${encodedTransformId} audio level monitoring: ${e}`);
16247
+ logger.warn(`Failed to setup encoded transform for audio level monitoring of mid=${mid}: ${e}`);
16198
16248
  }
16199
16249
  }
16200
16250
  if (getMediaFamily(mediaType) === exports.MediaFamily.Video) {
@@ -16577,6 +16627,12 @@ SCTP Max Message Size: ${maxMessageSize}`);
16577
16627
  var _a;
16578
16628
  return __awaiter(this, void 0, void 0, function* () {
16579
16629
  (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
16630
+ if (getWorkerManager().getWorker()) {
16631
+ yield getWorkerManager().sendRequestToWorker({
16632
+ type: MainMsgType.ClearMetadata,
16633
+ multistreamConnectionId: this.id,
16634
+ });
16635
+ }
16580
16636
  try {
16581
16637
  if (userOptions) {
16582
16638
  this.options = Object.assign(Object.assign({}, this.options), (yield userOptions));
@@ -16610,10 +16666,14 @@ SCTP Max Message Size: ${maxMessageSize}`);
16610
16666
  this.recvTransceivers.forEach((transceivers, mediaType) => {
16611
16667
  transceivers.forEach((t) => {
16612
16668
  const mid = this.midPredictor.getNextMid(mediaType);
16613
- t.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
16669
+ const rtcRtpTransceiver = this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
16614
16670
  direction: 'recvonly',
16615
- }));
16671
+ });
16672
+ t.replaceTransceiver(rtcRtpTransceiver);
16616
16673
  t.mid = mid;
16674
+ if (this.options.enableInboundAudioLevelMonitoring && mediaType === exports.MediaType.AudioMain) {
16675
+ this.setupEncodedTransform(rtcRtpTransceiver.receiver, MultistreamConnection.getEncodedTransformId(mediaType, mid), EncodedTransformType.AudioLevelMonitor);
16676
+ }
16617
16677
  });
16618
16678
  });
16619
16679
  });