fix(connection-indicator) use SSRCs to match tiles to stats

This commit is contained in:
Saúl Ibarra Corretgé
2022-10-31 22:17:05 +01:00
committed by Saúl Ibarra Corretgé
parent 73160de3b7
commit 9b1e662a93
4 changed files with 75 additions and 62 deletions

View File

@@ -2,10 +2,9 @@
import { Component } from 'react';
import { getVirtualScreenshareParticipantOwnerId } from '../../base/participants/functions';
import statsEmitter from '../statsEmitter';
declare var interfaceConfig: Object;
const defaultAutoHideTimeout = 5000;
/**
@@ -26,6 +25,11 @@ export type Props = {
*/
_autoHideTimeout: number,
/**
* Whether or not the statistics are for screen share.
*/
_isVirtualScreenshareParticipant: boolean,
/**
* The ID of the participant associated with the displayed connection indication and
* stats.
@@ -90,7 +94,7 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
* returns {void}
*/
componentDidMount() {
statsEmitter.subscribeToClientStats(this.props.participantId, this._onStatsUpdated);
statsEmitter.subscribeToClientStats(this._getRealParticipantId(this.props), this._onStatsUpdated);
}
/**
@@ -100,11 +104,12 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
* returns {void}
*/
componentDidUpdate(prevProps: Props) {
if (prevProps.participantId !== this.props.participantId) {
statsEmitter.unsubscribeToClientStats(
prevProps.participantId, this._onStatsUpdated);
statsEmitter.subscribeToClientStats(
this.props.participantId, this._onStatsUpdated);
const prevParticipantId = this._getRealParticipantId(prevProps);
const participantId = this._getRealParticipantId(this.props);
if (prevParticipantId !== participantId) {
statsEmitter.unsubscribeToClientStats(prevParticipantId, this._onStatsUpdated);
statsEmitter.subscribeToClientStats(participantId, this._onStatsUpdated);
}
}
@@ -116,11 +121,25 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
* @returns {void}
*/
componentWillUnmount() {
statsEmitter.unsubscribeToClientStats(this.props.participantId, this._onStatsUpdated);
statsEmitter.unsubscribeToClientStats(this._getRealParticipantId(this.props), this._onStatsUpdated);
clearTimeout(this.autoHideTimeout);
}
/**
* Gets the "real" participant ID. FOr a virtual screenshare participant, that is its "owner".
*
* @param {Props} props - The props where to extract the data from.
* @returns {string | undefined } The resolved participant ID.
*/
_getRealParticipantId(props: Props) {
if (props._isVirtualScreenshareParticipant) {
return getVirtualScreenshareParticipantOwnerId(props.participantId);
}
return props.participantId;
}
_onStatsUpdated: (Object) => void;
/**