You are on page 1of 30

Saturday, May 24, 2008 09:24 GMT

Technology Makes Life Easier

Technology makes life easier


http://sunil-gupta.blogspot.com/

Flash Player 10 Out With New Audio And Video Features

In a prerelease of Adobe Flash Player 10 code name "Astro", the noticable features are audio and video
features which will be available with proposed future release of Adobe Flash Media Server.

Dynamic Streaming

As streaming is dependent on newtwork condition, Dynamic Streaming will provide best quality video and will
be auto adjustable based on bandwidth availability. Video streams over RTMP from proposed future releases
of Flash Media Server can dynamically change bitrate as network conditions change.

RTMFP (Real Time Media Flow Protocol)

According to Adobe- RTMFP provides a UDP-based secure network transport alternative to RTMP-over-TCP.
To take advantage of the feature you will need to establish a net connection via future releases of Flash
Media Server or other Adobe server products. UDP (User Datagram Protocol) is an efficient and standardized
Internet protocol for delivering media assets because of its support for lossy delivery, improving performance
of real time communication. RTMFP is always encrypted which helps protect media delivery. This technology
is a result of Adobe's acquisition of Amicima, Inc. in 2006.

UDP Streaming. What would be the reaction of Red5 team?

Speex Audio Codec

The new, higher fidelity Speex voice codec that delivers the lowest-latency audio experience.

The complete feature list is here.

Reference:-
Adobe Flash® Player 10 beta

http://sunil-gupta.blogspot.com/2008/05/flash-player-10-out-with-new-audio-and.html

360 Degree Interactive Video And Future Of Flash Player And FMS

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 1 of 30


Today, I read two interesting blog posts "360 Degree Interactive Video" and "Multibitrate Support Coming to
Flash Player and FMS (?)" written by Stefan Richter from Flashcomguru.com talking about 360 degree
interactive video served by flash and possible upcoming features in flash player and FMS.
360 degree videos from Immersive Media are looking very impressive. Just drag your mouse on any direction
you want to view within the video once it starts playing.

More videos are here at - http://demos.immersivemedia.com/onlinecities/

Here is the video where kevin Towers shows how Flash Media Interactive Server, Flash Media Streaming
Server and Flash Media Rights Managment Server are leading the way in the protection and streaming of
digital video today.

Reference:-
360 Degree Interactive Video
Multibitrate Support Coming to Flash Player and FMS (?)
Adobe at NAB 2008- Flash Media Server

http://sunil-gupta.blogspot.com/2008/05/360-degree-interactive-video-and-future.html

Open Dialect -An Open Source Flash IDE Now Supports Linux

Few days back, I wrote about an interesting application called Open Dialect, a free open source flash IDE
written in C# using .Net 2.0 framework.

In my previous post, I mentioned that OpenDialect team is porting this application on Linux too. Today they
have announced the release of Open Dialect 0.2.0 (Linux/Windows Flash IDE).

Open Dialect 0.2.0 supports .SWF creation and testing on Linux and Windows, with partial support for OS X
10.5.

You can check Open Dialect in action here at- http://www.t21northamerica.com/T21NorthAmerica.html

To know more about this release or Open Dialect, follow the links in reference.

Reference:-
Open Dialect, Open source alternate of flash IDE
About Open Dialect
Open Dialect on Osflash
Screenshots

http://sunil-gupta.blogspot.com/2008/04/open-dialect-open-source-flash-ide-now.html

Open Dialect - Open source Flash IDE

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 2 of 30


Open Dialect is an open source Flash IDE based on Flex. It's written in C# using .Net 2.0 framework. They
call it Dynamic Inter-Active Learning Environment Creation Tool. The software is meant for creating
interactive learning Environments.

To know in detail about the this open source flash IDE, Follow the Open Dialect wiki here.

Below is the screenshot of open Dialect IDE.

More screenshots are available here.

Open Dialect 0.1.1 is available for Windows but they are porting it on Linux and OSX using MONO and
GTK+.

The available demo for showing the capabilities of Open Dialect is here.

References:-

Open Dialect
Open Dialect HomePage
Open Dialect Main Website

http://sunil-gupta.blogspot.com/2008/03/open-dialect-open-source-flash-ide.html

RTMP - Protocol Flavours

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 3 of 30


With the development of Adobe flash media server and Red5 flash server new protocols are also coming in
picture.
Here are some protocols for streaming of Audio/Video using Flash media server and Red5.

RTMP Real Time Messaging Protocol

RTMP is a TCP based propriety protocol developed by Adobe System for the purpose of streaming
Audio/Video data between Flash Player and media server.

RTMPT Real Time Messaging Protocol with Tunnel

RTMPT is a variation of RTMP which works behind the firewall as well. It works on Port 80 and encapsulate
the RTMP data in HTTP request.

RTMPS Real Time Messaging Protocol Secure

RTMPS is again a variation of RTMP which works over secure HTTPS connection.

RTMPE Real Time Messaging Protocol with Encryption

RTMPE is a new 128 bit encrypted protocol developed by Adobe systems for securing the stream data
between flash client and server. It's lightweight than SSL.
It's a DRM solution from Adobe for flash.

RTMPTE Real Time Messaging Protocol with Encryption and Tunnel

RTMPTE is a RTMPE tunneling over HTTP on port 80.

MRTMP Multiplex Real Time Messaging protocol

Multiplex RTMP is a protocol between edge and origin, developed by Red5 for clustering of stream data
using Terracotta.

Related Post
H.264 On RTMP

http://sunil-gupta.blogspot.com/2008/03/rtmp-protocol-flavours.html

Adobe Flash Media Rights Management Server

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 4 of 30


Adobe has relased Adobe Flash Media Rights Managment server. It's a platform to protect the media
contents delivered to Adobe Media Player and Adobe AIR? applications.
It's a DRM( Digital Rights Managment ) solution for Flash Video.

Some of the features of Adobe Flash Media Rights Managment server are listed below-

Cross-platform content delivery


Protect media content delivered to Adobe® Media Player and Adobe AIR? applications.

Content protection with Adobe Media Player


ensure the integrity of your content when you deliver it to Adobe Media Player users.

Offline access auditing


Track usage of your content when viewed through Adobe Media Player, even when consumers are offline.

For detail list of features, visit Adobe website here.


To know in detail about this new server follow the article of Tim Siglin here.

References:-

Adobe Flash Media Rights Management Server


Adobe Offers DRM for Flash Video with Flash Media Rights Management Server
Flash Media Rights Management Server Announced (and Released)

http://sunil-gupta.blogspot.com/2008/03/adobe-flash-media-rights-management.html

Red5 0.7.0 complete Changelog and Bugfixes

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 5 of 30


Red5 Changelog
----------------------------------------------------------

Red5 v0.7.0 final 02.23.2008

New Features:

- Initial Edge/Origin clustering support for multiple Edges with a single


Origin (Jira APPSERVER-66)
- Added stream listeners that can get notified about received packets
- Support for server-side Javascript (Jira APPSERVER-169)
- Added new base class org.red5.server.adapter.MultiThreadedApplicationAdapter
that allows multiple clients to connect simultaneously to the same
application
- Added new Flash Player 9 statuses NetStream.Play.FileStructureInvalid and
NetStream.Play.NoSupportedTrackFound
- New Flex admin tool (Jira APPSERVER-242)

Bugfixes:

- Pause near end of buffered streams works as expected (Jira APPSERVER-199)


- Fixed potential memory leak with RTMPT connections that are not properly
closed (Jira APPSERVER-193)
- "onMetaData" is only written to newly recorded FLV files and contains
valid properties now
- Don't try to decode objects for closed RTMPT connections
(Jira APPSERVER-208)
- New multi-threaded connection code fixes various timeout issues
(Jira APPSERVER-122, Jira APPSERVER-166 and Jira APPSERVER-167)
- Always use correct classloader inside applications (Jira APPSERVER-200)
- Tomcat cannot undeploy red5 application (Jira APPSERVER-204)
- "ByteArray" objects used old data after calling "compress" or "uncompress"
(Jira APPSERVER-211)
- "@DontSerialize" checks for properties also in inherited classes
(Jira APPSERVER-225)
- Enabled bidirectional class serialization (Jira APPSERVER-219)
- Array typed parameters in remoting service methods converted properly
(Jira APPSERVER-161)

References:-

http://jira.red5.org/secure/Dashboard.jspa
http://osflash.org/red5/070final

http://sunil-gupta.blogspot.com/2008/03/red5-070-complete-changelog-and.html

Terracotta - Network Attached Memory

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 6 of 30


Another great software from open source.

Few days back I wrote here about Red5 load balancing using Terracotta .
In this post I will write little bit about Terracotta technology.

Terracotta is an open source JVM clustering software for Java.It means the applications running on multiple
JVMs are capable to interact with each other as they are running on a same JVM.

They call it-


Network Attached Memory: Purpose Built To Store "Scratch Data".

Terracotta is useful in following scenarios:-

1:- HTTP Session Clustering


2:- Distributed Caching
3:- POJO Clustering/Spring integration
4:- Hibernate Caching
5:- Inter-JVM Coordination
6:- Collaboration, Coordination and Events
7:- Distributed workload distribution
8:- Virtual heap for large dataset

To know more about Terracotta follow the link here or watch very impressive demo here.

References:-

1:- Terracotta official website


2:- Terracotta Wiki
3:- Introduction to Terracotta with Example
4:- Terracotta Tech- Cluster your JVM- The Video
5:- Using Terracotta To Cluster a Single JVM Master/Worker Application

http://sunil-gupta.blogspot.com/2008/03/terracotta-network-attached-memory.html

H.264 on RTMP

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 7 of 30


Today morning i got a news here on red5 mailing list about the implementation of H.264 on RTMP by a
Japanese guy.
The blog is in Japanese. Below are the links for detail information on this.

Feed Demo Page (English compatible click once to enable audio)


http://vixy.tv/izumi-h264/

Programmer's blog (written in Japanese)


http://d.hatena.ne.jp/takuma104/20080317/1205783390

Demo Video on Server Start


http://vixy.tv/images/izumi_h264_demo.mp4

Now its time for Red5 team to comeup with H.264 solution.

Hope to hear it soon :)

http://sunil-gupta.blogspot.com/2008/03/h264-on-rtmp.html

Red5 offline Tutorials-Download pdfs here

Below is the offline version of many great Red5 tutorials so that you do not need to be online more to read
them again.

1:- Create new Java Red5 application


2:- Setting up Eclipse for Red5 development
3:- Create sample Red5 application
4:- Shared whiteboard application in red5
5:- Secure your red5 application using stunnel
6:- Red5-How to create New application
7:- How to stream from custom directories
8:- Getting started with Red5
9:- MySql and Red5
10:- Red5 and Flex on windows
11:- Streaming and database connection- Red5
12:- Streaming from custom directories
13:- Tomcat guide of creating new Red5 application
14:- Red5+openlaszlo+Red5
15:- Red5 Project Roadmap
16:- Red5 Documentation
17:- Deploying Red5 to Tomcat

http://sunil-gupta.blogspot.com/2008/03/red5-offline-resources-download-pdfs.html

MRTMP- Red5 load balancing

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 8 of 30


Red5 flash media server released their version 0.7.0 final on 02.23.2008.
The one of the major enhancement was the support of Initial Edge/Origin clustering for multiple Edges with a
single Origin.
Everyone who was interested to use Red5 on a large scale was looking for this solution.
I can find many questions in Red5 mailing list and other forums on this topic.
For this red5 has developed a new protocol called MRTMP( Multiplexing RTMP)-protocol between edge and
origin.
They are using Terracotta for acheiving this solution.
The detail architecture document can be found here and the implementation with Red5 and terracotta can be
found here.
The POC of Red5 and terracotta is here.
After releasing this feature, Red5 team can target huge production environments and Chris Allen has already
indicated about this on a post at flashcomguru.

Looking forward for many new great features and enhancements in near future from Red5 team.

http://sunil-gupta.blogspot.com/2008/03/mrtmp-red5-load-balancing.html

Red5 ready for H.264

What is H.264 and why everyone now is talking about this only.
Last year the online media giant YouTube also started showing H.264 contents.Flash media server 3 is
supporting H.264 content both live and on demand.
When we talk about FMS, one name also comes in mind and it's Red5, for those who can not go for FMS
because of its price.
Red5, for the people who live the open source way.
When Red5 released the v0.7.0, I was discussing in my blog post about the possibility of supporting H.264 in
near future by Red5 and few days back i read an article on Flashcomguru about Wowza media server
supporting H.264.
The link is here.
I was sure that Red5 team is also working on it. Red5 team always keep doing great things right on time.
So here is a statement from Chris Allen about Red5 supporting H.264 content in response to my comment on
wowza supporting H.264 at flashcomguru.

Correct, Red5, or more specifically, our team member Paul Gregoire is working on the h.264 support.
This should be done pretty soon. We are releasing Red5 0.7 today or tomorrow, and the h.264 stuff
will follow soon thereafter in 0.7.1 .

So cheers for Red5, Everyone is waiting for Red5 v0.7.1. Great efforts from Red5 team.

http://sunil-gupta.blogspot.com/2008/03/red5-ready-for-h264.html

Red5 v0.7.0 final release

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 9 of 30


The Red5 team yesterday acheived one more milestone and they have now comeup with Red5 version 0.7.0
final.Here is the official announcement from Red5 website.
Following are the major changes and known issues.

Major changes since 0.6.3:

1. Initial Edge/Origin clustering support for multiple Edges with a single Origin
New Flex admin tool.
2. Added a multi-threaded ApplicationAdapter that allows multiple clients to
connect simultaneously to the same application.
3. Added stream listeners that can get notified about received packets.
4. Fixed a critical memory leak bug in networking due to MINA ExecutorFilter.
5. Added new Flash Player 9 statuses NetStream.Play.FileStructureInvalid and
NetStream.Play.NoSupportedTrackFound.

The detail of changes will be available with the installation of Red5.

Known issues:

The admin application may not work as expected.

I am very eager to use this new version of Red5. It's another great acheivement from Red5 Team. Let?s hope
Red5 community will come up with more critical improvements such as H.264 support soon

References:-

Red5 v0.7.0 final release


Red5 official webpage
Create new application with Red5 and Flash

http://sunil-gupta.blogspot.com/2008/02/red5-v070-final-release.html

Microsoft buying Yahoo

From so many days, I am listening about this MicroHoo word. Everybody is talking about this MicroHoo and
many rumors started flowing in the air. Big surprise when i checked my favourite java forum . There also
everyone is talking about who buying whom.
I am also thinking of buying Microsoft :) Let see they accept my offer or not. By the way it's saturday night
and i am going to sleep after thinking of this deal.

http://sunil-gupta.blogspot.com/2008/02/microsoft-buying-yahoo.html

AsUnit-- Open-source Unit Testing for Action Script 2.0 and 3.0

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 10 of 30


Very recently i got a chance to work with AsUnit. We were looking for a testing framework for flash and after
googling, we found this tool called AsUnit. It's an open source unit test framework for flash. Because of no
documentation it was very hard to make it working for my first testing application. Most of the links given in
this page point to does not exist pages on the web. After some more googling on this gave me some idea of
how this works. Please find the reference of these websites from where i got some help to move forward with
AsUnit at the end of this post.In this post i will explain a very simple application using AsUnit.
AsUnit provides three ways to use their testing application in your application.

1. Framework
2. XUL UI
3. MXP

In the below example we will use the first one i.e. Framework. To start with below example, you have to first
download the Framework from here. It's a zip file. You can unzip this file in to your hard disk location. This will
generate some folders named as2, as3, as3docs and as25. As clear from name, these folders are for
different Actionscript versions. Since the below example is in Actionscript 3.0, we will use as3 folder.
To start with the example, First create a folder say TestExample in any location of your hard disk. Copy this
as3 folder to TestExample folder. Now it's time to create the sample application which we will test with
AsUnit.

Create a file named Example.as in the TestExample folder like this.

package {

public class Example {


public function add(num1:Number,num2:Number):Number{
return num1 + num2;
}
}
}

Now its time to create test case for this class. Create a file named ExampleTest in the same folder like this.

package {
//The below line import the AsUnit library of TestCase
import asunit.framework.TestCase;

public class ExampleTest extends TestCase {

//reference of Example class created above


private var example:Example;

public function ExampleTest(testMethod:String) {


super(testMethod);
}

//Default method for object instantiation


protected override function setUp():void {
example = new Example();
}

//Default method for Object deletion


protected override function tearDown():void {

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 11 of 30


example = null;
}

public function testInstantiated():void {


assertTrue("Example instantiated", example is Example);
}

public function testFail():void {


assertFalse("failing test", true);
}

/**
* Test the add method of Example class created above
*/
public function testAdd():void {
var result:Number = example.add(3,3);
assertEquals("Expected:6 Received:"+result, result, 6);
}
}
}

Now our test case is ready, Another thing we have to do is to create the TestSuite for executing many test
cases together. Create a file named ExecuteAllTests.as in the same folder like this.

package {
import asunit.framework.TestSuite;
import ExampleTest;

public class ExecuteAllTests extends TestSuite {

public function ExecuteAllTests () {


super();
//Adding first test
addTest(new ExampleTest("testInstantiated"));
//Adding second test
addTest(new ExampleTest("testAdd"));
}
}
}

Till here we are ready with our main application, test case, test suite, Now we will create a runner class to run
this test suite to produce some results.
Create a file named ExampleTestRunner.as in the same folder like this.

package {
import asunit.textui.TestRunner;

public class ExampleTestRunner extends TestRunner {

public function ExampleTestRunner() {


start(ExecuteAllTests, null, TestRunner.SHOW_TRACE);
}
}

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 12 of 30


}

As from the above structure you can see this runner class is taking our TestSuite class as a parameter and
the last parameter is a boolean to show and hide the trace.

Now it's time to run the application. For this create a flash file named ExampleTestRunner.fla in the same
folder. This file will be empty file. Just you need to put ExampleTestRunner in Document class under
properties tab. This step is to avoid the below error while compiling the fla file.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at asunit.textui::TestRunner/asunit.textui:TestRunner::addedHandler()
at flash.display::DisplayObjectContainer/addChild()
at asunit.textui::TestRunner/setPrinter()
at asunit.textui::TestRunner/doRun()
at asunit.textui::TestRunner/start()
at ExampleTestRunner$iinit()
at ExampleTestRunner_fla::MainTimeline/ExampleTestRunner_fla::frame1()

The more detail on this can be found from the references given below. The below image will show how to use
Document class in Flash CS3.

Its time to run the flash file and see the result. Test the flash movie by hitting Ctrl+Enter. YOu will see a
screen like this if everything goes fine.

The above screen shows that both the tests are passed, Now go to ExampleTest.as file again and change
this line assertEquals("Expected:6 Received:"+result, result, 6);
to assertEquals("Expected:6 Received:"+result, result, 7); and again run the application, you will see a
screen like this saying one test fail in two tests.

References:-

1. AsUnit testing with Actionscript 3.0 and flash CS 3.0


2. AsUnit Step by Step
3. Migrating from flash 8 to flash CS3
4. AsUnit Step by Step part 1 pdf
5. AsUnit Step by Step part 2 pdf

http://sunil-gupta.blogspot.com/2008/02/asunit-open-source-unit-testing-for.html

Back to Flex

It was May 30, 2006 when i started writing here. The very first post i wrote about was the Flex( Introduction to
flex data services). It's more than one and half year now and i am back again to flex.
Last time i got very little chance to work with flex but i enjoyed alot. This time it's going to be more exciting
and challenging. The work is great and interesting and i am ready to fight with flex again.

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 13 of 30


http://sunil-gupta.blogspot.com/2008/01/back-to-flex.html

Limitations of flash Action Script 2.0

Very recently When i was working for a project based on Red5 flash server and Flash 8 with Action Script
2.0. My requirement was to fetch the number of images from the web server and render them on flash client
repeatedly after n milliseconds. To avoid the flickering i used double buffering. But the problem was the time
it was taking to load the images from server and then render them. I was using the MovieClipLoader loadClip
function to dynamically load the jpeg files, Though the size of each jpeg was not more than 15 KB, but it was
taking around 3-4 seconds to load 16 jpeg images of size less than 15 KB. This was very frustating as i was
getting the updated images after 3-4 seconds. How good if flash provide some kind of sockets in Action script
2.0, by using that i can transfer the image object as binary data and then draw it on flash client.I am really
missing this functionality in flash to send image data either using Flash remoting. They have kept it for their
own product called Flash communication server.. I am still looking for a solution that can minimize the time
required to load these images from web server. If i can reduce it to 1 sec on higher bandwidth, It would be
great.

http://sunil-gupta.blogspot.com/2007/10/limitations-of-flash-action-script-20.html

Adding client information with every client in Red5

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 14 of 30


In Red5 forum, I have seen so many times, developers are asking for custom client id to identify a client.
Below I will try to explain how can one add additional client information with every client connected to your
application.

First we will create a client object--

public class Client{


String clientId = null;
String clienName = null;
String clientRole = null;

public String getRole(){


return clientRole;
}
public String getName(){
return clientName;
}
public String getId(){
return clientId;
}
public void setRole(String role){
clientRole = role;
}
public void setName(String name){
clientName = name;
}
public void setId(String id){
clientId = id;
}
}

Now we are ready with our client object, We will add this client object with the IClient in Red5 like below

public boolean roomConnect(IConnection iconnection, Object params[]){


if(!super.roomConnect(iconnection, params)){
log.info((new StringBuilder()).append("Application failed to connect room:
").append(iconnection.getScope().getName()).toString());
return false;
}
else{
log.info((new StringBuilder()).append("Application room connect initiated for room
").append(iconnection.getScope().getName()).append(": ").toString());

//We will add our client information right here


Client client = new Client();
client.setId(params[0].toString());
client.setName(params[1].toString());
client.setRole(params[2].toString());
iconnection.getClient().setAttribute("client", client);

return true
}
}

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 15 of 30


public boolean roomJoin(IClient iclient, IScope iscope){

/*Here you can see how to access your client information throughout the application*/

Client client = ((Client)iclient.getAttribute("client"));


String clientName = client.getName();
String clientId = client.getId();
String clientRole = client.getRole();

return true;
}

This way you can have your own client id's names and roles for different clients.

To create new Red5 application follow my previous post here.

http://sunil-gupta.blogspot.com/2007/08/adding-client-information-with-every.html

Red5 log forwarding to centralized log server

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 16 of 30


In order to view the log generated by Red5 in some other location( on a different log server on network), You
can use the log4j feature to forward your logs to a centralized log sever, where all your applications( multiple
red5 servers) are throwing their logs.This way you can later view your organize log through some log
interface.

Here i will explain, How you can configure your log settings in your red5 application in order to acheive
that.Let say you have an application with name Test.Open the log4j.properties file under your application
WEB-INF folder, Initially the contents will be -

# logging config, this should be auto reloaded by spring.

Now you can change it to -

#-----------------------------------------------------------------

#log4j.rootCategory=, A1
#log4j.appender.A1=org.apache.log4j.net.SocketAppender
#log4j.appender.A1.RemoteHost=XX.XX.XX.XX
#log4j.appender.A1.Port=8888
#log4j.appender.A1.Threshold=DEBUG
#log4j.appender.A1.locationInfo=true

#----------------------------------------------------------------------

The above lines describes that upon running the application, it will connect to this remote address on port
8888.

Now you can also put the server name in your log messages, so that at receiving end, you can differentiate
the log messages coming from different red5 servers. To acheive that, we will add some line in our
application source.

//------------------------------------------------------------------

public boolean appStart(IScope app){

String servername = null;


try{
servername = java.net.InetAddress.getLocalHost().getHostName();
}
catch(UnknownHostException un){
log.error("Unknown host exception found while getting host name of sever " + un);
}
catch(Exception e){
log.error("Exception while getting host name of sever " + e);
}
if(servername != null){
MDC.put("red5server",servername);
}

log.info("AppStart called for : " + app.getName());

if (!super.appStart(app)){
log.error("Unable to start the application");

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 17 of 30


return false;
}

return true;
}

//-------------------------------------------------------------

You can see from the above piece of code, that we have created a variable called "red5server" and we are
putting the server name in that.This variable will be accessed by log4j server later.

Now, the sending part is complete, We have to implement the receiving end i.e. The log4j server, which will
receive all these log messages.

In order to run log4j server, you need to create a properties file. I am showing here, a sample file called
"socketserver.properties". The contents of the file will be-

#--------------------------------------------------------------------

log4j.rootLogger=, A1

#log4j.appender.A1=org.apache.log4j.ConsoleAppender
#log4j.appender.A1.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.


#log4j.appender.A1.layout.ConversionPattern= %X{red5server} %5p [%t] (%F:%L) - %m%n

log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.File= remote-log.log

log4j.appender.A1.MaxFileSize=1024KB

log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern= %1.25X{red5server}- %p %t %c - %m%n

#------------------------------------------------------------------

Now you can see from above lines, I have referred to the same variable, i have created in source file.

"log4j.appender.A1.layout.ConversionPattern= %X{red5server} %5p [%t] (%F:%L) - %m%n"

This piece of code will add the red5 server name in the begining of every log message.

You can now start the log4j server in order to receive the logs from applications in this way-

java -cp log4j-1.2.14.jar org.apache.log4j.net.SimpleSocketServer 8888 socketserver.properties

Now your log4j server is up and running, Every application, which is referring to this log server will throw their
log messages to this server, which you can later on view.

Happy logging!!

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 18 of 30


To create new Red5 application, follow my post here

http://sunil-gupta.blogspot.com/2007/07/red5-log-forwarding-to-centralized-log.html

Desktop sharing with Red5 and Flash

From Last 15 days, I was trying hard to get it done. My previous research on this and some concept from
open source and commercial project, I am finally able to do a complete desktop sharing in my conference
application.And the best part is that, I am not using any native driver or so to acheive this, A pure java
solution with flash just works fine, I got some idea from here. But i tried a little different approach for this. And
the best thing is that, Only the user, who wants to share his desktop need java plugin in his browser,all other
users in the conference can just see and control his desktop with their flash client, Screen rendering part is
little bit slow at this time, but the mouse and keyboard controls are more faster than i expected.The only
frustating part having flash as a desktop sharing client is that, there is no way to remove the flash context
menu, So i have done a workaround(got it from some forum) and put right click event on context menu itself.

Now i am trying to make it more faster in terms of performence.

http://sunil-gupta.blogspot.com/2007/07/desktop-sharing-with-red5-and-flash.html

Open source video conferencing using Red5 and Open Laszlo

Openmeetings, A new multilanguage, and customizable video conference and group collaboration application
very similer to Adobe Connect. They have used Open Laszlo and Red5 as a technology to build this
application. The project has various features like screen sharing, Document importing. There are various file
format(.tga, .xcf, .wpg, .txt, .ico, .ttf, .pcd, .pcds, .ps, .psd, .tiff, .bmp, .svg, .dpx, .exr, .jpg, .jpeg, .gif, .png,
.ppt, .odp, .odt, .sxw, .wpd, .doc, .rtf, .txt, .ods, .sxc, .xls, .sxi, .pdf) that you can import and share with others
in the conference.The whiteboard items are draggable, You can edit the items, also some of them are
resizable as well, Whiteboard can be stored or recorded.

Take a live demo here

Demo

Screen 1- Conference Mode

Screen 2- Audience Mode

Screen 3- Multi color Interface

For more information visit the home page of Openmeetings here

Related Post
New Version Of Dimdim's Open Source Community Edition Releasing Soon

http://sunil-gupta.blogspot.com/2007/07/open-source-video-conferencing-using.html

Secure your Red5 applications with Stunnel

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 19 of 30


Steps to configure SSL in existing Red5 application

Software needed on machine where Red5 server is installed:-

1: Open SSL //Open source SSL libraries required for compiling Stunnel

2: Stunnel //Open source SSL wrapper software uses open SSL works both on
Windows and Linux.

3: gcc // The GNU C compiler (although it always bundled with Linux


Machine, but I did not find it. Necessary if you are compiling the
Open SSL and Stunnel from source. Not required if using RPM

Configuration needed on server machine:-

1:- Install the Open SSL (if windows use exe RPM or source for Linux machine can be downloaded from
here- http://www.openssl.org/ ).

2:- Install Stunnel (if windows use exe otherwise RPM or compilation from source is preferred, can be
downloaded from here- http://www.stunnel.org/download/). Make sure that you already have compiled Open
SSL in your machine before proceeding with the installation of Stunnel; otherwise it will fail to compile.

Under Linux the standard command to compile Stunnel from source are described below. For any update
please always follow the installation instructions given their website.

machine# gzip -dc stunnel-VERSION.tar.gz tar -xvzf -


machine# cd stunnel-VERSION
machine# ./configure
machine# make
machine# make install

There are several configurations that differ based on your computer and environment. That can be read from
the website itself.

3:- Running Stunnel (There are several ways/mode you can run the stunnel. Follow the FAQ available in their
website to choose the best which matches your requirements).
To run stunnel, you always require a configuration file. The process of making sample configuration file
(stunnel.conf) is described below.

The sample configuration file used was like this.

************************************************************************
sample.conf

; Sample stunnel configuration file by Sunil Gupta 2007


; Some options used here may not be adequate for your particular configuration

; Certificate/key is needed in server mode and optional in client mode

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 20 of 30


; The default certificate is provided only for testing and should not
; be used in a production environment

cert = /etc/stunnel/stunnel.pem
;chroot = /var/run/stunnel/
pid = /stunnel.pid
key = /etc/stunnel/stunnel.pem

; Some performance tunings


socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1

; Workaround for Eudora bug


;options = DONT_INSERT_EMPTY_FRAGMENTS

; Authentication stuff
;verify = 2
; Don't forget to c_rehash CApath
;CApath = certs
; It's often easier to use CAfile
;CAfile = certs.pem
; Don't forget to c_rehash CRLpath
;CRLpath = crls
; Alternatively you can use CRLfile
;CRLfile = crls.pem

; Some debugging stuff useful for troubleshooting


debug = 7
Output = /var/log/stunnel.log
foreground=yes
; Use it for client mode
; client = yes
; Service-level configuration

;[pop3s]
;accept = 995
;connect = 110

;[imaps]
;accept = 993
;connect = 143

;[ssmtp]
;accept = 465
;connect = 25

[rtmps - https]
TIMEOUTconnect=20
accept = 443
connect = 80
TIMEOUTclose = 20

; vim:ft=dosin

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 21 of 30


*****************************Finish*************************************

Note: - When you install Stunnel, you get a default sample file, which is not enough in most of the cases to
run the flash application. The additions to configuration file I made are as follows.
Also the line having ; in the start denotes the commented portion in file.

cert = /etc/stunnel/stunnel.pem
key = /etc/stunnel/stunnel.pem

pem stands for ?privacy enhanced mail' used as a key format. The above two lines tells the location of pem
files need to be generated. This will be configured by user. The above is the best location for Stunnel
although you can change it to any desired location.

;Some performance tunings

socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1

The above two lines are for better performance of Stunnel in our case.

; Workaround for Eudora bug


;options = DONT_INSERT_EMPTY_FRAGMENTS

The above line is a bug in a specific platform, since we are running it in Linux; we commented this line,
although it could be needed in some case.

; Some debugging stuff useful for troubleshooting


debug = 7
Output = /var/log/stunnel.log
foreground=yes

The above lines are very important, Because Stunnel by default run in background mode. You will never be
able to see if it is running. So better to put it in foreground, so that you can make sure that stunnel is running
properly. Also the debug = 7 is very important since by default stunnel does not generate any log. You can
direct him to generate log, so that you can debug your application by seeing all those log messages. The
above mentioned log directory is default Linux directory where all system logs are generated.

; Use it for client mode


; client = yes

In the sample configuration file, you will always find this option un-commented leading to a different
architecture, since we are running Stunnel in server mode not client mode, so we will comment this line.

[rtmps - https]
TIMEOUTconnect=20
accept = 443
connect = 80
TIMEOUTclose = 20

And the very last lines are mentioned above. In the sample configuration file, you will never find rtmps and it
is not even mentioned anywhere in Stunnel. The default file contains only https, add rtmps like it is added
here. Also accept port is 443, which is the default port used for secure communication and it is open like port

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 22 of 30


80 in all corporate firewalls in general. This port is to accept the connection from flash and to get the
encrypted data. The connect port is 80; this is the port where stunnel will forward the decrypted data to red5
server.
The TIMEOUTconnect and TIMEOUTclose can be useful in some cases when the server where the data is
being forwarded by Stunnel is delaying the connection. This is to make sure that connection is closed only
when server is not responding at all. The value is in seconds (i.e. 20 sec.)

Now in order to run your application under secure connection, you require a certificate to be created on the
machine where the Stunnel is installed. The procedure for creating a certificate and the possible directory to
put this certificate is described below.

Use of certificate:-

When an SSL client connects to an SSL server, the server presents a certificate, essentially an electronic
piece of proof that machine is who it claims to be. This certificate is signed by a 'Certificate Authority'
(hereafter a CA) -- usually a trusted third party like Verisign. A client will accept this certificate only if
The certificate presented matches the private key being used by the remote end.
The certificate has been signed correctly by the CA. The client recognizes the CA as trusted.

Every stunnel server has a private key. This is contained in the pem file which stunnel uses to initialize its
identity. If we notice above, we have given the reference of this pem file in the start of our configuration file
under cert.

This private key is put in /usr/local/ssl/certs/stunnel.pem.

Note:-Under client mode we need not to have certificate in most of the cases, but if we are running it in server
mode, we require a certificate. Since we are using server mode, I have generated a self certificate.

To make certificate:-

1: Go to /etc/stunnel directory and


2: Run the following command:-?

openssl req -new -x509 -days 365 -nodes -config stunnel.cnf -out stunnel.pem -keyout stunnel.pem

This creates a private key and self-signed certificate. More information on the options of this can be read from
FAQ section of Stunnel website.

While executing the command, it will ask for some questions like Country, City, Company etc., Give the
answer of those and it will generate the key and self certificate.

4:- Put your sample.conf file in /etc/stunnel directory where the .pem file was created earlier.

5:- Start Stunnel by issuing the command ?

machine# stunnel stunnel.conf

If you are /etc/stunnel directory otherwise complete path of configuration file-

machine# stunnel /etc/stunnel/stunnel.conf

The above command will start the stunnel and you can verify the log from /var/logs/stunnel.log file.

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 23 of 30


Red5 server side changes:-

6:- Now stunnel is up and running, we need to change the Red5 configuration to accept the connection from
Stunnel.

Go to red5 installation directory and search for conf folder where all red5 configuration files exist.

Open red5.properties file and under rtmps.host_port property put 443. The sample file can be like below.

rtmp.host_port = 0.0.0.0:1935
rtmp.threadcount = 4
debug_proxy.host_port = 0.0.0.0:1936
proxy_forward.host_port = 127.0.0.1:1935
rtmps.host_port = 127.0.0.1:443
http.host=0.0.0.0
http.port=5080
rtmpt.host=0.0.0.0
rtmpt.port=80

Flash client side changes:-

7:-Now we are done with server side, In order to run application under SSL, we need to change the client
side protocol from rtmp to rtmps like below. And compile the flash client and run it on browser, a certificate
will pop up, accept it and the application will run under SSL.

nc.connect (?rtmps://yourip/applicationname?); //used rtmps in place of rtmp

To create new Red5 application, follow my post here

http://sunil-gupta.blogspot.com/2007/06/secure-your-red5-applications-with.html

Test

Tetsing our application

No flash
Please install FLASH plugin.

http://sunil-gupta.blogspot.com/2007/05/test.html

Shared Whiteboard application in Red5

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 24 of 30


Working with Red5 server is a fun, In the last tutorial, I have created a sample application in Red5. Now this
time, I will try to explore the conecpt of shared objects in Red5 using an example of shared whiteboard.

Creating a simple shared whiteboard application in red5 is very easy, All you need is to get the corrdinates
and put them in the shared object and let shared object work for you.

On Client Side:- We have a shared object say

var whiteboard_SO:SharedObject = SharedObject?getRemote("whiteboard",nc.uri,"false");

Now when we move mouse pointer over a movie clip for drawing , we capture the xmouse and ymouse to
send them to server. For Example.

sample_MC.onPress = function(){
//Send xmouse and ymouse to server along with "press" event string
NetConnectionObj.call("somemethod", null,param1, param2,param3); //sending values
};

sample_MC.onMouseMove = function(){
//Send xmouse ymouse along with "move" event string
NetConnectionObj.call("somemethod", null,param1, param2,param3); //sending values
}
Now on server(java) side change the shared object with these values

E.g.

public void somemethod(Object[] params){


whiteboard_SO.setAttribute("point",params[0].toString()+":"+params[1].toString()+":"+params[2].toString());
// The above code will fire the onSync event on all connected clients.
}

Now on Client side :-

Whiteboard_SO.onSync = function(infolist){
// Inside the change event we will get the xmouse and ymouse and press string
//If event string is press, jump to new line(i.e. lineto(x,y))
//If event string is move, move with drawing(i.e. moveto(x,y))
}

This way , A shared whiteboard can easily be created.

To create a new Red5 application , follow my post here

Reference:-
Create whiteboard application with Flash communication server

http://sunil-gupta.blogspot.com/2007/04/shared-whiteboard-application-in-red5.html

How to create a sample application using Red5 and Flash

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 25 of 30


How to create a sample application using Red5 and Flash

Step 1:-

Get a default application template from doc folder of your Red5 installation directory (e.g. for windows: -
?C:\Program files\Red5\doc\templates\myapp?).
Copy this folder into Red5\webapps\ directory.

Step2:-

Now we have a default template available for running the server side application. We will change the default
configuration accordingly. Rename myapp folder to sample. This sample folder will be the name of your
application. We will now change the configuration files inside sample folder. The structure of the application
will be like this-

Open the red5-web.properties file and change the contextPath to sample like below ?

webapp.contextPath=/sample
webapp.virtualHosts=localhost, 127.0.0.1

Open web.xml file and change the display and webAppRootKey like below?

My First sample application with Red5

webAppRootKey
/sample

Now open the red5-web.xml file and change the application name likes below-

where org.xyz is the package structure used here. It could be replaced with actual application structure.
lib directory will contain the jar file of our application. We will explore it later while creating an application.

Step3:-

We are ready with the server side application configuration. Now we will create the actual application which
will interact with the flash client.

Open any java IDE like eclipse and create a new java project. Name it to Sample. Create following structure
in the Sample project.

src folder will contain the application package structure org.xyz. Compiled class file will be under classes
folder and lib folder will contain the jar of compiled class.

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 26 of 30


Now create a build.xml file for building this project with ant tool. The sample build file will be like this-

Here in ?jar? target we have copied the created jar file inside our application directory under webapps folder
of Red5 installation. One can manually do the copy paste.

Note: - Don?t forget to add red5.jar from your Red5 installation in the CLASSPATH of eclipse so that it can
find the Red5 libraries and compile the application without any errors..

Step4:-

Now we will create our source file. Create a java file, name it to Application.java

The sample application file will be like ?

Application.java

package org.xyz;

//log4j classes
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

//Red5 classes
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IClient;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;

/**This is the sample application class */

public class Application extends ApplicationAdapter{


/**Variable used for generating the log*/

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 27 of 30


private static final Log log = LogFactory.getLog(Application.class);

/**This method will execute when Red5 server will start*/


public boolean appStart(IScope app){
if(super.appStart(app) == false){
return false;
}
log.info("Application start method of Application called");
return true;
}

/**This method will execute when first client will connect to Red5 server*/
public boolean roomStart(IScope room){
if(super.roomStart(room) == false){
return false;
}
log.info("Inside room start of Application");
return true;
}

/**This method will execute everytime when a client will connect to Red5 server*/
public boolean roomConnect(IConnection conn, Object params[]){
if(super.roomConnect(conn, params) == false){
return false;
}
log.info("Inside room connect method of Application");
return true;
}

/**This method will be called when a client disconnect from the room*/
public void roomDisconnect(IConnection conn){
super.roomDisconnect(conn);
log.info("Inside room disconnect method of Application");
}

/**This method will be called when a client will be disconnected from application*/
public void appDisconnect(IConnection conn){
log.info("Inside app disconnect method of Application");
}

/**This method will be called from the client. This method will show ?Hello World!? on *the flash client side .
*/
public String sayHello(Object[] params){
log.info(?I got your name:-?+params[0].toString());
return ?Hello World!? + params[0].toString();
}

} ////////End of Application class

The above file was just to give a feel of how a server side code looks like.
Read Red5 documentation for more details on methods in AplicationAdapter class. Here we have defined a
method named sayHello, which will get user name from flash client and will append this user name to ?Hello

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 28 of 30


World!? and will send back to flash client.

Now run the jar task of your build.xml file, this will compile your application class, will generate the desired jar
and will copy it to your application directory inside Red5.

Step5:-

Now we are ready with server side application, we will start with the flash application to connect with the
Red5 server.

Create a new flash document ?

Drag an Alert component from window?components in the library. Open the Action-Frame and write the
following lines of code-

import mx.controls.Alert;

var nc:NetConnection = new NetConnection();

nc.val = this;
nc.onStatus = function(info){
switch(info.code){

case "NetConnection.Connect.Success":
Alert.show("Got connected with application);
this.val.callServer();
break;

case "NetConnection.Connect.Failed":
Alert.show(info.application);
break;

case "NetConnection.Connect.Rejected":
Alert.show(info.application);
break;

case "NetConnection.Connect.Closed":
Alert.show("Client Disconnected");

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 29 of 30


break;
}
};
nc.connect("rtmp://localhost/sample");

function callServer(){
var resultObj:Object = new Object();
nc.call("sayHello", resultObj,"Your Name");
resultObj.onResult = function(str){
Alert.show(str); //This will display "Hello World! Your Name"
}
};
}

Now save the application and name it to sample.fla(user preferred)


The above code is Action script 1 code; you can put this code in external .As file and refer it in the
application. Since this is not in the scope of this tutorial, so we will follow the above code.

Finish:-

Run your flash client and if its get successfully connect with Red5 server, it will display an alert box saying
?Hello World! Your Name?

With the help of above tutorial, you can extend your application to any level.

For more information on Red5 related documents follow the link provided below-

Red5- Open source flash server


Red5-How to create new applications ? Joachim Baunch
Migration Guide from FCS/FMS to Red5
Red5-How to create new application

http://sunil-gupta.blogspot.com/2007/03/how-to-create-sample-application-using.html

Saturday, May 24, 2008 09:24 GMT / Created by RSS2PDF.com Page 30 of 30

You might also like