diff options
author | Maxim Devaev <[email protected]> | 2022-11-07 15:29:21 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-11-07 15:29:21 +0300 |
commit | bb3600cfa872bdd9697c6e0f38cd75ad779441c8 (patch) | |
tree | 4eb03399093fea7d583298ad67839eb47088a1ce /web/share/js/kvm/stream.js | |
parent | 7a83ce0f79257fa52b3615b6d3c704dc000dc986 (diff) |
h264 fps counter
Diffstat (limited to 'web/share/js/kvm/stream.js')
-rw-r--r-- | web/share/js/kvm/stream.js | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/web/share/js/kvm/stream.js b/web/share/js/kvm/stream.js index 1c92948f..7402b096 100644 --- a/web/share/js/kvm/stream.js +++ b/web/share/js/kvm/stream.js @@ -44,6 +44,7 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) { var __info_interval = null; var __state = null; + var __frames = 0; self.getName = () => "H.264"; self.getMode = () => "janus"; @@ -268,8 +269,28 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) { var __updateInfo = function() { if (__handle !== null) { let online = !!(__state && __state.source && __state.source.online); - let bitrate = (__handle !== null ? __handle.getBitrate() : ""); - __setInfo(true, online, bitrate); + let info = ""; + if (__handle !== null) { + // https://wiki.whatwg.org/wiki/Video_Metrics + let frames = null; + let el = $("stream-video"); + if (el.webkitDecodedFrameCount !== undefined) { + frames = el.webkitDecodedFrameCount; + } else if (el.mozPaintedFrames !== undefined) { + frames = el.mozPaintedFrames; + } + if (frames !== null) { + info = `${frames - __frames} fps dynamic`; + __frames = frames; + } + + if (info.length > 0) { + info += " / "; + } + + info += `${__handle.getBitrate()}`.replace("kbits/sec", "kbps"); + } + __setInfo(true, online, info); } }; |