How to detect the bitrate of a live stream in Red5 or Red5 Pro

Sometimes you need to calculate the bitrate (in kbps) of a live stream to restrict the usage or manage to the bill of the user. As of today, there is no direct way to get the bitrate of a live stream in Red5 open source or Red5 Pro. Instead, you can use this old-school sampling technique to estimate the bitrate of a live stream which can be coded in any language for any platform.

The steps involved in evaluating the bitrate cab roughly be written as in the following manner :

  1. On application startup, start a timer which will be running continuously (every 2 seconds), aiding in evaluation of bitrates of all candidate streams taken fro a list.
  2. Detect publish start for a new stream
  3. On publish start add the stream to a list as a candidate for evaluation
  4. For each evaluation cycle inside the timer calculate the current estimated bitrate using bytes-transferred-inwards data
  5. Store the evaluated bitrate sample in a tmp data structure. In the similar way capture about 4 or 6 data samples.
  6. Take the average of all the data samples collected to get a average bitrate
  7. Finally use this average bitrate data to calculate bitrate per second.
  8. On unpublish remove the stream from list of candidates so that we dont get a NullPointerException

The code snippet below demonstrates how to calculate and log the average bitrate of a live stream in Red5.

(more…)

The Red5.getConnectionLocal method : Accessing the current connection in Red5 Pro

 

 

The diagram shown above is an abstract representation of how a connection flows through Red5 core. On connection attempt, Red5 verifies the basic protocol specific handshake as per the connection type (RTMP/RTSP/WebRTC).

Once the handshake is verified Red5 pro translates the connection to a registered Red5 pro connection and sets a reference to it using the static method – Red5.setConnectionLocal(IConnection) in the context of the current thread.

(more…)

Authenticating subscribers in a Red5 Pro Application

This article discusses the issue of stream security for subscribers over the various protocols supported by Red5pro (RTMP, RTSP and WebRTC) programmatically. IF you are new to the world of Red5/Red5Pro, I would suggest taking a peek at the Red5 development series on Github. Here you can find information ranging from what is Red5 to how to create and debug an application.

 
(more…)

Authenticating publishers in a Red5pro Application

Red5pro offers exciting new ways of engaging your users online with live streams and data online. You can publish live streams and even record them using flash player (desktop), android/ios (mobile) and WebRTC (HTML5 browser).

However, stream security for publishing still lingers as a challenge for the administration. This article discusses how you can secure your publishing streams for the various protocols supported by Red5pro (RTMP, RTSP and WebRTC) programmatically. IF you are new to the world of Red5/Red5Pro, I would suggest taking a peek at the Red5 development series on Github. Here you can find information ranging from what is Red5 to how to create and debug an application.

  (more…)

last comments
Andryan
Andryan

Once built, how do you get Red5 to use this jar?
admin
admin

JAR files are to be deployed in {RED5_HOME}/lib or {RED5_HOME}/webapps/{appname}/WEB-INF/lib