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.

OverflowMenuVideoQualityItem.web.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { VIDEO_QUALITY_LEVELS } from '../../base/conference';
  5. import { translate } from '../../base/i18n';
  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. _receiveVideoQuality: 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, _receiveVideoQuality } = this.props;
  56. const icon = _audioOnly || !_receiveVideoQuality
  57. ? 'icon-AUD'
  58. : VIDEO_QUALITY_TO_ICON[_receiveVideoQuality];
  59. return (
  60. <li
  61. aria-label = 'Call quality'
  62. className = 'overflow-menu-item'
  63. onClick = { this.props.onClick }>
  64. <span className = 'overflow-menu-item-icon'>
  65. <i className = { icon } />
  66. </span>
  67. <span className = 'profile-text'>
  68. { this.props.t('toolbar.callQuality') }
  69. </span>
  70. </li>
  71. );
  72. }
  73. }
  74. /**
  75. * Maps (parts of) the Redux state to the associated props for the
  76. * {@code OverflowMenuVideoQualityItem} component.
  77. *
  78. * @param {Object} state - The Redux state.
  79. * @private
  80. * @returns {{
  81. * _audioOnly: boolean,
  82. * _receiveVideoQuality: number
  83. * }}
  84. */
  85. function _mapStateToProps(state) {
  86. return {
  87. _audioOnly: state['features/base/conference'].audioOnly,
  88. _receiveVideoQuality:
  89. state['features/base/conference'].receiveVideoQuality
  90. };
  91. }
  92. export default translate(
  93. connect(_mapStateToProps)(OverflowMenuVideoQualityItem));