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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* @flow */
  2. import { VIDEO_MUTISM_AUTHORITY } from './constants';
  3. /**
  4. * Determines whether video is currently muted by the audio-only authority.
  5. *
  6. * @param {Store} store - The redux store.
  7. * @returns {boolean}
  8. */
  9. export function isVideoMutedByAudioOnly(store: { getState: Function }) {
  10. return _isVideoMutedByAuthority(store, VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY);
  11. }
  12. /**
  13. * Determines whether video is currently muted by a specific
  14. * <tt>VIDEO_MUTISM_AUTHORITY</tt>.
  15. *
  16. * @param {Store} store - The redux store.
  17. * @param {number} videoMutismAuthority - The <tt>VIDEO_MUTISM_AUTHORITY</tt>
  18. * which is to be checked whether it has muted video.
  19. * @returns {boolean} If video is currently muted by the specified
  20. * <tt>videoMutismAuthority</tt>, then <tt>true</tt>; otherwise, <tt>false</tt>.
  21. */
  22. function _isVideoMutedByAuthority(
  23. { getState }: { getState: Function },
  24. videoMutismAuthority: number) {
  25. return Boolean(
  26. // eslint-disable-next-line no-bitwise
  27. getState()['features/base/media'].video.muted & videoMutismAuthority);
  28. }
  29. /**
  30. * Determines whether video is currently muted by the user authority.
  31. *
  32. * @param {Store} store - The redux store.
  33. * @returns {boolean}
  34. */
  35. export function isVideoMutedByUser(store: { getState: Function }) {
  36. return _isVideoMutedByAuthority(store, VIDEO_MUTISM_AUTHORITY.USER);
  37. }
  38. /**
  39. * Determines whether a specific videoTrack should be rendered.
  40. *
  41. * @param {Track} videoTrack - The video track which is to be rendered.
  42. * @param {boolean} waitForVideoStarted - True if the specified videoTrack
  43. * should be rendered only after its associated video has started;
  44. * otherwise, false.
  45. * @returns {boolean} True if the specified videoTrack should be renderd;
  46. * otherwise, false.
  47. */
  48. export function shouldRenderVideoTrack(
  49. videoTrack: { muted: boolean, videoStarted: boolean },
  50. waitForVideoStarted: boolean) {
  51. return (
  52. videoTrack
  53. && !videoTrack.muted
  54. && (!waitForVideoStarted || videoTrack.videoStarted));
  55. }