Chapter 6. Building Red5

6.1. Build Environment Setup

6.1.1. Ant

Apache Ant 1.7 and above is required for building the Red5 project source code. download here http://archive.apache.org/dist/ant/binaries/

The path to the ant binary must be on your system PATH environment variable (test by typing ant -version at a system prompt) defined, typically


PATH=$PATH:/usr/local/ant 

You can check this on windows by typing set PATH or on unix by typing echo $PATH

6.1.2. Java

Java 1.5 or 1.6 and above is required for running ant, compiling the source and running the Red5 server.

Download Java 5 http://java.sun.com/j2se/1.5.0/download.html

Download Java 6 http://java.sun.com/j2se/1.6.0/download.html

You must have the environment variables for JAVA_HOME and JAVA_VERSION defined, typically


JAVA_HOME=C:\development\j2sdk\1.5.0_07 JAVA_VERSION=1.5 

You can check this on windows by typing

set JAVA_HOME			
		

or on unix by typing

$ echo $JAVA_HOME	
		

6.1.3. Red5

You must have the environment variables for RED5_HOME defined, typically


RED5_HOME=/www/red5_server

[Warning]Warning

FAILURE TO SETUP YOUR ENVIRONMENT VARIABLES WILL PREVENT YOUR FROM BEING ABLE TO BUILD PROPERLY

[Note]Note

You don't need netbeans or eclipse unless you need an IDE for java. Download Netbeans Download Eclipse

6.2. Building

6.2.1. Getting Red5 Source

The Red5 source code is available at the google code project page and svn repository.

  1. With your favourite SVN client check out the source code from svn at this address http://red5.googlecode.com/svn/java/server/trunk/ or https://red5.googlecode.com/svn/java/server/trunk/ if you have a google code login.

  2. Team members will be added to the google code project group and in your google code login you will find the svn password for committing changes at this address http://code.google.com/hosting/settings.

6.2.2. Getting Red5 Demo Applications Source

  1. With your favourite SVN client check out the source code from svn at this address http://red5.googlecode.com/svn/java/example/trunk/ or https://red5.googlecode.com/svn/java/example/trunk/ if you have a google code login.

6.2.3. Getting Red5 Flash Demo Source

  1. With your favourite SVN client check out the source code from svn at this address http://red5.googlecode.com/svn/flash/trunk/ or https://red5.googlecode.com/svn/flash/trunk/ if you have a google code login.

6.2.4. Running the ant build

To build the red5 source simply run the following command from the command line inside the red5 source directory.

$ ant dist 
		

6.2.5. Current Ant Targets

  • all - Runs clean, prepare, compile, jar, javadoc targets

  • bootstrap - Compile and start the server using the bootstrap class

  • checkout - checks out the Red5 server source (requires svnant.jar)

  • checkout-all - checks out the entire Red5 project sources from the root level to a specified directory

  • clean - cleans up all the files and directories

  • compile - Compiles Red5

  • compile_core - Build Red5 server sources and downloads java 6 dependancies

  • compile_core_compatibility - Build Red5 server sources and downloads java 5 dependancies

  • compile_demos - Copies over the root and installer webapp

  • compile_script - Compiles scripting sources

  • compile_tests - Compiles junit test classes

  • compile_war - Compiles Red5 into a war distribution

  • console - launches a non-SSL jconsole for managing Red5 in JMX.

  • console-ssl - launches a SSL jconsole for managing Red5 in JMX with SSL enabled.

  • doc-all - Generate docbook documentation for html-single, multi html and pdf.

  • doc-clean - Cleans the docbook files.

  • doc-html - Compile reference documentation to chunked html.

  • doc-htmlsingle - Compile reference documentation to single html.

  • doc-pdf - Compile reference documentation to pdf.

  • doc-prepare - Extra preparation for the documentation.

  • dist - Make Binary distribution.

  • dist-archive - Create archive file for distribution.

  • dist-cluster - Create Edge/Origin distribution.

  • dist-debian - Create Debian package.

  • dist-edge - Builds a Red5 edge distribution.

  • dist-origin - Builds a Red5 origin distribution.

  • dist-installer - Make Installer distribution.

  • dist-macosx - Create Mac OSX installer.

  • dist-windows - Create Windows installer.

  • dist-redhat - Create Redhat installer.

  • ivyclear - Clears out the Ivy cache.

  • jar-determine-classpath - Determine classpath for jar file.

  • jar - Make Archive.

  • javadoc - Generate JavaDoc.

  • java6.check - Checks for Java 6.

  • prepare - Prepares for building Red5.

  • server - Compile and start the server.

  • shutdown - Shuts down the running Red5 instance.

  • udp_server - Compile and start experimental UDP server.

  • run-tests - Run JUnit tests and generate HTML reports.

  • run-tests-systemtest - Runs some end-to-end system tests against a test server using a flash client.

  • run-tests-server - Run the selftest server.

  • svn-add - Add files to svn.

  • remotejar - Creates a jar that may be deployed with remote applications.

  • retrieve - Retrieves the libraries if needed.

  • rtmps_keystore - Creates the keystore file in the conf directory required by RTMPS.

  • truststore - Creates a duplicate keystore file and generates a truststore file for jconsole SSL connections.

  • upload-snapshot - Uploads a snapshot of Red5 to the repository.

  • war_demos - Build wars for demo apps.

  • webwar - Make Web Archive.

6.2.6. Ant and Ivy

When cleaning the dependancy libraries using and ant ivy with the following command

$ ant ivyclear

It is required to run the rebuild of Red5 in a particular way to make sure ivy retrieved the libraries correctly.

$ ant -Divy.conf.name="java6, eclipse" dist

6.3. How to build with eclipse

This guide assumes eclipse 3.1.0 and you have downloaded the entire red5 build from the subversion repository at https://red5.googlecode.com/svn/java/server/trunk

6.3.1. Recommended Eclipse Plugins

The following plugins are recommended or required for building red5 in eclipse.

6.3.2. Importing the Red5 Project

There are two ways to import the Red5 project. Either import an already downloaded working copy of the Red5 project or import the project directly from SVN.

Procedure 6.1. Import the checked out working copy.

  1. Start Eclipse.

  2. Begin to import project FileImport

  3. In the Import dialog box select the item Existing Projects into Workspace and hit next.

  4. Hit the browse button next to the Select root directory text box.

  5. Select the root folder where you downloaded the red5 repository,(e.g. c:\projects \osflash\red5 or /www/red5_server) and hit ok.

  6. Make sure red5 is selected in the projects area and hit Finish.

  7. Eclipse should automatically build the project, you can force a build from the menu ProjectBuild Project

Procedure 6.2. Import the project working copy from SVN. (Subclipse must be installed).

  1. Begin to import project FileImport

  2. In the Import dialog box select SVN and then select the item Checkout Projects from SVN and hit next.

  3. A list of available SVN urls will be available, if it is not available select Create a new repository location click Next and enter. http://red5.googlecode.com/svn/java/server/trunk or.\ https://red5.googlecode.com/svn/java/server/trunk if you have a google code login.

  4. Click Finish.

  5. Eclipse should automatically build the project, you can force a build from the menu ProjectBuild Project

6.3.3. Updating the Red5 source from Eclipse.

Procedure 6.3. Updating the Red5 source from trunk.

  1. In eclipse right click the Red5 source project.

  2. Locate to TeamUpdate

  3. The source will be updated from SVN.

  4. Right click the Red5 project and select Refresh.

  5. The project should also be cleaned after each update, by the following ProjectClean

6.3.4. 

Procedure 6.4. Debugging Red5 in Eclipse.

  1. Click the arrow next to the icon menu and then click Debug Configurations.

  2. Click Java Application in the menu then right click and New.

  3. Type a name for the debug configuration (ie Red) and type org.red5.server.Bootstrap as the main class.

  4. Select the Arguments tab.

  5. In the Program Arguments enter


    -Dlogback.ContextSelector=org.red5.logging.LoggingContextSelector -Dcatalina.useNaming=true  -Djava.security.debug=failure

  6. In the VM Arguments enter


    -cp ./conf

  7. In OSX with JDK 5 and JDK6 to specify JDK6 the PATH variable has to be set. Goto the Environment Tab, add a new variable called PATH, and place this in there.


    /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin

  8. Click Apply and Close.

  9. Goto the build configure path dialog Build PathConfigure Build Path

  10. In the Source tab choose Add Folder and select the src/conf directory.

  11. Make sure "Allow output folders for source folders" is selected.

  12. Under red5_server/src/conf, select Output Folder and choose Edit.

  13. Select Specific Output Folder, select the root directory and choose "create new folder" and choose "conf".

  14. Select conf, the output folder for the Red5 configs will now be placed into red5_server/conf.

  15. With the imported red5 project selected click the debug icon and it will launch the server.

  16. Console logging will appear in the console window.

If you get an error in the console like:

 
java.net.BindException: Address already in use: bind at sun.nio.ch.Net.bind(Native 
Method) at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown 
Source) at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source) at 
org.apache.mina.io.socket.SocketAcceptor.registerNew(SocketAcceptor.java:362) 
at org.apache.mina.io.socket.SocketAcceptor.access$800(SocketAcceptor.java:46) 
at org.apache.mina.io.socket.SocketAcceptor$Worker.run(SocketAcceptor.java:238) 
Exception in thread "main" 

Then the socket red5 wants to run is in use, you can change the socket port in the property rtmp.port in the property file red5.properties.

6.3.5. Ant, Ivy and Eclipse

When cleaning the dependancy libraries using ant and ivy with the following command

$ ant ivyclear

It is required to run the rebuild of Red5 in a particular way to make sure ivy retrieved the libraries correctly.

$ ant -Divy.conf.name="java6, eclipse" dist

Then back in eclipse right click the ivy.xml in the project and click Refresh it will also resolve the libraries in Eclipse.