Archive for the 'pjmedia' Category

WebRTC Acoustic Echo Cancellation on PJSIP


Echo, unless you’re in a karaoke pub, is very annoying.

Over the years we have added support for various echo suppression and cancellation algorithm and libraries, like Speex and bdIMAD.

WebRTC, besides being a communications protocol on its own right, contains a powerful media component which in turn contains, among other things, acoustic echo cancellation algorithm implementation.

Try pjsip using WebRTC AEC on the development code by following the usage notes.

Eventually this will form part of 2.5 release (before you ask, no, we don’t have a definite timeframe for it).

Originally posted on

pjsip adds support for OpenCORE AMR-WB AMR-NB codec

Support for more codecs is an ongoing request for pjsip.

Here’s a couple of of new ones from the AMR family: AMR-NB and AMR-WB.

It’s not part of any release yet, you have to get the latest code from the repository.

More details on the following tickets:

Let us know how you get along with it.

Port Your PJSIP Engine to BlackBerry 10 in Less Than 10 minutes

[This is a guest post from Gurtej Sandhu, developer relations at RIM]

If you haven’t already heard, the BlackBerry 10 countdown is on. If you have an existing application using PJSIP libraries, this is your opportunity to port your pjsip open source stack to BlackBerry 10 in a matter of minutes. As you may have already heard, Bob Cripps has successfully ported PJSIP to BlackBerry 10. Just very recently Bob has helped simplify building PJSIP for BlackBerry 10 by creating a set of executable scripts. This work has now all been committed to our BlackBerry github repository.

I took this opportunity to dig deep into building PJSIP for BlackBerry 10. As soon as I had my Linux environment up and running with all the prerequisites installed, I am happy to say that it took me less than ten minutes to build and load PJSIP BlackBerry 10 Cascades sample project to my BlackBerry 10 Dev Alpha device. So please don’t try to reinvent the wheel – dive right into this github repository to port PJSIP to BlackBerry 10. Remember to follow the README instructions as they are very important. You can also follow the instructions in PJSIP porting guide knowledge base article.

If you run into any issues in porting PJSIP to BlackBerry 10 you can send me a tweet @_GurtejSandhu or write your comment below and I will be happy to assist.

Again, huge kudos to Bob Cripps for contributing his recent work in simplifying building PJSIP for BlackBerry 10.

Success stories:

BlackBerry 10 Development:

Related Posts

Call for Symbian S60 testers for pjmedia APS direct

As we finish the current iteration of Symbian S60 implementation, most
importantly the implementation of APS-direct, we need all of you to
participate in testing it. This is from experience we know mobile
devices are very tricky and can behave differently from one firmware
to another.

So we need as many Symbian S60 3rd Edition phone as possible. The test will involve installing a test application, checking a few things, and filling in a report form

To do this we need your IMEI and a few other details, this is because
the requirements of Symbian Signed, we need to ‘burn’ your IMEI into
our test application.

Don’t reply with your details to the public list, instead fill in this

We can’t promise everyone will be accepted, because there is a hard
limit to the number of IMEIs we can burn, and we’ll prioritize
variation of devices, rather than first come first serve.

If you can get your friends family neighbours to join in that will be
even better.

If you any questions, just leave a comment and.

Thank you all!

Analyzing the PJMEDIA Tone Generator Algorithms Performance

We have just finished some refactoring in the PJMEDIA tone generator, due to some problems identified by ticket 619. The main problem was the bad quality tone generated by the fixed-point sine generator algorithm, causing some failed detections by the remote end. While fixing this, we also addressed other problems such as noticeable thump noise at the beginning and the end of a tone, and difference in audio level produced by the fixed point compared to the floating point generator.

The results are these enhancements to the tone generator, implemented by ticket 619:

  • introduced a new fixed-point sine generator backend, based on the CORDIC algorithm. While this algorithm is generally slower than the existing fixed-point backend (although it is still faster than the floating-point algorithm on platforms that lack FP support), it does produce more precise output, and more importantly, the precision is tuneable so that application can balance between precision and speed.
  • made the backend algorithm selectable via compile time setting.
  • added fade-in and fade-out to the tone generation to eliminate/reduce the thump noise.

To verify these, we analyzed the performance (in terms of both speed and precision) of the various backends. To see the result, please see the Analyzing the PJMEDIA Tone Generator Algorithms Performance in our wiki page.

New low-complexity echo suppressor for mobile devices

As many have probably experienced it first hand, the echo suppressor (ES) in pjmedia sucks, to put it mildly. And this has made matters worse since ES plays such a major role in PDA’s and/or mobile devices/smartphones, since echoes are heavily present on these devices and we can’t really put the Accoustic Echo Canceller (AEC) on these devices due to the high processing requirements of the AEC (see our results in Evaluating PJMEDIA Performance article).

So we scrapped the old echo suppressor and wrote another one from scratch. And I think this one works quite well.

First of all, it’s low-complexity so it doesn’t require high processing requirements. We tested on a PocketPC 2003 PDA with 312MHz StrongARM CPU, it only uses less than 0.5% (half percent) of CPU. So it’s very affordable for these devices.

And most importantly, I think it works! It suppresses echo significantly, it lets non-echo audio pass through, and also it allows double-talk where both parties are talking at the same time. This is a very important to allow enjoyable conversation between two people, so we’ve made sure that the new echo suppressor supports this.

For those who care with the details, the ES works by comparing the audio level pattern in the input signal from the microphone with the audio level pattern in the playback signal during the learning process. It calculates the correlation values for each tail position up to the configured echo tail length, and finds out which tail position has the best correlation value. This position is then marked as the echo position. While doing this, the ES also notes the gain factors, that is how much de-amplification to be applied to the input signal in order to remove the echo from the input. Once the tail position is found, the ES then applies the appropriate gain factor according to the state of the conversation (e.g. I’m talking you’re silent, you’re silent I’m talking, we’re both talking, etc.).

This works pretty well. On the downside though, we noticed that the ES still seems to let a quiet echo to pass and transmitted back to remote party, depending on the signal level at the time. For now we allow this to happen since the echo level is very low and  doesn’t seem to be too annoying, and lacking enough experience with the new algorithm we don’t want to make it cut signals too aggressively yet since it may inadvertently cut the “good” signal.

The new echo suppressor is available in SVN as pjmedia/echo_suppress.c, and it will be included in the next release.

Evaluating PJMEDIA Performance

Performance is one of the most common questions that developers asked. We’ve been asked questions like, can I run X on platform Y, or how much MIPS required to run component X, and so far our answer would be I don’t know, or at best, why don’t you try it yourself and see what happens.

So we decided to do a bit of benchmarking for pjmedia for several platforms that we have, and you can see the result here:

The test covers various platforms, and sometimes the same H/W platform but different OS’es (Linux/gcc vs Windows/Visual Studio) to see how they fare, and of course various PJMEDIA components.

As the article says, there are some drawbacks about the test method used, but nevertheless I think it could be useful to see the rough CPU requirements of various PJMEDIA components. Certainly it has been useful to us, and in fact there have been some surprises with the results. For example, we expected that WSOLA (Waveform Similarity Overlap and Add, the algorithm that we use to conceal packet lost and to handle clock drifts) to take large chunks of CPU usage, but turns out it is quite fast. Also resampling with small filter looks to be quite affordable too.

We’ll look forward to measure the performance on more platforms (notably, Symbian), and we’ll keep track of the performance for future releases. In the meantime, enjoy the article.

Subscribe to blog updates

View Perry Ismangil's profile on LinkedIn