@@ -38,12 +38,12 @@ class VideoDecoderIssueDetector extends BaseIssueDetector {
3838 ] ;
3939
4040 const throtthedStreams = data . video . inbound
41- . map ( ( incomeVideoStream ) => {
41+ . map ( ( incomeVideoStream ) : { ssrc : number , allDecodeTimePerFrame : number [ ] , volatility : number } | undefined => {
4242 const allDecodeTimePerFrame : number [ ] = [ ] ;
4343
4444 // We need at least 4 elements to have enough representation
4545 if ( allProcessedStats . length < 4 ) {
46- return ;
46+ return undefined ;
4747 }
4848
4949 // exclude first element to calculate accurate delta
@@ -72,7 +72,7 @@ class VideoDecoderIssueDetector extends BaseIssueDetector {
7272 if ( deltaTotalDecodeTime > 0 && deltaFramesDecoded > 0 ) {
7373 decodeTimePerFrame = deltaTotalDecodeTime * 1000 / deltaFramesDecoded ;
7474 }
75-
75+
7676 allDecodeTimePerFrame . push ( decodeTimePerFrame ) ;
7777 }
7878
@@ -83,9 +83,7 @@ class VideoDecoderIssueDetector extends BaseIssueDetector {
8383 const volatility = Math . sqrt ( variance ) ;
8484
8585 const isDecodeTimePerFrameIncrease = allDecodeTimePerFrame . every (
86- ( decodeTimePerFrame , index ) => {
87- return index === 0 || decodeTimePerFrame > allDecodeTimePerFrame [ index - 1 ] ;
88- } ,
86+ ( decodeTimePerFrame , index ) => index === 0 || decodeTimePerFrame > allDecodeTimePerFrame [ index - 1 ] ,
8987 ) ;
9088
9189 console . log ( {
@@ -96,23 +94,24 @@ class VideoDecoderIssueDetector extends BaseIssueDetector {
9694 } ) ;
9795
9896 if ( volatility > this . #volatilityThreshold && isDecodeTimePerFrameIncrease ) {
99- return { ssrc : incomeVideoStream . ssrc , allDecodeTimePerFrame, volatility, } ;
100- } else {
101- return undefined ;
97+ console . log ( 'CPU THROTTLE SUSPECTED FOR STREAM' , incomeVideoStream . ssrc ) ;
98+ return { ssrc : incomeVideoStream . ssrc , allDecodeTimePerFrame, volatility } ;
10299 }
100+
101+ return undefined ;
103102 } )
104103 . filter ( ( throttledVideoStream ) => Boolean ( throttledVideoStream ) ) ;
105104
106-
107105 const affectedStreamsPercent = throtthedStreams . length / ( data . video . inbound . length / 100 ) ;
108106 if ( affectedStreamsPercent > this . #affectedStreamsPercentThreshold) {
107+ console . log ( 'CPU THROTTLE DETECTED' ) ;
109108 issues . push ( {
110109 type : IssueType . CPU ,
111110 reason : IssueReason . DecoderCPUThrottling ,
112111 statsSample : {
113112 affectedStreamsPercent,
114- throtthedStreams : throtthedStreams ,
115- }
113+ throtthedStreams,
114+ } ,
116115 } ) ;
117116 }
118117
0 commit comments