| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984 | /* global $, APP, config, interfaceConfig */
/* eslint-disable no-unused-vars */
import React from 'react';
import ReactDOM from 'react-dom';
import { I18nextProvider } from 'react-i18next';
import { AtlasKitThemeProvider } from '@atlaskit/theme';
import { Provider } from 'react-redux';
import { i18next } from '../../../react/features/base/i18n';
import { AudioLevelIndicator } from '../../../react/features/audio-level-indicator';
import { Avatar as AvatarDisplay } from '../../../react/features/base/avatar';
import {
    getParticipantCount,
    getPinnedParticipant,
    pinParticipant
} from '../../../react/features/base/participants';
import { ConnectionIndicator } from '../../../react/features/connection-indicator';
import { DisplayName } from '../../../react/features/display-name';
import {
    DominantSpeakerIndicator,
    RaisedHandIndicator,
    StatusIndicators
} from '../../../react/features/filmstrip';
import {
    LAYOUTS,
    getCurrentLayout,
    setTileView,
    shouldDisplayTileView
} from '../../../react/features/video-layout';
import {CornerObj,DevHook} from '../../../rdev/hooks/Hooks';
/* eslint-enable no-unused-vars */
const logger = require('jitsi-meet-logger').getLogger(__filename);
/**
 * Display mode constant used when video is being displayed on the small video.
 * @type {number}
 * @constant
 */
const DISPLAY_VIDEO = 0;
/**
 * Display mode constant used when the user's avatar is being displayed on
 * the small video.
 * @type {number}
 * @constant
 */
const DISPLAY_AVATAR = 1;
/**
 * Display mode constant used when neither video nor avatar is being displayed
 * on the small video. And we just show the display name.
 * @type {number}
 * @constant
 */
const DISPLAY_BLACKNESS_WITH_NAME = 2;
/**
 * Display mode constant used when video is displayed and display name
 * at the same time.
 * @type {number}
 * @constant
 */
const DISPLAY_VIDEO_WITH_NAME = 3;
/**
 * Display mode constant used when neither video nor avatar is being displayed
 * on the small video. And we just show the display name.
 * @type {number}
 * @constant
 */
const DISPLAY_AVATAR_WITH_NAME = 4;
/**
 *
 */
// export default class SmallVideo {
class SmallVideoOrig {
    /**
     * Constructor.
     */
    constructor(VideoLayout) {
        this.isAudioMuted = false;
        this.isVideoMuted = false;
        this.videoStream = null;
        this.audioStream = null;
        this.VideoLayout = VideoLayout;
        this.videoIsHovered = false;
        /**
         * The current state of the user's bridge connection. The value should be
         * a string as enumerated in the library's participantConnectionStatus
         * constants.
         *
         * @private
         * @type {string|null}
         */
        this._connectionStatus = null;
        /**
         * Whether or not the ConnectionIndicator's popover is hovered. Modifies
         * how the video overlays display based on hover state.
         *
         * @private
         * @type {boolean}
         */
        this._popoverIsHovered = false;
        /**
         * Whether or not the connection indicator should be displayed.
         *
         * @private
         * @type {boolean}
         */
        this._showConnectionIndicator = !interfaceConfig.CONNECTION_INDICATOR_DISABLED;
        /**
         * Whether or not the dominant speaker indicator should be displayed.
         *
         * @private
         * @type {boolean}
         */
        this._showDominantSpeaker = false;
        /**
         * Whether or not the raised hand indicator should be displayed.
         *
         * @private
         * @type {boolean}
         */
        this._showRaisedHand = false;
        // Bind event handlers so they are only bound once for every instance.
        this._onPopoverHover = this._onPopoverHover.bind(this);
        this.updateView = this.updateView.bind(this);
        this._onContainerClick = this._onContainerClick.bind(this);
    }
    /**
     * Returns the identifier of this small video.
     *
     * @returns the identifier of this small video
     */
    getId() {
        return this.id;
    }
    /**
     * Indicates if this small video is currently visible.
     *
     * @return <tt>true</tt> if this small video isn't currently visible and
     * <tt>false</tt> - otherwise.
     */
    isVisible() {
        return this.$container.is(':visible');
    }
    /**
     * Creates an audio or video element for a particular MediaStream.
     */
    static createStreamElement(stream) {
        const isVideo = stream.isVideoTrack();
        const element = isVideo ? document.createElement('video') : document.createElement('audio');
        if (isVideo) {
            element.setAttribute('muted', 'true');
            element.setAttribute('playsInline', 'true'); /* for Safari on iOS to work */
        } else if (config.startSilent) {
            element.muted = true;
        }
        element.autoplay = !config.testing?.noAutoPlayVideo;
        element.id = SmallVideo.getStreamElementID(stream);
        return element;
    }
    /**
     * Returns the element id for a particular MediaStream.
     */
    static getStreamElementID(stream) {
        return (stream.isVideoTrack() ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();
    }
    /**
     * Configures hoverIn/hoverOut handlers. Depends on connection indicator.
     */
    bindHoverHandler() {
        // Add hover handler
        this.$container.hover(
            () => {
                this.videoIsHovered = true;
                this.updateView();
                this.updateIndicators();
            },
            () => {
                this.videoIsHovered = false;
                this.updateView();
                this.updateIndicators();
            }
        );
    }
    /**
     * Unmounts the ConnectionIndicator component.
    * @returns {void}
    */
    removeConnectionIndicator() {
        this._showConnectionIndicator = false;
        this.updateIndicators();
    }
    /**
     * Updates the connectionStatus stat which displays in the ConnectionIndicator.
    * @returns {void}
    */
    updateConnectionStatus(connectionStatus) {
        this._connectionStatus = connectionStatus;
        this.updateIndicators();
    }
    /**
     * Shows / hides the audio muted indicator over small videos.
     *
     * @param {boolean} isMuted indicates if the muted element should be shown
     * or hidden
     */
    showAudioIndicator(isMuted) {
        this.isAudioMuted = isMuted;
        this.updateStatusBar();
    }
    /**
     * Shows video muted indicator over small videos and disables/enables avatar
     * if video muted.
     *
     * @param {boolean} isMuted indicates if we should set the view to muted view
     * or not
     */
    setVideoMutedView(isMuted) {
        this.isVideoMuted = isMuted;
        this.updateView();
        this.updateStatusBar();
    }
    /**
     * Create or updates the ReactElement for displaying status indicators about
     * audio mute, video mute, and moderator status.
     *
     * @returns {void}
     */
    updateStatusBar() {
        const statusBarContainer = this.container.querySelector('.videocontainer__toolbar');
        if (!statusBarContainer) {
            return;
        }
        ReactDOM.render(
            <Provider store = { APP.store }>
            <DevHook type="div" className="indicator_trc t2 jdiv"></DevHook>
                <I18nextProvider i18n = { i18next }>
                    <StatusIndicators
                        showAudioMutedIndicator = { this.isAudioMuted }
                        showVideoMutedIndicator = { this.isVideoMuted }
                        participantID = { this.id } />
                </I18nextProvider>
            <DevHook type="div" className="indicator_trc t3 jdiv"></DevHook>
            </Provider>,
            statusBarContainer);
    }
    /**
     * Adds the element indicating the audio level of the participant.
     *
     * @returns {void}
     */
    addAudioLevelIndicator() {
        let audioLevelContainer = this._getAudioLevelContainer();
        if (audioLevelContainer) {
            return;
        }
        audioLevelContainer = document.createElement('span');
        audioLevelContainer.className = 'audioindicator-container';
        this.container.appendChild(audioLevelContainer);
        this.updateAudioLevelIndicator();
    }
    /**
     * Removes the element indicating the audio level of the participant.
     *
     * @returns {void}
     */
    removeAudioLevelIndicator() {
        const audioLevelContainer = this._getAudioLevelContainer();
        if (audioLevelContainer) {
            ReactDOM.unmountComponentAtNode(audioLevelContainer);
        }
    }
    /**
     * Updates the audio level for this small video.
     *
     * @param lvl the new audio level to set
     * @returns {void}
     */
    updateAudioLevelIndicator(lvl = 0) {
        const audioLevelContainer = this._getAudioLevelContainer();
        if (audioLevelContainer) {
            ReactDOM.render(<AudioLevelIndicator audioLevel = { lvl }/>, audioLevelContainer);
        }
    }
    /**
     * Queries the component's DOM for the element that should be the parent to the
     * AudioLevelIndicator.
     *
     * @returns {HTMLElement} The DOM element that holds the AudioLevelIndicator.
     */
    _getAudioLevelContainer() {
        return this.container.querySelector('.audioindicator-container');
    }
    /**
     * This is an especially interesting function. A naive reader might think that
     * it returns this SmallVideo's "video" element. But it is much more exciting.
     * It first finds this video's parent element using jquery, then uses a utility
     * from lib-jitsi-meet to extract the video element from it (with two more
     * jquery calls), and finally uses jquery again to encapsulate the video element
     * in an array. This last step allows (some might prefer "forces") users of
     * this function to access the video element via the 0th element of the returned
     * array (after checking its length of course!).
     */
    selectVideoElement() {
        return $($(this.container).find('video')[0]);
    }
    /**
     * Selects the HTML image element which displays user's avatar.
     *
     * @return {jQuery|HTMLElement} a jQuery selector pointing to the HTML image
     * element which displays the user's avatar.
     */
    $avatar() {
        return this.$container.find('.avatar-container');
    }
    /**
     * Returns the display name element, which appears on the video thumbnail.
     *
     * @return {jQuery} a jQuery selector pointing to the display name element of
     * the video thumbnail
     */
    $displayName() {
        return this.$container.find('.displayNameContainer');
    }
    /**
     * Creates or updates the participant's display name that is shown over the
     * video preview.
     *
     * @param {Object} props - The React {@code Component} props to pass into the
     * {@code DisplayName} component.
     * @returns {void}
     */
    _renderDisplayName(props) {
        const displayNameContainer = this.container.querySelector('.displayNameContainer');
        if (displayNameContainer) {
            ReactDOM.render(
                <Provider store = { APP.store }>
                    <I18nextProvider i18n = { i18next }>
                        <DisplayName { ...props } />
                    </I18nextProvider>
                </Provider>,
                displayNameContainer);
        }
    }
    /**
     * Removes the component responsible for showing the participant's display name,
     * if its container is present.
     *
     * @returns {void}
     */
    removeDisplayName() {
        const displayNameContainer = this.container.querySelector('.displayNameContainer');
        if (displayNameContainer) {
            ReactDOM.unmountComponentAtNode(displayNameContainer);
        }
    }
    /**
     * Enables / disables the css responsible for focusing/pinning a video
     * thumbnail.
     *
     * @param isFocused indicates if the thumbnail should be focused/pinned or not
     */
    focus(isFocused) {
        const focusedCssClass = 'videoContainerFocused';
        const isFocusClassEnabled = this.$container.hasClass(focusedCssClass);
        if (!isFocused && isFocusClassEnabled) {
            this.$container.removeClass(focusedCssClass);
        } else if (isFocused && !isFocusClassEnabled) {
            this.$container.addClass(focusedCssClass);
        }
    }
    /**
     *
     */
    hasVideo() {
        return this.selectVideoElement().length !== 0;
    }
    /**
     * Checks whether the user associated with this <tt>SmallVideo</tt> is currently
     * being displayed on the "large video".
     *
     * @return {boolean} <tt>true</tt> if the user is displayed on the large video
     * or <tt>false</tt> otherwise.
     */
    isCurrentlyOnLargeVideo() {
        return APP.store.getState()['features/large-video']?.participantId === this.id;
    }
    /**
     * Checks whether there is a playable video stream available for the user
     * associated with this <tt>SmallVideo</tt>.
     *
     * @return {boolean} <tt>true</tt> if there is a playable video stream available
     * or <tt>false</tt> otherwise.
     */
    isVideoPlayable() {
        return this.videoStream && !this.isVideoMuted && !APP.conference.isAudioOnly();
    }
    /**
     * Determines what should be display on the thumbnail.
     *
     * @return {number} one of <tt>DISPLAY_VIDEO</tt>,<tt>DISPLAY_AVATAR</tt>
     * or <tt>DISPLAY_BLACKNESS_WITH_NAME</tt>.
     */
    selectDisplayMode(input) {
        // Display name is always and only displayed when user is on the stage
        if (input.isCurrentlyOnLargeVideo && !input.tileViewEnabled) {
            return input.isVideoPlayable && !input.isAudioOnly ? DISPLAY_BLACKNESS_WITH_NAME : DISPLAY_AVATAR_WITH_NAME;
        } else if (input.isVideoPlayable && input.hasVideo && !input.isAudioOnly) {
            // check hovering and change state to video with name
            return input.isHovered ? DISPLAY_VIDEO_WITH_NAME : DISPLAY_VIDEO;
        }
        // check hovering and change state to avatar with name
        return input.isHovered ? DISPLAY_AVATAR_WITH_NAME : DISPLAY_AVATAR;
    }
    /**
     * Computes information that determine the display mode.
     *
     * @returns {Object}
     */
    computeDisplayModeInput() {
        return {
            isCurrentlyOnLargeVideo: this.isCurrentlyOnLargeVideo(),
            isHovered: this._isHovered(),
            isAudioOnly: APP.conference.isAudioOnly(),
            tileViewEnabled: shouldDisplayTileView(APP.store.getState()),
            isVideoPlayable: this.isVideoPlayable(),
            hasVideo: Boolean(this.selectVideoElement().length),
            connectionStatus: APP.conference.getParticipantConnectionStatus(this.id),
            mutedWhileDisconnected: this.mutedWhileDisconnected,
            canPlayEventReceived: this._canPlayEventReceived,
            videoStream: Boolean(this.videoStream),
            isVideoMuted: this.isVideoMuted,
            videoStreamMuted: this.videoStream ? this.videoStream.isMuted() : 'no stream'
        };
    }
    /**
     * Checks whether current video is considered hovered. Currently it is hovered
     * if the mouse is over the video, or if the connection
     * indicator is shown(hovered).
     * @private
     */
    _isHovered() {
        return this.videoIsHovered || this._popoverIsHovered;
    }
    /**
     * Updates the css classes of the thumbnail based on the current state.
     */
    updateView() {
        this.$container.removeClass((index, classNames) =>
            classNames.split(' ').filter(name => name.startsWith('display-')));
        const oldDisplayMode = this.displayMode;
        let displayModeString = '';
        const displayModeInput = this.computeDisplayModeInput();
        // Determine whether video, avatar or blackness should be displayed
        this.displayMode = this.selectDisplayMode(displayModeInput);
        switch (this.displayMode) {
        case DISPLAY_AVATAR_WITH_NAME:
            displayModeString = 'avatar-with-name';
            this.$container.addClass('display-avatar-with-name');
            break;
        case DISPLAY_BLACKNESS_WITH_NAME:
            displayModeString = 'blackness-with-name';
            this.$container.addClass('display-name-on-black');
            break;
        case DISPLAY_VIDEO:
            displayModeString = 'video';
            this.$container.addClass('display-video');
            break;
        case DISPLAY_VIDEO_WITH_NAME:
            displayModeString = 'video-with-name';
            this.$container.addClass('display-name-on-video');
            break;
        case DISPLAY_AVATAR:
        default:
            displayModeString = 'avatar';
            this.$container.addClass('display-avatar-only');
            break;
        }
        if (this.displayMode !== oldDisplayMode) {
            logger.debug(`Displaying ${displayModeString} for ${this.id}, data: [${JSON.stringify(displayModeInput)}]`);
        }
    }
    /**
     * Updates the react component displaying the avatar with the passed in avatar
     * url.
     *
     * @returns {void}
     */
    initializeAvatar() {
        const thumbnail = this.$avatar().get(0);
        if (thumbnail) {
            // Maybe add a special case for local participant, as on init of
            // LocalVideo.js the id is set to "local" but will get updated later.
            ReactDOM.render(
                <Provider store = { APP.store }>
                    <AvatarDisplay
                        className = 'userAvatar'
                        participantId = { this.id } />
                </Provider>,
                thumbnail
            );
        }
    }
    /**
     * Unmounts any attached react components (particular the avatar image) from
     * the avatar container.
     *
     * @returns {void}
     */
    removeAvatar() {
        const thumbnail = this.$avatar().get(0);
        if (thumbnail) {
            ReactDOM.unmountComponentAtNode(thumbnail);
        }
    }
    /**
     * Shows or hides the dominant speaker indicator.
     * @param show whether to show or hide.
     */
    showDominantSpeakerIndicator(show) {
        // Don't create and show dominant speaker indicator if
        // DISABLE_DOMINANT_SPEAKER_INDICATOR is true
        if (interfaceConfig.DISABLE_DOMINANT_SPEAKER_INDICATOR) {
            return;
        }
        if (!this.container) {
            logger.warn(`Unable to set dominant speaker indicator - ${this.videoSpanId} does not exist`);
            return;
        }
        if (this._showDominantSpeaker === show) {
            return;
        }
        this._showDominantSpeaker = show;
        this.$container.toggleClass('active-speaker', this._showDominantSpeaker);
        this.updateIndicators();
        this.updateView();
    }
    /**
     * Shows or hides the raised hand indicator.
     * @param show whether to show or hide.
     */
    showRaisedHandIndicator(show) {
        if (!this.container) {
            logger.warn(`Unable to raised hand indication - ${
                this.videoSpanId} does not exist`);
            return;
        }
        this._showRaisedHand = show;
        this.updateIndicators();
    }
    /**
     * Initalizes any browser specific properties. Currently sets the overflow
     * property for Qt browsers on Windows to hidden, thus fixing the following
     * problem:
     * Some browsers don't have full support of the object-fit property for the
     * video element and when we set video object-fit to "cover" the video
     * actually overflows the boundaries of its container, so it's important
     * to indicate that the "overflow" should be hidden.
     *
     * Setting this property for all browsers will result in broken audio levels,
     * which makes this a temporary solution, before reworking audio levels.
     */
    initBrowserSpecificProperties() {
        const userAgent = window.navigator.userAgent;
        if (userAgent.indexOf('QtWebEngine') > -1
                && (userAgent.indexOf('Windows') > -1 || userAgent.indexOf('Linux') > -1)) {
            this.$container.css('overflow', 'hidden');
        }
    }
    /**
     * Cleans up components on {@code SmallVideo} and removes itself from the DOM.
     *
     * @returns {void}
     */
    remove() {
        logger.log('Remove thumbnail', this.id);
        this.removeAudioLevelIndicator();
        const toolbarContainer
            = this.container.querySelector('.videocontainer__toolbar');
        if (toolbarContainer) {
            ReactDOM.unmountComponentAtNode(toolbarContainer);
        }
        this.removeConnectionIndicator();
        this.removeDisplayName();
        this.removeAvatar();
        this._unmountIndicators();
        // Remove whole container
        if (this.container.parentNode) {
            this.container.parentNode.removeChild(this.container);
        }
    }
    /**
     * Helper function for re-rendering multiple react components of the small
     * video.
     *
     * @returns {void}
     */
    rerender() {
        this.updateIndicators();
        this.updateStatusBar();
        this.updateView();
    }
    /**
     * Updates the React element responsible for showing connection status, dominant
     * speaker, and raised hand icons. Uses instance variables to get the necessary
     * state to display. Will create the React element if not already created.
     *
     * @private
     * @returns {void}
     */
    updateIndicators() {
        const indicatorToolbar = this.container.querySelector('.videocontainer__toptoolbar');
        if (!indicatorToolbar) {
            return;
        }
        const { NORMAL = 8 } = interfaceConfig.INDICATOR_FONT_SIZES || {};
        const iconSize = NORMAL;
        const showConnectionIndicator = this.videoIsHovered || !interfaceConfig.CONNECTION_INDICATOR_AUTO_HIDE_ENABLED;
        const state = APP.store.getState();
        const currentLayout = getCurrentLayout(state);
        const participantCount = getParticipantCount(state);
        let statsPopoverPosition, tooltipPosition;
        if (currentLayout === LAYOUTS.TILE_VIEW) {
            statsPopoverPosition = 'right top';
            tooltipPosition = 'right';
        } else if (currentLayout === LAYOUTS.VERTICAL_FILMSTRIP_VIEW) {
            statsPopoverPosition = this.statsPopoverLocation;
            tooltipPosition = 'left';
        } else {
            statsPopoverPosition = this.statsPopoverLocation;
            tooltipPosition = 'top';
        }
            // dev mod
            statsPopoverPosition = 'right top';
        ReactDOM.render(
            <Provider store = { APP.store }>
            <DevHook type="div" className="indicator_hook vid_toptoolbar_hook jdiv t0"></DevHook>
                <I18nextProvider i18n = { i18next }>
                    <div>
                        <AtlasKitThemeProvider mode = 'dark'>
                            { this._showConnectionIndicator
                                ? <ConnectionIndicator
                                    alwaysVisible = { showConnectionIndicator }
                                    connectionStatus = { this._connectionStatus }
                                    iconSize = { iconSize }
                                    isLocalVideo = { this.isLocal }
                                    enableStatsDisplay = { !interfaceConfig.filmStripOnly }
                                    participantId = { this.id }
                                    statsPopoverPosition = { statsPopoverPosition } />
                                : null }
                            <RaisedHandIndicator
                                iconSize = { iconSize }
                                participantId = { this.id }
                                tooltipPosition = { tooltipPosition } />
                            { this._showDominantSpeaker && participantCount > 2
                                ? <DominantSpeakerIndicator
                                    iconSize = { iconSize }
                                    tooltipPosition = { tooltipPosition } />
                                : null }
                        </AtlasKitThemeProvider>
                    </div>
                </I18nextProvider>
            <DevHook type="div" className="indicator_hook vid_toptoolbar_hook_after jdiv t1"></DevHook>
            </Provider>,
            indicatorToolbar
        );
    }
    /**
     * Callback invoked when the thumbnail is clicked and potentially trigger
     * pinning of the participant.
     *
     * @param {MouseEvent} event - The click event to intercept.
     * @private
     * @returns {void}
     */
    _onContainerClick(event) {
        const triggerPin = this._shouldTriggerPin(event);
        if (event.stopPropagation && triggerPin) {
            event.stopPropagation();
            event.preventDefault();
        }
        if (triggerPin) {
            this.togglePin();
        }
        return false;
    }
    /**
     * Returns whether or not a click event is targeted at certain elements which
     * should not trigger a pin.
     *
     * @param {MouseEvent} event - The click event to intercept.
     * @private
     * @returns {boolean}
     */
    _shouldTriggerPin(event) {
        // TODO Checking the classes is a workround to allow events to bubble into
        // the DisplayName component if it was clicked. React's synthetic events
        // will fire after jQuery handlers execute, so stop propogation at this
        // point will prevent DisplayName from getting click events. This workaround
        // should be removeable once LocalVideo is a React Component because then
        // the components share the same eventing system.
        const $source = $(event.target || event.srcElement);
        return $source.parents('.displayNameContainer').length === 0
            && $source.parents('.popover').length === 0
            && !event.target.classList.contains('popover');
    }
    /**
     * Pins the participant displayed by this thumbnail or unpins if already pinned.
     *
     * @returns {void}
     */
    togglePin() {
        const pinnedParticipant = getPinnedParticipant(APP.store.getState()) || {};
        const participantIdToPin = pinnedParticipant && pinnedParticipant.id === this.id ? null : this.id;
        APP.store.dispatch(pinParticipant(participantIdToPin));
    }
    /**
     * Removes the React element responsible for showing connection status, dominant
     * speaker, and raised hand icons.
     *
     * @private
     * @returns {void}
     */
    _unmountIndicators() {
        const indicatorToolbar = this.container.querySelector('.videocontainer__toptoolbar');
        if (indicatorToolbar) {
            ReactDOM.unmountComponentAtNode(indicatorToolbar);
        }
    }
    /**
     * Updates the current state of the connection indicator popover being hovered.
     * If hovered, display the small video as if it is hovered.
     *
     * @param {boolean} popoverIsHovered - Whether or not the mouse cursor is
     * currently over the connection indicator popover.
     * @returns {void}
     */
    _onPopoverHover(popoverIsHovered) {
        this._popoverIsHovered = popoverIsHovered;
        this.updateView();
    }
    /**
     * Sets the size of the thumbnail.
     */
    _setThumbnailSize() {
        const layout = getCurrentLayout(APP.store.getState());
        const heightToWidthPercent = 100
                / (this.isLocal ? interfaceConfig.LOCAL_THUMBNAIL_RATIO : interfaceConfig.REMOTE_THUMBNAIL_RATIO);
        switch (layout) {
        case LAYOUTS.VERTICAL_FILMSTRIP_VIEW: {
            this.$container.css('padding-top', `${heightToWidthPercent}%`);
            this.$avatar().css({
                height: '50%',
                width: `${heightToWidthPercent / 2}%`
            });
            break;
        }
        case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW: {
            const state = APP.store.getState();
            const { local, remote } = state['features/filmstrip'].horizontalViewDimensions;
            const size = this.isLocal ? local : remote;
            if (typeof size !== 'undefined') {
                const { height, width } = size;
                const avatarSize = height / 2;
                this.$container.css({
                    height: `${height}px`,
                    'min-height': `${height}px`,
                    'min-width': `${width}px`,
                    width: `${width}px`
                });
                this.$avatar().css({
                    height: `${avatarSize}px`,
                    width: `${avatarSize}px`
                });
            }
            break;
        }
        case LAYOUTS.TILE_VIEW: {
            const state = APP.store.getState();
            const { thumbnailSize } = state['features/filmstrip'].tileViewDimensions;
            if (typeof thumbnailSize !== 'undefined') {
                const { height, width } = thumbnailSize;
                const avatarSize = height / 2;
                this.$container.css({
                    height: `${height}px`,
                    'min-height': `${height}px`,
                    'min-width': `${width}px`,
                    width: `${width}px`
                });
                this.$avatar().css({
                    height: `${avatarSize}px`,
                    width: `${avatarSize}px`
                });
            }
            break;
        }
        }
    }
}
function sv_dec(fn) {
  return function() {
    // dec_fns[fn.name] && dec_fns[fn.name].pre ? dec_fns[fn.name].pre({that:this, arguments}) : 1
    const ret = fn.apply(this, arguments);
    // clog("SVD",fn.name,{ret,that:this,args:[...arguments]})
    window.react_trc_log.SmallVideoOrig.push(fn.name)
    window.react_trc_log.SmallVideoOrigSet.add(fn.name)
    window.react_trc_log.SmallVideoOrigCnt[fn.name] ? 0  : window.react_trc_log.SmallVideoOrigCnt[fn.name] = 0
    window.react_trc_log.SmallVideoOrigCnt[fn.name] += 1
    window.react_trc_log.SmallVideoTrc.includes(fn.name) ? window.log_tb(new Error(),fn.name) : 1
    // console.log('FSD',fn.name,ret, [this,...arguments]);
    // const ret2 = dec_fns[fn.name] && dec_fns[fn.name].post ? dec_fns[fn.name].post({that:this, arguments}) : 0
    // if (ret2){
        // return ret2.ret
    // }
    // const result = fn.apply(this, arguments);
    // console.log('Finished');
    return ret;
  }
}
// _getAudioLevelContainer {ret: span.audioindicator-container, that: LocalVideo, args: Array(0)}
// SmallVideo.js:900 SVD updateAudioLevelIndicator
function dec_cls(){
    var k,v,p 
    const skip = ["_getAudioLevelContainer","updateAudioLevelIndicator"]
    window.react_trc_log.SmallVideoOrig = []
    window.react_trc_log.SmallVideoOrigSet = new Set()
    window.react_trc_log.SmallVideoOrigCnt = {}
    for ([k,p] of Object.entries(Object.getOwnPropertyDescriptors(SmallVideoOrig.prototype))) {
        if (skip.includes(k)){continue}
        // clog("~",k,v)
        v=p.value
        clog("~",k,typeof(v))
        if (typeof(v) == "function"){
        SmallVideoOrig.prototype[k] = sv_dec(v)
        }
    }
}
// dec_cls()
glob_dev_hooks.smallvids = []
export default class SmallVideo extends SmallVideoOrig {
    constructor(VideoLayout){
        super(...arguments);
        glob_dev_hooks.smallvids.push(this)
        clog("NEW SmallVideo...",arguments,this.$container)
    }
    _setThumbnailSize(){
        super._setThumbnailSize(...arguments);
        clog("ACsv",this)
        // if ()
        this.isLocal ? this.$container.addClass("iloc") : this.$container.addClass("rloc")
        this.isLocal ? this.$container.addClass("local_vid") : this.$container.addClass("remote_vid")
        this.$container.addClass("small_vid")
    }
    _onContainerClick(event) {
        console.log("ON container click",this,event,[...arguments])
        if (window.msto.conference.force_follow && !window.amimod()){
        console.log("ON container click force focus")
            return
        }
        // return
        const triggerPin = this._shouldTriggerPin(event);
        if (event.stopPropagation && triggerPin) {
            event.stopPropagation();
            event.preventDefault();
        }
        if (triggerPin) {
            this.togglePin();
        }
        return false;
    }
}
 |