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.

actions.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // @flow
  2. import { getJitsiMeetGlobalNS } from '../base/util';
  3. import { getLocalVideoTrack } from '../../features/base/tracks';
  4. import {
  5. BLUR_DISABLED,
  6. BLUR_ENABLED
  7. } from './actionTypes';
  8. const logger = require('jitsi-meet-logger').getLogger(__filename);
  9. /**
  10. * Signals the local participant is switching between blurred or
  11. * non blurred video.
  12. *
  13. * @param {boolean} enabled - If true enables video blur, false otherwise
  14. *
  15. * @returns {Promise}
  16. */
  17. export function toggleBlurEffect(enabled: boolean) {
  18. return function(dispatch: (Object) => Object, getState: () => any) {
  19. if (getState()['features/blur'].blurEnabled !== enabled) {
  20. const videoTrack = getLocalVideoTrack(getState()['features/base/tracks']).jitsiTrack;
  21. return getJitsiMeetGlobalNS().effects.createBlurEffect()
  22. .then(blurEffectInstance =>
  23. videoTrack.enableEffect(enabled, blurEffectInstance)
  24. .then(() => {
  25. enabled ? dispatch(blurEnabled()) : dispatch(blurDisabled());
  26. })
  27. .catch(error => {
  28. enabled ? dispatch(blurDisabled()) : dispatch(blurEnabled());
  29. logger.log('enableEffect failed with error:', error);
  30. })
  31. )
  32. .catch(error => {
  33. dispatch(blurDisabled());
  34. logger.log('createBlurEffect failed with error:', error);
  35. });
  36. }
  37. };
  38. }
  39. /**
  40. * Signals the local participant that the blur has been enabled
  41. *
  42. * @returns {{
  43. * type: BLUR_ENABLED
  44. * }}
  45. */
  46. export function blurEnabled() {
  47. return {
  48. type: BLUR_ENABLED
  49. };
  50. }
  51. /**
  52. * Signals the local participant that the blur has been disabled
  53. *
  54. * @returns {{
  55. * type: BLUR_DISABLED
  56. * }}
  57. */
  58. export function blurDisabled() {
  59. return {
  60. type: BLUR_DISABLED
  61. };
  62. }