@stream-io/video-client 0.3.1 → 0.3.2

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/index.cjs.js CHANGED
@@ -7,9 +7,9 @@ var axios = require('axios');
7
7
  var twirpTransport = require('@protobuf-ts/twirp-transport');
8
8
  var rxjs = require('rxjs');
9
9
  var SDP = require('sdp-transform');
10
+ var uaParserJs = require('ua-parser-js');
10
11
  var WebSocket = require('isomorphic-ws');
11
12
  var operators = require('rxjs/operators');
12
- var uaParserJs = require('ua-parser-js');
13
13
  var https = require('https');
14
14
  var jwt = require('jsonwebtoken');
15
15
  require('crypto');
@@ -6289,6 +6289,56 @@ function getIceCandidate(candidate) {
6289
6289
  }
6290
6290
  }
6291
6291
 
6292
+ let sdkInfo;
6293
+ let osInfo;
6294
+ let deviceInfo;
6295
+ const setSdkInfo = (info) => {
6296
+ sdkInfo = info;
6297
+ };
6298
+ const getSdkInfo = () => {
6299
+ return sdkInfo;
6300
+ };
6301
+ const setOSInfo = (info) => {
6302
+ osInfo = info;
6303
+ };
6304
+ const getOSInfo = () => {
6305
+ return osInfo;
6306
+ };
6307
+ const setDeviceInfo = (info) => {
6308
+ deviceInfo = info;
6309
+ };
6310
+ const getDeviceInfo = () => {
6311
+ return deviceInfo;
6312
+ };
6313
+ const getClientDetails = () => {
6314
+ if (isReactNative()) {
6315
+ // Since RN doesn't support web, sharing browser info is not required
6316
+ return {
6317
+ sdk: getSdkInfo(),
6318
+ os: getOSInfo(),
6319
+ device: getDeviceInfo(),
6320
+ };
6321
+ }
6322
+ const userAgent = new uaParserJs.UAParser(navigator.userAgent);
6323
+ const { browser, os, device, cpu } = userAgent.getResult();
6324
+ return {
6325
+ sdk: getSdkInfo(),
6326
+ browser: {
6327
+ name: browser.name || navigator.userAgent,
6328
+ version: browser.version || '',
6329
+ },
6330
+ os: {
6331
+ name: os.name || '',
6332
+ version: os.version || '',
6333
+ architecture: cpu.architecture || '',
6334
+ },
6335
+ device: {
6336
+ name: `${device.vendor || ''} ${device.model || ''} ${device.type || ''}`,
6337
+ version: '',
6338
+ },
6339
+ };
6340
+ };
6341
+
6292
6342
  const DEFAULT_BITRATE = 1250000;
6293
6343
  const defaultTargetResolution = {
6294
6344
  bitrate: DEFAULT_BITRATE,
@@ -6303,9 +6353,11 @@ const defaultTargetResolution = {
6303
6353
  * @param targetResolution the expected target resolution.
6304
6354
  */
6305
6355
  const findOptimalVideoLayers = (videoTrack, targetResolution = defaultTargetResolution) => {
6356
+ var _a;
6306
6357
  const optimalVideoLayers = [];
6307
6358
  const settings = videoTrack.getSettings();
6308
6359
  const { width: w = 0, height: h = 0 } = settings;
6360
+ const isRNIos = isReactNative() && ((_a = getOSInfo()) === null || _a === void 0 ? void 0 : _a.name.toLowerCase()) === 'ios';
6309
6361
  const maxBitrate = getComputedMaxBitrate(targetResolution, w, h);
6310
6362
  let downscaleFactor = 1;
6311
6363
  ['f', 'h', 'q'].forEach((rid) => {
@@ -6319,10 +6371,11 @@ const findOptimalVideoLayers = (videoTrack, targetResolution = defaultTargetReso
6319
6371
  height: Math.round(h / downscaleFactor),
6320
6372
  maxBitrate: Math.round(maxBitrate / downscaleFactor),
6321
6373
  scaleResolutionDownBy: downscaleFactor,
6374
+ // Simulcast on iOS React-Native requires all encodings to share the same framerate
6322
6375
  maxFramerate: {
6323
6376
  f: 30,
6324
- h: 25,
6325
- q: 20,
6377
+ h: isRNIos ? 30 : 25,
6378
+ q: isRNIos ? 30 : 20,
6326
6379
  }[rid],
6327
6380
  });
6328
6381
  downscaleFactor *= 2;
@@ -6521,6 +6574,7 @@ class Publisher {
6521
6574
  * @param opts
6522
6575
  */
6523
6576
  this.publishStream = (mediaStream, track, trackType, opts = {}) => __awaiter(this, void 0, void 0, function* () {
6577
+ var _a;
6524
6578
  if (track.readyState === 'ended') {
6525
6579
  throw new Error(`Can't publish a track that has ended already.`);
6526
6580
  }
@@ -6548,7 +6602,14 @@ class Publisher {
6548
6602
  const videoEncodings = trackType === TrackType.VIDEO
6549
6603
  ? findOptimalVideoLayers(track, targetResolution)
6550
6604
  : undefined;
6551
- const codecPreferences = this.getCodecPreferences(trackType, opts.preferredCodec);
6605
+ let preferredCodec = opts.preferredCodec;
6606
+ if (!preferredCodec && trackType === TrackType.VIDEO) {
6607
+ const isRNAndroid = isReactNative() && ((_a = getOSInfo()) === null || _a === void 0 ? void 0 : _a.name.toLowerCase()) === 'android';
6608
+ if (isRNAndroid) {
6609
+ preferredCodec = 'VP8';
6610
+ }
6611
+ }
6612
+ const codecPreferences = this.getCodecPreferences(trackType, preferredCodec);
6552
6613
  // listen for 'ended' event on the track as it might be ended abruptly
6553
6614
  // by an external factor as permission revokes, device disconnected, etc.
6554
6615
  // keep in mind that `track.stop()` doesn't trigger this event.
@@ -6642,9 +6703,9 @@ class Publisher {
6642
6703
  });
6643
6704
  };
6644
6705
  this.updateVideoPublishQuality = (enabledRids) => __awaiter(this, void 0, void 0, function* () {
6645
- var _a;
6706
+ var _b;
6646
6707
  logger$3('info', 'Update publish quality, requested rids by SFU:', enabledRids);
6647
- const videoSender = (_a = this.transceiverRegistry[TrackType.VIDEO]) === null || _a === void 0 ? void 0 : _a.sender;
6708
+ const videoSender = (_b = this.transceiverRegistry[TrackType.VIDEO]) === null || _b === void 0 ? void 0 : _b.sender;
6648
6709
  if (!videoSender) {
6649
6710
  logger$3('warn', 'Update publish quality, no video sender found.');
6650
6711
  return;
@@ -6742,8 +6803,8 @@ class Publisher {
6742
6803
  * @param options the optional offer options to use.
6743
6804
  */
6744
6805
  this.negotiate = (options) => __awaiter(this, void 0, void 0, function* () {
6745
- var _b;
6746
- this.isIceRestarting = (_b = options === null || options === void 0 ? void 0 : options.iceRestart) !== null && _b !== void 0 ? _b : false;
6806
+ var _c;
6807
+ this.isIceRestarting = (_c = options === null || options === void 0 ? void 0 : options.iceRestart) !== null && _c !== void 0 ? _c : false;
6747
6808
  const offer = yield this.pc.createOffer(options);
6748
6809
  offer.sdp = this.mungeCodecs(offer.sdp);
6749
6810
  const trackInfos = this.getCurrentTrackInfos(offer.sdp);
@@ -6781,15 +6842,6 @@ class Publisher {
6781
6842
  this.mungeCodecs = (sdp) => {
6782
6843
  if (sdp) {
6783
6844
  sdp = toggleDtx(sdp, this.isDtxEnabled);
6784
- if (isReactNative()) {
6785
- if (this.preferredVideoCodec) {
6786
- sdp = setPreferredCodec(sdp, 'video', this.preferredVideoCodec);
6787
- }
6788
- sdp = setPreferredCodec(sdp, 'audio', this.isRedEnabled ? 'red' : 'opus');
6789
- if (!this.isRedEnabled) {
6790
- sdp = removeCodec(sdp, 'audio', 'red');
6791
- }
6792
- }
6793
6845
  }
6794
6846
  return sdp;
6795
6847
  };
@@ -9487,56 +9539,6 @@ const CallTypes = new CallTypesRegistry([
9487
9539
  }),
9488
9540
  ]);
9489
9541
 
9490
- let sdkInfo;
9491
- let osInfo;
9492
- let deviceInfo;
9493
- const setSdkInfo = (info) => {
9494
- sdkInfo = info;
9495
- };
9496
- const getSdkInfo = () => {
9497
- return sdkInfo;
9498
- };
9499
- const setOSInfo = (info) => {
9500
- osInfo = info;
9501
- };
9502
- const getOSInfo = () => {
9503
- return osInfo;
9504
- };
9505
- const setDeviceInfo = (info) => {
9506
- deviceInfo = info;
9507
- };
9508
- const getDeviceInfo = () => {
9509
- return deviceInfo;
9510
- };
9511
- const getClientDetails = () => {
9512
- if (isReactNative()) {
9513
- // Since RN doesn't support web, sharing browser info is not required
9514
- return {
9515
- sdk: getSdkInfo(),
9516
- os: getOSInfo(),
9517
- device: getDeviceInfo(),
9518
- };
9519
- }
9520
- const userAgent = new uaParserJs.UAParser(navigator.userAgent);
9521
- const { browser, os, device, cpu } = userAgent.getResult();
9522
- return {
9523
- sdk: getSdkInfo(),
9524
- browser: {
9525
- name: browser.name || navigator.userAgent,
9526
- version: browser.version || '',
9527
- },
9528
- os: {
9529
- name: os.name || '',
9530
- version: os.version || '',
9531
- architecture: cpu.architecture || '',
9532
- },
9533
- device: {
9534
- name: `${device.vendor || ''} ${device.model || ''} ${device.type || ''}`,
9535
- version: '',
9536
- },
9537
- };
9538
- };
9539
-
9540
9542
  class InputMediaDeviceManagerState {
9541
9543
  constructor() {
9542
9544
  this.statusSubject = new rxjs.BehaviorSubject(undefined);
@@ -12459,7 +12461,7 @@ class WSConnectionFallback {
12459
12461
  }
12460
12462
  }
12461
12463
 
12462
- const version = '0.3.1';
12464
+ const version = '0.3.2';
12463
12465
 
12464
12466
  const logger = getLogger(['location']);
12465
12467
  const HINT_URL = `https://hint.stream-io-video.com/`;
@@ -13525,11 +13527,13 @@ exports.CallState = CallState;
13525
13527
  exports.CallType = CallType;
13526
13528
  exports.CallTypes = CallTypes;
13527
13529
  exports.CameraManager = CameraManager;
13530
+ exports.CameraManagerState = CameraManagerState;
13528
13531
  exports.CreateDeviceRequestPushProviderEnum = CreateDeviceRequestPushProviderEnum;
13529
13532
  exports.ErrorFromResponse = ErrorFromResponse;
13530
13533
  exports.InputMediaDeviceManager = InputMediaDeviceManager;
13531
13534
  exports.InputMediaDeviceManagerState = InputMediaDeviceManagerState;
13532
13535
  exports.MicrophoneManager = MicrophoneManager;
13536
+ exports.MicrophoneManagerState = MicrophoneManagerState;
13533
13537
  exports.OwnCapability = OwnCapability;
13534
13538
  exports.RecordSettingsModeEnum = RecordSettingsModeEnum;
13535
13539
  exports.RecordSettingsQualityEnum = RecordSettingsQualityEnum;