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.

functions.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // @flow
  2. import { getJitsiMeetGlobalNS, loadScript } from '../base/util';
  3. let filterSupport;
  4. /**
  5. * Returns promise that resolves with the blur effect instance.
  6. *
  7. * @param {Object} virtualBackground - The virtual object that contains the background image source and
  8. * the isVirtualBackground flag that indicates if virtual image is activated .
  9. * @returns {Promise<JitsiStreamBackgroundEffect>} - Resolves with the background effect instance.
  10. */
  11. export function getBackgroundEffect(virtualBackground: Object) {
  12. const ns = getJitsiMeetGlobalNS();
  13. if (ns.effects && ns.effects.createVirtualBackgroundEffect) {
  14. return ns.effects.createVirtualBackgroundEffect(virtualBackground);
  15. }
  16. return loadScript('libs/virtual-background-effect.min.js').then(() =>
  17. ns.effects.createVirtualBackgroundEffect(virtualBackground));
  18. }
  19. /**
  20. * Checks context filter support.
  21. *
  22. * @returns {boolean} True if the filter is supported and false if the filter is not supported by the browser.
  23. */
  24. export function checkBlurSupport() {
  25. if (typeof filterSupport === 'undefined') {
  26. const canvas = document.createElement('canvas');
  27. const ctx = canvas.getContext('2d');
  28. filterSupport = typeof ctx.filter !== 'undefined';
  29. canvas.remove();
  30. }
  31. return filterSupport;
  32. }