Multipurpose streamer application for Red5 1.0

As Red5 1.0 release gets closer & RTMP reaches now to Android, Macs, PCs and much more, this is the best thing you may be looking for on the web. A Red51.0 RC1 custom streamer application (version 1) with Custom Directory Setter for recording and playback of files. Even though the application also implements stream security, it has not been tested properly yet.  The basic functionality of streaming and custom location is tested and is working properly.

To set custom location for recording/playback , please read the post here: http://flashvisions.com/java/ready-to-use-red5-streamer-application/

Download: Custom Streamer application for Red5 1.0 (RC1)

[rtmp application name:streamer]

Enjoy Live Streaming / Recording on Red5 1.0 (RC1)

 

last comments
speedlnx
speedlnx

Hello, can you post some instruction to have this app work?
derDoc
derDoc

Hi, first of all thanks for making a streaming app for red5 1.0.. since the old ones…

Passing configuration parameters into Red5 application

Often your Red5 project may need some external variable to be passed into Red5 application as a part of your configuration data, such that its not hard coded into the red5 application and you can change it as and when needed. For example : A database name, a configuration file path etc etc

 

Here we will demonstrate two ways to pass configuration data into Red5 application.

 

  1. Though red5-web.xml directly
  2. Through red5.properties routed via red5.xml

 

Passing parameters through red5-web.xml

This is the first method used to pass configuration data into your red5 application. In this example we will pass variable into the main application class.

 

package org.red5.core;

import org.red5.server.Scope;
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.service.ServiceUtils;

public class Application extends ApplicationAdapter {

public String database = "mydb.sqlite";

/** {@inheritDoc} */
@Override
public boolean appStart(IScope scope) {
return true;
}

@Override
public boolean connect(IConnection conn, IScope scope, Object[] params) {
return true;
}

@Override
public void disconnect(IConnection conn, IScope scope) {
super.disconnect(conn, scope);
}

public void setDatabase(String dbname)
{
database = dbname;
}

}

Note the last function: setDatabase this is the public setter function which will set the value of the variable database. Now the second part of this process is sending value to this function from outside Red5. For that we will be usingt the Red5 bean configuration file – red5-web.xml

So now we will edit the red5-web.xml file at the application’s bean handler definition and add the the variable property to it.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!--
Defines a properties file for dereferencing variables
-->
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="/WEB-INF/red5-web.properties" />
</bean>

<!--
Defines the web context
-->
<bean id="web.context" class="org.red5.server.Context"
    autowire="byType" />

<!--
Defines the web scopes
-->
<bean id="web.scope" class="org.red5.server.WebScope"
     init-method="register">
    <property name="server" ref="red5.server" />
    <property name="parent" ref="global.scope" />
    <property name="context" ref="web.context" />
    <property name="handler" ref="web.handler" />
    <property name="contextPath" value="${webapp.contextPath}" />
    <property name="virtualHosts" value="${webapp.virtualHosts}" />
</bean>

<!--
Defines the web handler which acts as an applications endpoint
-->
<bean id="web.handler" class="org.red5.core.Application" singleton="true">
    <property name="database" value="mydb.sqlite"/>
</bean>

</beans>

Note the application bean definition to see how the database property is passed into the application bean handler to the public setter function

<bean id="web.handler" class="org.red5.core.Application" singleton="true">
    <property name="database" value="mydb.sqlite"/>
</bean>

At this stage it is important to note of the setter function is named:
public function setDatabase, like in the following format

setVariablename. The variable name is camel-cased along with the word”set”

Ready to use – Red5 streamer with stream security


As RTMP continues to grow, and Red5 triumphs as the only open source RTMP server alive, there are concerns to protect your application from misuse. The following red5 application implements stream security for both playback and publishing.

You can edit the files – allowedHTMLdomains.txt and allowedSWFdomains.txt and add the domain names that you want to be able to playback/publish using your application. Each domain name must be added in a  new line.

The application also lets you allow/disallow publishing entirely. To do so edit the file red5-web.xml and set enable publish as true/false according to your needs:

<bean class="org.red5.core.security.PublishSecurity" init-method="init" id="publishSecurity">
<property name="application" ref="web.handler" />
<property name="htmlDomains" value="/WEB-INF/allowedHTMLdomains.txt" />
<property name="swfDomains" value="/WEB-INF/allowedSWFdomains.txt" />
<property name="publishNames" value="/WEB-INF/allowedPublishNames.txt" />
<property name="enablePublish" value="true" />
</bean>

You can also set stream publish security by defining specif stream names that are allowed for recording/broadcasting in the file allowedPublishNames.txt

Note : putting a * in any of the three security files will disable security for the particular context. Eg: Putting a * in allowedPublishNames.txt means that stream check is disabled.

This application is created for a quick and easy deployment, with guidance from red5.org.

Download:

Customstreamer_domaincontrol_source_0.8

Customstreamer_domaincontrol_deployable_0.8 [rtmp application name: domaincontrol]

Or generate your own with Red5 – Online Application Generator

Red5 Remoting

Remoting a facility by which a client can call a server method in a  request response fashion. Unlike RTMP remoting services are performed using AMF over HTTP/HTTPS. Red5 can act as both a RTMP server as well as a HTTP/HTTPS remoting server. Remoting enables non rtmp clients to access Red5 methods.  A very practical approach would be to request chat room user count for example. Using remoting you can request such data without consuming too much server resources as in a RTMP connection. You can also create chat programs with simple amf-polling as well. Remoting also lets you sync data types over both ends (client-server) (more…)