Flash-based Audio in Openfire part II

Just over a year ago, I blogged about using audio and video with openfire. At that time, I implemented a SIP based softphone in Adobe Flash using AsteriskWin32 and VAC4. My argument for an open-source, standards based, no-install web-based softphone as a requirement for Web 2.0 voice applications is still valid today and the emergence of Ribbit, TringMe, Zingaya (Flashphone) and others confirmed my thinking was not isolated.

It has however been a disappointment that all implementations I have encountered to-date have been closed, proprietary and inaccessible for integration (both client and server).

The latest release of the Red5 Plugin for Openfire features a completely open-source implementation of a web-based SIP softphone written in Flex3 and should work on both Windows and Linux. It uses MjSIP as the SIP user agent in the plugin and should work with most SIP proxies, but I have only tested with Asterisk. I have also only tested 2 simultaneous users, but there is no limit and will depend on how many users and media streams Red5 can cope with before it dies. Each telephone conversation consumes 2 user RTMP connections and 4 audio streams on Red5. All source code is provided and you are free to use it in your Openfire Red5 Plugin applications. Just confirm that the open-source licenses of MjSIP and Nelly2PCM are to your liking.

I have also integrated the softphone into SparkWeb and the Openfire SIP plugin. This will enable a user to make SIP calls from Spark and SparkWeb with the same user profile. The old Red5gateway will be depreciated and in a later release for window users, I will be adding AsteriskWin32 to the plugin and provide a complete SIP solution for Openfire.

As usual, any feedback will be appreciated.

For details of how this works read on…

The red5Phone Flex3 client makes a NetConnection with the Red5 SIP application. When it recieves a success response, it makes a remote “open” method call in the Red5 SIP application which creates a pair of SIPUser and RTMPUser objects for that user and instructs SIPUser to register the user with the specified SIP proxy. When the NetConnection is closed by the Flex3 client, the pair of objects are destroyed and the user is unregistered from the SIP proxy.

When the Flex3 client invokes “call” remotely, SIPUser starts a SIP outgoing call with the SIP proxy and exchanges RTP audio streams. It invokes “connected” on the Flex3 client and informs it of what stream names Flex3 client should use to publish from the PC microphone and play to the PC speaker. It then resamples the incoming audio RTP packets from 8KHZ to 11KHZ, converts from ulaw to ADPCM and calls a method in the RTMPUser object to publish the audio to Red5 using the same name it gave to the Flex3 client to play.

The RTMPUser objects also plays the stream being published by the Flex3 client which is in the Nellymoser ASAO codec. It calls asao2ulaw (my modified version of the open source nelly2pcm) to convert the packets to ulaw and pass to SIPUser through a PipedOutputStream.

An incoming call follows the same pattern, the incoming SIP signal appears as a remote “incoming” call on the flex3 client. The user can then pickup the call and the Red5phone Flex3 client remotely calls “accept” in SIPUser to accept the call. The audio is setup the same way as an outgoing call.

Why win32 ?

I think it’ll be better to use platform independent libraries,

It is not a Win32 implementation. It is all done in Java except Nelly2PCM which is in C and compiled for both windows and Linux.

  1. How is DTMF supported ?

  2. Is this http://www.igniterealtime.org/projects/openfire/plugins-beta/red5/readme.html still valid ?

  3. Do you think an H.264 and AAC compliant Red5 version is worked on ?

  1. DTMF is not supported yet, but I assume MjSIP does support it. It should be very straightfoward to put in a RTMP remote method “dtmf” in SIPUser to call from Flex3 application. The plumbing is all in place.

  2. Red5 Plugin on igniterealtime plugins area is at least 2 versions behind. See readme of latest version in the Red5 plugin community area. I am dropping the red5gateway in favour of the Red5Phone (it only worked on windows) and plan to concentrate on Spark and the un-named Red5 version of SparkWeb.

  3. There is an opensource RTMP server for H.264 and AAC called rubyizume (written in Ruby) that is being ported to red5. It should appear in a version soon.

You mentioned the source code, but I can’t seem to find it anywhere. Is it in the openfire svn? The beta-plugins page? I’m a bit confused.

The source is in the plugin.

hey dele,

thanks for your hard work on this awesome piece of software. I’ve started working on porting your plugin so that it will work as a straightforward webapp on a standalone Red5 server. I was wondering if you can foresee any particular problems this might cause, based on your implementation?

There should really be no problems. It is impmemented as a Red5 application and the only Openfire dependencies are calls to a static Class in the Red5 plugin to retrieve global parameters. That can be replaced with an xml or properties file. Thanks for the kind words

Congratulations for the plugin

Can you help me telling:

How to setup the whole plugin?

How to test only the SIP client? Which URL?

Best Regards,

Thiago

Enable HTTP_BIND on Openfire (if disabled) and note the HTTP port.

Copy the red5.war file to the Openfire_HOME/plugins directory.

Go to the page http://your_server:your_http_bind_port/red5/index.html

See readme for more details. If you running on Linux, see additional notes by Chris.

-dele

Thank you for the reply,

I got it running. But how to test SIP gateway?

I didn’t see any link on the index page.

Is there an example which is just a flashphone or something like that? How did you guys test SIP stuff?

Regards,

Thiago

This is all very cool dele! I’ll have to try it out sometime soon. It sure would be cool if I could ditch my VOIP phone client and use this instead. Well, I’d rather use a desktop version frankly, but hey. For what it’s worth, I’m working on the desktop version of Spark (Air) lately and I believe we’re planning on plugin support at some point. Wanted to let you know in case that was of interest to you in not having to hack sparkweb source itself. =)

Hi jadestorm,

Plugin support into SparkWeb or SparkAir would be real cool :). Pls let me know as soon as a design/spec is available. That would really help in adding the audo/video/telephony streaming features into SparkXXX without hacking.

Are you planning on using Flex 3 runtime-shared-libraries (RSLs)??

-dele-

hehehe well… the “we’re planning on plugin support” is about as far as we’ve gotten as far as I know. RSLs seem promising for this but we haven’t done anything serious with it yet. Honestly, once I get the desktop version going, I imagine it’ll be a bigger drive for plugin support than the web version, so once it comes about, you’ll probably see plugins show up soon after in some format. But we’ll definitely be in touch over it. =)

Finally someone posted an open source solution for this kind of application !!!

I’ve installed it and did some test calls (first I had to turn off the authentication on my switch since the mj sip stack does not seem to handle it very well).

The calls are established but I’ve got one way audio (there is no NAT or firewalls involved …)

I can hear the remote side when I make call but no one can hear me.

I guess I will have to dig in into the implementation … Unless someone has any idea ?

Maybe this can help you

Actually I’ve installed it on a standalone RED5 without OpenFire … and it works … Except that the outgoing RTP channel has very-very low volume … The other side can barely hear me.

Can you tell me how you got it running without OpenFire? Everytime I try to register outside of Openfire I 'm getting a Service Invocation error, which is

Caused by: java.lang.NoClassDefFoundError: org/red5/server/net/rtmp/RTMPClient$INetStreamEventHandler