From eeea5a907e9d1f88aa3d7fb8e4841d6c94144f1a Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Mon, 3 Aug 2020 22:26:34 +0200 Subject: [PATCH] webrtc stats --- .../views/frontend/templates/index.html | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/raspberry/roberto/views/frontend/templates/index.html b/raspberry/roberto/views/frontend/templates/index.html index 3bed61b..aeb2ba1 100644 --- a/raspberry/roberto/views/frontend/templates/index.html +++ b/raspberry/roberto/views/frontend/templates/index.html @@ -44,6 +44,7 @@ +
@@ -165,6 +166,25 @@ socket.on('data', (data) => { }); }; + +statsInterval = window.setInterval(getConnectionStats, 1000); + +function getConnectionStats() { + webrtcPeerConnection.getStats(null).then(stats => { + var statsOutput = ""; + + stats.forEach(report => { + if (report.type === "inbound-rtp" && report.kind === "video") { + Object.keys(report).forEach(statName => { + statsOutput += `${statName}: ${report[statName]}
\n`; + }); + } + }); + + document.querySelector(".stats-box").innerHTML = statsOutput; + }); +} +