livekit-client 1.9.5 → 1.9.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -14010,7 +14010,7 @@ let browserDetails;
14010
14010
  */
14011
14011
  function getBrowser(userAgent) {
14012
14012
  let force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
14013
- if (userAgent === undefined && (typeof document !== 'undefined' || typeof navigator === 'undefined')) {
14013
+ if (typeof userAgent === 'undefined' && typeof navigator === 'undefined') {
14014
14014
  return;
14015
14015
  }
14016
14016
  const ua = (userAgent !== null && userAgent !== void 0 ? userAgent : navigator.userAgent).toLowerCase();
@@ -14060,7 +14060,7 @@ function getMatch(exp, ua) {
14060
14060
  return match && match.length >= id && match[id] || '';
14061
14061
  }
14062
14062
 
14063
- var version$1 = "1.9.5";
14063
+ var version$1 = "1.9.7";
14064
14064
 
14065
14065
  const version = version$1;
14066
14066
  const protocolVersion = 9;
@@ -14350,10 +14350,12 @@ const getResizeObserver = () => {
14350
14350
  };
14351
14351
  let intersectionObserver = null;
14352
14352
  const getIntersectionObserver = () => {
14353
- if (!intersectionObserver) intersectionObserver = new IntersectionObserver(ioDispatchCallback, {
14354
- root: document,
14355
- rootMargin: '0px'
14356
- });
14353
+ if (!intersectionObserver) {
14354
+ intersectionObserver = new IntersectionObserver(ioDispatchCallback, {
14355
+ root: null,
14356
+ rootMargin: '0px'
14357
+ });
14358
+ }
14357
14359
  return intersectionObserver;
14358
14360
  };
14359
14361
  function getClientInfo() {
@@ -18219,7 +18221,7 @@ function computeBitrate(currentStats, prevStats) {
18219
18221
  return (bytesNow - bytesPrev) * 8 * 1000 / (currentStats.timestamp - prevStats.timestamp);
18220
18222
  }
18221
18223
 
18222
- const defaultDimensionsTimeout = 2 * 1000;
18224
+ const defaultDimensionsTimeout = 1000;
18223
18225
  class LocalTrack extends Track {
18224
18226
  /**
18225
18227
  *
@@ -20371,6 +20373,15 @@ class RemoteParticipant extends Participant {
20371
20373
  if (!publication) {
20372
20374
  return;
20373
20375
  }
20376
+ // also send unsubscribe, if track is actively subscribed
20377
+ const {
20378
+ track
20379
+ } = publication;
20380
+ if (track) {
20381
+ track.stop();
20382
+ publication.setTrack(undefined);
20383
+ }
20384
+ // remove track from maps only after unsubscribed has been fired
20374
20385
  this.tracks.delete(sid);
20375
20386
  // remove from the right type map
20376
20387
  switch (publication.kind) {
@@ -20381,14 +20392,6 @@ class RemoteParticipant extends Participant {
20381
20392
  this.videoTracks.delete(sid);
20382
20393
  break;
20383
20394
  }
20384
- // also send unsubscribe, if track is actively subscribed
20385
- const {
20386
- track
20387
- } = publication;
20388
- if (track) {
20389
- track.stop();
20390
- publication.setTrack(undefined);
20391
- }
20392
20395
  if (sendUnpublish) {
20393
20396
  this.emit(ParticipantEvent.TrackUnpublished, publication);
20394
20397
  }
@@ -20662,6 +20665,29 @@ function encodingsFromPresets(width, height, presets) {
20662
20665
  }
20663
20666
  encodings.push(encoding);
20664
20667
  });
20668
+ // RN ios simulcast requires all same framerates.
20669
+ if (isReactNative() && getReactNativeOs() === 'ios') {
20670
+ let topFramerate = undefined;
20671
+ encodings.forEach(encoding => {
20672
+ if (!topFramerate) {
20673
+ topFramerate = encoding.maxFramerate;
20674
+ } else if (encoding.maxFramerate && encoding.maxFramerate > topFramerate) {
20675
+ topFramerate = encoding.maxFramerate;
20676
+ }
20677
+ });
20678
+ let notifyOnce = true;
20679
+ encodings.forEach(encoding => {
20680
+ var _a;
20681
+ if (encoding.maxFramerate != topFramerate) {
20682
+ if (notifyOnce) {
20683
+ notifyOnce = false;
20684
+ livekitLogger.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.");
20685
+ }
20686
+ livekitLogger.info("Setting framerate of encoding \"".concat((_a = encoding.rid) !== null && _a !== void 0 ? _a : '', "\" to ").concat(topFramerate));
20687
+ encoding.maxFramerate = topFramerate;
20688
+ }
20689
+ });
20690
+ }
20665
20691
  return encodings;
20666
20692
  }
20667
20693
  /** @internal */
@@ -21218,7 +21244,7 @@ class LocalParticipant extends Participant {
21218
21244
  });
21219
21245
  }
21220
21246
  publish(track, opts, options, isStereo) {
21221
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
21247
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
21222
21248
  return __awaiter(this, void 0, void 0, function* () {
21223
21249
  const existingTrackOfSource = Array.from(this.tracks.values()).find(publishedTrack => track instanceof LocalTrack && publishedTrack.source === track.source);
21224
21250
  if (existingTrackOfSource && track.source !== Track.Source.Unknown) {
@@ -21279,8 +21305,15 @@ class LocalParticipant extends Participant {
21279
21305
  try {
21280
21306
  dims = yield track.waitForDimensions();
21281
21307
  } catch (e) {
21308
+ // use defaults, it's quite painful for congestion control without simulcast
21309
+ // so using default dims according to publish settings
21310
+ const defaultRes = (_d = (_c = this.roomOptions.videoCaptureDefaults) === null || _c === void 0 ? void 0 : _c.resolution) !== null && _d !== void 0 ? _d : VideoPresets.h720.resolution;
21311
+ dims = {
21312
+ width: defaultRes.width,
21313
+ height: defaultRes.height
21314
+ };
21282
21315
  // log failure
21283
- livekitLogger.error('could not determine track dimensions');
21316
+ livekitLogger.error('could not determine track dimensions, using defaults', dims);
21284
21317
  }
21285
21318
  // width and height should be defined for video
21286
21319
  req.width = dims.width;
@@ -21289,7 +21322,7 @@ class LocalParticipant extends Participant {
21289
21322
  if (track instanceof LocalVideoTrack) {
21290
21323
  if (isSVCCodec(opts.videoCodec)) {
21291
21324
  // set scalabilityMode to 'L3T3' by default
21292
- opts.scalabilityMode = (_c = opts.scalabilityMode) !== null && _c !== void 0 ? _c : 'L3T3';
21325
+ opts.scalabilityMode = (_e = opts.scalabilityMode) !== null && _e !== void 0 ? _e : 'L3T3';
21293
21326
  }
21294
21327
  // set up backup
21295
21328
  if (opts.videoCodec && opts.backupCodec && opts.videoCodec !== opts.backupCodec.codec) {
@@ -21311,9 +21344,9 @@ class LocalParticipant extends Participant {
21311
21344
  req.layers = videoLayersFromEncodings(req.width, req.height, simEncodings !== null && simEncodings !== void 0 ? simEncodings : encodings);
21312
21345
  } else if (track.kind === Track.Kind.Audio) {
21313
21346
  encodings = [{
21314
- maxBitrate: (_e = (_d = opts.audioPreset) === null || _d === void 0 ? void 0 : _d.maxBitrate) !== null && _e !== void 0 ? _e : opts.audioBitrate,
21315
- priority: (_g = (_f = opts.audioPreset) === null || _f === void 0 ? void 0 : _f.priority) !== null && _g !== void 0 ? _g : 'high',
21316
- networkPriority: (_j = (_h = opts.audioPreset) === null || _h === void 0 ? void 0 : _h.priority) !== null && _j !== void 0 ? _j : 'high'
21347
+ maxBitrate: (_g = (_f = opts.audioPreset) === null || _f === void 0 ? void 0 : _f.maxBitrate) !== null && _g !== void 0 ? _g : opts.audioBitrate,
21348
+ priority: (_j = (_h = opts.audioPreset) === null || _h === void 0 ? void 0 : _h.priority) !== null && _j !== void 0 ? _j : 'high',
21349
+ networkPriority: (_l = (_k = opts.audioPreset) === null || _k === void 0 ? void 0 : _k.priority) !== null && _l !== void 0 ? _l : 'high'
21317
21350
  }];
21318
21351
  }
21319
21352
  if (!this.engine || this.engine.isClosed) {
@@ -21355,7 +21388,7 @@ class LocalParticipant extends Participant {
21355
21388
  });
21356
21389
  // store RTPSender
21357
21390
  track.sender = yield this.engine.createSender(track, opts, encodings);
21358
- if (track.codec && isSVCCodec(track.codec) && encodings && ((_k = encodings[0]) === null || _k === void 0 ? void 0 : _k.maxBitrate)) {
21391
+ if (track.codec && isSVCCodec(track.codec) && encodings && ((_m = encodings[0]) === null || _m === void 0 ? void 0 : _m.maxBitrate)) {
21359
21392
  this.engine.publisher.setTrackCodecBitrate(req.cid, track.codec, encodings[0].maxBitrate / 1000);
21360
21393
  }
21361
21394
  this.engine.negotiate();