@webex/web-client-media-engine 3.11.5 → 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/esm/index.js CHANGED
@@ -336,12 +336,12 @@ Logger$2.useDefaults({
336
336
  },
337
337
  });
338
338
 
339
- var DeviceKind;
339
+ var DeviceKind$1;
340
340
  (function (DeviceKind) {
341
341
  DeviceKind["AudioInput"] = "audioinput";
342
342
  DeviceKind["AudioOutput"] = "audiooutput";
343
343
  DeviceKind["VideoInput"] = "videoinput";
344
- })(DeviceKind || (DeviceKind = {}));
344
+ })(DeviceKind$1 || (DeviceKind$1 = {}));
345
345
  /**
346
346
  * Prompts the user for permission to use a media input which produces a MediaStream with tracks
347
347
  * containing the requested types of media.
@@ -400,10 +400,10 @@ function setOnDeviceChangeHandler$1(handler) {
400
400
  function checkNavigatorPermissions(deviceKinds) {
401
401
  return __awaiter$2(this, void 0, void 0, function* () {
402
402
  const permissionRequests = [];
403
- if (deviceKinds.includes(DeviceKind.VideoInput)) {
403
+ if (deviceKinds.includes(DeviceKind$1.VideoInput)) {
404
404
  permissionRequests.push(navigator.permissions.query({ name: 'camera' }));
405
405
  }
406
- if (deviceKinds.includes(DeviceKind.AudioInput)) {
406
+ if (deviceKinds.includes(DeviceKind$1.AudioInput)) {
407
407
  permissionRequests.push(navigator.permissions.query({ name: 'microphone' }));
408
408
  }
409
409
  return Promise.all(permissionRequests);
@@ -451,8 +451,8 @@ function ensureDevicePermissions(deviceKinds, callback) {
451
451
  const hasDevicePermissions = yield checkDevicePermissions(deviceKinds);
452
452
  if (!hasDevicePermissions) {
453
453
  const stream = yield getUserMedia({
454
- audio: deviceKinds.includes(DeviceKind.AudioInput),
455
- video: deviceKinds.includes(DeviceKind.VideoInput),
454
+ audio: deviceKinds.includes(DeviceKind$1.AudioInput),
455
+ video: deviceKinds.includes(DeviceKind$1.VideoInput),
456
456
  });
457
457
  // Callback is here to call a function while an active capture exists, so that the browser
458
458
  // (Firefox) will allow the user to access device information.
@@ -473,7 +473,7 @@ function ensureDevicePermissions(deviceKinds, callback) {
473
473
 
474
474
  var media = /*#__PURE__*/Object.freeze({
475
475
  __proto__: null,
476
- get DeviceKind () { return DeviceKind; },
476
+ get DeviceKind () { return DeviceKind$1; },
477
477
  getUserMedia: getUserMedia,
478
478
  getDisplayMedia: getDisplayMedia,
479
479
  enumerateDevices: enumerateDevices,
@@ -610,7 +610,7 @@ function getDevices(deviceKind) {
610
610
  return __awaiter$2(this, void 0, void 0, function* () {
611
611
  let devices;
612
612
  try {
613
- devices = yield ensureDevicePermissions([DeviceKind.AudioInput, DeviceKind.VideoInput], enumerateDevices);
613
+ devices = yield ensureDevicePermissions([DeviceKind$1.AudioInput, DeviceKind$1.VideoInput], enumerateDevices);
614
614
  }
615
615
  catch (error) {
616
616
  throw new WebrtcCoreError(WebrtcCoreErrorType.DEVICE_PERMISSION_DENIED, 'Failed to ensure device permissions');
@@ -625,7 +625,7 @@ function getDevices(deviceKind) {
625
625
  */
626
626
  function getAudioInputDevices() {
627
627
  return __awaiter$2(this, void 0, void 0, function* () {
628
- return getDevices(DeviceKind.AudioInput);
628
+ return getDevices(DeviceKind$1.AudioInput);
629
629
  });
630
630
  }
631
631
  /**
@@ -635,7 +635,7 @@ function getAudioInputDevices() {
635
635
  */
636
636
  function getAudioOutputDevices() {
637
637
  return __awaiter$2(this, void 0, void 0, function* () {
638
- return getDevices(DeviceKind.AudioOutput);
638
+ return getDevices(DeviceKind$1.AudioOutput);
639
639
  });
640
640
  }
641
641
  /**
@@ -645,7 +645,7 @@ function getAudioOutputDevices() {
645
645
  */
646
646
  function getVideoInputDevices() {
647
647
  return __awaiter$2(this, void 0, void 0, function* () {
648
- return getDevices(DeviceKind.VideoInput);
648
+ return getDevices(DeviceKind$1.VideoInput);
649
649
  });
650
650
  }
651
651
  /**
@@ -1486,6 +1486,36 @@ class _LocalStream extends Stream {
1486
1486
  getEffects() {
1487
1487
  return this.effects;
1488
1488
  }
1489
+ /**
1490
+ * Method to serialize data about input, output streams
1491
+ * and also effects from LocalStream.
1492
+ *
1493
+ * @returns - A JSON-compatible object representation with data from LocalStream.
1494
+ */
1495
+ toJSON() {
1496
+ return {
1497
+ muted: this.muted,
1498
+ label: this.label,
1499
+ readyState: this.readyState,
1500
+ inputStream: {
1501
+ active: this.inputStream.active,
1502
+ id: this.inputStream.id,
1503
+ enabled: this.inputTrack.enabled,
1504
+ muted: this.inputTrack.muted,
1505
+ },
1506
+ outputStream: {
1507
+ active: this.outputStream.active,
1508
+ id: this.outputStream.id,
1509
+ },
1510
+ effects: this.effects.map((effect) => {
1511
+ return {
1512
+ id: effect.id,
1513
+ kind: effect.kind,
1514
+ isEnabled: effect.isEnabled,
1515
+ };
1516
+ }),
1517
+ };
1518
+ }
1489
1519
  /**
1490
1520
  * Cleanup the local effects.
1491
1521
  */
@@ -6561,6 +6591,27 @@ function isValidSourceAdvertisementMsg(msg) {
6561
6591
  return Boolean(maybeSourceAdvertisementMsg.seqNum &&
6562
6592
  truthyOrZero(maybeSourceAdvertisementMsg.numTotalSources) &&
6563
6593
  truthyOrZero(maybeSourceAdvertisementMsg.numLiveSources));
6594
+ }
6595
+ function compareNamedMediaGroupArrays(namedMediaGroups1, namedMediaGroups2) {
6596
+ var _a, _b;
6597
+ if (namedMediaGroups1.length !== namedMediaGroups2.length) {
6598
+ return false;
6599
+ }
6600
+ for (let i = 0; i < namedMediaGroups1.length; i += 1) {
6601
+ if (namedMediaGroups1[i].type !== namedMediaGroups2[i].type) {
6602
+ return false;
6603
+ }
6604
+ if (((_a = namedMediaGroups1[i]) === null || _a === void 0 ? void 0 : _a.value) !== ((_b = namedMediaGroups2[i]) === null || _b === void 0 ? void 0 : _b.value)) {
6605
+ return false;
6606
+ }
6607
+ }
6608
+ return true;
6609
+ }
6610
+ function compareSourceAdvertisementMsgs(sourceAdvertisementMsg1, sourceAdvertisementMsg2) {
6611
+ return (sourceAdvertisementMsg1.numLiveSources === sourceAdvertisementMsg2.numLiveSources &&
6612
+ sourceAdvertisementMsg1.numTotalSources === sourceAdvertisementMsg2.numTotalSources &&
6613
+ compareNamedMediaGroupArrays(sourceAdvertisementMsg1.namedMediaGroups || [], sourceAdvertisementMsg2.namedMediaGroups || []) &&
6614
+ sourceAdvertisementMsg1.videoContentHint === sourceAdvertisementMsg2.videoContentHint);
6564
6615
  }
6565
6616
 
6566
6617
  class SourceAdvertisementAckMsg {
@@ -6717,14 +6768,23 @@ class JmpSession extends EventEmitter$5 {
6717
6768
  }
6718
6769
  }
6719
6770
  sendSourceAdvertisement(numTotalSources, numLiveSources, namedMediaGroups, videoContentHint) {
6720
- const sourceAdvertisementMsg = new SourceAdvertisementMsg(this.currSourceAdvertisementSeqNum++, numTotalSources, numLiveSources, namedMediaGroups, videoContentHint);
6721
- this.sendJmpMsg(JmpMsgType.SourceAdvertisement, sourceAdvertisementMsg);
6722
- this.lastSentSourceAdvertisement = new RetransmitHandler(sourceAdvertisementMsg, this.maxNumRetransmits, this.retransmitIntervalMs, () => {
6723
- this.logger.info(`Retransmitting previously sent SourceAdvertisement...`);
6771
+ var _a;
6772
+ const sourceAdvertisementMsg = new SourceAdvertisementMsg(this.currSourceAdvertisementSeqNum, numTotalSources, numLiveSources, namedMediaGroups, videoContentHint);
6773
+ if (!this.lastSentSourceAdvertisement ||
6774
+ !compareSourceAdvertisementMsgs(this.lastSentSourceAdvertisement.msg, sourceAdvertisementMsg)) {
6724
6775
  this.sendJmpMsg(JmpMsgType.SourceAdvertisement, sourceAdvertisementMsg);
6725
- }, (expiredMsg) => {
6726
- this.logger.warn(`Retransmits for message expired: `, expiredMsg);
6727
- });
6776
+ (_a = this.lastSentSourceAdvertisement) === null || _a === void 0 ? void 0 : _a.cancel();
6777
+ this.lastSentSourceAdvertisement = new RetransmitHandler(sourceAdvertisementMsg, this.maxNumRetransmits, this.retransmitIntervalMs, () => {
6778
+ this.logger.info(`Retransmitting previously sent SourceAdvertisement...`);
6779
+ this.sendJmpMsg(JmpMsgType.SourceAdvertisement, sourceAdvertisementMsg);
6780
+ }, (expiredMsg) => {
6781
+ this.logger.warn(`Retransmits for message expired: `, expiredMsg);
6782
+ });
6783
+ this.currSourceAdvertisementSeqNum++;
6784
+ }
6785
+ else {
6786
+ this.logger.info(`Duplicate SourceAdvertisement detected and will not be sent: `, sourceAdvertisementMsg);
6787
+ }
6728
6788
  }
6729
6789
  sendMediaRequestStatus(streamStates) {
6730
6790
  var _a, _b;
@@ -6820,9 +6880,11 @@ class JmpSession extends EventEmitter$5 {
6820
6880
  this.txCallback = callback;
6821
6881
  }
6822
6882
  close() {
6823
- var _a;
6883
+ var _a, _b, _c;
6824
6884
  this.logger.info(`closing`);
6825
6885
  (_a = this.lastSentMediaRequest) === null || _a === void 0 ? void 0 : _a.cancel();
6886
+ (_b = this.lastSentMediaRequestStatus) === null || _b === void 0 ? void 0 : _b.cancel();
6887
+ (_c = this.lastSentSourceAdvertisement) === null || _c === void 0 ? void 0 : _c.cancel();
6826
6888
  }
6827
6889
  sendJmpMsg(msgType, payload) {
6828
6890
  var _a;
@@ -14586,6 +14648,7 @@ class MultistreamConnection extends EventEmitter$2 {
14586
14648
  this.recvTransceivers.forEach((recvTransceivers) => {
14587
14649
  recvTransceivers.forEach((t) => t.close());
14588
14650
  });
14651
+ this.jmpSessions.forEach((jmpSession) => jmpSession.close());
14589
14652
  this.pc.close();
14590
14653
  }
14591
14654
  sendMediaRequestStatus(mediaType) {
@@ -15056,5 +15119,7 @@ class StreamRequest {
15056
15119
  }
15057
15120
  }
15058
15121
 
15059
- export { ActiveSpeakerInfo, CodecInfo$1 as CodecInfo, ConnectionState, H264Codec, Logger$1 as JMPLogger, LocalCameraStream, LocalDisplayStream, LocalMicrophoneStream, LocalStream, LocalStreamEventNames, LocalSystemAudioStream, Logger, MediaCodecMimeType, MediaContent, MediaFamily, MediaStreamTrackKind, MediaType, MultistreamConnection, MultistreamConnectionEventNames, PeerConnection, Policy, ReceiveSlot, ReceiveSlotEvents, ReceiverSelectedInfo, RecommendedOpusBitrates, RemoteStream, SendSlot, StreamEventNames, StreamRequest, WcmeError, WcmeErrorType, Logger$2 as WebRtcCoreLogger, WebrtcCoreError, WebrtcCoreErrorType, compareReceiveSlotIds, createCameraStream, createDisplayStream, createDisplayStreamWithAudio, createMicrophoneStream, getAudioInputDevices, getAudioOutputDevices, getDevices, getLogLevel, getMediaContent, getMediaFamily, getMediaType, getRecommendedMaxBitrateForFrameSize, getVideoInputDevices, logErrorAndThrow, setLogHandler, setLogLevel, setOnDeviceChangeHandler };
15122
+ const { DeviceKind } = media;
15123
+
15124
+ export { ActiveSpeakerInfo, CodecInfo$1 as CodecInfo, ConnectionState, DeviceKind, H264Codec, Logger$1 as JMPLogger, LocalCameraStream, LocalDisplayStream, LocalMicrophoneStream, LocalStream, LocalStreamEventNames, LocalSystemAudioStream, Logger, MediaCodecMimeType, MediaContent, MediaFamily, MediaStreamTrackKind, MediaType, MultistreamConnection, MultistreamConnectionEventNames, PeerConnection, Policy, ReceiveSlot, ReceiveSlotEvents, ReceiverSelectedInfo, RecommendedOpusBitrates, RemoteStream, SendSlot, StreamEventNames, StreamRequest, WcmeError, WcmeErrorType, Logger$2 as WebRtcCoreLogger, WebrtcCoreError, WebrtcCoreErrorType, compareReceiveSlotIds, createCameraStream, createDisplayStream, createDisplayStreamWithAudio, createMicrophoneStream, getAudioInputDevices, getAudioOutputDevices, getDevices, getLogLevel, getMediaContent, getMediaFamily, getMediaType, getRecommendedMaxBitrateForFrameSize, getVideoInputDevices, logErrorAndThrow, setLogHandler, setLogLevel, setOnDeviceChangeHandler };
15060
15125
  //# sourceMappingURL=index.js.map