First experiments with the installed Red5 server

First experiments with the installed Red5 server. The oflaDemo streams from data files inside the exploded war. In this experiment i want to stream from outside the Red5 installation. Take a deep breath and dive into the code of the Red5 server:

Some small changes in DefaultStreamFilenameGenerator and the class is configurable via Spring: First i refactored the hardwired local variable "streams/" into a field to make to make the prefix configurable and added an appropriate setter.

private String prefix = "streams/";
...
public void setPrefix(String prefix) {
    this.prefix = prefix;
}

Next was to refactor the hardwired absolute path flag:

public boolean resolvesToAbsolutePath() {
    return false;
}

To make it configurable, too.

private boolean absolutePath = false;
...
public boolean resolvesToAbsolutePath() {
    return absolutePath;
}
public void setAbsolutePath(boolean absolutePath) {
    this.absolutePath = absolutePath;
}

The resulting bean definition in our example is added to red5-default.xml and looks is as follows (beware! name/id matters with Red5 bean resolving strategy):

    <bean id="streamFilenameGenerator" class="org.red5.server.stream.DefaultStreamFilenameGenerator">
      <property name="prefix" value="${sfg.prefix}" />
      <property name="absolutePath" value="${sfg.absolutePath}" />
    </bean>

With the configuration inside red5.properties.

# streamFilenameGenerator configuration
sfg.prefix=/tmp/upload/
sfg.absolutePath=true

Test the pimped version of Red5 with some small changes in the oflaDemo. As with the Red5 DefaultStreamFilenameGenerator the oflaDemo, DemoService is given a configurable field:

private String fileDirectory = "streams/";
...
public void setFileDirectory(String fileDirectory) {
    this.fileDirectory = fileDirectory;
}

The resulting configurable bean definition inside WEB-INF/red5-web.xml:

<bean id="demoService.service" class="org.red5.demos.oflaDemo.DemoService">
    <property name="fileDirectory" value="${fileDirectory}" />
</bean>

is configured via WEB-INF/red5-web.properties

#fileDirectory=streams/
fileDirectory=file:/tmp/upload/

Drop the oflaDemo.war into the embedded Tomcat deploy directory.

cp oflaDemo.war ~red5/red5/webapps

Red5 will "explode" the web archive and start the application. Point your browser to see the oflaDemo in action.