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

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