@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.es.js CHANGED
@@ -6,9 +6,9 @@ export { AxiosError } from 'axios';
6
6
  import { TwirpFetchTransport } from '@protobuf-ts/twirp-transport';
7
7
  import { ReplaySubject, BehaviorSubject, distinctUntilChanged as distinctUntilChanged$1, Observable, debounceTime, concatMap, from, shareReplay, merge, map as map$2, combineLatest, filter, pairwise, takeWhile, tap, debounce, timer } from 'rxjs';
8
8
  import * as SDP from 'sdp-transform';
9
+ import { UAParser } from 'ua-parser-js';
9
10
  import WebSocket from 'isomorphic-ws';
10
11
  import { take, map as map$1, distinctUntilChanged } from 'rxjs/operators';
11
- import { UAParser } from 'ua-parser-js';
12
12
  import https from 'https';
13
13
  import jwt from 'jsonwebtoken';
14
14
  import 'crypto';
@@ -6269,6 +6269,56 @@ function getIceCandidate(candidate) {
6269
6269
  }
6270
6270
  }
6271
6271
 
6272
+ let sdkInfo;
6273
+ let osInfo;
6274
+ let deviceInfo;
6275
+ const setSdkInfo = (info) => {
6276
+ sdkInfo = info;
6277
+ };
6278
+ const getSdkInfo = () => {
6279
+ return sdkInfo;
6280
+ };
6281
+ const setOSInfo = (info) => {
6282
+ osInfo = info;
6283
+ };
6284
+ const getOSInfo = () => {
6285
+ return osInfo;
6286
+ };
6287
+ const setDeviceInfo = (info) => {
6288
+ deviceInfo = info;
6289
+ };
6290
+ const getDeviceInfo = () => {
6291
+ return deviceInfo;
6292
+ };
6293
+ const getClientDetails = () => {
6294
+ if (isReactNative()) {
6295
+ // Since RN doesn't support web, sharing browser info is not required
6296
+ return {
6297
+ sdk: getSdkInfo(),
6298
+ os: getOSInfo(),
6299
+ device: getDeviceInfo(),
6300
+ };
6301
+ }
6302
+ const userAgent = new UAParser(navigator.userAgent);
6303
+ const { browser, os, device, cpu } = userAgent.getResult();
6304
+ return {
6305
+ sdk: getSdkInfo(),
6306
+ browser: {
6307
+ name: browser.name || navigator.userAgent,
6308
+ version: browser.version || '',
6309
+ },
6310
+ os: {
6311
+ name: os.name || '',
6312
+ version: os.version || '',
6313
+ architecture: cpu.architecture || '',
6314
+ },
6315
+ device: {
6316
+ name: `${device.vendor || ''} ${device.model || ''} ${device.type || ''}`,
6317
+ version: '',
6318
+ },
6319
+ };
6320
+ };
6321
+
6272
6322
  const DEFAULT_BITRATE = 1250000;
6273
6323
  const defaultTargetResolution = {
6274
6324
  bitrate: DEFAULT_BITRATE,
@@ -6283,9 +6333,11 @@ const defaultTargetResolution = {
6283
6333
  * @param targetResolution the expected target resolution.
6284
6334
  */
6285
6335
  const findOptimalVideoLayers = (videoTrack, targetResolution = defaultTargetResolution) => {
6336
+ var _a;
6286
6337
  const optimalVideoLayers = [];
6287
6338
  const settings = videoTrack.getSettings();
6288
6339
  const { width: w = 0, height: h = 0 } = settings;
6340
+ const isRNIos = isReactNative() && ((_a = getOSInfo()) === null || _a === void 0 ? void 0 : _a.name.toLowerCase()) === 'ios';
6289
6341
  const maxBitrate = getComputedMaxBitrate(targetResolution, w, h);
6290
6342
  let downscaleFactor = 1;
6291
6343
  ['f', 'h', 'q'].forEach((rid) => {
@@ -6299,10 +6351,11 @@ const findOptimalVideoLayers = (videoTrack, targetResolution = defaultTargetReso
6299
6351
  height: Math.round(h / downscaleFactor),
6300
6352
  maxBitrate: Math.round(maxBitrate / downscaleFactor),
6301
6353
  scaleResolutionDownBy: downscaleFactor,
6354
+ // Simulcast on iOS React-Native requires all encodings to share the same framerate
6302
6355
  maxFramerate: {
6303
6356
  f: 30,
6304
- h: 25,
6305
- q: 20,
6357
+ h: isRNIos ? 30 : 25,
6358
+ q: isRNIos ? 30 : 20,
6306
6359
  }[rid],
6307
6360
  });
6308
6361
  downscaleFactor *= 2;
@@ -6501,6 +6554,7 @@ class Publisher {
6501
6554
  * @param opts
6502
6555
  */
6503
6556
  this.publishStream = (mediaStream, track, trackType, opts = {}) => __awaiter(this, void 0, void 0, function* () {
6557
+ var _a;
6504
6558
  if (track.readyState === 'ended') {
6505
6559
  throw new Error(`Can't publish a track that has ended already.`);
6506
6560
  }
@@ -6528,7 +6582,14 @@ class Publisher {
6528
6582
  const videoEncodings = trackType === TrackType.VIDEO
6529
6583
  ? findOptimalVideoLayers(track, targetResolution)
6530
6584
  : undefined;
6531
- const codecPreferences = this.getCodecPreferences(trackType, opts.preferredCodec);
6585
+ let preferredCodec = opts.preferredCodec;
6586
+ if (!preferredCodec && trackType === TrackType.VIDEO) {
6587
+ const isRNAndroid = isReactNative() && ((_a = getOSInfo()) === null || _a === void 0 ? void 0 : _a.name.toLowerCase()) === 'android';
6588
+ if (isRNAndroid) {
6589
+ preferredCodec = 'VP8';
6590
+ }
6591
+ }
6592
+ const codecPreferences = this.getCodecPreferences(trackType, preferredCodec);
6532
6593
  // listen for 'ended' event on the track as it might be ended abruptly
6533
6594
  // by an external factor as permission revokes, device disconnected, etc.
6534
6595
  // keep in mind that `track.stop()` doesn't trigger this event.
@@ -6622,9 +6683,9 @@ class Publisher {
6622
6683
  });
6623
6684
  };
6624
6685
  this.updateVideoPublishQuality = (enabledRids) => __awaiter(this, void 0, void 0, function* () {
6625
- var _a;
6686
+ var _b;
6626
6687
  logger$3('info', 'Update publish quality, requested rids by SFU:', enabledRids);
6627
- const videoSender = (_a = this.transceiverRegistry[TrackType.VIDEO]) === null || _a === void 0 ? void 0 : _a.sender;
6688
+ const videoSender = (_b = this.transceiverRegistry[TrackType.VIDEO]) === null || _b === void 0 ? void 0 : _b.sender;
6628
6689
  if (!videoSender) {
6629
6690
  logger$3('warn', 'Update publish quality, no video sender found.');
6630
6691
  return;
@@ -6722,8 +6783,8 @@ class Publisher {
6722
6783
  * @param options the optional offer options to use.
6723
6784
  */
6724
6785
  this.negotiate = (options) => __awaiter(this, void 0, void 0, function* () {
6725
- var _b;
6726
- this.isIceRestarting = (_b = options === null || options === void 0 ? void 0 : options.iceRestart) !== null && _b !== void 0 ? _b : false;
6786
+ var _c;
6787
+ this.isIceRestarting = (_c = options === null || options === void 0 ? void 0 : options.iceRestart) !== null && _c !== void 0 ? _c : false;
6727
6788
  const offer = yield this.pc.createOffer(options);
6728
6789
  offer.sdp = this.mungeCodecs(offer.sdp);
6729
6790
  const trackInfos = this.getCurrentTrackInfos(offer.sdp);
@@ -6761,15 +6822,6 @@ class Publisher {
6761
6822
  this.mungeCodecs = (sdp) => {
6762
6823
  if (sdp) {
6763
6824
  sdp = toggleDtx(sdp, this.isDtxEnabled);
6764
- if (isReactNative()) {
6765
- if (this.preferredVideoCodec) {
6766
- sdp = setPreferredCodec(sdp, 'video', this.preferredVideoCodec);
6767
- }
6768
- sdp = setPreferredCodec(sdp, 'audio', this.isRedEnabled ? 'red' : 'opus');
6769
- if (!this.isRedEnabled) {
6770
- sdp = removeCodec(sdp, 'audio', 'red');
6771
- }
6772
- }
6773
6825
  }
6774
6826
  return sdp;
6775
6827
  };
@@ -9467,56 +9519,6 @@ const CallTypes = new CallTypesRegistry([
9467
9519
  }),
9468
9520
  ]);
9469
9521
 
9470
- let sdkInfo;
9471
- let osInfo;
9472
- let deviceInfo;
9473
- const setSdkInfo = (info) => {
9474
- sdkInfo = info;
9475
- };
9476
- const getSdkInfo = () => {
9477
- return sdkInfo;
9478
- };
9479
- const setOSInfo = (info) => {
9480
- osInfo = info;
9481
- };
9482
- const getOSInfo = () => {
9483
- return osInfo;
9484
- };
9485
- const setDeviceInfo = (info) => {
9486
- deviceInfo = info;
9487
- };
9488
- const getDeviceInfo = () => {
9489
- return deviceInfo;
9490
- };
9491
- const getClientDetails = () => {
9492
- if (isReactNative()) {
9493
- // Since RN doesn't support web, sharing browser info is not required
9494
- return {
9495
- sdk: getSdkInfo(),
9496
- os: getOSInfo(),
9497
- device: getDeviceInfo(),
9498
- };
9499
- }
9500
- const userAgent = new UAParser(navigator.userAgent);
9501
- const { browser, os, device, cpu } = userAgent.getResult();
9502
- return {
9503
- sdk: getSdkInfo(),
9504
- browser: {
9505
- name: browser.name || navigator.userAgent,
9506
- version: browser.version || '',
9507
- },
9508
- os: {
9509
- name: os.name || '',
9510
- version: os.version || '',
9511
- architecture: cpu.architecture || '',
9512
- },
9513
- device: {
9514
- name: `${device.vendor || ''} ${device.model || ''} ${device.type || ''}`,
9515
- version: '',
9516
- },
9517
- };
9518
- };
9519
-
9520
9522
  class InputMediaDeviceManagerState {
9521
9523
  constructor() {
9522
9524
  this.statusSubject = new BehaviorSubject(undefined);
@@ -12439,7 +12441,7 @@ class WSConnectionFallback {
12439
12441
  }
12440
12442
  }
12441
12443
 
12442
- const version = '0.3.1';
12444
+ const version = '0.3.2';
12443
12445
 
12444
12446
  const logger = getLogger(['location']);
12445
12447
  const HINT_URL = `https://hint.stream-io-video.com/`;
@@ -13493,5 +13495,5 @@ var browsers = /*#__PURE__*/Object.freeze({
13493
13495
  isSafari: isSafari
13494
13496
  });
13495
13497
 
13496
- export { AudioSettingsDefaultDeviceEnum, AudioSettingsRequestDefaultDeviceEnum, browsers as Browsers, Call, CallState, CallType, CallTypes, CallingState, CameraManager, CreateDeviceRequestPushProviderEnum, DebounceType, ErrorFromResponse, InputMediaDeviceManager, InputMediaDeviceManagerState, MicrophoneManager, OwnCapability, RecordSettingsModeEnum, RecordSettingsQualityEnum, RecordSettingsRequestModeEnum, RecordSettingsRequestQualityEnum, rxUtils as RxUtils, events as SfuEvents, models as SfuModels, StreamSfuClient, StreamVideoClient, StreamVideoReadOnlyStateStore, StreamVideoServerClient, StreamVideoWriteableStateStore, TranscriptionSettingsModeEnum, TranscriptionSettingsRequestModeEnum, VideoSettingsCameraFacingEnum, VideoSettingsRequestCameraFacingEnum, ViewportTracker, VisibilityState, checkIfAudioOutputChangeSupported, combineComparators, conditional, createSoundDetector, defaultSortPreset, descending, disposeOfMediaStream, dominantSpeaker, getAudioDevices, getAudioOutputDevices, getAudioStream, getClientDetails, getDeviceInfo, getLogger, getOSInfo, getScreenShareStream, getSdkInfo, getVideoDevices, getVideoStream, isStreamVideoLocalParticipant, livestreamOrAudioRoomSortPreset, logLevels, logToConsole, name, noopComparator, pinned, publishingAudio, publishingVideo, reactionType, role, screenSharing, setDeviceInfo, setLogLevel, setLogger, setOSInfo, setSdkInfo, speakerLayoutSortPreset, speaking, watchForAddedDefaultAudioDevice, watchForAddedDefaultAudioOutputDevice, watchForAddedDefaultVideoDevice, watchForDisconnectedAudioDevice, watchForDisconnectedAudioOutputDevice, watchForDisconnectedVideoDevice };
13498
+ export { AudioSettingsDefaultDeviceEnum, AudioSettingsRequestDefaultDeviceEnum, browsers as Browsers, Call, CallState, CallType, CallTypes, CallingState, CameraManager, CameraManagerState, CreateDeviceRequestPushProviderEnum, DebounceType, ErrorFromResponse, InputMediaDeviceManager, InputMediaDeviceManagerState, MicrophoneManager, MicrophoneManagerState, OwnCapability, RecordSettingsModeEnum, RecordSettingsQualityEnum, RecordSettingsRequestModeEnum, RecordSettingsRequestQualityEnum, rxUtils as RxUtils, events as SfuEvents, models as SfuModels, StreamSfuClient, StreamVideoClient, StreamVideoReadOnlyStateStore, StreamVideoServerClient, StreamVideoWriteableStateStore, TranscriptionSettingsModeEnum, TranscriptionSettingsRequestModeEnum, VideoSettingsCameraFacingEnum, VideoSettingsRequestCameraFacingEnum, ViewportTracker, VisibilityState, checkIfAudioOutputChangeSupported, combineComparators, conditional, createSoundDetector, defaultSortPreset, descending, disposeOfMediaStream, dominantSpeaker, getAudioDevices, getAudioOutputDevices, getAudioStream, getClientDetails, getDeviceInfo, getLogger, getOSInfo, getScreenShareStream, getSdkInfo, getVideoDevices, getVideoStream, isStreamVideoLocalParticipant, livestreamOrAudioRoomSortPreset, logLevels, logToConsole, name, noopComparator, pinned, publishingAudio, publishingVideo, reactionType, role, screenSharing, setDeviceInfo, setLogLevel, setLogger, setOSInfo, setSdkInfo, speakerLayoutSortPreset, speaking, watchForAddedDefaultAudioDevice, watchForAddedDefaultAudioOutputDevice, watchForAddedDefaultVideoDevice, watchForDisconnectedAudioDevice, watchForDisconnectedAudioOutputDevice, watchForDisconnectedVideoDevice };
13497
13499
  //# sourceMappingURL=index.es.js.map