Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

JitsiMeetJS.js 25KB

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