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.1KB

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