Categories: Uncategorized

Non-Drowsy Statistics


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.

Many people don’t realize that there’s a whole lot of data about the status of WebRTC streams readily available and (this is the fun part) all it takes is a single JavaScript call.

What is this great, omniscient call, you ask; RTCRtpReceiver.getStats().

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:

  1. Accessing the RTCPeerConnection after the publisher has started a stream (link).
  2. Then accessing the data from getStats on 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.

Happy coding!

Red5 Team

Share
Published by
Red5 Team

Recent Posts

Red5 on OCI vs AWS IVS: Why Oracle Cloud Infrastructure is an Excellent Choice for Live Streaming

As organizations evaluate live streaming solutions, Amazon Interactive Video Service (IVS) has emerged as a…

5 days ago

What’s New in Red5 Cloud v1.9.2? Valuable UI/UX Improvements and Bug Fixes

Let’s go over the latest updates introduced in Red5 Cloud since our previous blog covering…

6 days ago

Real-Time Streaming Solutions for 2025: Red5 vs. Phenix vs. Dolby Optiview

When businesses need ultra-low latency streaming capabilities, the choice of platform can significantly influence the…

2 weeks ago

AWS IVS vs Red5: Choosing the Right Live Streaming Solution for Your Business

1Understanding AWS IVS: Strengths and Limitations2Red5: A More Flexible Alternative3When to Choose Red5 Over AWS…

4 weeks ago

What’s New in Red5 Pro v14.2.1 and Red5 Cloud v1.9.1?

Let’s take a look at the latest Red5 Pro and Red5 Cloud releases introduced since…

1 month ago

AV1 vs VP9 vs. VP8: Complete Codec Evolution and Comparison for Live Streaming

1Quick Comparison Overview2The Complete Evolution: VP8 → VP9 → AV13Technical Comparison: VP8 vs VP9 vs…

1 month ago