Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ScreenObtainer.js 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. /* global chrome, $, alert */
  2. import JitsiTrackError from '../../JitsiTrackError';
  3. import * as JitsiTrackErrors from '../../JitsiTrackErrors';
  4. import browser from '../browser';
  5. const logger = require('jitsi-meet-logger').getLogger(__filename);
  6. const GlobalOnErrorHandler = require('../util/GlobalOnErrorHandler');
  7. /**
  8. * Indicates whether the Chrome desktop sharing extension is installed.
  9. * @type {boolean}
  10. */
  11. let chromeExtInstalled = false;
  12. /**
  13. * Indicates whether an update of the Chrome desktop sharing extension is
  14. * required.
  15. * @type {boolean}
  16. */
  17. let chromeExtUpdateRequired = false;
  18. let gumFunction = null;
  19. /**
  20. * The error returned by chrome when trying to start inline installation from
  21. * popup.
  22. */
  23. const CHROME_EXTENSION_POPUP_ERROR
  24. = 'Inline installs can not be initiated from pop-up windows.';
  25. /**
  26. * The error returned by chrome when trying to start inline installation from
  27. * iframe.
  28. */
  29. const CHROME_EXTENSION_IFRAME_ERROR
  30. = 'Chrome Web Store installations can only be started by the top frame.';
  31. /**
  32. * The error returned by chrome when trying to start inline installation
  33. * not from the "main" whitelisted site.
  34. * @type {string}
  35. */
  36. const CHROME_EXTENSION_INLINE_ERROR
  37. = 'Installs can only be initiated by one of'
  38. + ' the Chrome Web Store item\'s verified sites.';
  39. /**
  40. * The error returned by chrome when trying to start inline installation
  41. * with extension that doesn't support inline installation.
  42. *
  43. * @type {string}
  44. */
  45. const CHROME_EXTENSION_INLINE_NOT_SUPPORTED_ERROR
  46. = 'Inline installation is not supported for this item. '
  47. + 'The user will be redirected to the Chrome Web Store.';
  48. /**
  49. * The error message returned by chrome when the extension is installed.
  50. */
  51. const CHROME_NO_EXTENSION_ERROR_MSG // eslint-disable-line no-unused-vars
  52. = 'Could not establish connection. Receiving end does not exist.';
  53. /**
  54. * The error message returned by chrome when the extension install action needs
  55. * to be initiated by a user gesture.
  56. * @type {string}
  57. */
  58. const CHROME_USER_GESTURE_REQ_ERROR
  59. = 'Chrome Web Store installations can only be initated by a user gesture.';
  60. /**
  61. * The error message returned by chrome when the extension install has been
  62. * cancelled by the user.
  63. * @type {string}
  64. */
  65. const CHROME_USER_CANCEL_EXTENSION_INSTALL = 'User cancelled install';
  66. /**
  67. * Handles obtaining a stream from a screen capture on different browsers.
  68. */
  69. const ScreenObtainer = {
  70. /**
  71. * If not <tt>null</tt> it means that the initialization process is still in
  72. * progress. It is used to make desktop stream request wait and continue
  73. * after it's done.
  74. * {@type Promise|null}
  75. */
  76. intChromeExtPromise: null,
  77. obtainStream: null,
  78. /**
  79. * Initializes the function used to obtain a screen capture
  80. * (this.obtainStream).
  81. *
  82. * @param {object} options
  83. * @param {boolean} [options.desktopSharingChromeDisabled]
  84. * @param {boolean} [options.desktopSharingChromeExtId]
  85. * @param {boolean} [options.desktopSharingFirefoxDisabled]
  86. * @param {Function} gum GUM method
  87. */
  88. init(options = {
  89. desktopSharingChromeDisabled: false,
  90. desktopSharingChromeExtId: null,
  91. desktopSharingFirefoxDisabled: false
  92. }, gum) {
  93. this.options = options;
  94. gumFunction = gum;
  95. this.obtainStream = this._createObtainStreamMethod(options);
  96. if (!this.obtainStream) {
  97. logger.info('Desktop sharing disabled');
  98. }
  99. },
  100. /**
  101. * Returns a method which will be used to obtain the screen sharing stream
  102. * (based on the browser type).
  103. *
  104. * @param {object} options passed from {@link init} - check description
  105. * there
  106. * @returns {Function}
  107. * @private
  108. */
  109. _createObtainStreamMethod(options) {
  110. if (browser.isNWJS()) {
  111. return (_, onSuccess, onFailure) => {
  112. window.JitsiMeetNW.obtainDesktopStream(
  113. onSuccess,
  114. (error, constraints) => {
  115. let jitsiError;
  116. // FIXME:
  117. // This is very very dirty fix for recognising that the
  118. // user have clicked the cancel button from the Desktop
  119. // sharing pick window. The proper solution would be to
  120. // detect this in the NWJS application by checking the
  121. // streamId === "". Even better solution would be to
  122. // stop calling GUM from the NWJS app and just pass the
  123. // streamId to lib-jitsi-meet. This way the desktop
  124. // sharing implementation for NWJS and chrome extension
  125. // will be the same and lib-jitsi-meet will be able to
  126. // control the constraints, check the streamId, etc.
  127. //
  128. // I cannot find documentation about "InvalidStateError"
  129. // but this is what we are receiving from GUM when the
  130. // streamId for the desktop sharing is "".
  131. if (error && error.name === 'InvalidStateError') {
  132. jitsiError = new JitsiTrackError(
  133. JitsiTrackErrors.CHROME_EXTENSION_USER_CANCELED
  134. );
  135. } else {
  136. jitsiError = new JitsiTrackError(
  137. error, constraints, [ 'desktop' ]);
  138. }
  139. (typeof onFailure === 'function')
  140. && onFailure(jitsiError);
  141. });
  142. };
  143. } else if (browser.isElectron()) {
  144. return this.obtainScreenOnElectron;
  145. } else if (browser.isChrome() || browser.isOpera()) {
  146. if (browser.supportsGetDisplayMedia()
  147. && !options.desktopSharingChromeDisabled) {
  148. return this.obtainScreenFromGetDisplayMedia;
  149. } else if (options.desktopSharingChromeDisabled
  150. || !options.desktopSharingChromeExtId) {
  151. return null;
  152. }
  153. logger.info('Using Chrome extension for desktop sharing');
  154. this.intChromeExtPromise
  155. = initChromeExtension(options).then(() => {
  156. this.intChromeExtPromise = null;
  157. });
  158. return this.obtainScreenFromExtension;
  159. } else if (browser.isFirefox()) {
  160. if (options.desktopSharingFirefoxDisabled) {
  161. return null;
  162. } else if (window.location.protocol === 'http:') {
  163. logger.log('Screen sharing is not supported over HTTP. '
  164. + 'Use of HTTPS is required.');
  165. return null;
  166. }
  167. return this.obtainScreenOnFirefox;
  168. } else if (browser.isEdge() && browser.supportsGetDisplayMedia()) {
  169. return this.obtainScreenFromGetDisplayMedia;
  170. }
  171. logger.log(
  172. 'Screen sharing not supported by the current browser: ',
  173. browser.getName());
  174. return null;
  175. },
  176. /**
  177. * Checks whether obtaining a screen capture is supported in the current
  178. * environment.
  179. * @returns {boolean}
  180. */
  181. isSupported() {
  182. return this.obtainStream !== null;
  183. },
  184. /**
  185. * Obtains a screen capture stream on Firefox.
  186. * @param callback
  187. * @param errorCallback
  188. */
  189. obtainScreenOnFirefox(options, callback, errorCallback) {
  190. obtainWebRTCScreen(options.gumOptions, callback, errorCallback);
  191. },
  192. /**
  193. * Obtains a screen capture stream on Electron.
  194. *
  195. * @param {Object} [options] - Screen sharing options.
  196. * @param {Array<string>} [options.desktopSharingSources] - Array with the
  197. * sources that have to be displayed in the desktop picker window ('screen',
  198. * 'window', etc.).
  199. * @param onSuccess - Success callback.
  200. * @param onFailure - Failure callback.
  201. */
  202. obtainScreenOnElectron(options = {}, onSuccess, onFailure) {
  203. if (window.JitsiMeetScreenObtainer
  204. && window.JitsiMeetScreenObtainer.openDesktopPicker) {
  205. const { desktopSharingSources, gumOptions } = options;
  206. window.JitsiMeetScreenObtainer.openDesktopPicker(
  207. {
  208. desktopSharingSources: desktopSharingSources
  209. || this.options.desktopSharingChromeSources
  210. },
  211. (streamId, streamType) =>
  212. onGetStreamResponse(
  213. {
  214. response: {
  215. streamId,
  216. streamType
  217. },
  218. gumOptions
  219. },
  220. onSuccess,
  221. onFailure
  222. ),
  223. err => onFailure(new JitsiTrackError(
  224. JitsiTrackErrors.ELECTRON_DESKTOP_PICKER_ERROR,
  225. err
  226. ))
  227. );
  228. } else {
  229. onFailure(new JitsiTrackError(
  230. JitsiTrackErrors.ELECTRON_DESKTOP_PICKER_NOT_FOUND));
  231. }
  232. },
  233. /**
  234. * Asks Chrome extension to call chooseDesktopMedia and gets chrome
  235. * 'desktop' stream for returned stream token.
  236. */
  237. obtainScreenFromExtension(options, streamCallback, failCallback) {
  238. if (this.intChromeExtPromise !== null) {
  239. this.intChromeExtPromise.then(() => {
  240. this.obtainScreenFromExtension(
  241. options, streamCallback, failCallback);
  242. });
  243. return;
  244. }
  245. const {
  246. desktopSharingChromeExtId,
  247. desktopSharingChromeSources
  248. } = this.options;
  249. const {
  250. gumOptions
  251. } = options;
  252. const doGetStreamFromExtensionOptions = {
  253. desktopSharingChromeExtId,
  254. desktopSharingChromeSources:
  255. options.desktopSharingSources || desktopSharingChromeSources,
  256. gumOptions
  257. };
  258. if (chromeExtInstalled) {
  259. doGetStreamFromExtension(
  260. doGetStreamFromExtensionOptions,
  261. streamCallback,
  262. failCallback);
  263. } else {
  264. if (chromeExtUpdateRequired) {
  265. /* eslint-disable no-alert */
  266. alert(
  267. 'Jitsi Desktop Streamer requires update. '
  268. + 'Changes will take effect after next Chrome restart.');
  269. /* eslint-enable no-alert */
  270. }
  271. // for opera there is no inline install
  272. // extension "Download Chrome Extension" allows us to open
  273. // the chrome webstore and install from there and then activate our
  274. // extension
  275. if (browser.isOpera()) {
  276. this.handleExternalInstall(options, streamCallback,
  277. failCallback);
  278. return;
  279. }
  280. try {
  281. chrome.webstore.install(
  282. getWebStoreInstallUrl(this.options),
  283. arg => {
  284. logger.log('Extension installed successfully', arg);
  285. chromeExtInstalled = true;
  286. // We need to give a moment to the endpoint to become
  287. // available.
  288. waitForExtensionAfterInstall(this.options, 200, 10)
  289. .then(() => {
  290. doGetStreamFromExtension(
  291. doGetStreamFromExtensionOptions,
  292. streamCallback,
  293. failCallback);
  294. })
  295. .catch(() => {
  296. this.handleExtensionInstallationError(options,
  297. streamCallback, failCallback);
  298. });
  299. },
  300. this.handleExtensionInstallationError.bind(this,
  301. options, streamCallback, failCallback)
  302. );
  303. } catch (e) {
  304. this.handleExtensionInstallationError(options, streamCallback,
  305. failCallback, e);
  306. }
  307. }
  308. },
  309. /* eslint-disable max-params */
  310. handleExternalInstall(options, streamCallback, failCallback, e) {
  311. const webStoreInstallUrl = getWebStoreInstallUrl(this.options);
  312. options.listener('waitingForExtension', webStoreInstallUrl);
  313. this.checkForChromeExtensionOnInterval(options, streamCallback,
  314. failCallback, e);
  315. },
  316. handleExtensionInstallationError(options, streamCallback, failCallback, e) {
  317. const webStoreInstallUrl = getWebStoreInstallUrl(this.options);
  318. if ((CHROME_EXTENSION_POPUP_ERROR === e
  319. || CHROME_EXTENSION_IFRAME_ERROR === e
  320. || CHROME_EXTENSION_INLINE_ERROR === e
  321. || CHROME_EXTENSION_INLINE_NOT_SUPPORTED_ERROR === e)
  322. && options.interval > 0
  323. && typeof options.checkAgain === 'function'
  324. && typeof options.listener === 'function') {
  325. this.handleExternalInstall(options, streamCallback,
  326. failCallback, e);
  327. return;
  328. }
  329. const msg
  330. = `Failed to install the extension from ${webStoreInstallUrl}`;
  331. logger.log(msg, e);
  332. let error;
  333. if (e === CHROME_USER_CANCEL_EXTENSION_INSTALL) {
  334. error = JitsiTrackErrors.CHROME_EXTENSION_USER_CANCELED;
  335. } else if (e === CHROME_USER_GESTURE_REQ_ERROR) {
  336. error = JitsiTrackErrors.CHROME_EXTENSION_USER_GESTURE_REQUIRED;
  337. } else {
  338. error = JitsiTrackErrors.CHROME_EXTENSION_INSTALLATION_ERROR;
  339. }
  340. failCallback(new JitsiTrackError(error, msg));
  341. },
  342. /* eslint-enable max-params */
  343. checkForChromeExtensionOnInterval(options, streamCallback, failCallback) {
  344. if (options.checkAgain() === false) {
  345. failCallback(new JitsiTrackError(
  346. JitsiTrackErrors.CHROME_EXTENSION_INSTALLATION_ERROR));
  347. return;
  348. }
  349. waitForExtensionAfterInstall(this.options, options.interval, 1)
  350. .then(() => {
  351. chromeExtInstalled = true;
  352. options.listener('extensionFound');
  353. this.obtainScreenFromExtension(options,
  354. streamCallback, failCallback);
  355. })
  356. .catch(() => {
  357. this.checkForChromeExtensionOnInterval(options,
  358. streamCallback, failCallback);
  359. });
  360. },
  361. /**
  362. * Obtains a screen capture stream using getDisplayMedia.
  363. *
  364. * @param callback - The success callback.
  365. * @param errorCallback - The error callback.
  366. */
  367. obtainScreenFromGetDisplayMedia(options, callback, errorCallback) {
  368. navigator.mediaDevices.getDisplayMedia({ video: true })
  369. .then(stream => {
  370. let applyConstraintsPromise;
  371. if (stream
  372. && stream.getTracks()
  373. && stream.getTracks().length > 0) {
  374. applyConstraintsPromise = stream.getTracks()[0]
  375. .applyConstraints(options.trackOptions);
  376. } else {
  377. applyConstraintsPromise = Promise.resolve();
  378. }
  379. applyConstraintsPromise.then(() =>
  380. callback({
  381. stream,
  382. sourceId: stream.id
  383. }));
  384. })
  385. .catch(() =>
  386. errorCallback(new JitsiTrackError(JitsiTrackErrors
  387. .CHROME_EXTENSION_USER_CANCELED)));
  388. }
  389. };
  390. /**
  391. * Obtains a desktop stream using getUserMedia.
  392. * For this to work on Chrome, the
  393. * 'chrome://flags/#enable-usermedia-screen-capture' flag must be enabled.
  394. *
  395. * On firefox, the document's domain must be white-listed in the
  396. * 'media.getusermedia.screensharing.allowed_domains' preference in
  397. * 'about:config'.
  398. */
  399. function obtainWebRTCScreen(options, streamCallback, failCallback) {
  400. gumFunction([ 'screen' ], options)
  401. .then(stream => streamCallback({ stream }), failCallback);
  402. }
  403. /**
  404. * Constructs inline install URL for Chrome desktop streaming extension.
  405. * The 'chromeExtensionId' must be defined in options parameter.
  406. * @param options supports "desktopSharingChromeExtId"
  407. * @returns {string}
  408. */
  409. function getWebStoreInstallUrl(options) {
  410. return (
  411. `https://chrome.google.com/webstore/detail/${
  412. options.desktopSharingChromeExtId}`);
  413. }
  414. /**
  415. * Checks whether an update of the Chrome extension is required.
  416. * @param minVersion minimal required version
  417. * @param extVersion current extension version
  418. * @returns {boolean}
  419. */
  420. function isUpdateRequired(minVersion, extVersion) {
  421. try {
  422. const s1 = minVersion.split('.');
  423. const s2 = extVersion.split('.');
  424. const len = Math.max(s1.length, s2.length);
  425. for (let i = 0; i < len; i++) {
  426. let n1 = 0,
  427. n2 = 0;
  428. if (i < s1.length) {
  429. n1 = parseInt(s1[i], 10);
  430. }
  431. if (i < s2.length) {
  432. n2 = parseInt(s2[i], 10);
  433. }
  434. if (isNaN(n1) || isNaN(n2)) {
  435. return true;
  436. } else if (n1 !== n2) {
  437. return n1 > n2;
  438. }
  439. }
  440. // will happen if both versions have identical numbers in
  441. // their components (even if one of them is longer, has more components)
  442. return false;
  443. } catch (e) {
  444. GlobalOnErrorHandler.callErrorHandler(e);
  445. logger.error('Failed to parse extension version', e);
  446. return true;
  447. }
  448. }
  449. /**
  450. *
  451. * @param callback
  452. * @param options
  453. */
  454. function checkChromeExtInstalled(callback, options) {
  455. if (typeof chrome === 'undefined' || !chrome || !chrome.runtime) {
  456. // No API, so no extension for sure
  457. callback(false, false);
  458. return;
  459. }
  460. chrome.runtime.sendMessage(
  461. options.desktopSharingChromeExtId,
  462. { getVersion: true },
  463. response => {
  464. if (!response || !response.version) {
  465. // Communication failure - assume that no endpoint exists
  466. logger.warn(
  467. 'Extension not installed?: ', chrome.runtime.lastError);
  468. callback(false, false);
  469. return;
  470. }
  471. // Check installed extension version
  472. const extVersion = response.version;
  473. logger.log(`Extension version is: ${extVersion}`);
  474. const updateRequired
  475. = isUpdateRequired(
  476. options.desktopSharingChromeMinExtVersion,
  477. extVersion);
  478. callback(!updateRequired, updateRequired);
  479. }
  480. );
  481. }
  482. /**
  483. *
  484. * @param options
  485. * @param streamCallback
  486. * @param failCallback
  487. */
  488. function doGetStreamFromExtension(options, streamCallback, failCallback) {
  489. const {
  490. desktopSharingChromeSources,
  491. desktopSharingChromeExtId,
  492. gumOptions
  493. } = options;
  494. // Sends 'getStream' msg to the extension.
  495. // Extension id must be defined in the config.
  496. chrome.runtime.sendMessage(
  497. desktopSharingChromeExtId,
  498. {
  499. getStream: true,
  500. sources: desktopSharingChromeSources
  501. },
  502. response => {
  503. if (!response) {
  504. // possibly re-wraping error message to make code consistent
  505. const lastError = chrome.runtime.lastError;
  506. failCallback(lastError instanceof Error
  507. ? lastError
  508. : new JitsiTrackError(
  509. JitsiTrackErrors.CHROME_EXTENSION_GENERIC_ERROR,
  510. lastError));
  511. return;
  512. }
  513. logger.log('Response from extension: ', response);
  514. onGetStreamResponse(
  515. {
  516. response,
  517. gumOptions
  518. },
  519. streamCallback,
  520. failCallback
  521. );
  522. }
  523. );
  524. }
  525. /**
  526. * Initializes <link rel=chrome-webstore-item /> with extension id set in
  527. * config.js to support inline installs. Host site must be selected as main
  528. * website of published extension.
  529. * @param options supports "desktopSharingChromeExtId"
  530. */
  531. function initInlineInstalls(options) {
  532. if ($('link[rel=chrome-webstore-item]').length === 0) {
  533. $('head').append('<link rel="chrome-webstore-item">');
  534. }
  535. $('link[rel=chrome-webstore-item]').attr('href',
  536. getWebStoreInstallUrl(options));
  537. }
  538. /**
  539. *
  540. * @param options
  541. *
  542. * @return {Promise} - a Promise resolved once the initialization process is
  543. * finished.
  544. */
  545. function initChromeExtension(options) {
  546. // Initialize Chrome extension inline installs
  547. initInlineInstalls(options);
  548. return new Promise(resolve => {
  549. // Check if extension is installed
  550. checkChromeExtInstalled((installed, updateRequired) => {
  551. chromeExtInstalled = installed;
  552. chromeExtUpdateRequired = updateRequired;
  553. logger.info(
  554. `Chrome extension installed: ${
  555. chromeExtInstalled} updateRequired: ${
  556. chromeExtUpdateRequired}`);
  557. resolve();
  558. }, options);
  559. });
  560. }
  561. /**
  562. * Checks "retries" times on every "waitInterval"ms whether the ext is alive.
  563. * @param {Object} options the options passed to ScreanObtainer.obtainStream
  564. * @param {int} waitInterval the number of ms between retries
  565. * @param {int} retries the number of retries
  566. * @returns {Promise} returns promise that will be resolved when the extension
  567. * is alive and rejected if the extension is not alive even after "retries"
  568. * checks
  569. */
  570. function waitForExtensionAfterInstall(options, waitInterval, retries) {
  571. if (retries === 0) {
  572. return Promise.reject();
  573. }
  574. return new Promise((resolve, reject) => {
  575. let currentRetries = retries;
  576. const interval = window.setInterval(() => {
  577. checkChromeExtInstalled(installed => {
  578. if (installed) {
  579. window.clearInterval(interval);
  580. resolve();
  581. } else {
  582. currentRetries--;
  583. if (currentRetries === 0) {
  584. reject();
  585. window.clearInterval(interval);
  586. }
  587. }
  588. }, options);
  589. }, waitInterval);
  590. });
  591. }
  592. /**
  593. * Handles response from external application / extension and calls GUM to
  594. * receive the desktop streams or reports error.
  595. * @param {object} options
  596. * @param {object} options.response
  597. * @param {string} options.response.streamId - the streamId for the desktop
  598. * stream.
  599. * @param {string} options.response.error - error to be reported.
  600. * @param {object} options.gumOptions - options passed to GUM.
  601. * @param {Function} onSuccess - callback for success.
  602. * @param {Function} onFailure - callback for failure.
  603. * @param {object} gumOptions - options passed to GUM.
  604. */
  605. function onGetStreamResponse(
  606. options = {
  607. response: {},
  608. gumOptions: {}
  609. },
  610. onSuccess,
  611. onFailure) {
  612. const { streamId, streamType, error } = options.response || {};
  613. if (streamId) {
  614. const gumOptions = {
  615. desktopStream: streamId,
  616. ...options.gumOptions
  617. };
  618. gumFunction([ 'desktop' ], gumOptions)
  619. .then(stream => onSuccess({
  620. stream,
  621. sourceId: streamId,
  622. sourceType: streamType
  623. }), onFailure);
  624. } else {
  625. // As noted in Chrome Desktop Capture API:
  626. // If user didn't select any source (i.e. canceled the prompt)
  627. // then the callback is called with an empty streamId.
  628. if (streamId === '') {
  629. onFailure(new JitsiTrackError(
  630. JitsiTrackErrors.CHROME_EXTENSION_USER_CANCELED));
  631. return;
  632. }
  633. onFailure(new JitsiTrackError(
  634. JitsiTrackErrors.CHROME_EXTENSION_GENERIC_ERROR,
  635. error));
  636. }
  637. }
  638. export default ScreenObtainer;