@@ -85,9 +85,11 @@ const ConnectComponent: FC<ConnectComponentProps> = (
85
85
86
86
const bitrate = 8 * ( currentBytesReceived - prevBytesReceived ) * 1000 / dx ; // bits per seconds
87
87
88
- const packetLoss = report ?. packetsReceived ? report ?. packetsLost / report ?. packetsReceived * 100 : NaN ; // in %
88
+ const dxPacketsLost = ( report ?. packetsLost ?? 0 ) - ( lastReport ?. packetsLost ?? 0 ) ;
89
+ const dxPacketsReceived = ( report ?. packetsReceived ?? 0 ) - ( lastReport ?. packetsReceived ?? 0 ) ;
90
+ const packetLoss = dxPacketsReceived ? dxPacketsLost / dxPacketsReceived * 100 : NaN ; // in %
89
91
90
- const selectedCandidatePairId = result [ report . transportId ] ?. selectedCandidatePairId ;
92
+ const selectedCandidatePairId = result [ report ? .transportId || "" ] ?. selectedCandidatePairId ;
91
93
const roundTripTime = result [ selectedCandidatePairId ] ?. currentRoundTripTime ;
92
94
93
95
const dxJitterBufferEmittedCount = ( report ?. jitterBufferEmittedCount ?? 0 ) - ( lastReport ?. jitterBufferEmittedCount ?? 0 ) ;
@@ -96,7 +98,7 @@ const ConnectComponent: FC<ConnectComponentProps> = (
96
98
97
99
const codecId = report ?. codecId || "" ;
98
100
99
- if ( report . kind === "video" ) {
101
+ if ( report ? .kind === "video" ) {
100
102
const codec = result [ codecId ] ?. mimeType ?. split ( "/" ) ?. [ 1 ] ;
101
103
102
104
const videoStats = VideoStatsSchema . safeParse ( {
@@ -105,10 +107,10 @@ const ConnectComponent: FC<ConnectComponentProps> = (
105
107
codec,
106
108
bufferDelay,
107
109
roundTripTime,
108
- frameRate : report . framesPerSecond
110
+ frameRate : report ? .framesPerSecond ?? NaN
109
111
} ) ;
110
112
111
- if ( videoStats . success ) {
113
+ if ( videoStats . success && report ?. trackIdentifier ) {
112
114
statistics . setData ( report . trackIdentifier , { ...videoStats . data , type : "video" } ) ;
113
115
}
114
116
@@ -126,7 +128,7 @@ const ConnectComponent: FC<ConnectComponentProps> = (
126
128
dtx : false
127
129
} ) ;
128
130
129
- if ( audioStats . success ) {
131
+ if ( audioStats . success && report ?. trackIdentifier ) {
130
132
statistics . setData ( report . trackIdentifier , { ...audioStats . data , type : "audio" } ) ;
131
133
}
132
134
}
@@ -226,13 +228,14 @@ const RoomPage: FC<Props> = ({ roomId, wasCameraDisabled, wasMicrophoneDisabled
226
228
className = "m-1 w-full rounded bg-brand-grey-80 px-4 py-2 text-white hover:bg-brand-grey-100"
227
229
type = "submit"
228
230
>
229
- Show simulcast controls
231
+ { showSimulcastMenu ? "Hide simulcast controls" : " Show simulcast controls" }
230
232
</ button >
231
233
< button
232
234
onClick = { showStats }
233
235
className = "m-1 w-full rounded bg-brand-grey-80 px-4 py-2 text-white hover:bg-brand-grey-100"
234
236
type = "submit"
235
- > Show statistics
237
+ >
238
+ { statistics . status ? "Hide statistics" : "Show statistics" }
236
239
</ button >
237
240
</ div >
238
241
</ div >
0 commit comments