Stats. Don't worry. We're not dragging out your high school math teacher. We're talking about fun statistics! OK. Well, important ones at least.
What is this great, omniscient call, you ask;
It returns a promise with an
RTCStatsReport object which provides an enormous amount of information about your streams (both incoming and outgoing).
Let’s say you want to calculate the number of packets lost in a session and alert the user that they may be experiencing a bad viewing experience because of network issues. You simply need to dive into the
RTCStatsReport and look at the
RTCInboundRTPStreamStats. There you will find a
packetsLost property which tracks (any guesses?) how much packet loss you are seeing over a period of time. If it becomes higher than let’s say 30%, you would alert your user. Convenient, right?
Since we integrated Red5 Pro with WebRTC, the same valuable stats are also accessible with our HTML5 Streaming SDK.
Once a WebRTC peer connection (either publisher or subscriber) has been properly established, you can access the underlying
RTCPeerConnection using the
getConnection() method on the publisher or subscriber instance. From there, you can use any of the APIs [call?]
RTCPeerConnection provides to gather data you need.
As an example, our testbed publisher examples show bitrate and packet count. We are able to show this by:
- Accessing the
RTCPeerConnectionafter the publisher has started a stream (link).
- Then accessing the data from
getStatson an interval (link).
So there you have it. All the stats you need, no math needed! So what shall you do with this powerful tool? Let us know, but no matter what, we will not be held responsible for it.