Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
import { createToolbarEvent } from '../../analytics/AnalyticsEvents';
import { sendAnalytics } from '../../analytics/functions';
import { IReduxState } from '../../app/types';
import { MEET_FEATURES } from '../../base/jwt/constants';
import AbstractButton, { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton';
import { isE2EEOnInMeeting } from '../../e2ee/functions';
import { maybeShowPremiumFeatureDialog } from '../../jaas/actions';
import { canStartSubtitles, isCCTabEnabled } from '../functions.any';
/**
* Props interface for the Abstract Closed Caption Button component.
*
* @interface IAbstractProps
* @augments {AbstractButtonProps}
*/
export interface IAbstractProps extends AbstractButtonProps {
/**
* The default language used for transcriptions, shown on the button when subtitles are enabled
* without a translation language selected (i.e. the source language).
*/
_defaultLanguage?: string;
/**
* Whether end-to-end encryption is on, which rules out transcription.
*/
_e2eeEnabled?: boolean;
/**
* Whether the subtitles tab is enabled in the UI.
*/
_isCCTabEnabled: boolean;
/**
* Whether subtitle translation (language selection) is enabled.
*/
_isTranslationEnabled?: boolean;
_language: string | null;
/**
* Whether the local participant is currently requesting subtitles.
*/
_requestingSubtitles: boolean;
/**
* Selected language for subtitle.
*/
_subtitles: string;
languages?: string;
languagesHead?: string;
}
/**
* The button component which starts/stops the transcription.
*/
export class AbstractClosedCaptionButton
extends AbstractButton<IAbstractProps> {
/**
* Helper function to be implemented by subclasses, which should be used
* to handle the closed caption button being clicked / pressed.
*
* @protected
* @returns {void}
*/
_handleClickOpenLanguageSelector() {
// To be implemented by subclass.
}
/**
* Handles clicking / pressing the button.
*
* @override
* @protected
* @returns {void}
*/
override _handleClick() {
const { _requestingSubtitles, dispatch } = this.props;
sendAnalytics(createToolbarEvent('transcribing.ccButton',
{
'requesting_subtitles': Boolean(_requestingSubtitles)
}));
const dialogShown = dispatch(maybeShowPremiumFeatureDialog(MEET_FEATURES.RECORDING));
if (!dialogShown) {
this._handleClickOpenLanguageSelector();
}
}
/**
* Indicates whether this button is disabled or not.
*
* @override
* @protected
* @returns {boolean}
*/
override _isDisabled() {
const { _e2eeEnabled, _isCCTabEnabled, _requestingSubtitles } = this.props;
// Requested subtitles can still be turned off, and with the CC tab the button only opens the panel, whose
// own start button is disabled instead.
return Boolean(_e2eeEnabled) && !_requestingSubtitles && !_isCCTabEnabled;
}
/**
* Why the button is disabled.
*
* @override
* @protected
* @returns {string}
*/
override _getDisabledReason() {
return 'transcribing.unavailableWithE2EE';
}
/**
* Indicates whether this button is in toggled state or not.
*
* @override
* @protected
* @returns {boolean}
*/
override _isToggled() {
return this.props._requestingSubtitles;
}
}
/**
* Maps (parts of) the redux state to the associated props for the
* {@code AbstractClosedCaptionButton} component.
*
* @param {Object} state - The redux state.
* @param {Object} ownProps - The properties explicitly passed to the component
* instance.
* @private
* @returns {{
* _requestingSubtitles: boolean,
* _language: string,
* visible: boolean
* }}
*/
export function _abstractMapStateToProps(state: IReduxState, ownProps: IAbstractProps) {
const { _requestingSubtitles, _language } = state['features/subtitles'];
// if the participant is moderator, it can enable transcriptions and if
// transcriptions are already started for the meeting, guests can just show them
const { visible = canStartSubtitles(state) } = ownProps;
return {
_e2eeEnabled: isE2EEOnInMeeting(state),
_isCCTabEnabled: isCCTabEnabled(state),
_requestingSubtitles,
_language,
visible
};
}