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 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { IReduxState } from '../app/types';
  2. import { getMultipleVideoSendingSupportFeatureFlag } from '../base/config/functions.any';
  3. import { isWindows } from '../base/environment/environment';
  4. import { isMobileBrowser } from '../base/environment/utils';
  5. import { browser } from '../base/lib-jitsi-meet';
  6. import { VIDEO_TYPE } from '../base/media/constants';
  7. import { getLocalDesktopTrack, getLocalVideoTrack } from '../base/tracks/functions';
  8. /**
  9. * Is the current screen sharing session audio only.
  10. *
  11. * @param {IReduxState} state - The state of the application.
  12. * @returns {boolean}
  13. */
  14. export function isAudioOnlySharing(state: IReduxState) {
  15. return isScreenAudioShared(state) && !isScreenVideoShared(state);
  16. }
  17. /**
  18. * State of audio sharing.
  19. *
  20. * @param {IReduxState} state - The state of the application.
  21. * @returns {boolean}
  22. */
  23. export function isScreenAudioShared(state: IReduxState) {
  24. return state['features/screen-share'].isSharingAudio;
  25. }
  26. /**
  27. * Returns the visibility of the audio only screen share button. Currently only chrome browser and electron on
  28. * windows supports this functionality.
  29. *
  30. * @returns {boolean}
  31. */
  32. export function isScreenAudioSupported() {
  33. return (!isMobileBrowser() && browser.isChrome()) || (browser.isElectron() && isWindows());
  34. }
  35. /**
  36. * Is any screen media currently being shared, audio or video.
  37. *
  38. * @param {IReduxState} state - The state of the application.
  39. * @returns {boolean}
  40. */
  41. export function isScreenMediaShared(state: IReduxState) {
  42. return isScreenAudioShared(state) || isScreenVideoShared(state);
  43. }
  44. /**
  45. * Is screen sharing currently active.
  46. *
  47. * @param {IReduxState} state - The state of the application.
  48. * @returns {boolean}
  49. */
  50. export function isScreenVideoShared(state: IReduxState) {
  51. const tracks = state['features/base/tracks'];
  52. const localScreenshare = getLocalDesktopTrack(tracks);
  53. if (getMultipleVideoSendingSupportFeatureFlag(state)) {
  54. return localScreenshare?.jitsiTrack && !localScreenshare.jitsiTrack.isMuted();
  55. }
  56. const localVideo = getLocalVideoTrack(tracks);
  57. return localVideo?.jitsiTrack?.getVideoType() === VIDEO_TYPE.DESKTOP;
  58. }