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.

StatusIndicators.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { MEDIA_TYPE } from '../../../base/media';
  4. import {
  5. PARTICIPANT_ROLE,
  6. getParticipantByIdOrUndefined,
  7. isScreenShareParticipantById
  8. } from '../../../base/participants';
  9. import { connect } from '../../../base/redux';
  10. import {
  11. getVideoTrackByParticipant,
  12. isLocalTrackMuted,
  13. isRemoteTrackMuted
  14. } from '../../../base/tracks';
  15. import { getIndicatorsTooltipPosition } from '../../functions.web';
  16. import AudioMutedIndicator from './AudioMutedIndicator';
  17. import ModeratorIndicator from './ModeratorIndicator';
  18. import ScreenShareIndicator from './ScreenShareIndicator';
  19. declare var interfaceConfig: Object;
  20. /**
  21. * The type of the React {@code Component} props of {@link StatusIndicators}.
  22. */
  23. type Props = {
  24. /**
  25. * Indicates if the audio muted indicator should be visible or not.
  26. */
  27. _showAudioMutedIndicator: Boolean,
  28. /**
  29. * Indicates if the moderator indicator should be visible or not.
  30. */
  31. _showModeratorIndicator: Boolean,
  32. /**
  33. * Indicates if the screen share indicator should be visible or not.
  34. */
  35. _showScreenShareIndicator: Boolean,
  36. /**
  37. * The ID of the participant for which the status bar is rendered.
  38. */
  39. participantID: String,
  40. /**
  41. * The type of thumbnail.
  42. */
  43. thumbnailType: string
  44. };
  45. /**
  46. * React {@code Component} for showing the status bar in a thumbnail.
  47. *
  48. * @augments Component
  49. */
  50. class StatusIndicators extends Component<Props> {
  51. /**
  52. * Implements React's {@link Component#render()}.
  53. *
  54. * @inheritdoc
  55. * @returns {ReactElement}
  56. */
  57. render() {
  58. const {
  59. _showAudioMutedIndicator,
  60. _showModeratorIndicator,
  61. _showScreenShareIndicator,
  62. thumbnailType
  63. } = this.props;
  64. const tooltipPosition = getIndicatorsTooltipPosition(thumbnailType);
  65. return (
  66. <>
  67. { _showAudioMutedIndicator && <AudioMutedIndicator tooltipPosition = { tooltipPosition } /> }
  68. { _showModeratorIndicator && <ModeratorIndicator tooltipPosition = { tooltipPosition } />}
  69. { _showScreenShareIndicator && <ScreenShareIndicator tooltipPosition = { tooltipPosition } /> }
  70. </>
  71. );
  72. }
  73. }
  74. /**
  75. * Maps (parts of) the Redux state to the associated {@code StatusIndicators}'s props.
  76. *
  77. * @param {Object} state - The Redux state.
  78. * @param {Object} ownProps - The own props of the component.
  79. * @private
  80. * @returns {{
  81. * _showAudioMutedIndicator: boolean,
  82. * _showModeratorIndicator: boolean,
  83. * _showScreenShareIndicator: boolean
  84. * }}
  85. */
  86. function _mapStateToProps(state, ownProps) {
  87. const { participantID, audio, moderator, screenshare } = ownProps;
  88. // Only the local participant won't have id for the time when the conference is not yet joined.
  89. const participant = getParticipantByIdOrUndefined(state, participantID);
  90. const tracks = state['features/base/tracks'];
  91. let isAudioMuted = true;
  92. let isScreenSharing = false;
  93. if (participant?.local) {
  94. isAudioMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.AUDIO);
  95. } else if (!participant?.fakeParticipant || isScreenShareParticipantById(state, participantID)) {
  96. // remote participants excluding shared video
  97. const track = getVideoTrackByParticipant(state, participant);
  98. isScreenSharing = track?.videoType === 'desktop';
  99. isAudioMuted = isRemoteTrackMuted(tracks, MEDIA_TYPE.AUDIO, participantID);
  100. }
  101. const { disableModeratorIndicator } = state['features/base/config'];
  102. return {
  103. _showAudioMutedIndicator: isAudioMuted && audio,
  104. _showModeratorIndicator:
  105. !disableModeratorIndicator && participant && participant.role === PARTICIPANT_ROLE.MODERATOR && moderator,
  106. _showScreenShareIndicator: isScreenSharing && screenshare
  107. };
  108. }
  109. export default connect(_mapStateToProps)(StatusIndicators);