2022-09-13 07:36:00 +00:00
|
|
|
import { Theme } from '@mui/material';
|
|
|
|
import { withStyles } from '@mui/styles';
|
2022-03-29 09:23:40 +00:00
|
|
|
import clsx from 'clsx';
|
2017-06-16 14:02:39 +00:00
|
|
|
import React, { Component } from 'react';
|
2022-08-26 09:54:03 +00:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
2017-06-16 14:02:39 +00:00
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
import ContextMenu from '../../base/components/context-menu/ContextMenu';
|
2022-08-26 09:54:03 +00:00
|
|
|
import { isMobileBrowser } from '../../base/environment/utils';
|
|
|
|
import { translate } from '../../base/i18n/functions';
|
|
|
|
|
|
|
|
type DownloadUpload = {
|
|
|
|
download: number;
|
|
|
|
upload: number;
|
2022-09-08 09:52:36 +00:00
|
|
|
};
|
2017-06-16 14:02:39 +00:00
|
|
|
|
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The type of the React {@code Component} props of
|
|
|
|
* {@link ConnectionStatsTable}.
|
2017-06-16 14:02:39 +00:00
|
|
|
*/
|
2022-08-26 09:54:03 +00:00
|
|
|
interface Props extends WithTranslation {
|
2018-10-30 05:02:23 +00:00
|
|
|
|
2020-10-02 13:20:24 +00:00
|
|
|
/**
|
|
|
|
* The audio SSRC of this client.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
audioSsrc: number;
|
2020-10-02 13:20:24 +00:00
|
|
|
|
2017-06-16 14:02:39 +00:00
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* Statistics related to bandwidth.
|
|
|
|
* {{
|
|
|
|
* download: Number,
|
|
|
|
* upload: Number
|
2021-11-04 21:10:43 +00:00
|
|
|
* }}.
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
bandwidth: DownloadUpload;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Statistics related to bitrate.
|
|
|
|
* {{
|
|
|
|
* download: Number,
|
|
|
|
* upload: Number
|
2021-11-04 21:10:43 +00:00
|
|
|
* }}.
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
bitrate: DownloadUpload;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of bridges (aka media servers) currently used in the
|
|
|
|
* conference.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
bridgeCount: number;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
/**
|
|
|
|
* An object containing the CSS classes.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
classes: any;
|
2021-12-15 13:18:41 +00:00
|
|
|
|
2020-08-13 21:56:14 +00:00
|
|
|
/**
|
|
|
|
* Audio/video codecs in use for the connection.
|
|
|
|
*/
|
2022-08-26 09:54:03 +00:00
|
|
|
codec: {
|
|
|
|
[key: string]: {
|
|
|
|
audio: string;
|
|
|
|
video: string;
|
2022-09-08 09:52:36 +00:00
|
|
|
};
|
|
|
|
};
|
2020-08-13 21:56:14 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* A message describing the connection quality.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
connectionSummary: string;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
2022-08-26 09:54:03 +00:00
|
|
|
/**
|
|
|
|
* Whether or not should display the "Show More" link.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
disableShowMoreStats: boolean;
|
2022-08-26 09:54:03 +00:00
|
|
|
|
2020-11-24 09:49:10 +00:00
|
|
|
/**
|
|
|
|
* Whether or not should display the "Save Logs" link.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
enableSaveLogs: boolean;
|
2020-11-24 09:49:10 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* Statistics related to frame rates for each ssrc.
|
|
|
|
* {{
|
|
|
|
* [ ssrc ]: Number
|
2021-11-04 21:10:43 +00:00
|
|
|
* }}.
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
framerate: Object;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the statistics are for local video.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
isLocalVideo: boolean;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
2022-04-04 18:57:58 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the statistics are for screen share.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
isVirtualScreenshareParticipant: boolean;
|
2022-04-04 18:57:58 +00:00
|
|
|
|
2020-07-13 15:20:59 +00:00
|
|
|
/**
|
|
|
|
* The send-side max enabled resolution (aka the highest layer that is not
|
|
|
|
* suspended on the send-side).
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
maxEnabledResolution: number;
|
2020-07-13 15:20:59 +00:00
|
|
|
|
2020-10-02 13:20:24 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when the user clicks on the download logs link.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
onSaveLogs: () => void;
|
2020-10-02 13:20:24 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when the show additional stats link is clicked.
|
2017-06-16 14:02:39 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
onShowMore: (e?: React.MouseEvent) => void;
|
2017-06-16 14:02:39 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* Statistics related to packet loss.
|
|
|
|
* {{
|
|
|
|
* download: Number,
|
|
|
|
* upload: Number
|
2021-11-04 21:10:43 +00:00
|
|
|
* }}.
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
packetLoss: DownloadUpload;
|
2022-08-26 09:54:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The endpoint id of this client.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
participantId: string;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The region that we think the client is in.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
region: string;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Statistics related to display resolutions for each ssrc.
|
|
|
|
* {{
|
|
|
|
* [ ssrc ]: {
|
|
|
|
* height: Number,
|
|
|
|
* width: Number
|
|
|
|
* }
|
2021-11-04 21:10:43 +00:00
|
|
|
* }}.
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
2022-08-26 09:54:03 +00:00
|
|
|
resolution: {
|
|
|
|
[ssrc: string]: {
|
|
|
|
height: number;
|
|
|
|
width: number;
|
2022-09-08 09:52:36 +00:00
|
|
|
};
|
|
|
|
};
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The region of the media server that we are connected to.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
serverRegion: string;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not additional stats about bandwidth and transport should be
|
|
|
|
* displayed. Will not display even if true for remote participants.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
shouldShowMore: boolean;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-26 09:54:03 +00:00
|
|
|
* Whether source name signaling is enabled.
|
2020-10-02 13:20:24 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
sourceNameSignalingEnabled: boolean;
|
2020-10-02 13:20:24 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* Statistics related to transports.
|
|
|
|
*/
|
2022-08-26 09:54:03 +00:00
|
|
|
transport: Array<{
|
|
|
|
ip: string;
|
|
|
|
localCandidateType: string;
|
|
|
|
localip: string;
|
|
|
|
p2p: boolean;
|
|
|
|
remoteCandidateType: string;
|
|
|
|
transportType: string;
|
|
|
|
type: string;
|
2022-09-08 09:52:36 +00:00
|
|
|
}>;
|
2022-05-09 13:42:45 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-26 09:54:03 +00:00
|
|
|
* The video SSRC of this client.
|
2022-05-09 13:42:45 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
videoSsrc: number;
|
2022-08-26 09:54:03 +00:00
|
|
|
}
|
2018-10-30 05:02:23 +00:00
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* Click handler.
|
|
|
|
*
|
|
|
|
* @param {SyntheticEvent} event - The click event.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-08-26 09:54:03 +00:00
|
|
|
function onClick(event: React.MouseEvent) {
|
2021-01-21 20:46:47 +00:00
|
|
|
// If the event is propagated to the thumbnail container the participant will be pinned. That's why the propagation
|
|
|
|
// needs to be stopped.
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
|
2022-09-13 07:36:00 +00:00
|
|
|
const styles = (theme: Theme) => {
|
2021-12-15 13:18:41 +00:00
|
|
|
return {
|
2022-03-29 09:23:40 +00:00
|
|
|
actions: {
|
|
|
|
margin: '10px auto',
|
2022-09-13 07:36:00 +00:00
|
|
|
textAlign: 'center' as const
|
2022-03-29 09:23:40 +00:00
|
|
|
},
|
|
|
|
connectionStatsTable: {
|
|
|
|
'&, & > table': {
|
|
|
|
fontSize: '12px',
|
|
|
|
fontWeight: '400',
|
|
|
|
|
|
|
|
'& td': {
|
|
|
|
padding: '2px 0'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'& > table': {
|
|
|
|
whiteSpace: 'nowrap'
|
|
|
|
},
|
|
|
|
|
|
|
|
'& td:nth-child(n-1)': {
|
|
|
|
paddingLeft: '5px'
|
|
|
|
},
|
|
|
|
|
|
|
|
'& $upload, & $download': {
|
|
|
|
marginRight: '2px'
|
|
|
|
}
|
|
|
|
},
|
2021-12-15 13:18:41 +00:00
|
|
|
contextMenu: {
|
2022-09-13 07:36:00 +00:00
|
|
|
position: 'relative' as const,
|
2021-12-15 13:18:41 +00:00
|
|
|
marginTop: 0,
|
|
|
|
right: 'auto',
|
2022-09-13 07:36:00 +00:00
|
|
|
padding: `${theme.spacing(2)} ${theme.spacing(1)}`,
|
|
|
|
marginLeft: theme.spacing(1),
|
|
|
|
marginRight: theme.spacing(1),
|
|
|
|
marginBottom: theme.spacing(1)
|
2022-03-29 09:23:40 +00:00
|
|
|
},
|
|
|
|
download: {},
|
|
|
|
mobile: {
|
2022-09-13 07:36:00 +00:00
|
|
|
margin: theme.spacing(3)
|
2022-03-29 09:23:40 +00:00
|
|
|
},
|
|
|
|
status: {
|
|
|
|
fontWeight: 'bold'
|
|
|
|
},
|
|
|
|
upload: {}
|
2021-12-15 13:18:41 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* React {@code Component} for displaying connection statistics.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments Component
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
|
|
|
class ConnectionStatsTable extends Component<Props> {
|
2017-06-16 14:02:39 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2022-04-04 18:57:58 +00:00
|
|
|
const {
|
|
|
|
classes,
|
|
|
|
disableShowMoreStats,
|
|
|
|
enableSaveLogs,
|
2022-04-29 14:32:16 +00:00
|
|
|
isVirtualScreenshareParticipant,
|
2022-04-04 18:57:58 +00:00
|
|
|
isLocalVideo
|
|
|
|
} = this.props;
|
2022-03-29 09:23:40 +00:00
|
|
|
const className = clsx(classes.connectionStatsTable, { [classes.mobile]: isMobileBrowser() });
|
2017-06-16 14:02:39 +00:00
|
|
|
|
2022-04-29 14:32:16 +00:00
|
|
|
if (isVirtualScreenshareParticipant) {
|
2022-04-04 18:57:58 +00:00
|
|
|
return this._renderScreenShareStatus();
|
|
|
|
}
|
|
|
|
|
2017-06-16 14:02:39 +00:00
|
|
|
return (
|
2021-12-15 13:18:41 +00:00
|
|
|
<ContextMenu
|
|
|
|
className = { classes.contextMenu }
|
|
|
|
hidden = { false }
|
|
|
|
inDrawer = { true }>
|
|
|
|
<div
|
|
|
|
className = { className }
|
|
|
|
onClick = { onClick }>
|
|
|
|
{ this._renderStatistics() }
|
2022-03-29 09:23:40 +00:00
|
|
|
<div className = { classes.actions }>
|
2021-12-15 13:18:41 +00:00
|
|
|
{ isLocalVideo && enableSaveLogs ? this._renderSaveLogs() : null}
|
|
|
|
{ !disableShowMoreStats && this._renderShowMoreLink() }
|
|
|
|
</div>
|
|
|
|
{ this.props.shouldShowMore ? this._renderAdditionalStats() : null }
|
2020-10-02 13:20:24 +00:00
|
|
|
</div>
|
2021-12-15 13:18:41 +00:00
|
|
|
</ContextMenu>
|
2017-06-16 14:02:39 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-04-04 18:57:58 +00:00
|
|
|
/**
|
|
|
|
* Creates a ReactElement that will display connection statistics for a screen share thumbnail.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderScreenShareStatus() {
|
|
|
|
const { classes } = this.props;
|
2022-05-12 22:47:38 +00:00
|
|
|
const className = clsx(classes.connectionStatsTable, { [classes.mobile]: isMobileBrowser() });
|
2022-04-04 18:57:58 +00:00
|
|
|
|
|
|
|
return (<ContextMenu
|
|
|
|
className = { classes.contextMenu }
|
|
|
|
hidden = { false }
|
|
|
|
inDrawer = { true }>
|
|
|
|
<div
|
|
|
|
className = { className }
|
|
|
|
onClick = { onClick }>
|
2022-05-12 22:47:38 +00:00
|
|
|
<tbody>
|
|
|
|
{ this._renderResolution() }
|
|
|
|
{ this._renderFrameRate() }
|
|
|
|
</tbody>
|
2022-04-04 18:57:58 +00:00
|
|
|
</div>
|
|
|
|
</ContextMenu>);
|
|
|
|
}
|
|
|
|
|
2017-06-16 14:02:39 +00:00
|
|
|
/**
|
|
|
|
* Creates a table as ReactElement that will display additional statistics
|
2018-09-17 18:21:03 +00:00
|
|
|
* related to bandwidth and transport for the local user.
|
2017-06-16 14:02:39 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderAdditionalStats() {
|
2020-10-02 13:20:24 +00:00
|
|
|
const { isLocalVideo } = this.props;
|
|
|
|
|
2017-06-16 14:02:39 +00:00
|
|
|
return (
|
2022-03-29 09:23:40 +00:00
|
|
|
<table>
|
2017-06-16 14:02:39 +00:00
|
|
|
<tbody>
|
2020-10-02 13:20:24 +00:00
|
|
|
{ isLocalVideo ? this._renderBandwidth() : null }
|
|
|
|
{ isLocalVideo ? this._renderTransport() : null }
|
|
|
|
{ isLocalVideo ? this._renderRegion() : null }
|
|
|
|
{ this._renderAudioSsrc() }
|
|
|
|
{ this._renderVideoSsrc() }
|
|
|
|
{ this._renderParticipantId() }
|
2017-06-16 14:02:39 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a table row as a ReactElement for displaying bandwidth related
|
|
|
|
* statistics.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderBandwidth() {
|
2022-03-29 09:23:40 +00:00
|
|
|
const { classes } = this.props;
|
2017-06-16 14:02:39 +00:00
|
|
|
const { download, upload } = this.props.bandwidth || {};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
{ this.props.t('connectionindicator.bandwidth') }
|
|
|
|
</td>
|
|
|
|
<td>
|
2022-03-29 09:23:40 +00:00
|
|
|
<span className = { classes.download }>
|
2017-06-16 14:02:39 +00:00
|
|
|
↓
|
|
|
|
</span>
|
|
|
|
{ download ? `${download} Kbps` : 'N/A' }
|
2022-03-29 09:23:40 +00:00
|
|
|
<span className = { classes.upload }>
|
2017-06-16 14:02:39 +00:00
|
|
|
↑
|
|
|
|
</span>
|
|
|
|
{ upload ? `${upload} Kbps` : 'N/A' }
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a a table row as a ReactElement for displaying bitrate related
|
|
|
|
* statistics.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderBitrate() {
|
2022-03-29 09:23:40 +00:00
|
|
|
const { classes } = this.props;
|
2017-06-16 14:02:39 +00:00
|
|
|
const { download, upload } = this.props.bitrate || {};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<span>
|
|
|
|
{ this.props.t('connectionindicator.bitrate') }
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
2022-03-29 09:23:40 +00:00
|
|
|
<span className = { classes.download }>
|
2017-06-16 14:02:39 +00:00
|
|
|
↓
|
|
|
|
</span>
|
|
|
|
{ download ? `${download} Kbps` : 'N/A' }
|
2022-03-29 09:23:40 +00:00
|
|
|
<span className = { classes.upload }>
|
2017-06-16 14:02:39 +00:00
|
|
|
↑
|
|
|
|
</span>
|
|
|
|
{ upload ? `${upload} Kbps` : 'N/A' }
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-10-02 13:20:24 +00:00
|
|
|
/**
|
|
|
|
* Creates a table row as a ReactElement for displaying the audio ssrc.
|
|
|
|
* This will typically be something like "Audio SSRC: 12345".
|
|
|
|
*
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_renderAudioSsrc() {
|
|
|
|
const { audioSsrc, t } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<span>{ t('connectionindicator.audio_ssrc') }</span>
|
|
|
|
</td>
|
|
|
|
<td>{ audioSsrc || 'N/A' }</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a table row as a ReactElement for displaying the video ssrc.
|
|
|
|
* This will typically be something like "Video SSRC: 12345".
|
|
|
|
*
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_renderVideoSsrc() {
|
|
|
|
const { videoSsrc, t } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<span>{ t('connectionindicator.video_ssrc') }</span>
|
|
|
|
</td>
|
|
|
|
<td>{ videoSsrc || 'N/A' }</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a table row as a ReactElement for displaying the endpoint id.
|
|
|
|
* This will typically be something like "Endpoint id: 1e8fbg".
|
|
|
|
*
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_renderParticipantId() {
|
|
|
|
const { participantId, t } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<span>{ t('connectionindicator.participant_id') }</span>
|
|
|
|
</td>
|
|
|
|
<td>{ participantId || 'N/A' }</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-13 21:56:14 +00:00
|
|
|
/**
|
|
|
|
* Creates a a table row as a ReactElement for displaying codec, if present.
|
2020-09-02 15:28:22 +00:00
|
|
|
* This will typically be something like "Codecs (A/V): Opus, vp8".
|
2020-08-13 21:56:14 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderCodecs() {
|
2022-05-09 13:42:45 +00:00
|
|
|
const { codec, t, sourceNameSignalingEnabled } = this.props;
|
2020-08-13 21:56:14 +00:00
|
|
|
|
|
|
|
if (!codec) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let codecString;
|
|
|
|
|
2022-05-09 13:42:45 +00:00
|
|
|
if (sourceNameSignalingEnabled) {
|
|
|
|
codecString = `${codec.audio}, ${codec.video}`;
|
|
|
|
} else {
|
|
|
|
// Only report one codec, in case there are multiple for a user.
|
|
|
|
Object.keys(codec || {})
|
|
|
|
.forEach(ssrc => {
|
|
|
|
const { audio, video } = codec[ssrc];
|
2020-08-13 21:56:14 +00:00
|
|
|
|
2022-05-09 13:42:45 +00:00
|
|
|
codecString = `${audio}, ${video}`;
|
|
|
|
});
|
|
|
|
}
|
2020-08-13 21:56:14 +00:00
|
|
|
|
|
|
|
if (!codecString) {
|
|
|
|
codecString = 'N/A';
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<span>{ t('connectionindicator.codecs') }</span>
|
|
|
|
</td>
|
|
|
|
<td>{ codecString }</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-26 16:55:09 +00:00
|
|
|
/**
|
|
|
|
* Creates a table row as a ReactElement for displaying a summary message
|
|
|
|
* about the current connection status.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderConnectionSummary() {
|
2022-03-29 09:23:40 +00:00
|
|
|
const { classes } = this.props;
|
|
|
|
|
2017-09-26 16:55:09 +00:00
|
|
|
return (
|
2022-03-29 09:23:40 +00:00
|
|
|
<tr className = { classes.status }>
|
2017-09-26 16:55:09 +00:00
|
|
|
<td>
|
|
|
|
<span>{ this.props.t('connectionindicator.status') }</span>
|
|
|
|
</td>
|
|
|
|
<td>{ this.props.connectionSummary }</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-09-17 18:21:03 +00:00
|
|
|
/**
|
|
|
|
* Creates a table row as a ReactElement for displaying the "connected to"
|
|
|
|
* information.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_renderRegion() {
|
|
|
|
const { region, serverRegion, t } = this.props;
|
|
|
|
let str = serverRegion;
|
|
|
|
|
|
|
|
if (!serverRegion) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (region && serverRegion && region !== serverRegion) {
|
|
|
|
str += ` from ${region}`;
|
2018-08-08 01:39:10 +00:00
|
|
|
}
|
2018-08-07 18:31:51 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
2018-09-17 18:21:03 +00:00
|
|
|
<span>{ t('connectionindicator.connectedTo') }</span>
|
2018-08-07 18:31:51 +00:00
|
|
|
</td>
|
|
|
|
<td>{ str }</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-09-17 18:21:03 +00:00
|
|
|
/**
|
|
|
|
* Creates a table row as a ReactElement for displaying the "bridge count"
|
|
|
|
* information.
|
|
|
|
*
|
|
|
|
* @returns {*}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_renderBridgeCount() {
|
|
|
|
const { bridgeCount, t } = this.props;
|
|
|
|
|
|
|
|
// 0 is valid, but undefined/null/NaN aren't.
|
|
|
|
if (!bridgeCount && bridgeCount !== 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<span>{ t('connectionindicator.bridgeCount') }</span>
|
|
|
|
</td>
|
|
|
|
<td>{ bridgeCount }</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-06-16 14:02:39 +00:00
|
|
|
/**
|
|
|
|
* Creates a table row as a ReactElement for displaying frame rate related
|
|
|
|
* statistics.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderFrameRate() {
|
2022-05-09 13:42:45 +00:00
|
|
|
const { framerate, t, sourceNameSignalingEnabled } = this.props;
|
|
|
|
|
|
|
|
let frameRateString;
|
|
|
|
|
|
|
|
if (sourceNameSignalingEnabled) {
|
|
|
|
frameRateString = framerate || 'N/A';
|
|
|
|
} else {
|
|
|
|
frameRateString = Object.keys(framerate || {})
|
2022-08-26 09:54:03 +00:00
|
|
|
.map(ssrc => framerate[ssrc as keyof typeof framerate])
|
2022-05-09 13:42:45 +00:00
|
|
|
.join(', ') || 'N/A';
|
|
|
|
}
|
2017-06-16 14:02:39 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<span>{ t('connectionindicator.framerate') }</span>
|
|
|
|
</td>
|
|
|
|
<td>{ frameRateString }</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a tables row as a ReactElement for displaying packet loss related
|
|
|
|
* statistics.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderPacketLoss() {
|
2022-03-29 09:23:40 +00:00
|
|
|
const { classes, packetLoss, t } = this.props;
|
2017-06-16 14:02:39 +00:00
|
|
|
let packetLossTableData;
|
|
|
|
|
|
|
|
if (packetLoss) {
|
|
|
|
const { download, upload } = packetLoss;
|
|
|
|
|
|
|
|
packetLossTableData = (
|
|
|
|
<td>
|
2022-03-29 09:23:40 +00:00
|
|
|
<span className = { classes.download }>
|
2017-06-16 14:02:39 +00:00
|
|
|
↓
|
|
|
|
</span>
|
|
|
|
{ download === null ? 'N/A' : `${download}%` }
|
2022-03-29 09:23:40 +00:00
|
|
|
<span className = { classes.upload }>
|
2017-06-16 14:02:39 +00:00
|
|
|
↑
|
|
|
|
</span>
|
|
|
|
{ upload === null ? 'N/A' : `${upload}%` }
|
|
|
|
</td>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
packetLossTableData = <td>N/A</td>;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<span>
|
|
|
|
{ t('connectionindicator.packetloss') }
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
{ packetLossTableData }
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a table row as a ReactElement for displaying resolution related
|
|
|
|
* statistics.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderResolution() {
|
2022-05-09 13:42:45 +00:00
|
|
|
const { resolution, maxEnabledResolution, t, sourceNameSignalingEnabled } = this.props;
|
|
|
|
let resolutionString;
|
|
|
|
|
|
|
|
if (sourceNameSignalingEnabled) {
|
|
|
|
resolutionString = resolution ? `${resolution.width}x${resolution.height}` : 'N/A';
|
|
|
|
} else {
|
|
|
|
resolutionString = Object.keys(resolution || {})
|
|
|
|
.map(ssrc => {
|
|
|
|
const { width, height } = resolution[ssrc];
|
|
|
|
|
|
|
|
return `${width}x${height}`;
|
|
|
|
})
|
|
|
|
.join(', ') || 'N/A';
|
|
|
|
}
|
2017-06-16 14:02:39 +00:00
|
|
|
|
2020-07-13 15:20:59 +00:00
|
|
|
if (maxEnabledResolution && maxEnabledResolution < 720) {
|
|
|
|
const maxEnabledResolutionTitle = t('connectionindicator.maxEnabledResolution');
|
|
|
|
|
|
|
|
resolutionString += ` (${maxEnabledResolutionTitle} ${maxEnabledResolution}p)`;
|
|
|
|
}
|
|
|
|
|
2017-06-16 14:02:39 +00:00
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<span>{ t('connectionindicator.resolution') }</span>
|
|
|
|
</td>
|
|
|
|
<td>{ resolutionString }</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-10-02 13:20:24 +00:00
|
|
|
/**
|
|
|
|
* Creates a ReactElement for display a link to save the logs.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderSaveLogs() {
|
|
|
|
return (
|
|
|
|
<span>
|
|
|
|
<a
|
|
|
|
className = 'savelogs link'
|
2021-06-10 12:48:44 +00:00
|
|
|
onClick = { this.props.onSaveLogs }
|
|
|
|
role = 'button'
|
|
|
|
tabIndex = { 0 }>
|
2020-10-02 13:20:24 +00:00
|
|
|
{ this.props.t('connectionindicator.savelogs') }
|
|
|
|
</a>
|
|
|
|
<span> | </span>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-16 14:02:39 +00:00
|
|
|
/**
|
|
|
|
* Creates a ReactElement for display a link to toggle showing additional
|
|
|
|
* statistics.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderShowMoreLink() {
|
|
|
|
const translationKey
|
|
|
|
= this.props.shouldShowMore
|
2017-10-02 23:08:07 +00:00
|
|
|
? 'connectionindicator.less'
|
|
|
|
: 'connectionindicator.more';
|
2017-06-16 14:02:39 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<a
|
2017-08-14 15:02:58 +00:00
|
|
|
className = 'showmore link'
|
2021-06-10 12:48:44 +00:00
|
|
|
onClick = { this.props.onShowMore }
|
|
|
|
role = 'button'
|
|
|
|
tabIndex = { 0 }>
|
2017-06-16 14:02:39 +00:00
|
|
|
{ this.props.t(translationKey) }
|
|
|
|
</a>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a table as a ReactElement for displaying connection statistics.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderStatistics() {
|
2018-08-07 18:31:51 +00:00
|
|
|
const isRemoteVideo = !this.props.isLocalVideo;
|
|
|
|
|
2017-06-16 14:02:39 +00:00
|
|
|
return (
|
2022-03-29 09:23:40 +00:00
|
|
|
<table>
|
2017-06-16 14:02:39 +00:00
|
|
|
<tbody>
|
2017-09-26 16:55:09 +00:00
|
|
|
{ this._renderConnectionSummary() }
|
2017-06-16 14:02:39 +00:00
|
|
|
{ this._renderBitrate() }
|
|
|
|
{ this._renderPacketLoss() }
|
2018-09-17 18:21:03 +00:00
|
|
|
{ isRemoteVideo ? this._renderRegion() : null }
|
2017-06-16 14:02:39 +00:00
|
|
|
{ this._renderResolution() }
|
|
|
|
{ this._renderFrameRate() }
|
2020-08-13 21:56:14 +00:00
|
|
|
{ this._renderCodecs() }
|
2018-09-17 18:21:03 +00:00
|
|
|
{ isRemoteVideo ? null : this._renderBridgeCount() }
|
2017-06-16 14:02:39 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates table rows as ReactElements for displaying transport related
|
|
|
|
* statistics.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement[]}
|
|
|
|
*/
|
|
|
|
_renderTransport() {
|
|
|
|
const { t, transport } = this.props;
|
|
|
|
|
|
|
|
if (!transport || transport.length === 0) {
|
|
|
|
const NA = (
|
|
|
|
<tr key = 'address'>
|
|
|
|
<td>
|
|
|
|
<span>{ t('connectionindicator.address') }</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
N/A
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
|
|
|
|
return [ NA ];
|
|
|
|
}
|
|
|
|
|
2022-08-26 09:54:03 +00:00
|
|
|
const data: {
|
2022-09-08 09:52:36 +00:00
|
|
|
localIP: string[];
|
|
|
|
localPort: string[];
|
|
|
|
remoteIP: string[];
|
|
|
|
remotePort: string[];
|
|
|
|
transportType: string[];
|
2022-08-26 09:54:03 +00:00
|
|
|
} = {
|
2017-06-16 14:02:39 +00:00
|
|
|
localIP: [],
|
|
|
|
localPort: [],
|
|
|
|
remoteIP: [],
|
|
|
|
remotePort: [],
|
|
|
|
transportType: []
|
|
|
|
};
|
|
|
|
|
|
|
|
for (let i = 0; i < transport.length; i++) {
|
|
|
|
const ip = getIP(transport[i].ip);
|
|
|
|
const localIP = getIP(transport[i].localip);
|
|
|
|
const localPort = getPort(transport[i].localip);
|
|
|
|
const port = getPort(transport[i].ip);
|
|
|
|
|
|
|
|
if (!data.remoteIP.includes(ip)) {
|
|
|
|
data.remoteIP.push(ip);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!data.localIP.includes(localIP)) {
|
|
|
|
data.localIP.push(localIP);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!data.localPort.includes(localPort)) {
|
|
|
|
data.localPort.push(localPort);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!data.remotePort.includes(port)) {
|
|
|
|
data.remotePort.push(port);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!data.transportType.includes(transport[i].type)) {
|
|
|
|
data.transportType.push(transport[i].type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// All of the transports should be either P2P or JVB
|
2017-07-12 11:19:07 +00:00
|
|
|
let isP2P = false, isTURN = false;
|
|
|
|
|
|
|
|
if (transport.length) {
|
|
|
|
isP2P = transport[0].p2p;
|
|
|
|
isTURN = transport[0].localCandidateType === 'relay'
|
|
|
|
|| transport[0].remoteCandidateType === 'relay';
|
|
|
|
}
|
|
|
|
|
2019-02-05 23:13:59 +00:00
|
|
|
const additionalData = [];
|
2017-07-12 11:19:07 +00:00
|
|
|
|
|
|
|
if (isP2P) {
|
2019-02-05 23:13:59 +00:00
|
|
|
additionalData.push(
|
2019-08-22 10:36:04 +00:00
|
|
|
<span> (p2p)</span>);
|
2019-02-05 23:13:59 +00:00
|
|
|
}
|
|
|
|
if (isTURN) {
|
2019-08-22 10:36:04 +00:00
|
|
|
additionalData.push(<span> (turn)</span>);
|
2017-07-12 11:19:07 +00:00
|
|
|
}
|
2017-06-16 14:02:39 +00:00
|
|
|
|
|
|
|
// First show remote statistics, then local, and then transport type.
|
|
|
|
const tableRowConfigurations = [
|
|
|
|
{
|
2017-07-12 11:19:07 +00:00
|
|
|
additionalData,
|
2017-06-16 14:02:39 +00:00
|
|
|
data: data.remoteIP,
|
|
|
|
key: 'remoteaddress',
|
|
|
|
label: t('connectionindicator.remoteaddress',
|
|
|
|
{ count: data.remoteIP.length })
|
|
|
|
},
|
|
|
|
{
|
|
|
|
data: data.remotePort,
|
|
|
|
key: 'remoteport',
|
|
|
|
label: t('connectionindicator.remoteport',
|
|
|
|
{ count: transport.length })
|
|
|
|
},
|
|
|
|
{
|
|
|
|
data: data.localIP,
|
|
|
|
key: 'localaddress',
|
|
|
|
label: t('connectionindicator.localaddress',
|
|
|
|
{ count: data.localIP.length })
|
|
|
|
},
|
|
|
|
{
|
|
|
|
data: data.localPort,
|
|
|
|
key: 'localport',
|
|
|
|
label: t('connectionindicator.localport',
|
|
|
|
{ count: transport.length })
|
|
|
|
},
|
|
|
|
{
|
|
|
|
data: data.transportType,
|
|
|
|
key: 'transport',
|
|
|
|
label: t('connectionindicator.transport',
|
|
|
|
{ count: data.transportType.length })
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
return tableRowConfigurations.map(this._renderTransportTableRow);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a table row as a ReactElement for displaying a transport related
|
|
|
|
* statistic.
|
|
|
|
*
|
|
|
|
* @param {Object} config - Describes the contents of the row.
|
|
|
|
* @param {ReactElement} config.additionalData - Extra data to display next
|
|
|
|
* to the passed in config.data.
|
|
|
|
* @param {Array} config.data - The transport statistics to display.
|
|
|
|
* @param {string} config.key - The ReactElement's key. Must be unique for
|
|
|
|
* iterating over multiple child rows.
|
|
|
|
* @param {string} config.label - The text to display describing the data.
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
2022-08-26 09:54:03 +00:00
|
|
|
_renderTransportTableRow(config: any) {
|
2017-06-16 14:02:39 +00:00
|
|
|
const { additionalData, data, key, label } = config;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr key = { key }>
|
|
|
|
<td>
|
|
|
|
<span>
|
|
|
|
{ label }
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{ getStringFromArray(data) }
|
|
|
|
{ additionalData || null }
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Utility for getting the IP from a transport statistics object's
|
|
|
|
* representation of an IP.
|
|
|
|
*
|
|
|
|
* @param {string} value - The transport's IP to parse.
|
|
|
|
* @private
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-08-26 09:54:03 +00:00
|
|
|
function getIP(value: string) {
|
2017-08-28 21:49:24 +00:00
|
|
|
if (!value) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2017-06-16 14:02:39 +00:00
|
|
|
return value.substring(0, value.lastIndexOf(':'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Utility for getting the port from a transport statistics object's
|
|
|
|
* representation of an IP.
|
|
|
|
*
|
|
|
|
* @param {string} value - The transport's IP to parse.
|
|
|
|
* @private
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-08-26 09:54:03 +00:00
|
|
|
function getPort(value: string) {
|
2017-08-28 21:49:24 +00:00
|
|
|
if (!value) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2017-06-16 14:02:39 +00:00
|
|
|
return value.substring(value.lastIndexOf(':') + 1, value.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Utility for concatenating values in an array into a comma separated string.
|
|
|
|
*
|
|
|
|
* @param {Array} array - Transport statistics to concatenate.
|
|
|
|
* @private
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-08-26 09:54:03 +00:00
|
|
|
function getStringFromArray(array: string[]) {
|
2017-06-16 14:02:39 +00:00
|
|
|
let res = '';
|
|
|
|
|
|
|
|
for (let i = 0; i < array.length; i++) {
|
|
|
|
res += (i === 0 ? '' : ', ') + array[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
export default translate(withStyles(styles)(ConnectionStatsTable));
|