Wednesday, December 15, 2010

Acoustic Echo Cancellation support for Flash Player

If you ever developed a Flash application with live audio/video communication you probably ran into trouble with acoustic echo/feedback.
The flash.media.useEchoSuppression property doesn't solve the problem Flash Player had no AEC support.
Maybe you tried some workarounds but faced the requirement that the user had to use a headset for a good experience.

Please read my latest post about the current implementation of the AEC feature.

Fortunately AEC support will be part of a Flash Player version in 2011.
MicrophoneEnhancedOptions and MicrophoneEnhancedMode are not included in the current beta version of the Flash Player (10.2) but according to this Jira ticket from the Adobe Flash Player Bug and Issue Management System this feature is developed and will be part of an upcoming player version in 2011.

The code, when both speaker and microphone are used simultaneously, might look like this:

...
import flash.media.Microphone;
import flash.media.MicrophoneEnhancedMode;
import flash.media.MicrophoneEnhancedOptions;
import flash.media.SoundCodec;
...
var microphone:Microphone = Microphone.getEnhancedMicrophone(deviceIndex);
microphone.codec = SoundCodec.SPEEX;
var enhancedOptions = new MicrophoneEnhancedOptions();
enhancedOptions.mode = MicrophoneEnhancedMode.FULL_DUPLEX;
microphone.enhancedOptions = enhancedOptions;
...

Example chat room using Red5 and Adobe Cirrus aka Stratus rendezvous service, i created for a small ActionScript 3 VideoChatAPI in February 2009.
I developed it for a collaboration software of Dorian. It's using the direct RTMFP peer to peer connection feature of Flash Player 10, the 10.1 multicast feature is not suitable in this case.