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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // @flow
  2. import { createScreenshotCaptureEffect } from '../stream-effects/screenshot-capture';
  3. import { getLocalVideoTrack } from '../../features/base/tracks';
  4. import { SET_SCREENSHOT_CAPTURE } from './actionTypes';
  5. /**
  6. * Marks the on-off state of screenshot captures.
  7. *
  8. * @param {boolean} enabled - Whether to turn screen captures on or off.
  9. * @returns {{
  10. * type: START_SCREENSHOT_CAPTURE,
  11. * payload: enabled
  12. * }}
  13. */
  14. function setScreenshotCapture(enabled) {
  15. return {
  16. type: SET_SCREENSHOT_CAPTURE,
  17. payload: enabled
  18. };
  19. }
  20. /**
  21. * Action that toggles the screenshot captures.
  22. *
  23. * @param {boolean} enabled - Bool that represents the intention to start/stop screenshot captures.
  24. * @returns {Promise}
  25. */
  26. export function toggleScreenshotCaptureEffect(enabled: boolean) {
  27. return function(dispatch: (Object) => Object, getState: () => any) {
  28. const state = getState();
  29. if (state['features/screenshot-capture'].capturesEnabled !== enabled) {
  30. const { jitsiTrack } = getLocalVideoTrack(state['features/base/tracks']);
  31. // Screenshot capture effect doesn't return a modified stream. Therefore, we don't have to
  32. // switch the stream at the conference level, starting/stopping the effect will suffice here.
  33. return createScreenshotCaptureEffect(state)
  34. .then(effect => {
  35. enabled ? effect.startEffect(jitsiTrack.getOriginalStream()) : effect.stopEffect();
  36. dispatch(setScreenshotCapture(enabled));
  37. });
  38. }
  39. return Promise.resolve();
  40. };
  41. }