From 61046994ab927b251bcd0fb2c18ed8f45ebff9ed Mon Sep 17 00:00:00 2001 From: Vittorio Palmisano Date: Thu, 9 May 2024 16:18:26 +0200 Subject: [PATCH] fix metrics when using null decoder --- scripts/peer-connection-stats.js | 4 +++- src/rtcstats.ts | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/peer-connection-stats.js b/scripts/peer-connection-stats.js index 048950a..1b722fe 100644 --- a/scripts/peer-connection-stats.js +++ b/scripts/peer-connection-stats.js @@ -372,6 +372,7 @@ async function getPeerConnectionStats( concealmentEvents, insertedSamplesForDeceleration, removedSamplesForAcceleration, + keyFramesDecoded, } = s Object.assign(values.inboundRtp, { kind, @@ -402,6 +403,7 @@ async function getPeerConnectionStats( concealmentEvents, insertedSamplesForDeceleration, removedSamplesForAcceleration, + keyFramesDecoded, }) } else if (s.type === 'remote-candidate') { values.remoteAddress = s.address @@ -431,7 +433,7 @@ async function getPeerConnectionStats( // Update video framesPerSecond. if ( values.inboundRtp.kind === 'video' && - values.inboundRtp.decoderImplementation !== 'NullVideoDecoder' + values.inboundRtp.keyFramesDecoded > 0 ) { const frames = positiveDiff( values.inboundRtp.framesReceived, diff --git a/src/rtcstats.ts b/src/rtcstats.ts index 6b04c64..e3401f6 100644 --- a/src/rtcstats.ts +++ b/src/rtcstats.ts @@ -448,10 +448,7 @@ export function updateRtcStats( ) }) } - if ( - inboundRtp.kind === 'video' && - inboundRtp.decoderImplementation !== 'unknown' - ) { + if (inboundRtp.kind === 'video' && inboundRtp.keyFramesDecoded > 0) { //setStats(stats, prefix + 'FramesDecoded', key, inboundRtp.framesDecoded setStats( stats,