Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

functions.ts 2.1KB

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