Thursday, May 29, 2008

Red5 and Server-Side ActionScript - A Gift to Flash Developers

Ryan: Hi Bob, Did you hear about Red5 Flash Server?

Bob: Yeah i know Red5, it's an alternate to Flash Media Server with cool features and it's free.

Ryan: Did you try it?

Bob: It's very hard for me, i am a pure flash developer. I do server side coding in ActionScript using Server-Side ActionScript. For coding server side applications in Red5, i need to learn Java.

Ryan: What if you are able to do server-side ActionScript coding in Red5?

Bob: Wow, I would love to go for Red5 over FMS. Red5 with server-side ActionScript is a gift for me. Along with new application development, i can also easily convert my existing FMS based applications into Red5

This was the normal conversation between two flash developers who love to do coding in ActionScript and because of the fact that Red5 is written in Java, they are not so comfortable to move from FMS to Red5.

Here is the question- Why I posted this conversation? Well, i have a reason to share it. Please read below-

Red5 server will soon introduce a new feature in the future releases and it's "server-side Actionscript support".

With server-side ActionScript API for Red5, it will be possible to support FMS applications written independently of Red5, possibly with little or no refactoring.

Does it sound great? If yes, then it's time now to read all technical stuffs behind this new feature rather than reading this post. Here are the details-

Support for server side actionscript
FMS Application Portability

Monday, May 26, 2008

Red5 + RTMPS - Who Need FMS?

Few days back, i wrote a post about Red5 vs FMS. In that post, i did a quick comparison between Red5 and FMS, Now one more point needs to be added in that list and its "Built-in Support of RTMPS in Red5".

Yes Red5 has achieved another great feature. Red5 now has built-in support for RTMPS. Before this many users achieved RTMPS with the help of Stunnel, but now they don't need to go for it. They have this option in Red5 itself.

Paul Gregoire from Red5 team today announced the support of RTMPS in Red5 along with a nice tutorial to follow. Later, the Red5 community also started talking about this new feature. You can find latest conversation over RTMPS here. This feature is available via SVN starting with revision 2819 and will be available in future release of Red5 (Currently Red5 is in version 0.7.0)

Wednesday, May 21, 2008

Save Video Images To Server Using Red5 and Flex

Here is a small tutorial telling how to save video preview images from Flex client to Red5 server.

The work is to take a snapshot of a video stream from the client and some how get it to be a saved image on the server. There are ways to acheive this using ffmpeg or using a scripting language in combination with Red5. But this is the simplest one as it does not require any additional library. Flex does everything.

You can get a PNG or JPEG file saved to the Red5 server the following way-

Client Side (Development took place on Free flex sdk 3.0.0.477)

So lets assume that you already have a netconnection to your serverside application. You also have a camera opened and attached to a UI component in the browser. I have it so when a button called "Take sceen shot" is clicked the function "handleScreenShot" is called.

NOTE: SharedVideo is a public var of type Video. When I attached the video from the camera to the UI, I copied it into Shared video.

private function handleScreenShot():void {

// Clear out any previous snapshots

pnlSnapshot.removeAllChildren();


var snapshotHolder:UIComponent = new UIComponent();

var snapshot:BitmapData = new BitmapData(320, 240, true);

var snapshotbitmap:Bitmap = new Bitmap(snapshot);

snapshotHolder.addChild(snapshotbitmap);

pnlSnapshot.addChild(snapshotHolder);

snapshot.draw(SharedVideo);

pnlSnapshot.visible = true;


// Here is how you encode the bitmapimage to a png or jpeg ByteArray and send it to the server

//var jpgEncoder:JPEGEncoder = new JPEGEncoder(75);

//var jpgBytes:ByteArray = jpgEncoder.encode(snapshot);

var pngEncoder:PNGEncoder = new PNGEncoder();

var pngBytes:ByteArray = pngEncoder.encode(snapshot);


nc.call("Save_ScreenShot", null, pngBytes);

}

Server Side

Ok now the server side code for the function "Save_ScreenShot". I have this right inside the main java file of my Red5 applicationNOTE: You must import the following classes.

import org.red5.io.amf3.ByteArray
import javax.imageio.ImageIO
import java.io.ByteArrayInputStream
import java.awt.image.BufferedImage

public String Save_ScreenShot(ByteArray _RAWBitmapImage) {
// Use functionality in org.red5.io.amf3.ByteArray to get parameters of the ByteArray
int BCurrentlyAvailable = _RAWBitmapImage.bytesAvailable();
int BWholeSize = _RAWBitmapImage.length(); // Put the Red5 ByteArray into a standard Java array of bytes
byte c[] = new byte[BWholeSize];
_RAWBitmapImage.readBytes(c);

// Transform the byte array into a java buffered image
ByteArrayInputStream db = new ByteArrayInputStream(c);

if(BCurrentlyAvailable > 0) {
System.out.println("The byte Array currently has " + BCurrentlyAvailable + " bytes. The Buffer has " + db.available());
try{
BufferedImage JavaImage = ImageIO.read(db);
// Now lets try and write the buffered image out to a file
if(JavaImage != null) { // If you sent a jpeg to the server, just change PNG to JPEG and Red5ScreenShot.png to .jpeg
ImageIO.write(JavaImage, "PNG", new File("Red5ScreenShot.png"));
}

} catch(IOException e) {log.info("Save_ScreenShot: Writing of screenshot failed " + e); System.out.println("IO Error " + e);}
}

return "End of save screen shot";

This is one way, You can also make it working for the other way i.e. getting images from server to client.

Thanks to Charles Palen for posting the snippet of this code in Red5 community.

Friday, May 16, 2008

Red5 And RTMFP( Real Time Media Flow Protocol): Will It Be?

Just two days back, Adobe made a prerelease of Adobe Flash Player 10. There are many new significent features, improvements. Some of the features like RTMFP(Real Time Media Flow Protocol) just discussed but not shared the deatil yet by Adobe.

This prerelease from Adobe gave great news to Open Source Flash community( http://osflash.org), more Specifically red5 community and they already started talking about it here and here.

What is p2p RTMFP?

You can get good idea about it here at -

http://www.flashcomguru.com/index.cfm/2008/5/15/player-10-beta-speex-p2p-rtmfp

and

http://justin.everett-church.com/index.php/2008/05/16/rtmfp-in-flash-player-10-beta/

or read RTMFP FAQs

But from the release notes, it seems that many new features will be available only to FMS users with future release of FMS, so it will be another challenge for the red5 team.

Saturday, May 10, 2008

Building Red5 Applications- Video

I found a video of Chris Allen that walks you through getting started actually using Red5 server, so i thought of sharing it here.



This video will help you to better understand what is Red5 and how can you start building applications using Red5.

Reference:-
Building Red5 Applications

Friday, May 9, 2008

Embedded Tomcat In RED5

The development of Red5 server is on the fast track. Red5 developers are adding more and more functionality in order to make Red5 server, a tough competitor of FMS.

Paul Gregoire from Red5 has worked on Embedded Tomcat in Red5. Now we have a choice between Jetty and Tomcat as a web container, Previously Jetty was the only web container with Red5.

Though emebeded Tomcat won't impact your application in terms of functionality. But it gives you the option to choose between web containers and an advantage that it will now be easier to run the Edge/ Origin setup from the embedded Tomcat as opposed to the Tomcat standalone container.

How to change the settings to make it working with Tomcat?

Go to red5.xml in conf directory and comment the jetty server and uncomment the Tomcat server like below-



 <!-- Now we can load the servlet engine, this has to happen after the context are loaded -->
<!--
  <bean id="jetty6.server" class="org.red5.server.jetty.JettyLoader" init-method="init" autowire="byType" depends-on="context.loader">

  <property name="webappFolder" value="${red5.root}/webapps" />
 </bean> -->



 <bean id="tomcat.server" class="org.red5.server.tomcat.TomcatLoader" init-method="init" destroy-method="shutdown" autowire="byType" depends-on="context.loader">

  <!- - Note: the webapp root folder must be specified before the "contexts" property - ->
  <property name="webappFolder" value="${red5.root}/webapps" />
 
     <property name="embedded">

      <bean class="org.apache.catalina.startup.Embedded" />
     </property>
  
     <property name="engine">
   <bean class="org.apache.catalina.core.StandardEngine">

          <property name="name" value="red5Engine" />
          <property name="defaultHost" value="localhost" />
   </bean>  
     </property>

    
     <property name="realm">
      <bean class="org.apache.catalina.realm.MemoryRealm" />
  </property>
        
     <property name="connector">

   <bean class="org.apache.catalina.connector.Connector">
          <property name="port"><value>${http.port}</value></property>
          <property name="redirectPort"><value>${https.port}</value></property>

          <property name="enableLookups"><value>false</value></property>
   </bean>
     </property>
      
        <property name="baseHost">
        <bean class="org.apache.catalina.core.StandardHost">

            <property name="name" value="localhost" />
            <property name="unpackWARs" value="true" />
            <property name="autoDeploy" value="true" />

            <property name="xmlValidation" value="false" />
            <property name="xmlNamespaceAware" value="false" />
        </bean>   
     </property>  



  <property name="valves">
        <list>
       <bean id="valve.access" class="org.apache.catalina.valves.AccessLogValve">
                 <property name="directory" value="log" />

                 <property name="prefix" value="localhost_access." />
                 <property name="suffix" value=".log" />
                 <property name="pattern" value="common" />

                 <property name="resolveHosts" value="false" />
                 <property name="rotatable" value="true" />
          </bean>
         </list>

        </property>
    
 </bean>      


 <!-- Default context. This can be shared between web app contexts -->
 <!--
 <bean id="default.context"
       class="org.springframework.context.support.FileSystemXmlApplicationContext">

     <constructor-arg><value>/webapps/red5-default.xml</value></constructor-arg>
     <constructor-arg><ref bean="red5.common" /></constructor-arg>
 </bean>

 -->
 <!-- You can add further contexts here. This allows for multiple separate global scopes -->



 
The discussion over embeded Tomcat in Red5 is going on Red5 mailing list.

Open Source SIP Phone With Red5 And Flex3

Few days back, i wrote an interesting post talking about implementation of open source SIP phone with Red5 and Flex3.

This was possible with latest release of Red5 plugin for Openfire that features a completely open-source implementation of a web-based SIP softphone written in Flex3.



The below diagram shows how the implementation works-



More detail information over its working and the technologies behind its implementation are available here at- Flash-based Audio in Openfire part II

Friday, May 2, 2008

Red5 Showcase-- Applications Using Red5 Continues...

In my previous post of Red5 showcase, I shared the information of many applications that are using Red5 media server as a part of their development. This post will showcase few more such applications.


Pixelquote(http://pixelquote.com/) is an application based on Red5. It's a huge Pixelwall where visitors can simply add Pixels with their Messages.


http://www.ligachannel.com/ is a website of Italian singer. The website uses Red5 VOD Protected Streaming and audio/video recording widgets.



Dimdim(http://www.dimdim.com/) is an open source web conferencing system that uses Red5. Dimdim is available for free so everyone- not just big companies with big budgets - can use it. And Dimdim is available as open source software so you can extend and improve it freely.



ePresence (http://epresence.tv/) is both a webcasting and web conferencing system that supports full duplex, multi-point audio and video conferencing + desktop sharing. This new functionality has been added by integrating an Open Source real-time communications platform Red 5 with ePresence Server.


Gchats Visichat(http://www.gchats.com/red5chat/visichat/) is a live video chat community that connects you with people from around the world. Connecting is easy with public and private chat rooms. With breakthrough video and voice technology which gives you a real and natural experience.



Zingaya(http://www.zingaya.jp/) is a VOIP server built on Red5 for Flashphone.


Sticko(http://www.sticko.com/) is a multimedia content manager. You can manage your live video webcasts, photos, and videos from one place. Its a video portal with widgets for popular social networking sites like facebook, mySpace, Blogger, LiveSpace, WordPress, vBulletin and more.


Sprasia(http://www.sprasia.com/) is a website where you can edit videos and can add effects on top of it and share it with whole world. You can directly import videos from YouTube and can apply cool effects on top of these videos. Red5 is being used as a part of their development.


VPlace(http://www.vplace.com.br/) is an E-Learning system with Flex and Red5 with features like file sharing, nice laser pointer, chat, etcetera and live Screen Sharing feature in process. The website is in Portuguese.


Delta StrikeDelta Strike(http://gamedev.fh-hagenberg.at/projects/delta-strike/) is an online and free browser independent multiplayer real-time strategy game.


Hubba BubbaHubba Bubba world( http://www.hubbabubba.com/hbw/mmo/index.do ) is a real time multi-player 3D game.

http://www.f-ab.net- Browser for Flash Movie with embedded Red5 for FLVPhone, a video conference telephone. Read more about this here.


Red5 is hot and many companies around the world are showing interest in building applications based on Red5. I will again showcase Red5 based applications as soon as I hear any new.

You can also contribute to Red5 showcase, if you are aware of any application that is based on Red5 and not listed here, just drop a comment with little details, I will include that in Red5 showcase.

Related Posts:-
New Version Of Dimdim's Open Source Community Edition Going To Release
Sprasia Now Open For All- Public Beta Released

Previous Post- Red5 ShowCase:-
Red5 Showcase-- Applications using Red5

Technology makes life easier

Daily Technology Tips

Open Source Flash Jobs

Adobe Flex Developer Center: Recent tutorials

Programming Discussion Forum