Browse Source

webrtc stats

main
Hendrik Langer 4 years ago
parent
commit
eeea5a907e
  1. 20
      raspberry/roberto/views/frontend/templates/index.html

20
raspberry/roberto/views/frontend/templates/index.html

@ -44,6 +44,7 @@
<input type="text" name="message_data" id="message_data" placeholder="Message"> <input type="text" name="message_data" id="message_data" placeholder="Message">
<input type="submit" value="Send"> <input type="submit" value="Send">
</form> </form>
<div class="stats-box"></div>
<!--<h2 id="start">Press a button on your controller to start</h2>--> <!--<h2 id="start">Press a button on your controller to start</h2>-->
@ -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 += `<strong>${statName}:</strong> ${report[statName]}<br>\n`;
});
}
});
document.querySelector(".stats-box").innerHTML = statsOutput;
});
}
</script> </script>
<script src="{{ url_for('frontend.virtualjoystick_js') }}"></script> <script src="{{ url_for('frontend.virtualjoystick_js') }}"></script>

Loading…
Cancel
Save