@whereby.com/browser-sdk 2.0.0-alpha16 → 2.0.0-alpha17

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/lib.esm.js CHANGED
@@ -128,7 +128,7 @@ define("WherebyEmbed", {
128
128
  if (roomUrl.searchParams.get("roomKey")) {
129
129
  this.url.searchParams.append("roomKey", roomUrl.searchParams.get("roomKey"));
130
130
  }
131
- Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha16", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
131
+ Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha17", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
132
132
  // add to URL if set in any way
133
133
  (o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
134
134
  if (!this.url.searchParams.has(k) && typeof v === "string") {
@@ -648,21 +648,21 @@ var rtcManagerEvents = {
648
648
  DOMINANT_SPEAKER: "dominant_speaker",
649
649
  };
650
650
 
651
- const browserName$3 = adapter.browserDetails.browser;
651
+ const browserName$2 = adapter.browserDetails.browser;
652
652
  const browserVersion$1 = adapter.browserDetails.version;
653
653
 
654
654
  // SDP mangling for deprioritizing H264
655
655
  function deprioritizeH264(sdp) {
656
656
  return SDPUtils.splitSections(sdp)
657
- .map((section) => {
657
+ .map(section => {
658
658
  // only modify video sections
659
659
  if (SDPUtils.getKind(section) !== "video") return section;
660
660
 
661
661
  // list of payloadTypes used in this sdp/section
662
662
  const h264payloadTypes = SDPUtils.matchPrefix(section, "a=rtpmap:")
663
- .map((line) => SDPUtils.parseRtpMap(line))
664
- .filter((codec) => /h264/i.test(codec.name))
665
- .map((codec) => "" + codec.payloadType);
663
+ .map(line => SDPUtils.parseRtpMap(line))
664
+ .filter(codec => /h264/i.test(codec.name))
665
+ .map(codec => "" + codec.payloadType);
666
666
 
667
667
  // return as is if no h264 found
668
668
  if (!h264payloadTypes.length) return section;
@@ -672,7 +672,7 @@ function deprioritizeH264(sdp) {
672
672
  const mlinePayloadsSection = /(\s\d+)+$/i.exec(mline)[0];
673
673
  const mlinePayloadsNonH264 = mlinePayloadsSection
674
674
  .split(" ")
675
- .filter((payloadType) => payloadType && !h264payloadTypes.includes(payloadType));
675
+ .filter(payloadType => payloadType && !h264payloadTypes.includes(payloadType));
676
676
  const reorderedPayloads = [...mlinePayloadsNonH264, ...h264payloadTypes].join(" ");
677
677
  const newmline = mline.replace(mlinePayloadsSection, " " + reorderedPayloads);
678
678
  return section.replace(mline, newmline);
@@ -700,12 +700,12 @@ function replaceSSRCs(currentDescription, newDescription) {
700
700
  // https://bugzilla.mozilla.org/show_bug.cgi?id=1478685
701
701
  // filter out the mid rtp header extension
702
702
  function filterMidExtension(sdp) {
703
- if (browserName$3 !== "safari" && (browserName$3 !== "firefox" || browserVersion$1 >= 63 || browserVersion$1 === 60)) {
703
+ if (browserName$2 !== "safari" && (browserName$2 !== "firefox" || browserVersion$1 >= 63 || browserVersion$1 === 60)) {
704
704
  return sdp;
705
705
  }
706
706
  return (
707
707
  SDPUtils.splitLines(sdp.trim())
708
- .filter((line) => {
708
+ .filter(line => {
709
709
  if (!line.startsWith("a=extmap:")) {
710
710
  return true;
711
711
  }
@@ -721,21 +721,21 @@ function filterMidExtension(sdp) {
721
721
  // https://bugzilla.mozilla.org/show_bug.cgi?id=1534673
722
722
  // Filter out a:msid-semantic header
723
723
  function filterMsidSemantic(sdp) {
724
- if (browserName$3 !== "firefox") {
724
+ if (browserName$2 !== "firefox") {
725
725
  return sdp;
726
726
  }
727
727
  return (
728
728
  SDPUtils.splitLines(sdp.trim())
729
- .map((line) => (line.startsWith("a=msid-semantic:") ? "a=msid-semantic: WMS *" : line))
729
+ .map(line => (line.startsWith("a=msid-semantic:") ? "a=msid-semantic: WMS *" : line))
730
730
  .join("\r\n") + "\r\n"
731
731
  );
732
732
  }
733
733
 
734
734
  function isRelayed(pc) {
735
- return pc.getStats(null).then((result) => {
735
+ return pc.getStats(null).then(result => {
736
736
  let localCandidateType;
737
737
  let remoteCandidateType;
738
- result.forEach((report) => {
738
+ result.forEach(report => {
739
739
  // Chrome 58+ / spec
740
740
  if (report.type === "transport" && report.selectedCandidatePairId) {
741
741
  const transport = result.get(report.selectedCandidatePairId);
@@ -765,7 +765,7 @@ const logger$4 = console;
765
765
 
766
766
  // use https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-setparameters to change the video bandwidth.
767
767
  function setVideoBandwidthUsingSetParameters(pc, bandwidth) {
768
- const sender = pc.getSenders().find((s) => s.track && s.track.kind === "video");
768
+ const sender = pc.getSenders().find(s => s.track && s.track.kind === "video");
769
769
  if (!sender) {
770
770
  return Promise.resolve();
771
771
  }
@@ -786,7 +786,7 @@ function setVideoBandwidthUsingSetParameters(pc, bandwidth) {
786
786
  parameters.encodings[0].maxBitrate = bandwidth * 1000; // convert to bps
787
787
  }
788
788
 
789
- return sender.setParameters(parameters).catch((err) => {
789
+ return sender.setParameters(parameters).catch(err => {
790
790
  logger$4.error("setParameters err: ", err);
791
791
  });
792
792
  }
@@ -811,7 +811,7 @@ class Session {
811
811
  this.streamIds = [];
812
812
  this.streams = [];
813
813
  this.earlyIceCandidates = [];
814
- this.afterConnected = new Promise((resolve) => {
814
+ this.afterConnected = new Promise(resolve => {
815
815
  this.registerConnected = resolve;
816
816
  });
817
817
  this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
@@ -848,10 +848,10 @@ class Session {
848
848
  this.streamIds.push(stream.id);
849
849
  this.streams.push(stream);
850
850
  if (RTCPeerConnection.prototype.addTrack) {
851
- stream.getAudioTracks().forEach((track) => {
851
+ stream.getAudioTracks().forEach(track => {
852
852
  this.pc.addTrack(track, stream);
853
853
  });
854
- stream.getVideoTracks().forEach((track) => {
854
+ stream.getVideoTracks().forEach(track => {
855
855
  this.pc.addTrack(track, stream);
856
856
  });
857
857
  } else {
@@ -871,7 +871,7 @@ class Session {
871
871
  removeTrack(track) {
872
872
  const stream = this.streams[0];
873
873
  stream.removeTrack(track);
874
- const sender = this.pc.getSenders().find((sender) => sender.track === track);
874
+ const sender = this.pc.getSenders().find(sender => sender.track === track);
875
875
  if (sender) {
876
876
  this.pc.removeTrack(sender);
877
877
  }
@@ -887,8 +887,8 @@ class Session {
887
887
 
888
888
  if (this.pc) {
889
889
  if (this.pc.removeTrack) {
890
- stream.getTracks().forEach((track) => {
891
- const sender = this.pc.getSenders().find((sender) => sender.track === track);
890
+ stream.getTracks().forEach(track => {
891
+ const sender = this.pc.getSenders().find(sender => sender.track === track);
892
892
  if (sender) {
893
893
  this.pc.removeTrack(sender);
894
894
  }
@@ -906,14 +906,14 @@ class Session {
906
906
  // wrapper around SRD which stores a promise
907
907
  this.srdComplete = this.pc.setRemoteDescription(desc);
908
908
  return this.srdComplete.then(() => {
909
- this.earlyIceCandidates.forEach((candidate) => this.pc.addIceCandidate(candidate));
909
+ this.earlyIceCandidates.forEach(candidate => this.pc.addIceCandidate(candidate));
910
910
  this.earlyIceCandidates = [];
911
911
  });
912
912
  }
913
913
 
914
914
  handleOffer(message) {
915
915
  if (!this.canModifyPeerConnection()) {
916
- return new Promise((resolve) => {
916
+ return new Promise(resolve => {
917
917
  this.pending.push(() => this.handleOffer(message).then(resolve));
918
918
  });
919
919
  }
@@ -931,7 +931,7 @@ class Session {
931
931
  .then(() => {
932
932
  return this.pc.createAnswer();
933
933
  })
934
- .then((answer) => {
934
+ .then(answer => {
935
935
  answerToSignal = answer;
936
936
  return this.pc.setLocalDescription(answer);
937
937
  })
@@ -959,7 +959,7 @@ class Session {
959
959
  () => {
960
960
  return setVideoBandwidthUsingSetParameters(this.pc, this.bandwidth);
961
961
  },
962
- (e) => {
962
+ e => {
963
963
  logger$3.warn("Could not set remote description from remote answer: ", e);
964
964
  }
965
965
  );
@@ -980,7 +980,7 @@ class Session {
980
980
  // filter due to https://github.com/webrtcHacks/adapter/issues/863
981
981
  return;
982
982
  }
983
- this.pc.addIceCandidate(candidate).catch((e) => {
983
+ this.pc.addIceCandidate(candidate).catch(e => {
984
984
  logger$3.warn("Failed to add ICE candidate ('%s'): %s", candidate ? candidate.candidate : null, e);
985
985
  });
986
986
  });
@@ -1018,11 +1018,11 @@ class Session {
1018
1018
  if (!pc) return false;
1019
1019
  const senders = pc.getSenders();
1020
1020
  function dbg(msg) {
1021
- const tr = (t) => t && `id:${t.id},kind:${t.kind},state:${t.readyState}`;
1021
+ const tr = t => t && `id:${t.id},kind:${t.kind},state:${t.readyState}`;
1022
1022
  logger$3.warn(
1023
1023
  `${msg}. newTrack:${tr(newTrack)}, oldTrack:${tr(oldTrack)}, sender tracks: ${JSON.stringify(
1024
- senders.map((s) => `s ${tr(s.track)}`)
1025
- )}, sender first codecs: ${JSON.stringify(senders.map((s) => (s.getParameters().codecs || [])[0]))}`
1024
+ senders.map(s => `s ${tr(s.track)}`)
1025
+ )}, sender first codecs: ${JSON.stringify(senders.map(s => (s.getParameters().codecs || [])[0]))}`
1026
1026
  );
1027
1027
  }
1028
1028
  if (!senders.length) {
@@ -1030,7 +1030,7 @@ class Session {
1030
1030
  }
1031
1031
  // If we didn't specify oldTrack, replace with first of its kind
1032
1032
  if (!oldTrack) {
1033
- oldTrack = (senders.find((s) => s.track && s.track.kind === newTrack.kind) || {}).track;
1033
+ oldTrack = (senders.find(s => s.track && s.track.kind === newTrack.kind) || {}).track;
1034
1034
  if (!oldTrack) {
1035
1035
  // odin: Temporary debug data, remove if you see after 2020-12-01
1036
1036
  dbg("No sender with same kind! Add new track then.");
@@ -1087,7 +1087,7 @@ class Session {
1087
1087
  // we already know that the track has been added at least to the mediastream
1088
1088
  return result;
1089
1089
  }
1090
- const stream = this.streams.find((s) => s.getTracks().find((t) => t.id === newTrack.id)) || this.streams[0];
1090
+ const stream = this.streams.find(s => s.getTracks().find(t => t.id === newTrack.id)) || this.streams[0];
1091
1091
  if (!stream) {
1092
1092
  dbg("No stream?");
1093
1093
  return Promise.reject(new Error("replaceTrack: No stream?"));
@@ -1116,7 +1116,7 @@ class Session {
1116
1116
  if (pc.localDescription.type === "offer") {
1117
1117
  return pc
1118
1118
  .createOffer()
1119
- .then((offer) => {
1119
+ .then(offer => {
1120
1120
  offer.sdp = replaceSSRCs(pc.localDescription.sdp, offer.sdp);
1121
1121
  return pc.setLocalDescription(offer);
1122
1122
  })
@@ -1128,7 +1128,7 @@ class Session {
1128
1128
  .then(() => {
1129
1129
  return pc.createAnswer();
1130
1130
  })
1131
- .then((answer) => {
1131
+ .then(answer => {
1132
1132
  answer.sdp = replaceSSRCs(pc.localDescription.sdp, answer.sdp);
1133
1133
  return pc.setLocalDescription(answer);
1134
1134
  });
@@ -1143,7 +1143,7 @@ class Session {
1143
1143
  if (!this.pc.getStats) {
1144
1144
  return;
1145
1145
  }
1146
- isRelayed(this.pc).then((isRelayed) => {
1146
+ isRelayed(this.pc).then(isRelayed => {
1147
1147
  if (isRelayed && this.bandwidth === 0) {
1148
1148
  this.changeBandwidth(this.maximumTurnBandwidth);
1149
1149
  }
@@ -4239,7 +4239,7 @@ const CAMERA_STREAM_ID = "0";
4239
4239
 
4240
4240
  const logger$2 = console;
4241
4241
 
4242
- const browserName$2 = adapter.browserDetails.browser;
4242
+ const browserName$1 = adapter.browserDetails.browser;
4243
4243
  const browserVersion = adapter.browserDetails.version;
4244
4244
 
4245
4245
  class BaseRtcManager {
@@ -4279,7 +4279,7 @@ class BaseRtcManager {
4279
4279
  }
4280
4280
 
4281
4281
  numberOfRemotePeers() {
4282
- return Object.values(this.peerConnections).filter((session) => session.clientId !== this._selfId).length;
4282
+ return Object.values(this.peerConnections).filter(session => session.clientId !== this._selfId).length;
4283
4283
  }
4284
4284
 
4285
4285
  _setConnectionStatus(session, newStatus, clientId) {
@@ -4353,7 +4353,7 @@ class BaseRtcManager {
4353
4353
  // Some macs + ios devices have troubles using h264 encoder since safari 14
4354
4354
  // this will make them encode VP8 instead if available
4355
4355
  const deprioritizeH264Encoding =
4356
- browserName$2 === "safari" && browserVersion >= 14 && this._features.deprioritizeH264OnSafari;
4356
+ browserName$1 === "safari" && browserVersion >= 14 && this._features.deprioritizeH264OnSafari;
4357
4357
 
4358
4358
  this.peerConnections[peerConnectionId] = session = new Session({
4359
4359
  peerConnectionId,
@@ -4372,7 +4372,7 @@ class BaseRtcManager {
4372
4372
  }
4373
4373
 
4374
4374
  _getNonLocalCameraStreamIds() {
4375
- return Object.keys(this.localStreams).filter((streamId) => streamId !== CAMERA_STREAM_ID);
4375
+ return Object.keys(this.localStreams).filter(streamId => streamId !== CAMERA_STREAM_ID);
4376
4376
  }
4377
4377
 
4378
4378
  _isScreensharingLocally() {
@@ -4401,7 +4401,7 @@ class BaseRtcManager {
4401
4401
  }
4402
4402
  const session = this._getOrCreateSession(peerConnectionId, initialBandwidth);
4403
4403
  const constraints = { optional: [] };
4404
- if (browserName$2 === "chrome") {
4404
+ if (browserName$1 === "chrome") {
4405
4405
  constraints.optional.push({
4406
4406
  googCpuOveruseDetection: true,
4407
4407
  });
@@ -4414,13 +4414,13 @@ class BaseRtcManager {
4414
4414
  const host = this._features.turnServerOverrideHost;
4415
4415
  const port = host.indexOf(":") > 0 ? "" : ":443";
4416
4416
  const override = ":" + host + port;
4417
- peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.map((original) => {
4417
+ peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.map(original => {
4418
4418
  const entry = Object.assign({}, original);
4419
4419
  if (entry.url) {
4420
4420
  entry.url = entry.url.replace(/:[^?]*/, override);
4421
4421
  }
4422
4422
  if (entry.urls) {
4423
- entry.urls = entry.urls.map((url) => url.replace(/:[^?]*/, override));
4423
+ entry.urls = entry.urls.map(url => url.replace(/:[^?]*/, override));
4424
4424
  }
4425
4425
  return entry;
4426
4426
  });
@@ -4434,12 +4434,12 @@ class BaseRtcManager {
4434
4434
  }[this._features.useOnlyTURN];
4435
4435
  if (filter) {
4436
4436
  peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.filter(
4437
- (entry) => entry.url && entry.url.match(filter)
4437
+ entry => entry.url && entry.url.match(filter)
4438
4438
  );
4439
4439
  }
4440
4440
  }
4441
4441
 
4442
- if (browserName$2 === "chrome") {
4442
+ if (browserName$1 === "chrome") {
4443
4443
  peerConnectionConfig.sdpSemantics = "unified-plan";
4444
4444
  }
4445
4445
 
@@ -4450,7 +4450,7 @@ class BaseRtcManager {
4450
4450
  clientId,
4451
4451
  });
4452
4452
 
4453
- pc.ontrack = (event) => {
4453
+ pc.ontrack = event => {
4454
4454
  const stream = event.streams[0];
4455
4455
  if (stream.id === "default" && stream.getAudioTracks().length === 0) {
4456
4456
  // due to our PlanB / UnifiedPlan conversion we can run into this:
@@ -4492,7 +4492,7 @@ class BaseRtcManager {
4492
4492
  case "completed":
4493
4493
  newStatus = TYPES.CONNECTION_SUCCESSFUL;
4494
4494
  if (!session.wasEverConnected) {
4495
- this._pendingActionsForConnectedPeerConnections.forEach((action) => {
4495
+ this._pendingActionsForConnectedPeerConnections.forEach(action => {
4496
4496
  if (typeof action === "function") {
4497
4497
  action();
4498
4498
  }
@@ -4504,7 +4504,7 @@ class BaseRtcManager {
4504
4504
  if (
4505
4505
  !session.wasEverConnected &&
4506
4506
  (pc.iceConnectionState.match(/connected|completed/) ||
4507
- (browserName$2 === "chrome" && pc.localDescription && pc.localDescription.type === "answer"))
4507
+ (browserName$1 === "chrome" && pc.localDescription && pc.localDescription.type === "answer"))
4508
4508
  ) {
4509
4509
  session.wasEverConnected = true;
4510
4510
  if (this._features.bandwidth !== "false") {
@@ -4575,7 +4575,7 @@ class BaseRtcManager {
4575
4575
  // Don't add existing screenshare-streams when using SFU as those will be
4576
4576
  // added in a separate session/peerConnection
4577
4577
  if (shouldAddLocalVideo) {
4578
- Object.keys(this.localStreams).forEach((id) => {
4578
+ Object.keys(this.localStreams).forEach(id => {
4579
4579
  if (id === CAMERA_STREAM_ID) {
4580
4580
  return;
4581
4581
  }
@@ -4612,27 +4612,27 @@ class BaseRtcManager {
4612
4612
  }
4613
4613
 
4614
4614
  _forEachPeerConnection(func) {
4615
- Object.keys(this.peerConnections).forEach((peerConnectionId) => {
4615
+ Object.keys(this.peerConnections).forEach(peerConnectionId => {
4616
4616
  const peerConnection = this.peerConnections[peerConnectionId];
4617
4617
  func(peerConnection);
4618
4618
  });
4619
4619
  }
4620
4620
 
4621
4621
  _addStreamToPeerConnections(stream) {
4622
- this._forEachPeerConnection((session) => {
4622
+ this._forEachPeerConnection(session => {
4623
4623
  this._withForcedRenegotiation(session, () => session.addStream(stream));
4624
4624
  });
4625
4625
  }
4626
4626
 
4627
4627
  _addTrackToPeerConnections(track, stream) {
4628
- this._forEachPeerConnection((session) => {
4628
+ this._forEachPeerConnection(session => {
4629
4629
  this._withForcedRenegotiation(session, () => session.addTrack(track, stream));
4630
4630
  });
4631
4631
  }
4632
4632
 
4633
4633
  _replaceTrackToPeerConnections(oldTrack, newTrack) {
4634
4634
  const promises = [];
4635
- this._forEachPeerConnection((session) => {
4635
+ this._forEachPeerConnection(session => {
4636
4636
  if (!session.hasConnectedPeerConnection()) {
4637
4637
  logger$2.log("Session doesn't have a connected PeerConnection, adding pending action!");
4638
4638
  const pendingActions = this._pendingActionsForConnectedPeerConnections;
@@ -4650,7 +4650,7 @@ class BaseRtcManager {
4650
4650
  reject(`ReplaceTrack returned false`);
4651
4651
  return;
4652
4652
  }
4653
- replacedTrackPromise.then((track) => resolve(track)).catch((error) => reject(error));
4653
+ replacedTrackPromise.then(track => resolve(track)).catch(error => reject(error));
4654
4654
  };
4655
4655
  pendingActions.push(action);
4656
4656
  });
@@ -4668,13 +4668,13 @@ class BaseRtcManager {
4668
4668
  }
4669
4669
 
4670
4670
  _removeStreamFromPeerConnections(stream) {
4671
- this._forEachPeerConnection((session) => {
4671
+ this._forEachPeerConnection(session => {
4672
4672
  this._withForcedRenegotiation(session, () => session.removeStream(stream));
4673
4673
  });
4674
4674
  }
4675
4675
 
4676
4676
  _removeTrackFromPeerConnections(track) {
4677
- this._forEachPeerConnection((session) => {
4677
+ this._forEachPeerConnection(session => {
4678
4678
  this._withForcedRenegotiation(session, () => session.removeTrack(track));
4679
4679
  });
4680
4680
  }
@@ -4727,11 +4727,11 @@ class BaseRtcManager {
4727
4727
  }
4728
4728
 
4729
4729
  disconnectAll() {
4730
- Object.keys(this.peerConnections).forEach((peerConnectionId) => {
4730
+ Object.keys(this.peerConnections).forEach(peerConnectionId => {
4731
4731
  this.disconnect(peerConnectionId);
4732
4732
  });
4733
4733
  this.peerConnections = {};
4734
- this._socketListenerDeregisterFunctions.forEach((func) => {
4734
+ this._socketListenerDeregisterFunctions.forEach(func => {
4735
4735
  func();
4736
4736
  });
4737
4737
  this._socketListenerDeregisterFunctions = [];
@@ -4748,7 +4748,7 @@ class BaseRtcManager {
4748
4748
  * used in getUserMedia.
4749
4749
  */
4750
4750
  fixChromeAudio(constraints) {
4751
- if (browserName$2 !== "chrome") {
4751
+ if (browserName$1 !== "chrome") {
4752
4752
  return;
4753
4753
  }
4754
4754
  const localStream = this._getLocalCameraStream();
@@ -4756,7 +4756,7 @@ class BaseRtcManager {
4756
4756
  if (!audioTrack || audioTrack.readyState !== "ended") {
4757
4757
  return;
4758
4758
  }
4759
- return navigator.mediaDevices.getUserMedia({ audio: constraints }).then((stream) => {
4759
+ return navigator.mediaDevices.getUserMedia({ audio: constraints }).then(stream => {
4760
4760
  const track = stream.getAudioTracks()[0];
4761
4761
  track.enabled = audioTrack.enabled; // retain mute state and don't accidentally unmute.
4762
4762
  localStream.removeTrack(audioTrack); // remove the old track.
@@ -4790,7 +4790,7 @@ class BaseRtcManager {
4790
4790
  this._socketListenerDeregisterFunctions = [
4791
4791
  () => this._clearMediaServersRefresh(),
4792
4792
 
4793
- this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, (data) => {
4793
+ this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, data => {
4794
4794
  if (data.error) {
4795
4795
  logger$2.warn("FETCH_MEDIASERVER_CONFIG failed:", data.error);
4796
4796
  return;
@@ -4798,11 +4798,11 @@ class BaseRtcManager {
4798
4798
  this._updateAndScheduleMediaServersRefresh(data);
4799
4799
  }),
4800
4800
 
4801
- this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, (data) => {
4801
+ this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, data => {
4802
4802
  this._connect(data.clientId);
4803
4803
  }),
4804
4804
 
4805
- this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, (data) => {
4805
+ this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, data => {
4806
4806
  const session = this._getSession(data.clientId);
4807
4807
  if (!session) {
4808
4808
  logger$2.warn("No RTCPeerConnection on ICE_CANDIDATE", data);
@@ -4811,7 +4811,7 @@ class BaseRtcManager {
4811
4811
  session.addIceCandidate(data.message);
4812
4812
  }),
4813
4813
 
4814
- this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, (data) => {
4814
+ this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, data => {
4815
4815
  const session = this._getSession(data.clientId);
4816
4816
  if (!session) {
4817
4817
  logger$2.warn("No RTCPeerConnection on ICE_END_OF_CANDIDATES", data);
@@ -4821,14 +4821,14 @@ class BaseRtcManager {
4821
4821
  }),
4822
4822
 
4823
4823
  // when a new SDP offer is received from another client
4824
- this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
4824
+ this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, data => {
4825
4825
  const session = this._getSession(data.clientId);
4826
4826
  if (!session) {
4827
4827
  logger$2.warn("No RTCPeerConnection on SDP_OFFER", data);
4828
4828
  return;
4829
4829
  }
4830
4830
  const offer = this._transformIncomingSdp(data.message, session.pc);
4831
- session.handleOffer(offer).then((answer) => {
4831
+ session.handleOffer(offer).then(answer => {
4832
4832
  this._emitServerEvent(RELAY_MESSAGES.SDP_ANSWER, {
4833
4833
  receiverId: data.clientId,
4834
4834
  message: this._transformOutgoingSdp(answer),
@@ -4837,7 +4837,7 @@ class BaseRtcManager {
4837
4837
  }),
4838
4838
 
4839
4839
  // when a new SDP answer is received from another client
4840
- this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
4840
+ this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, data => {
4841
4841
  const session = this._getSession(data.clientId);
4842
4842
  if (!session) {
4843
4843
  logger$2.warn("No RTCPeerConnection on SDP_ANSWER", data);
@@ -4855,7 +4855,7 @@ class BaseRtcManager {
4855
4855
  }
4856
4856
 
4857
4857
  const logger$1 = console;
4858
- const browserName$1 = adapter.browserDetails.browser;
4858
+ const browserName = adapter.browserDetails.browser;
4859
4859
  class P2pRtcManager extends BaseRtcManager {
4860
4860
  _connect(clientId) {
4861
4861
  const shouldAddLocalVideo = true;
@@ -4907,7 +4907,7 @@ class P2pRtcManager extends BaseRtcManager {
4907
4907
  session.isOperationPending = true;
4908
4908
 
4909
4909
  pc.createOffer(constraints || this.offerOptions)
4910
- .then((offer) => {
4910
+ .then(offer => {
4911
4911
  this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
4912
4912
  receiverId: clientId,
4913
4913
  message: this._transformOutgoingSdp(offer),
@@ -4916,17 +4916,17 @@ class P2pRtcManager extends BaseRtcManager {
4916
4916
  // workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1394602
4917
4917
  // make Chrome send media later when there are two (more more?) video tracks.
4918
4918
  if (
4919
- browserName$1 === "chrome" &&
4920
- pc.getSenders().filter((sender) => sender.track && sender.track.kind === "video").length >= 2
4919
+ browserName === "chrome" &&
4920
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === "video").length >= 2
4921
4921
  ) {
4922
4922
  session.pendingOffer = offer;
4923
4923
  return;
4924
4924
  }
4925
- pc.setLocalDescription(offer).catch((e) => {
4925
+ pc.setLocalDescription(offer).catch(e => {
4926
4926
  logger$1.warn("RTCPeerConnection.setLocalDescription() failed with local offer", e);
4927
4927
  });
4928
4928
  })
4929
- .catch((e) => {
4929
+ .catch(e => {
4930
4930
  logger$1.warn("RTCPeerConnection.createOffer() failed to create local offer", e);
4931
4931
  });
4932
4932
  }
@@ -4976,7 +4976,7 @@ class P2pRtcManager extends BaseRtcManager {
4976
4976
  return 0;
4977
4977
  }
4978
4978
 
4979
- this._forEachPeerConnection((session) => {
4979
+ this._forEachPeerConnection(session => {
4980
4980
  session.changeBandwidth(bandwidth);
4981
4981
  });
4982
4982
 
@@ -5007,7 +5007,7 @@ class P2pRtcManager extends BaseRtcManager {
5007
5007
  pc.addTrack(this._stoppedVideoTrack, localCameraStream);
5008
5008
  }
5009
5009
 
5010
- pc.onicecandidate = (event) => {
5010
+ pc.onicecandidate = event => {
5011
5011
  if (event.candidate) {
5012
5012
  session.relayCandidateSeen = session.relayCandidateSeen || event.candidate.type === "relay";
5013
5013
  this._emitServerEvent(RELAY_MESSAGES.ICE_CANDIDATE, {
@@ -5064,7 +5064,7 @@ class P2pRtcManager extends BaseRtcManager {
5064
5064
  const numPeers = this.numberOfPeerconnections();
5065
5065
  if (numPeers === 0) {
5066
5066
  setTimeout(() => {
5067
- this.numberOfPeerconnections();
5067
+ //const numPeers = this.numberOfPeerconnections();
5068
5068
  }, 60 * 1000);
5069
5069
  }
5070
5070
  }
@@ -5078,13 +5078,13 @@ class P2pRtcManager extends BaseRtcManager {
5078
5078
 
5079
5079
  stopOrResumeVideo(localStream, enable) {
5080
5080
  // actually turn off the camera. Chrome-only (Firefox has different plans)
5081
- if (browserName$1 !== "chrome") {
5081
+ if (browserName !== "chrome") {
5082
5082
  return;
5083
5083
  }
5084
5084
  if (enable === false) {
5085
5085
  // try to stop the local camera so the camera light goes off.
5086
5086
  setTimeout(() => {
5087
- localStream.getVideoTracks().forEach((track) => {
5087
+ localStream.getVideoTracks().forEach(track => {
5088
5088
  if (track.enabled === false) {
5089
5089
  track.stop();
5090
5090
  localStream.removeTrack(track);
@@ -5123,7 +5123,7 @@ class P2pRtcManager extends BaseRtcManager {
5123
5123
  // device has been plugged out or similar
5124
5124
  return;
5125
5125
  }
5126
- navigator.mediaDevices.getUserMedia({ video: constraints }).then((stream) => {
5126
+ navigator.mediaDevices.getUserMedia({ video: constraints }).then(stream => {
5127
5127
  const track = stream.getVideoTracks()[0];
5128
5128
  localStream.addTrack(track);
5129
5129
  this._emit(EVENTS.LOCAL_STREAM_TRACK_ADDED, {
@@ -5309,7 +5309,7 @@ class VegaConnection extends EventEmitter {
5309
5309
  this.socket.onerror = null;
5310
5310
  this.socket = null;
5311
5311
 
5312
- this.sents.forEach((sent) => sent.close());
5312
+ this.sents.forEach(sent => sent.close());
5313
5313
 
5314
5314
  this.emit("close");
5315
5315
  }
@@ -5383,13 +5383,13 @@ class VegaConnection extends EventEmitter {
5383
5383
  const sent = {
5384
5384
  id: request.id,
5385
5385
  method: request.method,
5386
- resolve: (data2) => {
5386
+ resolve: data2 => {
5387
5387
  if (!this.sents.delete(request.id)) return;
5388
5388
 
5389
5389
  clearTimeout(sent.timer);
5390
5390
  pResolve(data2);
5391
5391
  },
5392
- reject: (error) => {
5392
+ reject: error => {
5393
5393
  if (!this.sents.delete(request.id)) return;
5394
5394
 
5395
5395
  clearTimeout(sent.timer);
@@ -5487,30 +5487,30 @@ const modifyMediaCapabilities = (routerRtpCapabilities, features) => {
5487
5487
 
5488
5488
  if (vp9On) {
5489
5489
  const { preferredPayloadType } = routerRtpCapabilities.codecs.find(
5490
- (codec) => codec.mimeType.toLowerCase() === "video/vp9"
5490
+ codec => codec.mimeType.toLowerCase() === "video/vp9"
5491
5491
  );
5492
5492
 
5493
5493
  const { preferredPayloadType: aptPreferredPayloadType } = routerRtpCapabilities.codecs.find(
5494
- (codec) => codec.mimeType.toLowerCase() === "video/rtx" && codec.parameters.apt === preferredPayloadType
5494
+ codec => codec.mimeType.toLowerCase() === "video/rtx" && codec.parameters.apt === preferredPayloadType
5495
5495
  );
5496
5496
 
5497
5497
  routerRtpCapabilities.codecs = routerRtpCapabilities.codecs.filter(
5498
- (codec) =>
5498
+ codec =>
5499
5499
  codec.kind === "audio" ||
5500
5500
  codec.preferredPayloadType === preferredPayloadType ||
5501
5501
  codec.preferredPayloadType === aptPreferredPayloadType
5502
5502
  );
5503
5503
  } else if (h264On) {
5504
5504
  const { preferredPayloadType } = routerRtpCapabilities.codecs.find(
5505
- (codec) => codec.mimeType.toLowerCase() === "video/h264"
5505
+ codec => codec.mimeType.toLowerCase() === "video/h264"
5506
5506
  );
5507
5507
 
5508
5508
  const { preferredPayloadType: aptPreferredPayloadType } = routerRtpCapabilities.codecs.find(
5509
- (codec) => codec.mimeType.toLowerCase() === "video/rtx" && codec.parameters.apt === preferredPayloadType
5509
+ codec => codec.mimeType.toLowerCase() === "video/rtx" && codec.parameters.apt === preferredPayloadType
5510
5510
  );
5511
5511
 
5512
5512
  routerRtpCapabilities.codecs = routerRtpCapabilities.codecs.filter(
5513
- (codec) =>
5513
+ codec =>
5514
5514
  codec.kind === "audio" ||
5515
5515
  codec.preferredPayloadType === preferredPayloadType ||
5516
5516
  codec.preferredPayloadType === aptPreferredPayloadType
@@ -5544,7 +5544,7 @@ const maybeTurnOnly = (transportConfig, features) => {
5544
5544
  }[features.useOnlyTURN];
5545
5545
 
5546
5546
  if (filter) {
5547
- transportConfig.iceServers = transportConfig.iceServers.filter((entry) => entry.url && entry.url.match(filter));
5547
+ transportConfig.iceServers = transportConfig.iceServers.filter(entry => entry.url && entry.url.match(filter));
5548
5548
  }
5549
5549
  };
5550
5550
 
@@ -5648,7 +5648,7 @@ class VegaRtcManager {
5648
5648
  this._socketListenerDeregisterFunctions.push(
5649
5649
  () => this._clearMediaServersRefresh(),
5650
5650
 
5651
- this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, (data) => {
5651
+ this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, data => {
5652
5652
  if (data.error) {
5653
5653
  logger.warn("FETCH_MEDIASERVER_CONFIG failed:", data.error);
5654
5654
  return;
@@ -5685,7 +5685,7 @@ class VegaRtcManager {
5685
5685
  this._vegaConnection = new VegaConnection(wsUrl, logger);
5686
5686
  this._vegaConnection.on("open", () => this._join());
5687
5687
  this._vegaConnection.on("close", () => this._onClose());
5688
- this._vegaConnection.on("message", (message) => this._onMessage(message));
5688
+ this._vegaConnection.on("message", message => this._onMessage(message));
5689
5689
  }
5690
5690
 
5691
5691
  _onClose() {
@@ -5766,7 +5766,7 @@ class VegaRtcManager {
5766
5766
  maybeTurnOnly(transportOptions, this._features);
5767
5767
 
5768
5768
  const transport = this._mediasoupDevice[creator](transportOptions);
5769
- const onConnectionStateListener = async (connectionState) => {
5769
+ const onConnectionStateListener = async connectionState => {
5770
5770
  logger.debug(`Transport ConnectionStateChanged ${connectionState}`);
5771
5771
  if (connectionState !== "disconnected" && connectionState !== "failed") {
5772
5772
  return;
@@ -5878,7 +5878,7 @@ class VegaRtcManager {
5878
5878
  const error = await transport
5879
5879
  .restartIce({ iceParameters })
5880
5880
  .then(() => null)
5881
- .catch((err) => err);
5881
+ .catch(err => err);
5882
5882
 
5883
5883
  if (error) {
5884
5884
  logger.error(`_restartIce: ICE restart failed: ${error}`);
@@ -5889,7 +5889,7 @@ class VegaRtcManager {
5889
5889
  break;
5890
5890
  default:
5891
5891
  // exponential backoff
5892
- await new Promise((resolve) => {
5892
+ await new Promise(resolve => {
5893
5893
  setTimeout(() => {
5894
5894
  resolve();
5895
5895
  }, Math.min(RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS * 2 ** retried, 60000));
@@ -5899,7 +5899,7 @@ class VegaRtcManager {
5899
5899
  }
5900
5900
  return;
5901
5901
  }
5902
- await new Promise((resolve) => {
5902
+ await new Promise(resolve => {
5903
5903
  setTimeout(() => {
5904
5904
  resolve();
5905
5905
  }, 60000 * Math.min(8, retried + 1));
@@ -6473,54 +6473,6 @@ class VegaRtcManager {
6473
6473
  this._webcamPaused = !enable;
6474
6474
 
6475
6475
  this._pauseResumeWebcam();
6476
-
6477
- if (browserName === "chrome") {
6478
- // actually turn off the camera. Chrome-only (Firefox etc. has different plans)
6479
-
6480
- if (!enable) {
6481
- clearTimeout(this._stopCameraTimeout);
6482
-
6483
- // try to stop the local camera so the camera light goes off.
6484
- this._stopCameraTimeout = setTimeout(() => {
6485
- localStream.getVideoTracks().forEach((track) => {
6486
- if (track.enabled === false) {
6487
- track.stop();
6488
- localStream.removeTrack(track);
6489
-
6490
- this._emitToPWA(EVENTS.LOCAL_STREAM_TRACK_REMOVED, {
6491
- stream: localStream,
6492
- track,
6493
- });
6494
-
6495
- if (
6496
- this._webcamProducer &&
6497
- !this._webcamProducer.closed &&
6498
- this._webcamProducer.track === track
6499
- ) {
6500
- this._stopProducer(this._webcamProducer);
6501
- this._webcamProducer = null;
6502
- this._webcamTrack = null;
6503
- }
6504
- }
6505
- });
6506
- }, 5000);
6507
- } else if (localStream.getVideoTracks().length === 0) {
6508
- // re-enable the stream
6509
- const constraints = this._webrtcProvider.getMediaConstraints().video;
6510
- navigator.mediaDevices.getUserMedia({ video: constraints }).then((stream) => {
6511
- const track = stream.getVideoTracks()[0];
6512
- localStream.addTrack(track);
6513
-
6514
- this._emitToPWA(EVENTS.LOCAL_STREAM_TRACK_ADDED, {
6515
- streamId: localStream.id,
6516
- tracks: [track],
6517
- screenShare: false,
6518
- });
6519
-
6520
- this._sendWebcam(track);
6521
- });
6522
- }
6523
- }
6524
6476
  }
6525
6477
 
6526
6478
  supportsScreenShareAudio() {
@@ -6587,7 +6539,7 @@ class VegaRtcManager {
6587
6539
  }
6588
6540
 
6589
6541
  disconnectAll() {
6590
- this._socketListenerDeregisterFunctions.forEach((func) => {
6542
+ this._socketListenerDeregisterFunctions.forEach(func => {
6591
6543
  func();
6592
6544
  });
6593
6545
 
@@ -6630,7 +6582,7 @@ class VegaRtcManager {
6630
6582
  return;
6631
6583
  }
6632
6584
  })
6633
- .catch((error) => {
6585
+ .catch(error => {
6634
6586
  console.error('"message" failed [error:%o]', error);
6635
6587
  });
6636
6588
  }
@@ -6765,7 +6717,7 @@ class VegaRtcManager {
6765
6717
  const toPauseConsumers = [];
6766
6718
  const toResumeConsumers = [];
6767
6719
 
6768
- this._consumers.forEach((consumer) => {
6720
+ this._consumers.forEach(consumer => {
6769
6721
  if (consumer.appData.sourceClientId !== clientId) return;
6770
6722
 
6771
6723
  const hasAccepted = consumer.appData.screenShare ? hasAcceptedScreenStream : hasAcceptedWebcamStream;
@@ -9104,6 +9056,6 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
9104
9056
  };
9105
9057
  }
9106
9058
 
9107
- const sdkVersion = "2.0.0-alpha16";
9059
+ const sdkVersion = "2.0.0-alpha17";
9108
9060
 
9109
9061
  export { VideoView, sdkVersion, useLocalMedia, useRoomConnection };