2018-04-11 20:04:40 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { translate } from '../../base/i18n';
|
2019-08-30 16:39:06 +00:00
|
|
|
import {
|
|
|
|
IconVideoQualityAudioOnly,
|
|
|
|
IconVideoQualityHD,
|
|
|
|
IconVideoQualityLD,
|
|
|
|
IconVideoQualitySD
|
|
|
|
} from '../../base/icons';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../base/redux';
|
2021-07-08 13:42:07 +00:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
|
2020-09-01 19:19:04 +00:00
|
|
|
import { VIDEO_QUALITY_LEVELS } from '../constants';
|
2020-09-01 21:45:59 +00:00
|
|
|
import { findNearestQualityLevel } from '../functions';
|
2018-04-11 20:04:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A map of of selectable receive resolutions to corresponding icons.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
const VIDEO_QUALITY_TO_ICON = {
|
2020-10-06 20:42:38 +00:00
|
|
|
[VIDEO_QUALITY_LEVELS.ULTRA]: IconVideoQualityHD,
|
2019-08-30 16:39:06 +00:00
|
|
|
[VIDEO_QUALITY_LEVELS.HIGH]: IconVideoQualityHD,
|
|
|
|
[VIDEO_QUALITY_LEVELS.STANDARD]: IconVideoQualitySD,
|
|
|
|
[VIDEO_QUALITY_LEVELS.LOW]: IconVideoQualityLD
|
2018-04-11 20:04:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of
|
2021-07-08 13:42:07 +00:00
|
|
|
* {@link VideoQualityButton}.
|
2018-04-11 20:04:40 +00:00
|
|
|
*/
|
2021-07-08 13:42:07 +00:00
|
|
|
type Props = AbstractButtonProps & {
|
2018-04-11 20:04:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not audio only mode is currently enabled.
|
|
|
|
*/
|
|
|
|
_audioOnly: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The currently configured maximum quality resolution to be received from
|
2020-04-28 02:51:40 +00:00
|
|
|
* and sent to remote participants.
|
2018-04-11 20:04:40 +00:00
|
|
|
*/
|
2020-04-28 02:51:40 +00:00
|
|
|
_videoQuality: number,
|
2018-04-11 20:04:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React {@code Component} responsible for displaying a button in the overflow
|
|
|
|
* menu of the toolbar, including an icon showing the currently selected
|
|
|
|
* max receive quality.
|
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
2021-07-08 13:42:07 +00:00
|
|
|
class VideoQualityButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.callQuality';
|
|
|
|
label = 'toolbar.callQuality';
|
|
|
|
tooltip = 'toolbar.callQuality';
|
2021-06-10 12:48:44 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-08 13:42:07 +00:00
|
|
|
* Dynamically retrieves the icon.
|
2021-06-10 12:48:44 +00:00
|
|
|
*/
|
2021-07-08 13:42:07 +00:00
|
|
|
get icon() {
|
|
|
|
const { _audioOnly, _videoQuality } = this.props;
|
2021-06-10 12:48:44 +00:00
|
|
|
|
2021-07-08 13:42:07 +00:00
|
|
|
const videoQualityLevel = findNearestQualityLevel(_videoQuality);
|
2021-06-10 12:48:44 +00:00
|
|
|
|
2021-07-08 13:42:07 +00:00
|
|
|
const icon = _audioOnly || !videoQualityLevel
|
|
|
|
? IconVideoQualityAudioOnly
|
|
|
|
: VIDEO_QUALITY_TO_ICON[videoQualityLevel];
|
|
|
|
|
|
|
|
return icon;
|
|
|
|
}
|
2021-06-10 12:48:44 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-08 13:42:07 +00:00
|
|
|
* Required by linter due to AbstractButton overwritten prop being writable.
|
2021-06-10 12:48:44 +00:00
|
|
|
*
|
2021-07-08 13:42:07 +00:00
|
|
|
* @param {string} value - The icon value.
|
2021-06-10 12:48:44 +00:00
|
|
|
*/
|
2021-07-08 13:42:07 +00:00
|
|
|
set icon(value) {
|
|
|
|
return value;
|
2021-06-10 12:48:44 +00:00
|
|
|
}
|
|
|
|
|
2018-04-11 20:04:40 +00:00
|
|
|
/**
|
2021-07-08 13:42:07 +00:00
|
|
|
* Handles clicking / pressing the button.
|
2018-04-11 20:04:40 +00:00
|
|
|
*
|
2021-07-08 13:42:07 +00:00
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {void}
|
2018-04-11 20:04:40 +00:00
|
|
|
*/
|
2021-07-08 13:42:07 +00:00
|
|
|
_handleClick() {
|
2021-09-14 07:07:20 +00:00
|
|
|
const { handleClick } = this.props;
|
|
|
|
|
|
|
|
if (handleClick) {
|
|
|
|
handleClick();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2018-04-11 20:04:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated props for the
|
2021-07-08 13:42:07 +00:00
|
|
|
* {@code VideoQualityButton} component.
|
2018-04-11 20:04:40 +00:00
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _audioOnly: boolean,
|
2020-04-28 02:51:40 +00:00
|
|
|
* _videoQuality: number
|
2018-04-11 20:04:40 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
return {
|
2019-07-31 12:47:52 +00:00
|
|
|
_audioOnly: state['features/base/audio-only'].enabled,
|
2020-09-01 19:19:04 +00:00
|
|
|
_videoQuality: state['features/video-quality'].preferredVideoQuality
|
2018-04-11 20:04:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(
|
2021-07-08 13:42:07 +00:00
|
|
|
connect(_mapStateToProps)(VideoQualityButton));
|