@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/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
  /**
@@ -6591,6 +6591,27 @@ function isValidSourceAdvertisementMsg(msg) {
6591
6591
  return Boolean(maybeSourceAdvertisementMsg.seqNum &&
6592
6592
  truthyOrZero(maybeSourceAdvertisementMsg.numTotalSources) &&
6593
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);
6594
6615
  }
6595
6616
 
6596
6617
  class SourceAdvertisementAckMsg {
@@ -6747,14 +6768,23 @@ class JmpSession extends EventEmitter$5 {
6747
6768
  }
6748
6769
  }
6749
6770
  sendSourceAdvertisement(numTotalSources, numLiveSources, namedMediaGroups, videoContentHint) {
6750
- const sourceAdvertisementMsg = new SourceAdvertisementMsg(this.currSourceAdvertisementSeqNum++, numTotalSources, numLiveSources, namedMediaGroups, videoContentHint);
6751
- this.sendJmpMsg(JmpMsgType.SourceAdvertisement, sourceAdvertisementMsg);
6752
- this.lastSentSourceAdvertisement = new RetransmitHandler(sourceAdvertisementMsg, this.maxNumRetransmits, this.retransmitIntervalMs, () => {
6753
- 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)) {
6754
6775
  this.sendJmpMsg(JmpMsgType.SourceAdvertisement, sourceAdvertisementMsg);
6755
- }, (expiredMsg) => {
6756
- this.logger.warn(`Retransmits for message expired: `, expiredMsg);
6757
- });
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
+ }
6758
6788
  }
6759
6789
  sendMediaRequestStatus(streamStates) {
6760
6790
  var _a, _b;
@@ -6850,9 +6880,11 @@ class JmpSession extends EventEmitter$5 {
6850
6880
  this.txCallback = callback;
6851
6881
  }
6852
6882
  close() {
6853
- var _a;
6883
+ var _a, _b, _c;
6854
6884
  this.logger.info(`closing`);
6855
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();
6856
6888
  }
6857
6889
  sendJmpMsg(msgType, payload) {
6858
6890
  var _a;
@@ -9498,7 +9530,7 @@ class EgressSdpMunger {
9498
9530
  reset() {
9499
9531
  this.streamIds = [];
9500
9532
  }
9501
- mungeLocalDescription(mediaDescription, simulcastEnabled, rtxEnabled, twccDisabled) {
9533
+ mungeLocalDescription(mediaDescription, options) {
9502
9534
  var _a;
9503
9535
  retainCodecs(mediaDescription, ['h264', 'opus', 'rtx']);
9504
9536
  if (mediaDescription.codecs.size === 0) {
@@ -9508,10 +9540,10 @@ class EgressSdpMunger {
9508
9540
  mediaDescription.rids = [];
9509
9541
  mediaDescription.simulcast = undefined;
9510
9542
  removeMidRidExtensions(mediaDescription);
9511
- if (simulcastEnabled) {
9543
+ if (options.simulcastEnabled) {
9512
9544
  addVlaExtension(mediaDescription);
9513
9545
  }
9514
- const numStreams = simulcastEnabled ? 3 : 1;
9546
+ const numStreams = options.simulcastEnabled ? 3 : 1;
9515
9547
  if (!this.streamIds.length) {
9516
9548
  if (mediaDescription.ssrcs.length) {
9517
9549
  const ssrcs = [
@@ -9552,7 +9584,7 @@ class EgressSdpMunger {
9552
9584
  const newStreamId = {
9553
9585
  ssrc: generateSsrc(),
9554
9586
  };
9555
- if (rtxEnabled) {
9587
+ if (options.rtxEnabled) {
9556
9588
  newStreamId.rtxSsrc = generateSsrc();
9557
9589
  }
9558
9590
  this.streamIds.push(newStreamId);
@@ -9565,18 +9597,18 @@ class EgressSdpMunger {
9565
9597
  const rtpSsrc = streamId.ssrc;
9566
9598
  mediaDescription.addLine(new SsrcLine(rtpSsrc, 'cname', `${rtpSsrc}-cname`));
9567
9599
  mediaDescription.addLine(new SsrcLine(rtpSsrc, 'msid', '-', '1'));
9568
- if (rtxEnabled) {
9600
+ if (options.rtxEnabled) {
9569
9601
  const rtxSsrc = streamId.rtxSsrc;
9570
9602
  mediaDescription.addLine(new SsrcLine(rtxSsrc, 'cname', `${rtpSsrc}-cname`));
9571
9603
  mediaDescription.addLine(new SsrcLine(rtxSsrc, 'msid', '-', '1'));
9572
9604
  mediaDescription.addLine(new SsrcGroupLine('FID', [rtpSsrc, rtxSsrc]));
9573
9605
  }
9574
9606
  });
9575
- if (simulcastEnabled) {
9607
+ if (options.simulcastEnabled) {
9576
9608
  mediaDescription.addLine(new SsrcGroupLine('SIM', this.streamIds.map((streamId) => streamId.ssrc)));
9577
9609
  }
9578
9610
  applyFormatParameters(mediaDescription, this.customCodecParameters);
9579
- if (twccDisabled) {
9611
+ if (options.twccDisabled) {
9580
9612
  disableTwcc(mediaDescription);
9581
9613
  }
9582
9614
  }
@@ -10105,14 +10137,14 @@ class IngressSdpMunger {
10105
10137
  getReceiverId() {
10106
10138
  return Object.assign({ ssrc: this.ssrc }, (this.rtxSsrc ? { rtxSsrc: this.rtxSsrc } : {}));
10107
10139
  }
10108
- mungeLocalDescription(mediaDescription, twccDisabled) {
10140
+ mungeLocalDescription(mediaDescription, options) {
10109
10141
  retainCodecs(mediaDescription, ['h264', 'opus', 'rtx']);
10110
10142
  if (mediaDescription.codecs.size === 0) {
10111
10143
  logErrorAndThrow(WcmeErrorType.SDP_MUNGE_MISSING_CODECS, `No codecs present in m-line with MID ${mediaDescription.mid} after filtering.`);
10112
10144
  }
10113
10145
  mediaDescription.bandwidth = new BandwidthLine('TIAS', 20000000);
10114
10146
  removeMidRidExtensions(mediaDescription);
10115
- if (twccDisabled) {
10147
+ if (options.twccDisabled) {
10116
10148
  disableTwcc(mediaDescription);
10117
10149
  }
10118
10150
  }
@@ -10308,7 +10340,7 @@ class ReceiveOnlyTransceiver extends Transceiver {
10308
10340
  return this.receiver.getStats();
10309
10341
  }
10310
10342
  mungeLocalDescription(mediaDescription) {
10311
- this.munger.mungeLocalDescription(mediaDescription, this.twccDisabled);
10343
+ this.munger.mungeLocalDescription(mediaDescription, { twccDisabled: this.twccDisabled });
10312
10344
  }
10313
10345
  mungeRemoteDescription(mediaDescription) {
10314
10346
  this.munger.mungeRemoteDescription(mediaDescription);
@@ -14171,7 +14203,11 @@ class SendOnlyTransceiver extends Transceiver {
14171
14203
  return params.encodings.length > 1;
14172
14204
  }
14173
14205
  mungeLocalDescription(mediaDescription) {
14174
- this.munger.mungeLocalDescription(mediaDescription, this.isSimulcastEnabled(), this.rtxEnabled, this.twccDisabled);
14206
+ this.munger.mungeLocalDescription(mediaDescription, {
14207
+ simulcastEnabled: this.isSimulcastEnabled(),
14208
+ rtxEnabled: this.rtxEnabled,
14209
+ twccDisabled: this.twccDisabled,
14210
+ });
14175
14211
  }
14176
14212
  mungeLocalDescriptionForRemoteServer(mediaDescription) {
14177
14213
  this.munger.mungeLocalDescriptionForRemoteServer(mediaDescription, getMediaContent(this.mediaType), this.csi);
@@ -14228,6 +14264,9 @@ class SendSlot {
14228
14264
  setNamedMediaGroups(namedMediaGroups) {
14229
14265
  this.sendTransceiver.setNamedMediaGroups(namedMediaGroups);
14230
14266
  }
14267
+ clearNamedMediaGroups() {
14268
+ this.setNamedMediaGroups([]);
14269
+ }
14231
14270
  get active() {
14232
14271
  return this.sendTransceiver.active;
14233
14272
  }
@@ -14616,6 +14655,7 @@ class MultistreamConnection extends EventEmitter$2 {
14616
14655
  this.recvTransceivers.forEach((recvTransceivers) => {
14617
14656
  recvTransceivers.forEach((t) => t.close());
14618
14657
  });
14658
+ this.jmpSessions.forEach((jmpSession) => jmpSession.close());
14619
14659
  this.pc.close();
14620
14660
  }
14621
14661
  sendMediaRequestStatus(mediaType) {
@@ -15086,5 +15126,7 @@ class StreamRequest {
15086
15126
  }
15087
15127
  }
15088
15128
 
15089
- 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 };
15129
+ const { DeviceKind } = media;
15130
+
15131
+ 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 };
15090
15132
  //# sourceMappingURL=index.js.map