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.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { IReduxState, IStore } from '../../app/types';
  2. import { isTrackStreamingStatusActive } from '../../connection-indicator/functions';
  3. import { MEDIA_TYPE, VIDEO_TYPE } from '../media/constants';
  4. import { getParticipantById, isScreenShareParticipant } from '../participants/functions';
  5. import { getTrackByMediaTypeAndParticipant, getVideoTrackByParticipant } from '../tracks/functions';
  6. /**
  7. * Indicates whether the test mode is enabled. When it's enabled
  8. * {@link TestHint} and other components from the testing package will be
  9. * rendered in various places across the app to help with automatic testing.
  10. *
  11. * @param {IReduxState} state - The redux store state.
  12. * @returns {boolean}
  13. */
  14. export function isTestModeEnabled(state: IReduxState): boolean {
  15. const testingConfig = state['features/base/config'].testing;
  16. return Boolean(testingConfig?.testMode);
  17. }
  18. /**
  19. * Returns the video type of the remote participant's video.
  20. *
  21. * @param {IStore} store - The redux store.
  22. * @param {string} id - The participant ID for the remote video.
  23. * @returns {VIDEO_TYPE}
  24. */
  25. export function getRemoteVideoType({ getState }: IStore, id: string) {
  26. const state = getState();
  27. const participant = getParticipantById(state, id);
  28. if (isScreenShareParticipant(participant)) {
  29. return VIDEO_TYPE.DESKTOP;
  30. }
  31. return getTrackByMediaTypeAndParticipant(state['features/base/tracks'], MEDIA_TYPE.VIDEO, id)?.videoType;
  32. }
  33. /**
  34. * Returns whether the last media event received for large video indicates that the video is playing, if not muted.
  35. *
  36. * @param {IStore} store - The redux store.
  37. * @returns {boolean}
  38. */
  39. export function isLargeVideoReceived({ getState }: IStore): boolean {
  40. const state = getState();
  41. const largeVideoParticipantId = state['features/large-video'].participantId ?? '';
  42. const largeVideoParticipant = getParticipantById(state, largeVideoParticipantId ?? '');
  43. const videoTrack = getVideoTrackByParticipant(state, largeVideoParticipant);
  44. return Boolean(videoTrack && !videoTrack.muted && isTrackStreamingStatusActive(videoTrack));
  45. }
  46. /**
  47. * Returns whether the last media event received for a remote video indicates that the video is playing, if not muted.
  48. *
  49. * @param {IStore} store - The redux store.
  50. * @param {string} id - The participant ID for the remote video.
  51. * @returns {boolean}
  52. */
  53. export function isRemoteVideoReceived({ getState }: IStore, id: string): boolean {
  54. const state = getState();
  55. const participant = getParticipantById(state, id);
  56. const videoTrack = getVideoTrackByParticipant(state, participant);
  57. return Boolean(videoTrack && !videoTrack.muted && isTrackStreamingStatusActive(videoTrack));
  58. }