• January 31, 2010
  • Red5

Online Audio Recorder

A online audio recording and sharing utility application that demonstrates the power of Red5 with Adobe Flash client.

Click to launch application

Red5 to mysql without JDBC

In this tutorial we see how to connect to a mysql database, regardless of whether you have access to JDBC adapter on your Red5 running server. Definitely JDBC would be faster, but this method will get you across just fine in any Red5 project involving databases.

Since we wont be using Java way of connecting to mysql, i pick php as the delegate for that. so our communication will be like this:

JAVA -> PHP -> MYSQL

and

MYSQL -> PHP -> JAVA
(more…)

Handling application stop event in tomcat based red5 compilations

As you would know red5 is a media server package, which runs on top or other server cores  like Tomcat and Jetty.  There are few minor differences , hence in the way both compilations handle events and behaviors. The one we will be talking about here is specifically the “appStop” event. The “appStop” is suppose to fire off whenever the application stops/shuts down. The anomaly here is that on a tomcat based red5 compilations (which is the default one) the “appStop” does not fire up. This is because the is no straight forward  “hook” / “point of entry” to determine when the server core stops. Hence we need to create a “Shutdown Hook” to handle the server/application shutdown by ourself.

The best way to do this is to create a internal / private class in your Application class source.  Sample:

/* ShutDown Hook for Red5 Application */
class ShutdownHook extends Thread
{
Application app;

public ShutdownHook(Application app)
{
this.app = app;
}

public void run()
{
// do something here
}
}

Next we relate it to our Application class by the “addShutdownHook” method. This method is not something for red5 only. Its the most common way to intercept and handle your java application shutdown. So in the Application class appStart() method we can add:

public boolean appStart(IScope app)
{

Runtime.getRuntime().addShutdownHook(new ShutdownHook(this));

return true;
}

We add it to the appStart() method to make sure it is called only once.
Note how we pass the reference to the Application class itself to the constructor “ShutdownHook”. Now by defining the properties as “protected” or “public” you can access then when the application/server is shutting down and do any cleanup jobs that you may have.

JW FLV Player – Red5 streaming issue – (unable to replay)

As of the current version of JW FLV Media Player 4.6, there is a issue with streaming flv videos from red5 server (tested with 0.7). As there is no solution given on the forum i decided to explore it on my own. The problem happens when flash requests a stream from red5. At this stage red5 generates a meta file which is used to trigger meta event on flv players. However at this stage the flv itself is considered as broken. Hence any attempt to play back the video now will fail until the meta is removed and flv restores to normal by red core engine. It seems the most obvious manual way to do this manually was to hit the stop button and help red5 understand the stream request was released (more…)