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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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. console.log("ljm_5x 3")
  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. Statistics.init(options);
  162. // Initialize global window.connectionTimes
  163. // FIXME do not use 'window'
  164. if (!window.connectionTimes) {
  165. window.connectionTimes = {};
  166. }
  167. if (options.enableAnalyticsLogging !== true) {
  168. logger.warn('Analytics disabled, disposing.');
  169. this.analytics.dispose();
  170. }
  171. if (options.enableWindowOnErrorHandler) {
  172. GlobalOnErrorHandler.addHandler(
  173. this.getGlobalOnErrorHandler.bind(this));
  174. }
  175. // Log deployment-specific information, if available. Defined outside
  176. // the application by individual deployments
  177. const aprops = options.deploymentInfo;
  178. if (aprops && Object.keys(aprops).length > 0) {
  179. const logObject = {};
  180. for (const attr in aprops) {
  181. if (aprops.hasOwnProperty(attr)) {
  182. logObject[attr] = aprops[attr];
  183. }
  184. }
  185. logObject.id = 'deployment_info';
  186. Statistics.sendLog(JSON.stringify(logObject));
  187. }
  188. if (this.version) {
  189. const logObject = {
  190. id: 'component_version',
  191. component: 'lib-jitsi-meet',
  192. version: this.version
  193. };
  194. Statistics.sendLog(JSON.stringify(logObject));
  195. }
  196. return RTC.init(options);
  197. },
  198. /**
  199. * Returns whether the desktop sharing is enabled or not.
  200. *
  201. * @returns {boolean}
  202. */
  203. isDesktopSharingEnabled() {
  204. return RTC.isDesktopSharingEnabled();
  205. },
  206. /**
  207. * Returns whether the current execution environment supports WebRTC (for
  208. * use within this library).
  209. *
  210. * @returns {boolean} {@code true} if WebRTC is supported in the current
  211. * execution environment (for use within this library); {@code false},
  212. * otherwise.
  213. */
  214. isWebRtcSupported() {
  215. return RTC.isWebRtcSupported();
  216. },
  217. setLogLevel(level) {
  218. Logger.setLogLevel(level);
  219. },
  220. /**
  221. * Sets the log level to the <tt>Logger</tt> instance with given id.
  222. *
  223. * @param {Logger.levels} level the logging level to be set
  224. * @param {string} id the logger id to which new logging level will be set.
  225. * Usually it's the name of the JavaScript source file including the path
  226. * ex. "modules/xmpp/ChatRoom.js"
  227. */
  228. setLogLevelById(level, id) {
  229. Logger.setLogLevelById(level, id);
  230. },
  231. /**
  232. * Registers new global logger transport to the library logging framework.
  233. *
  234. * @param globalTransport
  235. * @see Logger.addGlobalTransport
  236. */
  237. addGlobalLogTransport(globalTransport) {
  238. Logger.addGlobalTransport(globalTransport);
  239. },
  240. /**
  241. * Removes global logging transport from the library logging framework.
  242. *
  243. * @param globalTransport
  244. * @see Logger.removeGlobalTransport
  245. */
  246. removeGlobalLogTransport(globalTransport) {
  247. Logger.removeGlobalTransport(globalTransport);
  248. },
  249. /**
  250. * Sets global options which will be used by all loggers. Changing these
  251. * works even after other loggers are created.
  252. *
  253. * @param options
  254. * @see Logger.setGlobalOptions
  255. */
  256. setGlobalLogOptions(options) {
  257. Logger.setGlobalOptions(options);
  258. },
  259. /**
  260. * Creates the media tracks and returns them trough the callback.
  261. *
  262. * @param options Object with properties / settings specifying the tracks
  263. * which should be created. should be created or some additional
  264. * configurations about resolution for example.
  265. * @param {Array} options.effects optional effects array for the track
  266. * @param {Array} options.devices the devices that will be requested
  267. * @param {string} options.resolution resolution constraints
  268. * @param {string} options.cameraDeviceId
  269. * @param {string} options.micDeviceId
  270. * @param {intiger} interval - the interval (in ms) for
  271. * checking whether the desktop sharing extension is installed or not
  272. * @param {Function} checkAgain - returns boolean. While checkAgain()==true
  273. * createLocalTracks will wait and check on every "interval" ms for the
  274. * extension. If the desktop extension is not install and checkAgain()==true
  275. * createLocalTracks will finish with rejected Promise.
  276. * @param {Function} listener - The listener will be called to notify the
  277. * user of lib-jitsi-meet that createLocalTracks is starting external
  278. * extension installation process.
  279. * NOTE: If the inline installation process is not possible and external
  280. * installation is enabled the listener property will be called to notify
  281. * the start of external installation process. After that createLocalTracks
  282. * will start to check for the extension on every interval ms until the
  283. * plugin is installed or until checkAgain return false. If the extension
  284. * is found createLocalTracks will try to get the desktop sharing track and
  285. * will finish the execution. If checkAgain returns false, createLocalTracks
  286. * will finish the execution with rejected Promise.
  287. *
  288. * @param {boolean} (firePermissionPromptIsShownEvent) - if event
  289. * JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN should be fired
  290. * @param originalOptions - internal use only, to be able to store the
  291. * originally requested options.
  292. * @returns {Promise.<{Array.<JitsiTrack>}, JitsiConferenceError>} A promise
  293. * that returns an array of created JitsiTracks if resolved, or a
  294. * JitsiConferenceError if rejected.
  295. */
  296. createLocalTracks(
  297. options = {}, firePermissionPromptIsShownEvent, originalOptions) {
  298. let promiseFulfilled = false;
  299. if (firePermissionPromptIsShownEvent === true) {
  300. window.setTimeout(() => {
  301. if (!promiseFulfilled) {
  302. JitsiMediaDevices.emitEvent(
  303. JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN,
  304. browser.getName());
  305. }
  306. }, USER_MEDIA_PERMISSION_PROMPT_TIMEOUT);
  307. }
  308. if (!window.connectionTimes) {
  309. window.connectionTimes = {};
  310. }
  311. window.connectionTimes['obtainPermissions.start']
  312. = window.performance.now();
  313. return RTC.obtainAudioAndVideoPermissions(options)
  314. .then(tracks => {
  315. promiseFulfilled = true;
  316. window.connectionTimes['obtainPermissions.end']
  317. = window.performance.now();
  318. Statistics.sendAnalytics(
  319. createGetUserMediaEvent(
  320. 'success',
  321. getAnalyticsAttributesFromOptions(options)));
  322. if (!RTC.options.disableAudioLevels) {
  323. for (let i = 0; i < tracks.length; i++) {
  324. const track = tracks[i];
  325. const mStream = track.getOriginalStream();
  326. if (track.getType() === MediaType.AUDIO) {
  327. Statistics.startLocalStats(mStream,
  328. track.setAudioLevel.bind(track));
  329. track.addEventListener(
  330. JitsiTrackEvents.LOCAL_TRACK_STOPPED,
  331. () => {
  332. Statistics.stopLocalStats(mStream);
  333. });
  334. }
  335. }
  336. }
  337. // set real device ids
  338. const currentlyAvailableMediaDevices
  339. = RTC.getCurrentlyAvailableMediaDevices();
  340. if (currentlyAvailableMediaDevices) {
  341. for (let i = 0; i < tracks.length; i++) {
  342. const track = tracks[i];
  343. track._setRealDeviceIdFromDeviceList(
  344. currentlyAvailableMediaDevices);
  345. }
  346. }
  347. // set the contentHint to "detail" for desktop tracks
  348. // eslint-disable-next-line prefer-const
  349. for (const track of tracks) {
  350. if (track.type === MediaType.VIDEO
  351. && track.videoType === 'desktop') {
  352. this.setVideoTrackContentHints(track.track, 'detail');
  353. }
  354. }
  355. return tracks;
  356. })
  357. .catch(error => {
  358. promiseFulfilled = true;
  359. if (error.name === JitsiTrackErrors.UNSUPPORTED_RESOLUTION
  360. && !browser.usesNewGumFlow()) {
  361. const oldResolution = options.resolution || '720';
  362. const newResolution = getLowerResolution(oldResolution);
  363. if (newResolution !== null) {
  364. options.resolution = newResolution;
  365. logger.debug(
  366. 'Retry createLocalTracks with resolution',
  367. newResolution);
  368. Statistics.sendAnalytics(createGetUserMediaEvent(
  369. 'warning',
  370. {
  371. 'old_resolution': oldResolution,
  372. 'new_resolution': newResolution,
  373. reason: 'unsupported resolution'
  374. }));
  375. return this.createLocalTracks(
  376. options,
  377. undefined,
  378. originalOptions || Object.assign({}, options));
  379. }
  380. // We tried everything. If there is a mandatory device id,
  381. // remove it and let gum find a device to use.
  382. if (originalOptions
  383. && error.gum.constraints
  384. && error.gum.constraints.video
  385. && error.gum.constraints.video.mandatory
  386. && error.gum.constraints.video.mandatory.sourceId) {
  387. originalOptions.cameraDeviceId = undefined;
  388. return this.createLocalTracks(originalOptions);
  389. }
  390. }
  391. if (error.name
  392. === JitsiTrackErrors.SCREENSHARING_USER_CANCELED) {
  393. // User cancelled action is not really an error, so only
  394. // log it as an event to avoid having conference classified
  395. // as partially failed
  396. const logObject = {
  397. id: 'screensharing_user_canceled',
  398. message: error.message
  399. };
  400. Statistics.sendLog(JSON.stringify(logObject));
  401. Statistics.sendAnalytics(
  402. createGetUserMediaEvent(
  403. 'warning',
  404. {
  405. reason: 'extension install user canceled'
  406. }));
  407. } else if (error.name === JitsiTrackErrors.NOT_FOUND) {
  408. // logs not found devices with just application log to cs
  409. const logObject = {
  410. id: 'usermedia_missing_device',
  411. status: error.gum.devices
  412. };
  413. Statistics.sendLog(JSON.stringify(logObject));
  414. const attributes
  415. = getAnalyticsAttributesFromOptions(options);
  416. attributes.reason = 'device not found';
  417. attributes.devices = error.gum.devices.join('.');
  418. Statistics.sendAnalytics(
  419. createGetUserMediaEvent('error', attributes));
  420. } else {
  421. // Report gUM failed to the stats
  422. Statistics.sendGetUserMediaFailed(error);
  423. const attributes
  424. = getAnalyticsAttributesFromOptions(options);
  425. attributes.reason = error.name;
  426. Statistics.sendAnalytics(
  427. createGetUserMediaEvent('error', attributes));
  428. }
  429. window.connectionTimes['obtainPermissions.end']
  430. = window.performance.now();
  431. return Promise.reject(error);
  432. });
  433. },
  434. /**
  435. * Create a TrackVADEmitter service that connects an audio track to an VAD (voice activity detection) processor in
  436. * order to obtain VAD scores for individual PCM audio samples.
  437. * @param {string} localAudioDeviceId - The target local audio device.
  438. * @param {number} sampleRate - Sample rate at which the emitter will operate. Possible values 256, 512, 1024,
  439. * 4096, 8192, 16384. Passing other values will default to closes neighbor.
  440. * I.e. Providing a value of 4096 means that the emitter will process 4096 PCM samples at a time, higher values mean
  441. * longer calls, lowers values mean more calls but shorter.
  442. * @param {Object} vadProcessor - VAD Processors that does the actual compute on a PCM sample.The processor needs
  443. * to implement the following functions:
  444. * - <tt>getSampleLength()</tt> - Returns the sample size accepted by calculateAudioFrameVAD.
  445. * - <tt>getRequiredPCMFrequency()</tt> - Returns the PCM frequency at which the processor operates.
  446. * i.e. (16KHz, 44.1 KHz etc.)
  447. * - <tt>calculateAudioFrameVAD(pcmSample)</tt> - Process a 32 float pcm sample of getSampleLength size.
  448. * @returns {Promise<TrackVADEmitter>}
  449. */
  450. createTrackVADEmitter(localAudioDeviceId, sampleRate, vadProcessor) {
  451. return TrackVADEmitter.create(localAudioDeviceId, sampleRate, vadProcessor);
  452. },
  453. /**
  454. * Create AudioMixer, which is essentially a wrapper over web audio ChannelMergerNode. It essentially allows the
  455. * user to mix multiple MediaStreams into a single one.
  456. *
  457. * @returns {AudioMixer}
  458. */
  459. createAudioMixer() {
  460. return new AudioMixer();
  461. },
  462. /**
  463. * Go through all audio devices on the system and return one that is active, i.e. has audio signal.
  464. *
  465. * @returns Promise<Object> - Object containing information about the found device.
  466. */
  467. getActiveAudioDevice() {
  468. return getActiveAudioDevice();
  469. },
  470. /**
  471. * Checks if its possible to enumerate available cameras/microphones.
  472. *
  473. * @returns {Promise<boolean>} a Promise which will be resolved only once
  474. * the WebRTC stack is ready, either with true if the device listing is
  475. * available available or with false otherwise.
  476. * @deprecated use JitsiMeetJS.mediaDevices.isDeviceListAvailable instead
  477. */
  478. isDeviceListAvailable() {
  479. logger.warn('This method is deprecated, use '
  480. + 'JitsiMeetJS.mediaDevices.isDeviceListAvailable instead');
  481. return this.mediaDevices.isDeviceListAvailable();
  482. },
  483. /**
  484. * Returns true if changing the input (camera / microphone) or output
  485. * (audio) device is supported and false if not.
  486. *
  487. * @param {string} [deviceType] - type of device to change. Default is
  488. * {@code undefined} or 'input', 'output' - for audio output device change.
  489. * @returns {boolean} {@code true} if available; {@code false}, otherwise.
  490. * @deprecated use JitsiMeetJS.mediaDevices.isDeviceChangeAvailable instead
  491. */
  492. isDeviceChangeAvailable(deviceType) {
  493. logger.warn('This method is deprecated, use '
  494. + 'JitsiMeetJS.mediaDevices.isDeviceChangeAvailable instead');
  495. return this.mediaDevices.isDeviceChangeAvailable(deviceType);
  496. },
  497. /**
  498. * Checks if the current environment supports having multiple audio
  499. * input devices in use simultaneously.
  500. *
  501. * @returns {boolean} True if multiple audio input devices can be used.
  502. */
  503. isMultipleAudioInputSupported() {
  504. return this.mediaDevices.isMultipleAudioInputSupported();
  505. },
  506. /**
  507. * Checks if local tracks can collect stats and collection is enabled.
  508. *
  509. * @param {boolean} True if stats are being collected for local tracks.
  510. */
  511. isCollectingLocalStats() {
  512. return Statistics.audioLevelsEnabled
  513. && LocalStatsCollector.isLocalStatsSupported();
  514. },
  515. /**
  516. * Executes callback with list of media devices connected.
  517. *
  518. * @param {function} callback
  519. * @deprecated use JitsiMeetJS.mediaDevices.enumerateDevices instead
  520. */
  521. enumerateDevices(callback) {
  522. logger.warn('This method is deprecated, use '
  523. + 'JitsiMeetJS.mediaDevices.enumerateDevices instead');
  524. this.mediaDevices.enumerateDevices(callback);
  525. },
  526. /* eslint-disable max-params */
  527. /**
  528. * @returns function that can be used to be attached to window.onerror and
  529. * if options.enableWindowOnErrorHandler is enabled returns
  530. * the function used by the lib.
  531. * (function(message, source, lineno, colno, error)).
  532. */
  533. getGlobalOnErrorHandler(message, source, lineno, colno, error) {
  534. logger.error(
  535. `UnhandledError: ${message}`,
  536. `Script: ${source}`,
  537. `Line: ${lineno}`,
  538. `Column: ${colno}`,
  539. 'StackTrace: ', error);
  540. Statistics.reportGlobalError(error);
  541. },
  542. /**
  543. * Informs lib-jitsi-meet about the current network status.
  544. *
  545. * @param {boolean} isOnline - {@code true} if the internet connectivity is online or {@code false}
  546. * otherwise.
  547. */
  548. setNetworkInfo({ isOnline }) {
  549. NetworkInfo.updateNetworkInfo({ isOnline });
  550. },
  551. /**
  552. * Set the contentHint on the transmitted stream track to indicate
  553. * charaterstics in the video stream, which informs PeerConnection
  554. * on how to encode the track (to prefer motion or individual frame detail)
  555. * @param {MediaStreamTrack} track - the track that is transmitted
  556. * @param {String} hint - contentHint value that needs to be set on the track
  557. */
  558. setVideoTrackContentHints(track, hint) {
  559. if ('contentHint' in track) {
  560. track.contentHint = hint;
  561. if (track.contentHint !== hint) {
  562. logger.debug('Invalid video track contentHint');
  563. }
  564. } else {
  565. logger.debug('MediaStreamTrack contentHint attribute not supported');
  566. }
  567. },
  568. precallTest,
  569. /* eslint-enable max-params */
  570. /**
  571. * Represents a hub/namespace for utility functionality which may be of
  572. * interest to lib-jitsi-meet clients.
  573. */
  574. util: {
  575. AuthUtil,
  576. ScriptUtil,
  577. browser
  578. }
  579. });