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

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;
@@ -14620,6 +14652,7 @@ class MultistreamConnection extends EventEmitter$2 {
14620
14652
  this.recvTransceivers.forEach((recvTransceivers) => {
14621
14653
  recvTransceivers.forEach((t) => t.close());
14622
14654
  });
14655
+ this.jmpSessions.forEach((jmpSession) => jmpSession.close());
14623
14656
  this.pc.close();
14624
14657
  }
14625
14658
  sendMediaRequestStatus(mediaType) {
@@ -15090,8 +15123,11 @@ class StreamRequest {
15090
15123
  }
15091
15124
  }
15092
15125
 
15126
+ const { DeviceKind } = media;
15127
+
15093
15128
  exports.ActiveSpeakerInfo = ActiveSpeakerInfo;
15094
15129
  exports.CodecInfo = CodecInfo$1;
15130
+ exports.DeviceKind = DeviceKind;
15095
15131
  exports.H264Codec = H264Codec;
15096
15132
  exports.JMPLogger = Logger$1;
15097
15133
  exports.LocalCameraStream = LocalCameraStream;