您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

OverflowMenuVideoQualityItem.web.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { VIDEO_QUALITY_LEVELS } from '../../base/conference';
  4. import { translate } from '../../base/i18n';
  5. import { connect } from '../../base/redux';
  6. /**
  7. * A map of of selectable receive resolutions to corresponding icons.
  8. *
  9. * @private
  10. * @type {Object}
  11. */
  12. const VIDEO_QUALITY_TO_ICON = {
  13. [VIDEO_QUALITY_LEVELS.HIGH]: 'icon-HD',
  14. [VIDEO_QUALITY_LEVELS.STANDARD]: 'icon-SD',
  15. [VIDEO_QUALITY_LEVELS.LOW]: 'icon-LD'
  16. };
  17. /**
  18. * The type of the React {@code Component} props of
  19. * {@link OverflowMenuVideoQualityItem}.
  20. */
  21. type Props = {
  22. /**
  23. * Whether or not audio only mode is currently enabled.
  24. */
  25. _audioOnly: boolean,
  26. /**
  27. * The currently configured maximum quality resolution to be received from
  28. * remote participants.
  29. */
  30. _receiverVideoQuality: number,
  31. /**
  32. * Callback to invoke when {@link OverflowMenuVideoQualityItem} is clicked.
  33. */
  34. onClick: Function,
  35. /**
  36. * Invoked to obtain translated strings.
  37. */
  38. t: Function
  39. };
  40. /**
  41. * React {@code Component} responsible for displaying a button in the overflow
  42. * menu of the toolbar, including an icon showing the currently selected
  43. * max receive quality.
  44. *
  45. * @extends Component
  46. */
  47. class OverflowMenuVideoQualityItem extends Component<Props> {
  48. /**
  49. * Implements React's {@link Component#render()}.
  50. *
  51. * @inheritdoc
  52. * @returns {ReactElement}
  53. */
  54. render() {
  55. const { _audioOnly, _receiverVideoQuality } = this.props;
  56. const icon = _audioOnly || !_receiverVideoQuality
  57. ? 'icon-AUD'
  58. : VIDEO_QUALITY_TO_ICON[_receiverVideoQuality];
  59. return (
  60. <li
  61. aria-label =
  62. { this.props.t('toolbar.accessibilityLabel.callQuality') }
  63. className = 'overflow-menu-item'
  64. onClick = { this.props.onClick }>
  65. <span className = 'overflow-menu-item-icon'>
  66. <i className = { icon } />
  67. </span>
  68. <span className = 'profile-text'>
  69. { this.props.t('toolbar.callQuality') }
  70. </span>
  71. </li>
  72. );
  73. }
  74. }
  75. /**
  76. * Maps (parts of) the Redux state to the associated props for the
  77. * {@code OverflowMenuVideoQualityItem} component.
  78. *
  79. * @param {Object} state - The Redux state.
  80. * @private
  81. * @returns {{
  82. * _audioOnly: boolean,
  83. * _receiverVideoQuality: number
  84. * }}
  85. */
  86. function _mapStateToProps(state) {
  87. return {
  88. _audioOnly: state['features/base/audio-only'].enabled,
  89. _receiverVideoQuality:
  90. state['features/base/conference'].preferredReceiverVideoQuality
  91. };
  92. }
  93. export default translate(
  94. connect(_mapStateToProps)(OverflowMenuVideoQualityItem));