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

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