Friday, October 23, 2009

Red5 Live Audio Streaming Delay Solution

Hi.

I finally came across a solution for the Red5 live audio streaming delay problem... turns out, it is simply caused by specifying a buffer on the audio stream of the listening client... which makes sense!

The flash movie connected to the live audio stream will hold back on playing the audio until it has x seconds buffered... it can never get closer to real time than the length of audio buffered.

mediaStreamLive = new NetStream(this.red5Connection);
mediaStreamLive.setBufferTime(0);

So, between having a fast hosting server, and minimal buffer time, we are now achieving near real-time audio transmission rates.

Tuesday, October 20, 2009

Red5 0.7.0 Logging Success!!

Well, for the first time today, I got the Red5 logback logger to work.

The revelation hit me when I realized after reading:
http://www.avchat.net/blog/missing-red5-log-files-where-are-they/

That the log directory is expected in a different location depending on whether you use the red5.bat, or the Windows Service to launch the red5 server.

The demo applications which write to a log have logback.xml in the folder:
[appNameHere]/WEB-INF/classes/logback.xml

i) With the red5.bat launching method, all of the demo webapps merrily log to their logs using the XML reference to the log directory of:
<File>log/aaecWebinar.log</File>

ii) With the Windows service launching method, the demo apps all stop logging... unless you change the XML reference to the log directory of:
<File>../log/aaecWebinar.log</File>



logback.xml Red5 Notes:


i) Change all the "myAppenderNameHere" references to be the same string (your choice)
ii) Change "com.company.webAppName" to the package name of your red5 java application.


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="myAppenderNameHere" class="ch.qos.logback.core.FileAppender">
<File>../log/aaecWebinar.log</File>
<Append>false</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<ImmediateFlush>true</ImmediateFlush>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%date [%thread] %-5level %logger{35} - %msg%n
</Pattern>
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="myAppenderNameHere" />
</root>
<logger name="com.company.webAppName">
<level value="DEBUG" />
</logger>
</configuration>



Java code:



i) The following 2 imports are required:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

ii) And in my constructor, I configure the Logger:

public class Application extends ApplicationAdapter {
protected static Logger log = LoggerFactory.getLogger(Application.class);
[..... other code follows .... ]

iii) And then I call the logger methods.

public boolean appConnect( IConnection conn , Object[] params ){
log.info("appConnect id: " + conn.getClient().getId() );
}


Hopefully this clears things up. Let me know how things go!