@webex/web-client-media-engine 3.11.6 → 3.11.8

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
@@ -340,12 +340,12 @@ Logger$2.useDefaults({
340
340
  },
341
341
  });
342
342
 
343
- var DeviceKind;
343
+ var DeviceKind$1;
344
344
  (function (DeviceKind) {
345
345
  DeviceKind["AudioInput"] = "audioinput";
346
346
  DeviceKind["AudioOutput"] = "audiooutput";
347
347
  DeviceKind["VideoInput"] = "videoinput";
348
- })(DeviceKind || (DeviceKind = {}));
348
+ })(DeviceKind$1 || (DeviceKind$1 = {}));
349
349
  /**
350
350
  * Prompts the user for permission to use a media input which produces a MediaStream with tracks
351
351
  * containing the requested types of media.
@@ -404,10 +404,10 @@ function setOnDeviceChangeHandler$1(handler) {
404
404
  function checkNavigatorPermissions(deviceKinds) {
405
405
  return __awaiter$2(this, void 0, void 0, function* () {
406
406
  const permissionRequests = [];
407
- if (deviceKinds.includes(DeviceKind.VideoInput)) {
407
+ if (deviceKinds.includes(DeviceKind$1.VideoInput)) {
408
408
  permissionRequests.push(navigator.permissions.query({ name: 'camera' }));
409
409
  }
410
- if (deviceKinds.includes(DeviceKind.AudioInput)) {
410
+ if (deviceKinds.includes(DeviceKind$1.AudioInput)) {
411
411
  permissionRequests.push(navigator.permissions.query({ name: 'microphone' }));
412
412
  }
413
413
  return Promise.all(permissionRequests);
@@ -455,8 +455,8 @@ function ensureDevicePermissions(deviceKinds, callback) {
455
455
  const hasDevicePermissions = yield checkDevicePermissions(deviceKinds);
456
456
  if (!hasDevicePermissions) {
457
457
  const stream = yield getUserMedia({
458
- audio: deviceKinds.includes(DeviceKind.AudioInput),
459
- video: deviceKinds.includes(DeviceKind.VideoInput),
458
+ audio: deviceKinds.includes(DeviceKind$1.AudioInput),
459
+ video: deviceKinds.includes(DeviceKind$1.VideoInput),
460
460
  });
461
461
  // Callback is here to call a function while an active capture exists, so that the browser
462
462
  // (Firefox) will allow the user to access device information.
@@ -477,7 +477,7 @@ function ensureDevicePermissions(deviceKinds, callback) {
477
477
 
478
478
  var media = /*#__PURE__*/Object.freeze({
479
479
  __proto__: null,
480
- get DeviceKind () { return DeviceKind; },
480
+ get DeviceKind () { return DeviceKind$1; },
481
481
  getUserMedia: getUserMedia,
482
482
  getDisplayMedia: getDisplayMedia,
483
483
  enumerateDevices: enumerateDevices,
@@ -614,7 +614,7 @@ function getDevices(deviceKind) {
614
614
  return __awaiter$2(this, void 0, void 0, function* () {
615
615
  let devices;
616
616
  try {
617
- devices = yield ensureDevicePermissions([DeviceKind.AudioInput, DeviceKind.VideoInput], enumerateDevices);
617
+ devices = yield ensureDevicePermissions([DeviceKind$1.AudioInput, DeviceKind$1.VideoInput], enumerateDevices);
618
618
  }
619
619
  catch (error) {
620
620
  throw new WebrtcCoreError(exports.WebrtcCoreErrorType.DEVICE_PERMISSION_DENIED, 'Failed to ensure device permissions');
@@ -629,7 +629,7 @@ function getDevices(deviceKind) {
629
629
  */
630
630
  function getAudioInputDevices() {
631
631
  return __awaiter$2(this, void 0, void 0, function* () {
632
- return getDevices(DeviceKind.AudioInput);
632
+ return getDevices(DeviceKind$1.AudioInput);
633
633
  });
634
634
  }
635
635
  /**
@@ -639,7 +639,7 @@ function getAudioInputDevices() {
639
639
  */
640
640
  function getAudioOutputDevices() {
641
641
  return __awaiter$2(this, void 0, void 0, function* () {
642
- return getDevices(DeviceKind.AudioOutput);
642
+ return getDevices(DeviceKind$1.AudioOutput);
643
643
  });
644
644
  }
645
645
  /**
@@ -649,7 +649,7 @@ function getAudioOutputDevices() {
649
649
  */
650
650
  function getVideoInputDevices() {
651
651
  return __awaiter$2(this, void 0, void 0, function* () {
652
- return getDevices(DeviceKind.VideoInput);
652
+ return getDevices(DeviceKind$1.VideoInput);
653
653
  });
654
654
  }
655
655
  /**
@@ -6595,6 +6595,27 @@ function isValidSourceAdvertisementMsg(msg) {
6595
6595
  return Boolean(maybeSourceAdvertisementMsg.seqNum &&
6596
6596
  truthyOrZero(maybeSourceAdvertisementMsg.numTotalSources) &&
6597
6597
  truthyOrZero(maybeSourceAdvertisementMsg.numLiveSources));
6598
+ }
6599
+ function compareNamedMediaGroupArrays(namedMediaGroups1, namedMediaGroups2) {
6600
+ var _a, _b;
6601
+ if (namedMediaGroups1.length !== namedMediaGroups2.length) {
6602
+ return false;
6603
+ }
6604
+ for (let i = 0; i < namedMediaGroups1.length; i += 1) {
6605
+ if (namedMediaGroups1[i].type !== namedMediaGroups2[i].type) {
6606
+ return false;
6607
+ }
6608
+ if (((_a = namedMediaGroups1[i]) === null || _a === void 0 ? void 0 : _a.value) !== ((_b = namedMediaGroups2[i]) === null || _b === void 0 ? void 0 : _b.value)) {
6609
+ return false;
6610
+ }
6611
+ }
6612
+ return true;
6613
+ }
6614
+ function compareSourceAdvertisementMsgs(sourceAdvertisementMsg1, sourceAdvertisementMsg2) {
6615
+ return (sourceAdvertisementMsg1.numLiveSources === sourceAdvertisementMsg2.numLiveSources &&
6616
+ sourceAdvertisementMsg1.numTotalSources === sourceAdvertisementMsg2.numTotalSources &&
6617
+ compareNamedMediaGroupArrays(sourceAdvertisementMsg1.namedMediaGroups || [], sourceAdvertisementMsg2.namedMediaGroups || []) &&
6618
+ sourceAdvertisementMsg1.videoContentHint === sourceAdvertisementMsg2.videoContentHint);
6598
6619
  }
6599
6620
 
6600
6621
  class SourceAdvertisementAckMsg {
@@ -6751,14 +6772,23 @@ class JmpSession extends events$3.EventEmitter {
6751
6772
  }
6752
6773
  }
6753
6774
  sendSourceAdvertisement(numTotalSources, numLiveSources, namedMediaGroups, videoContentHint) {
6754
- const sourceAdvertisementMsg = new SourceAdvertisementMsg(this.currSourceAdvertisementSeqNum++, numTotalSources, numLiveSources, namedMediaGroups, videoContentHint);
6755
- this.sendJmpMsg(JmpMsgType.SourceAdvertisement, sourceAdvertisementMsg);
6756
- this.lastSentSourceAdvertisement = new RetransmitHandler(sourceAdvertisementMsg, this.maxNumRetransmits, this.retransmitIntervalMs, () => {
6757
- this.logger.info(`Retransmitting previously sent SourceAdvertisement...`);
6775
+ var _a;
6776
+ const sourceAdvertisementMsg = new SourceAdvertisementMsg(this.currSourceAdvertisementSeqNum, numTotalSources, numLiveSources, namedMediaGroups, videoContentHint);
6777
+ if (!this.lastSentSourceAdvertisement ||
6778
+ !compareSourceAdvertisementMsgs(this.lastSentSourceAdvertisement.msg, sourceAdvertisementMsg)) {
6758
6779
  this.sendJmpMsg(JmpMsgType.SourceAdvertisement, sourceAdvertisementMsg);
6759
- }, (expiredMsg) => {
6760
- this.logger.warn(`Retransmits for message expired: `, expiredMsg);
6761
- });
6780
+ (_a = this.lastSentSourceAdvertisement) === null || _a === void 0 ? void 0 : _a.cancel();
6781
+ this.lastSentSourceAdvertisement = new RetransmitHandler(sourceAdvertisementMsg, this.maxNumRetransmits, this.retransmitIntervalMs, () => {
6782
+ this.logger.info(`Retransmitting previously sent SourceAdvertisement...`);
6783
+ this.sendJmpMsg(JmpMsgType.SourceAdvertisement, sourceAdvertisementMsg);
6784
+ }, (expiredMsg) => {
6785
+ this.logger.warn(`Retransmits for message expired: `, expiredMsg);
6786
+ });
6787
+ this.currSourceAdvertisementSeqNum++;
6788
+ }
6789
+ else {
6790
+ this.logger.info(`Duplicate SourceAdvertisement detected and will not be sent: `, sourceAdvertisementMsg);
6791
+ }
6762
6792
  }
6763
6793
  sendMediaRequestStatus(streamStates) {
6764
6794
  var _a, _b;
@@ -6854,9 +6884,11 @@ class JmpSession extends events$3.EventEmitter {
6854
6884
  this.txCallback = callback;
6855
6885
  }
6856
6886
  close() {
6857
- var _a;
6887
+ var _a, _b, _c;
6858
6888
  this.logger.info(`closing`);
6859
6889
  (_a = this.lastSentMediaRequest) === null || _a === void 0 ? void 0 : _a.cancel();
6890
+ (_b = this.lastSentMediaRequestStatus) === null || _b === void 0 ? void 0 : _b.cancel();
6891
+ (_c = this.lastSentSourceAdvertisement) === null || _c === void 0 ? void 0 : _c.cancel();
6860
6892
  }
6861
6893
  sendJmpMsg(msgType, payload) {
6862
6894
  var _a;
@@ -9502,7 +9534,7 @@ class EgressSdpMunger {
9502
9534
  reset() {
9503
9535
  this.streamIds = [];
9504
9536
  }
9505
- mungeLocalDescription(mediaDescription, simulcastEnabled, rtxEnabled, twccDisabled) {
9537
+ mungeLocalDescription(mediaDescription, options) {
9506
9538
  var _a;
9507
9539
  retainCodecs(mediaDescription, ['h264', 'opus', 'rtx']);
9508
9540
  if (mediaDescription.codecs.size === 0) {
@@ -9512,10 +9544,10 @@ class EgressSdpMunger {
9512
9544
  mediaDescription.rids = [];
9513
9545
  mediaDescription.simulcast = undefined;
9514
9546
  removeMidRidExtensions(mediaDescription);
9515
- if (simulcastEnabled) {
9547
+ if (options.simulcastEnabled) {
9516
9548
  addVlaExtension(mediaDescription);
9517
9549
  }
9518
- const numStreams = simulcastEnabled ? 3 : 1;
9550
+ const numStreams = options.simulcastEnabled ? 3 : 1;
9519
9551
  if (!this.streamIds.length) {
9520
9552
  if (mediaDescription.ssrcs.length) {
9521
9553
  const ssrcs = [
@@ -9556,7 +9588,7 @@ class EgressSdpMunger {
9556
9588
  const newStreamId = {
9557
9589
  ssrc: generateSsrc(),
9558
9590
  };
9559
- if (rtxEnabled) {
9591
+ if (options.rtxEnabled) {
9560
9592
  newStreamId.rtxSsrc = generateSsrc();
9561
9593
  }
9562
9594
  this.streamIds.push(newStreamId);
@@ -9569,18 +9601,18 @@ class EgressSdpMunger {
9569
9601
  const rtpSsrc = streamId.ssrc;
9570
9602
  mediaDescription.addLine(new SsrcLine(rtpSsrc, 'cname', `${rtpSsrc}-cname`));
9571
9603
  mediaDescription.addLine(new SsrcLine(rtpSsrc, 'msid', '-', '1'));
9572
- if (rtxEnabled) {
9604
+ if (options.rtxEnabled) {
9573
9605
  const rtxSsrc = streamId.rtxSsrc;
9574
9606
  mediaDescription.addLine(new SsrcLine(rtxSsrc, 'cname', `${rtpSsrc}-cname`));
9575
9607
  mediaDescription.addLine(new SsrcLine(rtxSsrc, 'msid', '-', '1'));
9576
9608
  mediaDescription.addLine(new SsrcGroupLine('FID', [rtpSsrc, rtxSsrc]));
9577
9609
  }
9578
9610
  });
9579
- if (simulcastEnabled) {
9611
+ if (options.simulcastEnabled) {
9580
9612
  mediaDescription.addLine(new SsrcGroupLine('SIM', this.streamIds.map((streamId) => streamId.ssrc)));
9581
9613
  }
9582
9614
  applyFormatParameters(mediaDescription, this.customCodecParameters);
9583
- if (twccDisabled) {
9615
+ if (options.twccDisabled) {
9584
9616
  disableTwcc(mediaDescription);
9585
9617
  }
9586
9618
  }
@@ -10109,14 +10141,14 @@ class IngressSdpMunger {
10109
10141
  getReceiverId() {
10110
10142
  return Object.assign({ ssrc: this.ssrc }, (this.rtxSsrc ? { rtxSsrc: this.rtxSsrc } : {}));
10111
10143
  }
10112
- mungeLocalDescription(mediaDescription, twccDisabled) {
10144
+ mungeLocalDescription(mediaDescription, options) {
10113
10145
  retainCodecs(mediaDescription, ['h264', 'opus', 'rtx']);
10114
10146
  if (mediaDescription.codecs.size === 0) {
10115
10147
  logErrorAndThrow(exports.WcmeErrorType.SDP_MUNGE_MISSING_CODECS, `No codecs present in m-line with MID ${mediaDescription.mid} after filtering.`);
10116
10148
  }
10117
10149
  mediaDescription.bandwidth = new BandwidthLine('TIAS', 20000000);
10118
10150
  removeMidRidExtensions(mediaDescription);
10119
- if (twccDisabled) {
10151
+ if (options.twccDisabled) {
10120
10152
  disableTwcc(mediaDescription);
10121
10153
  }
10122
10154
  }
@@ -10312,7 +10344,7 @@ class ReceiveOnlyTransceiver extends Transceiver {
10312
10344
  return this.receiver.getStats();
10313
10345
  }
10314
10346
  mungeLocalDescription(mediaDescription) {
10315
- this.munger.mungeLocalDescription(mediaDescription, this.twccDisabled);
10347
+ this.munger.mungeLocalDescription(mediaDescription, { twccDisabled: this.twccDisabled });
10316
10348
  }
10317
10349
  mungeRemoteDescription(mediaDescription) {
10318
10350
  this.munger.mungeRemoteDescription(mediaDescription);
@@ -14175,7 +14207,11 @@ class SendOnlyTransceiver extends Transceiver {
14175
14207
  return params.encodings.length > 1;
14176
14208
  }
14177
14209
  mungeLocalDescription(mediaDescription) {
14178
- this.munger.mungeLocalDescription(mediaDescription, this.isSimulcastEnabled(), this.rtxEnabled, this.twccDisabled);
14210
+ this.munger.mungeLocalDescription(mediaDescription, {
14211
+ simulcastEnabled: this.isSimulcastEnabled(),
14212
+ rtxEnabled: this.rtxEnabled,
14213
+ twccDisabled: this.twccDisabled,
14214
+ });
14179
14215
  }
14180
14216
  mungeLocalDescriptionForRemoteServer(mediaDescription) {
14181
14217
  this.munger.mungeLocalDescriptionForRemoteServer(mediaDescription, getMediaContent(this.mediaType), this.csi);
@@ -14232,6 +14268,9 @@ class SendSlot {
14232
14268
  setNamedMediaGroups(namedMediaGroups) {
14233
14269
  this.sendTransceiver.setNamedMediaGroups(namedMediaGroups);
14234
14270
  }
14271
+ clearNamedMediaGroups() {
14272
+ this.setNamedMediaGroups([]);
14273
+ }
14235
14274
  get active() {
14236
14275
  return this.sendTransceiver.active;
14237
14276
  }
@@ -14620,6 +14659,7 @@ class MultistreamConnection extends EventEmitter$2 {
14620
14659
  this.recvTransceivers.forEach((recvTransceivers) => {
14621
14660
  recvTransceivers.forEach((t) => t.close());
14622
14661
  });
14662
+ this.jmpSessions.forEach((jmpSession) => jmpSession.close());
14623
14663
  this.pc.close();
14624
14664
  }
14625
14665
  sendMediaRequestStatus(mediaType) {
@@ -15090,8 +15130,11 @@ class StreamRequest {
15090
15130
  }
15091
15131
  }
15092
15132
 
15133
+ const { DeviceKind } = media;
15134
+
15093
15135
  exports.ActiveSpeakerInfo = ActiveSpeakerInfo;
15094
15136
  exports.CodecInfo = CodecInfo$1;
15137
+ exports.DeviceKind = DeviceKind;
15095
15138
  exports.H264Codec = H264Codec;
15096
15139
  exports.JMPLogger = Logger$1;
15097
15140
  exports.LocalCameraStream = LocalCameraStream;