You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JitsiMeetJS.js 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /* global __filename */
  2. import Logger from 'jitsi-meet-logger';
  3. import * as JitsiConferenceErrors from './JitsiConferenceErrors';
  4. import * as JitsiConferenceEvents from './JitsiConferenceEvents';
  5. import JitsiConnection from './JitsiConnection';
  6. import * as JitsiConnectionErrors from './JitsiConnectionErrors';
  7. import * as JitsiConnectionEvents from './JitsiConnectionEvents';
  8. import JitsiMediaDevices from './JitsiMediaDevices';
  9. import * as JitsiMediaDevicesEvents from './JitsiMediaDevicesEvents';
  10. import JitsiTrackError from './JitsiTrackError';
  11. import * as JitsiTrackErrors from './JitsiTrackErrors';
  12. import * as JitsiTrackEvents from './JitsiTrackEvents';
  13. import * as JitsiTranscriptionStatus from './JitsiTranscriptionStatus';
  14. import RTC from './modules/RTC/RTC';
  15. import browser from './modules/browser';
  16. import NetworkInfo from './modules/connectivity/NetworkInfo';
  17. import { ParticipantConnectionStatus }
  18. from './modules/connectivity/ParticipantConnectionStatus';
  19. import getActiveAudioDevice from './modules/detection/ActiveDeviceDetector';
  20. import * as DetectionEvents from './modules/detection/DetectionEvents';
  21. import TrackVADEmitter from './modules/detection/TrackVADEmitter';
  22. import ProxyConnectionService
  23. from './modules/proxyconnection/ProxyConnectionService';
  24. import recordingConstants from './modules/recording/recordingConstants';
  25. import Settings from './modules/settings/Settings';
  26. import LocalStatsCollector from './modules/statistics/LocalStatsCollector';
  27. import precallTest from './modules/statistics/PrecallTest';
  28. import Statistics from './modules/statistics/statistics';
  29. import AuthUtil from './modules/util/AuthUtil';
  30. import GlobalOnErrorHandler from './modules/util/GlobalOnErrorHandler';
  31. import ScriptUtil from './modules/util/ScriptUtil';
  32. import * as VideoSIPGWConstants from './modules/videosipgw/VideoSIPGWConstants';
  33. import AudioMixer from './modules/webaudio/AudioMixer';
  34. import * as MediaType from './service/RTC/MediaType';
  35. import Resolutions from './service/RTC/Resolutions';
  36. import * as ConnectionQualityEvents
  37. from './service/connectivity/ConnectionQualityEvents';
  38. import * as E2ePingEvents from './service/e2eping/E2ePingEvents';
  39. import { createGetUserMediaEvent } from './service/statistics/AnalyticsEvents';
  40. const logger = Logger.getLogger(__filename);
  41. /**
  42. * The amount of time to wait until firing
  43. * {@link JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN} event.
  44. */
  45. const USER_MEDIA_PERMISSION_PROMPT_TIMEOUT = 1000;
  46. /**
  47. * Gets the next lowest desirable resolution to try for a camera. If the given
  48. * resolution is already the lowest acceptable resolution, returns {@code null}.
  49. *
  50. * @param resolution the current resolution
  51. * @return the next lowest resolution from the given one, or {@code null} if it
  52. * is already the lowest acceptable resolution.
  53. */
  54. function getLowerResolution(resolution) {
  55. if (!Resolutions[resolution]) {
  56. return null;
  57. }
  58. const order = Resolutions[resolution].order;
  59. let res = null;
  60. let resName = null;
  61. Object.keys(Resolutions).forEach(r => {
  62. const value = Resolutions[r];
  63. if (!res || (res.order < value.order && value.order < order)) {
  64. resName = r;
  65. res = value;
  66. }
  67. });
  68. if (resName === resolution) {
  69. resName = null;
  70. }
  71. return resName;
  72. }
  73. /**
  74. * Extracts from an 'options' objects with a specific format (TODO what IS the
  75. * format?) the attributes which are to be logged in analytics events.
  76. *
  77. * @param options gum options (???)
  78. * @returns {*} the attributes to attach to analytics events.
  79. */
  80. function getAnalyticsAttributesFromOptions(options) {
  81. const attributes = {
  82. 'audio_requested':
  83. options.devices.includes('audio'),
  84. 'video_requested':
  85. options.devices.includes('video'),
  86. 'screen_sharing_requested':
  87. options.devices.includes('desktop')
  88. };
  89. if (attributes.video_requested) {
  90. attributes.resolution = options.resolution;
  91. }
  92. return attributes;
  93. }
  94. /**
  95. * Tries to deal with the following problem: {@code JitsiMeetJS} is not only
  96. * this module, it's also a global (i.e. attached to {@code window}) namespace
  97. * for all globals of the projects in the Jitsi Meet family. If lib-jitsi-meet
  98. * is loaded through an HTML {@code script} tag, {@code JitsiMeetJS} will
  99. * automatically be attached to {@code window} by webpack. Unfortunately,
  100. * webpack's source code does not check whether the global variable has already
  101. * been assigned and overwrites it. Which is OK for the module
  102. * {@code JitsiMeetJS} but is not OK for the namespace {@code JitsiMeetJS}
  103. * because it may already contain the values of other projects in the Jitsi Meet
  104. * family. The solution offered here works around webpack by merging all
  105. * existing values of the namespace {@code JitsiMeetJS} into the module
  106. * {@code JitsiMeetJS}.
  107. *
  108. * @param {Object} module - The module {@code JitsiMeetJS} (which will be
  109. * exported and may be attached to {@code window} by webpack later on).
  110. * @private
  111. * @returns {Object} - A {@code JitsiMeetJS} module which contains all existing
  112. * value of the namespace {@code JitsiMeetJS} (if any).
  113. */
  114. function _mergeNamespaceAndModule(module) {
  115. return (
  116. typeof window.JitsiMeetJS === 'object'
  117. ? Object.assign({}, window.JitsiMeetJS, module)
  118. : module);
  119. }
  120. /**
  121. * The public API of the Jitsi Meet library (a.k.a. {@code JitsiMeetJS}).
  122. */
  123. export default _mergeNamespaceAndModule({
  124. version: '{#COMMIT_HASH#}',
  125. JitsiConnection,
  126. /**
  127. * {@code ProxyConnectionService} is used to connect a remote peer to a
  128. * local Jitsi participant without going through a Jitsi conference. It is
  129. * currently used for room integration development, specifically wireless
  130. * screensharing. Its API is experimental and will likely change; usage of
  131. * it is advised against.
  132. */
  133. ProxyConnectionService,
  134. constants: {
  135. participantConnectionStatus: ParticipantConnectionStatus,
  136. recording: recordingConstants,
  137. sipVideoGW: VideoSIPGWConstants,
  138. transcriptionStatus: JitsiTranscriptionStatus
  139. },
  140. events: {
  141. conference: JitsiConferenceEvents,
  142. connection: JitsiConnectionEvents,
  143. detection: DetectionEvents,
  144. track: JitsiTrackEvents,
  145. mediaDevices: JitsiMediaDevicesEvents,
  146. connectionQuality: ConnectionQualityEvents,
  147. e2eping: E2ePingEvents
  148. },
  149. errors: {
  150. conference: JitsiConferenceErrors,
  151. connection: JitsiConnectionErrors,
  152. track: JitsiTrackErrors
  153. },
  154. errorTypes: {
  155. JitsiTrackError
  156. },
  157. logLevels: Logger.levels,
  158. mediaDevices: JitsiMediaDevices,
  159. analytics: Statistics.analytics,
  160. init(options = {}) {
  161. Settings.init(options.externalStorage);
  162. Statistics.init(options);
  163. // Initialize global window.connectionTimes
  164. // FIXME do not use 'window'
  165. if (!window.connectionTimes) {
  166. window.connectionTimes = {};
  167. }
  168. if (options.enableAnalyticsLogging !== true) {
  169. logger.warn('Analytics disabled, disposing.');
  170. this.analytics.dispose();
  171. }
  172. if (options.enableWindowOnErrorHandler) {
  173. GlobalOnErrorHandler.addHandler(
  174. this.getGlobalOnErrorHandler.bind(this));
  175. }
  176. // Log deployment-specific information, if available. Defined outside
  177. // the application by individual deployments
  178. const aprops = options.deploymentInfo;
  179. if (aprops && Object.keys(aprops).length > 0) {
  180. const logObject = {};
  181. for (const attr in aprops) {
  182. if (aprops.hasOwnProperty(attr)) {
  183. logObject[attr] = aprops[attr];
  184. }
  185. }
  186. logObject.id = 'deployment_info';
  187. Statistics.sendLog(JSON.stringify(logObject));
  188. }
  189. if (this.version) {
  190. const logObject = {
  191. id: 'component_version',
  192. component: 'lib-jitsi-meet',
  193. version: this.version
  194. };
  195. Statistics.sendLog(JSON.stringify(logObject));
  196. }
  197. return RTC.init(options);
  198. },
  199. /**
  200. * Returns whether the desktop sharing is enabled or not.
  201. *
  202. * @returns {boolean}
  203. */
  204. isDesktopSharingEnabled() {
  205. return RTC.isDesktopSharingEnabled();
  206. },
  207. /**
  208. * Returns whether the current execution environment supports WebRTC (for
  209. * use within this library).
  210. *
  211. * @returns {boolean} {@code true} if WebRTC is supported in the current
  212. * execution environment (for use within this library); {@code false},
  213. * otherwise.
  214. */
  215. isWebRtcSupported() {
  216. return RTC.isWebRtcSupported();
  217. },
  218. setLogLevel(level) {
  219. Logger.setLogLevel(level);
  220. },
  221. /**
  222. * Sets the log level to the <tt>Logger</tt> instance with given id.
  223. *
  224. * @param {Logger.levels} level the logging level to be set
  225. * @param {string} id the logger id to which new logging level will be set.
  226. * Usually it's the name of the JavaScript source file including the path
  227. * ex. "modules/xmpp/ChatRoom.js"
  228. */
  229. setLogLevelById(level, id) {
  230. Logger.setLogLevelById(level, id);
  231. },
  232. /**
  233. * Registers new global logger transport to the library logging framework.
  234. *
  235. * @param globalTransport
  236. * @see Logger.addGlobalTransport
  237. */
  238. addGlobalLogTransport(globalTransport) {
  239. Logger.addGlobalTransport(globalTransport);
  240. },
  241. /**
  242. * Removes global logging transport from the library logging framework.
  243. *
  244. * @param globalTransport
  245. * @see Logger.removeGlobalTransport
  246. */
  247. removeGlobalLogTransport(globalTransport) {
  248. Logger.removeGlobalTransport(globalTransport);
  249. },
  250. /**
  251. * Sets global options which will be used by all loggers. Changing these
  252. * works even after other loggers are created.
  253. *
  254. * @param options
  255. * @see Logger.setGlobalOptions
  256. */
  257. setGlobalLogOptions(options) {
  258. Logger.setGlobalOptions(options);
  259. },
  260. /**
  261. * Creates the media tracks and returns them trough the callback.
  262. *
  263. * @param options Object with properties / settings specifying the tracks
  264. * which should be created. should be created or some additional
  265. * configurations about resolution for example.
  266. * @param {Array} options.effects optional effects array for the track
  267. * @param {Array} options.devices the devices that will be requested
  268. * @param {string} options.resolution resolution constraints
  269. * @param {string} options.cameraDeviceId
  270. * @param {string} options.micDeviceId
  271. * @param {intiger} interval - the interval (in ms) for
  272. * checking whether the desktop sharing extension is installed or not
  273. * @param {Function} checkAgain - returns boolean. While checkAgain()==true
  274. * createLocalTracks will wait and check on every "interval" ms for the
  275. * extension. If the desktop extension is not install and checkAgain()==true
  276. * createLocalTracks will finish with rejected Promise.
  277. * @param {Function} listener - The listener will be called to notify the
  278. * user of lib-jitsi-meet that createLocalTracks is starting external
  279. * extension installation process.
  280. * NOTE: If the inline installation process is not possible and external
  281. * installation is enabled the listener property will be called to notify
  282. * the start of external installation process. After that createLocalTracks
  283. * will start to check for the extension on every interval ms until the
  284. * plugin is installed or until checkAgain return false. If the extension
  285. * is found createLocalTracks will try to get the desktop sharing track and
  286. * will finish the execution. If checkAgain returns false, createLocalTracks
  287. * will finish the execution with rejected Promise.
  288. *
  289. * @param {boolean} (firePermissionPromptIsShownEvent) - if event
  290. * JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN should be fired
  291. * @param originalOptions - internal use only, to be able to store the
  292. * originally requested options.
  293. * @returns {Promise.<{Array.<JitsiTrack>}, JitsiConferenceError>} A promise
  294. * that returns an array of created JitsiTracks if resolved, or a
  295. * JitsiConferenceError if rejected.
  296. */
  297. createLocalTracks(
  298. options = {}, firePermissionPromptIsShownEvent, originalOptions) {
  299. let promiseFulfilled = false;
  300. if (firePermissionPromptIsShownEvent === true) {
  301. window.setTimeout(() => {
  302. if (!promiseFulfilled) {
  303. JitsiMediaDevices.emitEvent(
  304. JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN,
  305. browser.getName());
  306. }
  307. }, USER_MEDIA_PERMISSION_PROMPT_TIMEOUT);
  308. }
  309. if (!window.connectionTimes) {
  310. window.connectionTimes = {};
  311. }
  312. window.connectionTimes['obtainPermissions.start']
  313. = window.performance.now();
  314. return RTC.obtainAudioAndVideoPermissions(options)
  315. .then(tracks => {
  316. promiseFulfilled = true;
  317. window.connectionTimes['obtainPermissions.end']
  318. = window.performance.now();
  319. Statistics.sendAnalytics(
  320. createGetUserMediaEvent(
  321. 'success',
  322. getAnalyticsAttributesFromOptions(options)));
  323. if (!RTC.options.disableAudioLevels) {
  324. for (let i = 0; i < tracks.length; i++) {
  325. const track = tracks[i];
  326. const mStream = track.getOriginalStream();
  327. if (track.getType() === MediaType.AUDIO) {
  328. Statistics.startLocalStats(mStream,
  329. track.setAudioLevel.bind(track));
  330. track.addEventListener(
  331. JitsiTrackEvents.LOCAL_TRACK_STOPPED,
  332. () => {
  333. Statistics.stopLocalStats(mStream);
  334. });
  335. }
  336. }
  337. }
  338. // set real device ids
  339. const currentlyAvailableMediaDevices
  340. = RTC.getCurrentlyAvailableMediaDevices();
  341. if (currentlyAvailableMediaDevices) {
  342. for (let i = 0; i < tracks.length; i++) {
  343. const track = tracks[i];
  344. track._setRealDeviceIdFromDeviceList(
  345. currentlyAvailableMediaDevices);
  346. }
  347. }
  348. // set the contentHint to "detail" for desktop tracks
  349. // eslint-disable-next-line prefer-const
  350. for (const track of tracks) {
  351. if (track.type === MediaType.VIDEO
  352. && track.videoType === 'desktop') {
  353. this.setVideoTrackContentHints(track.track, 'detail');
  354. }
  355. }
  356. return tracks;
  357. })
  358. .catch(error => {
  359. promiseFulfilled = true;
  360. if (error.name === JitsiTrackErrors.UNSUPPORTED_RESOLUTION
  361. && !browser.usesNewGumFlow()) {
  362. const oldResolution = options.resolution || '720';
  363. const newResolution = getLowerResolution(oldResolution);
  364. if (newResolution !== null) {
  365. options.resolution = newResolution;
  366. logger.debug(
  367. 'Retry createLocalTracks with resolution',
  368. newResolution);
  369. Statistics.sendAnalytics(createGetUserMediaEvent(
  370. 'warning',
  371. {
  372. 'old_resolution': oldResolution,
  373. 'new_resolution': newResolution,
  374. reason: 'unsupported resolution'
  375. }));
  376. return this.createLocalTracks(
  377. options,
  378. undefined,
  379. originalOptions || Object.assign({}, options));
  380. }
  381. // We tried everything. If there is a mandatory device id,
  382. // remove it and let gum find a device to use.
  383. if (originalOptions
  384. && error.gum.constraints
  385. && error.gum.constraints.video
  386. && error.gum.constraints.video.mandatory
  387. && error.gum.constraints.video.mandatory.sourceId) {
  388. originalOptions.cameraDeviceId = undefined;
  389. return this.createLocalTracks(originalOptions);
  390. }
  391. }
  392. if (error.name
  393. === JitsiTrackErrors.SCREENSHARING_USER_CANCELED) {
  394. // User cancelled action is not really an error, so only
  395. // log it as an event to avoid having conference classified
  396. // as partially failed
  397. const logObject = {
  398. id: 'screensharing_user_canceled',
  399. message: error.message
  400. };
  401. Statistics.sendLog(JSON.stringify(logObject));
  402. Statistics.sendAnalytics(
  403. createGetUserMediaEvent(
  404. 'warning',
  405. {
  406. reason: 'extension install user canceled'
  407. }));
  408. } else if (error.name === JitsiTrackErrors.NOT_FOUND) {
  409. // logs not found devices with just application log to cs
  410. const logObject = {
  411. id: 'usermedia_missing_device',
  412. status: error.gum.devices
  413. };
  414. Statistics.sendLog(JSON.stringify(logObject));
  415. const attributes
  416. = getAnalyticsAttributesFromOptions(options);
  417. attributes.reason = 'device not found';
  418. attributes.devices = error.gum.devices.join('.');
  419. Statistics.sendAnalytics(
  420. createGetUserMediaEvent('error', attributes));
  421. } else {
  422. // Report gUM failed to the stats
  423. Statistics.sendGetUserMediaFailed(error);
  424. const attributes
  425. = getAnalyticsAttributesFromOptions(options);
  426. attributes.reason = error.name;
  427. Statistics.sendAnalytics(
  428. createGetUserMediaEvent('error', attributes));
  429. }
  430. window.connectionTimes['obtainPermissions.end']
  431. = window.performance.now();
  432. return Promise.reject(error);
  433. });
  434. },
  435. /**
  436. * Create a TrackVADEmitter service that connects an audio track to an VAD (voice activity detection) processor in
  437. * order to obtain VAD scores for individual PCM audio samples.
  438. * @param {string} localAudioDeviceId - The target local audio device.
  439. * @param {number} sampleRate - Sample rate at which the emitter will operate. Possible values 256, 512, 1024,
  440. * 4096, 8192, 16384. Passing other values will default to closes neighbor.
  441. * I.e. Providing a value of 4096 means that the emitter will process 4096 PCM samples at a time, higher values mean
  442. * longer calls, lowers values mean more calls but shorter.
  443. * @param {Object} vadProcessor - VAD Processors that does the actual compute on a PCM sample.The processor needs
  444. * to implement the following functions:
  445. * - <tt>getSampleLength()</tt> - Returns the sample size accepted by calculateAudioFrameVAD.
  446. * - <tt>getRequiredPCMFrequency()</tt> - Returns the PCM frequency at which the processor operates.
  447. * i.e. (16KHz, 44.1 KHz etc.)
  448. * - <tt>calculateAudioFrameVAD(pcmSample)</tt> - Process a 32 float pcm sample of getSampleLength size.
  449. * @returns {Promise<TrackVADEmitter>}
  450. */
  451. createTrackVADEmitter(localAudioDeviceId, sampleRate, vadProcessor) {
  452. return TrackVADEmitter.create(localAudioDeviceId, sampleRate, vadProcessor);
  453. },
  454. /**
  455. * Create AudioMixer, which is essentially a wrapper over web audio ChannelMergerNode. It essentially allows the
  456. * user to mix multiple MediaStreams into a single one.
  457. *
  458. * @returns {AudioMixer}
  459. */
  460. createAudioMixer() {
  461. return new AudioMixer();
  462. },
  463. /**
  464. * Go through all audio devices on the system and return one that is active, i.e. has audio signal.
  465. *
  466. * @returns Promise<Object> - Object containing information about the found device.
  467. */
  468. getActiveAudioDevice() {
  469. return getActiveAudioDevice();
  470. },
  471. /**
  472. * Checks if its possible to enumerate available cameras/microphones.
  473. *
  474. * @returns {Promise<boolean>} a Promise which will be resolved only once
  475. * the WebRTC stack is ready, either with true if the device listing is
  476. * available available or with false otherwise.
  477. * @deprecated use JitsiMeetJS.mediaDevices.isDeviceListAvailable instead
  478. */
  479. isDeviceListAvailable() {
  480. logger.warn('This method is deprecated, use '
  481. + 'JitsiMeetJS.mediaDevices.isDeviceListAvailable instead');
  482. return this.mediaDevices.isDeviceListAvailable();
  483. },
  484. /**
  485. * Returns true if changing the input (camera / microphone) or output
  486. * (audio) device is supported and false if not.
  487. *
  488. * @param {string} [deviceType] - type of device to change. Default is
  489. * {@code undefined} or 'input', 'output' - for audio output device change.
  490. * @returns {boolean} {@code true} if available; {@code false}, otherwise.
  491. * @deprecated use JitsiMeetJS.mediaDevices.isDeviceChangeAvailable instead
  492. */
  493. isDeviceChangeAvailable(deviceType) {
  494. logger.warn('This method is deprecated, use '
  495. + 'JitsiMeetJS.mediaDevices.isDeviceChangeAvailable instead');
  496. return this.mediaDevices.isDeviceChangeAvailable(deviceType);
  497. },
  498. /**
  499. * Checks if the current environment supports having multiple audio
  500. * input devices in use simultaneously.
  501. *
  502. * @returns {boolean} True if multiple audio input devices can be used.
  503. */
  504. isMultipleAudioInputSupported() {
  505. return this.mediaDevices.isMultipleAudioInputSupported();
  506. },
  507. /**
  508. * Checks if local tracks can collect stats and collection is enabled.
  509. *
  510. * @param {boolean} True if stats are being collected for local tracks.
  511. */
  512. isCollectingLocalStats() {
  513. return Statistics.audioLevelsEnabled
  514. && LocalStatsCollector.isLocalStatsSupported();
  515. },
  516. /**
  517. * Executes callback with list of media devices connected.
  518. *
  519. * @param {function} callback
  520. * @deprecated use JitsiMeetJS.mediaDevices.enumerateDevices instead
  521. */
  522. enumerateDevices(callback) {
  523. logger.warn('This method is deprecated, use '
  524. + 'JitsiMeetJS.mediaDevices.enumerateDevices instead');
  525. this.mediaDevices.enumerateDevices(callback);
  526. },
  527. /* eslint-disable max-params */
  528. /**
  529. * @returns function that can be used to be attached to window.onerror and
  530. * if options.enableWindowOnErrorHandler is enabled returns
  531. * the function used by the lib.
  532. * (function(message, source, lineno, colno, error)).
  533. */
  534. getGlobalOnErrorHandler(message, source, lineno, colno, error) {
  535. logger.error(
  536. `UnhandledError: ${message}`,
  537. `Script: ${source}`,
  538. `Line: ${lineno}`,
  539. `Column: ${colno}`,
  540. 'StackTrace: ', error);
  541. Statistics.reportGlobalError(error);
  542. },
  543. /**
  544. * Informs lib-jitsi-meet about the current network status.
  545. *
  546. * @param {boolean} isOnline - {@code true} if the internet connectivity is online or {@code false}
  547. * otherwise.
  548. */
  549. setNetworkInfo({ isOnline }) {
  550. NetworkInfo.updateNetworkInfo({ isOnline });
  551. },
  552. /**
  553. * Set the contentHint on the transmitted stream track to indicate
  554. * charaterstics in the video stream, which informs PeerConnection
  555. * on how to encode the track (to prefer motion or individual frame detail)
  556. * @param {MediaStreamTrack} track - the track that is transmitted
  557. * @param {String} hint - contentHint value that needs to be set on the track
  558. */
  559. setVideoTrackContentHints(track, hint) {
  560. if ('contentHint' in track) {
  561. track.contentHint = hint;
  562. if (track.contentHint !== hint) {
  563. logger.debug('Invalid video track contentHint');
  564. }
  565. } else {
  566. logger.debug('MediaStreamTrack contentHint attribute not supported');
  567. }
  568. },
  569. precallTest,
  570. /* eslint-enable max-params */
  571. /**
  572. * Represents a hub/namespace for utility functionality which may be of
  573. * interest to lib-jitsi-meet clients.
  574. */
  575. util: {
  576. AuthUtil,
  577. ScriptUtil,
  578. browser
  579. }
  580. });