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

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