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.ts 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* eslint-disable lines-around-comment */
  2. import { IState } from '../app/types';
  3. // @ts-ignore
  4. import { NOTIFICATION_TIMEOUT_TYPE, showWarningNotification } from '../notifications';
  5. // @ts-ignore
  6. import { isScreenAudioShared } from '../screen-share';
  7. /**
  8. * Is noise suppression currently enabled.
  9. *
  10. * @param {IState} state - The state of the application.
  11. * @returns {boolean}
  12. */
  13. export function isNoiseSuppressionEnabled(state: IState): boolean {
  14. return state['features/noise-suppression'].enabled;
  15. }
  16. /**
  17. * Verify if noise suppression can be enabled in the current state.
  18. *
  19. * @param {*} state - Redux state.
  20. * @param {*} dispatch - Redux dispatch.
  21. * @param {*} localAudio - Current local audio track.
  22. * @returns {boolean}
  23. */
  24. export function canEnableNoiseSuppression(state: IState, dispatch: Function, localAudio: any) : boolean {
  25. const { channelCount } = localAudio.track.getSettings();
  26. // Sharing screen audio implies an effect being applied to the local track, because currently we don't support
  27. // more then one effect at a time the user has to choose between sharing audio or having noise suppression active.
  28. if (isScreenAudioShared(state)) {
  29. dispatch(showWarningNotification({
  30. titleKey: 'notify.noiseSuppressionFailedTitle',
  31. descriptionKey: 'notify.noiseSuppressionDesktopAudioDescription'
  32. }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
  33. return false;
  34. }
  35. // Stereo audio tracks aren't currently supported, make sure the current local track is mono
  36. if (channelCount > 1) {
  37. dispatch(showWarningNotification({
  38. titleKey: 'notify.noiseSuppressionFailedTitle',
  39. descriptionKey: 'notify.noiseSuppressionStereoDescription'
  40. }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
  41. return false;
  42. }
  43. return true;
  44. }