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.js 1.7KB

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