Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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 { ParticipantConnectionStatus }
  28. from './modules/connectivity/ParticipantConnectionStatus';
  29. import RTC from './modules/RTC/RTC';
  30. import browser from './modules/browser';
  31. import ScriptUtil from './modules/util/ScriptUtil';
  32. import recordingConstants from './modules/recording/recordingConstants';
  33. import ProxyConnectionService
  34. from './modules/proxyconnection/ProxyConnectionService';
  35. import Statistics from './modules/statistics/statistics';
  36. import * as VideoSIPGWConstants from './modules/videosipgw/VideoSIPGWConstants';
  37. const logger = Logger.getLogger(__filename);
  38. /**
  39. * The amount of time to wait until firing
  40. * {@link JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN} event.
  41. */
  42. const USER_MEDIA_PERMISSION_PROMPT_TIMEOUT = 1000;
  43. /**
  44. * Gets the next lowest desirable resolution to try for a camera. If the given
  45. * resolution is already the lowest acceptable resolution, returns {@code null}.
  46. *
  47. * @param resolution the current resolution
  48. * @return the next lowest resolution from the given one, or {@code null} if it
  49. * is already the lowest acceptable resolution.
  50. */
  51. function getLowerResolution(resolution) {
  52. if (!Resolutions[resolution]) {
  53. return null;
  54. }
  55. const order = Resolutions[resolution].order;
  56. let res = null;
  57. let resName = null;
  58. Object.keys(Resolutions).forEach(r => {
  59. const value = Resolutions[r];
  60. if (!res || (res.order < value.order && value.order < order)) {
  61. resName = r;
  62. res = value;
  63. }
  64. });
  65. if (resName === resolution) {
  66. resName = null;
  67. }
  68. return resName;
  69. }
  70. /**
  71. * Extracts from an 'options' objects with a specific format (TODO what IS the
  72. * format?) the attributes which are to be logged in analytics events.
  73. *
  74. * @param options gum options (???)
  75. * @returns {*} the attributes to attach to analytics events.
  76. */
  77. function getAnalyticsAttributesFromOptions(options) {
  78. const attributes = {
  79. 'audio_requested':
  80. options.devices.includes('audio'),
  81. 'video_requested':
  82. options.devices.includes('video'),
  83. 'screen_sharing_requested':
  84. options.devices.includes('desktop')
  85. };
  86. if (attributes.video_requested) {
  87. attributes.resolution = options.resolution;
  88. }
  89. return attributes;
  90. }
  91. /**
  92. * Tries to deal with the following problem: {@code JitsiMeetJS} is not only
  93. * this module, it's also a global (i.e. attached to {@code window}) namespace
  94. * for all globals of the projects in the Jitsi Meet family. If lib-jitsi-meet
  95. * is loaded through an HTML {@code script} tag, {@code JitsiMeetJS} will
  96. * automatically be attached to {@code window} by webpack. Unfortunately,
  97. * webpack's source code does not check whether the global variable has already
  98. * been assigned and overwrites it. Which is OK for the module
  99. * {@code JitsiMeetJS} but is not OK for the namespace {@code JitsiMeetJS}
  100. * because it may already contain the values of other projects in the Jitsi Meet
  101. * family. The solution offered here works around webpack by merging all
  102. * existing values of the namespace {@code JitsiMeetJS} into the module
  103. * {@code JitsiMeetJS}.
  104. *
  105. * @param {Object} module - The module {@code JitsiMeetJS} (which will be
  106. * exported and may be attached to {@code window} by webpack later on).
  107. * @private
  108. * @returns {Object} - A {@code JitsiMeetJS} module which contains all existing
  109. * value of the namespace {@code JitsiMeetJS} (if any).
  110. */
  111. function _mergeNamespaceAndModule(module) {
  112. return (
  113. typeof window.JitsiMeetJS === 'object'
  114. ? Object.assign({}, window.JitsiMeetJS, module)
  115. : module);
  116. }
  117. /**
  118. * The public API of the Jitsi Meet library (a.k.a. {@code JitsiMeetJS}).
  119. */
  120. export default _mergeNamespaceAndModule({
  121. version: '{#COMMIT_HASH#}',
  122. JitsiConnection,
  123. /**
  124. * {@code ProxyConnectionService} is used to connect a remote peer to a
  125. * local Jitsi participant without going through a Jitsi conference. It is
  126. * currently used for room integration development, specifically wireless
  127. * screensharing. Its API is experimental and will likely change; usage of
  128. * it is advised against.
  129. */
  130. ProxyConnectionService,
  131. constants: {
  132. participantConnectionStatus: ParticipantConnectionStatus,
  133. recording: recordingConstants,
  134. sipVideoGW: VideoSIPGWConstants,
  135. transcriptionStatus: JitsiTranscriptionStatus
  136. },
  137. events: {
  138. conference: JitsiConferenceEvents,
  139. connection: JitsiConnectionEvents,
  140. detection: DetectionEvents,
  141. track: JitsiTrackEvents,
  142. mediaDevices: JitsiMediaDevicesEvents,
  143. connectionQuality: ConnectionQualityEvents,
  144. e2eping: E2ePingEvents
  145. },
  146. errors: {
  147. conference: JitsiConferenceErrors,
  148. connection: JitsiConnectionErrors,
  149. track: JitsiTrackErrors
  150. },
  151. errorTypes: {
  152. JitsiTrackError
  153. },
  154. logLevels: Logger.levels,
  155. mediaDevices: JitsiMediaDevices,
  156. analytics: Statistics.analytics,
  157. init(options = {}) {
  158. Statistics.init(options);
  159. // Initialize global window.connectionTimes
  160. // FIXME do not use 'window'
  161. if (!window.connectionTimes) {
  162. window.connectionTimes = {};
  163. }
  164. if (options.enableAnalyticsLogging !== true) {
  165. logger.warn('Analytics disabled, disposing.');
  166. this.analytics.dispose();
  167. }
  168. if (options.enableWindowOnErrorHandler) {
  169. GlobalOnErrorHandler.addHandler(
  170. this.getGlobalOnErrorHandler.bind(this));
  171. }
  172. // Log deployment-specific information, if available. Defined outside
  173. // the application by individual deployments
  174. const aprops = options.deploymentInfo;
  175. if (aprops && Object.keys(aprops).length > 0) {
  176. const logObject = {};
  177. for (const attr in aprops) {
  178. if (aprops.hasOwnProperty(attr)) {
  179. logObject[attr] = aprops[attr];
  180. }
  181. }
  182. logObject.id = 'deployment_info';
  183. Statistics.sendLog(JSON.stringify(logObject));
  184. }
  185. if (this.version) {
  186. const logObject = {
  187. id: 'component_version',
  188. component: 'lib-jitsi-meet',
  189. version: this.version
  190. };
  191. Statistics.sendLog(JSON.stringify(logObject));
  192. }
  193. return RTC.init(options);
  194. },
  195. /**
  196. * Returns whether the desktop sharing is enabled or not.
  197. *
  198. * @returns {boolean}
  199. */
  200. isDesktopSharingEnabled() {
  201. return RTC.isDesktopSharingEnabled();
  202. },
  203. /**
  204. * Returns whether the current execution environment supports WebRTC (for
  205. * use within this library).
  206. *
  207. * @returns {boolean} {@code true} if WebRTC is supported in the current
  208. * execution environment (for use within this library); {@code false},
  209. * otherwise.
  210. */
  211. isWebRtcSupported() {
  212. return RTC.isWebRtcSupported();
  213. },
  214. setLogLevel(level) {
  215. Logger.setLogLevel(level);
  216. },
  217. /**
  218. * Sets the log level to the <tt>Logger</tt> instance with given id.
  219. *
  220. * @param {Logger.levels} level the logging level to be set
  221. * @param {string} id the logger id to which new logging level will be set.
  222. * Usually it's the name of the JavaScript source file including the path
  223. * ex. "modules/xmpp/ChatRoom.js"
  224. */
  225. setLogLevelById(level, id) {
  226. Logger.setLogLevelById(level, id);
  227. },
  228. /**
  229. * Registers new global logger transport to the library logging framework.
  230. *
  231. * @param globalTransport
  232. * @see Logger.addGlobalTransport
  233. */
  234. addGlobalLogTransport(globalTransport) {
  235. Logger.addGlobalTransport(globalTransport);
  236. },
  237. /**
  238. * Removes global logging transport from the library logging framework.
  239. *
  240. * @param globalTransport
  241. * @see Logger.removeGlobalTransport
  242. */
  243. removeGlobalLogTransport(globalTransport) {
  244. Logger.removeGlobalTransport(globalTransport);
  245. },
  246. /**
  247. * Sets global options which will be used by all loggers. Changing these
  248. * works even after other loggers are created.
  249. *
  250. * @param options
  251. * @see Logger.setGlobalOptions
  252. */
  253. setGlobalLogOptions(options) {
  254. Logger.setGlobalOptions(options);
  255. },
  256. /**
  257. * Creates the media tracks and returns them trough the callback.
  258. *
  259. * @param options Object with properties / settings specifying the tracks
  260. * which should be created. should be created or some additional
  261. * configurations about resolution for example.
  262. * @param {Array} options.effects optional effects array for the track
  263. * @param {Array} options.devices the devices that will be requested
  264. * @param {string} options.resolution resolution constraints
  265. * @param {string} options.cameraDeviceId
  266. * @param {string} options.micDeviceId
  267. * @param {object} options.desktopSharingExtensionExternalInstallation -
  268. * enables external installation process for desktop sharing extension if
  269. * the inline installation is not posible. The following properties should
  270. * be provided:
  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.CHROME_EXTENSION_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: 'chrome_extension_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. * Set the contentHint on the transmitted stream track to indicate
  545. * charaterstics in the video stream, which informs PeerConnection
  546. * on how to encode the track (to prefer motion or individual frame detail)
  547. * @param {MediaStreamTrack} track - the track that is transmitted
  548. * @param {String} hint - contentHint value that needs to be set on the track
  549. */
  550. setVideoTrackContentHints(track, hint) {
  551. if ('contentHint' in track) {
  552. track.contentHint = hint;
  553. if (track.contentHint !== hint) {
  554. logger.debug('Invalid video track contentHint');
  555. }
  556. } else {
  557. logger.debug('MediaStreamTrack contentHint attribute not supported');
  558. }
  559. },
  560. /* eslint-enable max-params */
  561. /**
  562. * Represents a hub/namespace for utility functionality which may be of
  563. * interest to lib-jitsi-meet clients.
  564. */
  565. util: {
  566. AuthUtil,
  567. ScriptUtil,
  568. browser
  569. }
  570. });