Giter VIP home page Giter VIP logo

asterisk-amr's Introduction

Asterisk patch for AMR and AMR-WB

To add a codec for SIP/SDP (m=, rtmap, and ftmp), you create a format module in Asterisk: codec_amr.patch (for m= and rtmap) and res/res_format_attr_amr.c (for fmtp). However, this requires both call legs to support AMR (pass-through only). If one leg does not support AMR, the call has no audio. Or, if you use the pre-recorded voice and music files of Asterisk, these files cannot be heard, because they are not in AMR but in slin. Therefore, this repository adds not just a format module for the audio-codecs AMR and AMR-WB but a transcoding module as well: codecs/codec_amr.c.

This is an implementation of IETF RFC 4867. Sometimes, AMR is called AMR Narrowband (AMR-NB). AMR Wideband (ITU-T Recommendation G.722.2) is sometimes abbreviated W-AMR (GSA). GSMA Mobile HD Voice is AMR-WB. Research papers comparing AMR and AMR-WB with other audio codecs: InterSpeech 2010, ICASSP 2010, InterSpeech 2011. Further examples…

This patch is for Asterisk 13. If you use an older version of Asterisk, and AMR without AMR-WB is sufficient in your case, please, have a look at those patches:

Installing the patch

The patch was built on top of Asterisk 13.10. If you use a newer version and the patch fails, please, report!

cd /usr/src/
wget downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar zxf ./asterisk*
cd ./asterisk*
sudo apt-get --assume-yes install build-essential autoconf libssl-dev libncurses-dev libnewt-dev libxml2-dev libsqlite3-dev uuid-dev libjansson-dev libblocksruntime-dev

Install libraries:

If you do not want transcoding but pass-through only (because of license issues) please, skip this step. To support transcoding, you’ll need to install OpenCORE AMR, for example in Debian/Ubuntu:

sudo apt-get --assume-yes install libopencore-amrnb-dev libopencore-amrwb-dev libvo-amrwbenc-dev

Apply all patches:

wget github.com/traud/asterisk-amr/archive/master.zip
unzip -qq master.zip
rm master.zip
cp --verbose --recursive ./asterisk-amr*/* ./
patch -p0 <./codec_amr.patch
patch -p0 <./build_tools.patch

Run the bootstrap script to re-generate configure:

./bootstrap.sh

Configure your patched Asterisk:

./configure

Enable slin16 in menuselect for transcoding, for example via:

make menuselect.makeopts
./menuselect/menuselect --enable-category MENUSELECT_CORE_SOUNDS

Compile and install:

make
sudo make install

Testing

You can test AMR-WB out of the box using

A. (Google Android) CSipSimple

B. (Google Android) CounterPath Bria

C. (Apple iOS) CounterPath Bria

D. (Windows Phone 8) Linphone

On ingress, this module supports the octet-aligned mode and the bandwidth-efficient mode. Currently on egress, only the bandwidth-efficient mode is advertised when transcoding. However, if the originating party supports AMR, it’s mode is passed transparently. Because Linphone supports only the octet-aligned mode, but does not honor the line fmtp in SDP, the mode is not negotiated correctly and ingress calls create distorted audio in Linphone. This bug is reported to the Linphone team. However, these VoIP/SIP clients offer G.722 and Opus, which should be used for wide-band audio instead. G.722 transcoding is build into Asterisk already. Opus can be added as transcoding module…

Actually, this repository was created for Nokia Mobile Phones which support AMR (since the year 2006) and AMR-WB (since the year 2009) in VoIP/SIP, like:

What is missing

This transcoding module is shoddy work. Therefore, please, double-check the source of codecs/codec_amr.c for any feature you need. For example IETF RFC 4867 offers frame CRC, robust sorting and interleaving. If you need this, please, add that code or report the device/app which requires this. I simply do not have a testing device for this. Several AMR frames per payload (compound payload) are another issue, for example when FEC or a packetization time (ptime) longer than 20 ms are used. The transcoding module works for me and contains everything I need. If you cannot code yourself, however, a feature is missing for you, please, report and send me at least a testing device.

Thanks goes to

  • teams of the Android Open Source Project (AOSP), OpenCORE AMR, Debian Multimedia, and Ubuntu for providing the libraries.
  • Asterisk team: Thanks to their efforts and architecture this AMR module was written in one working day.
  • Sean Bright provided the starting point with his Opus patch.
  • Юрий Остапчук provided an code example for the bandwidth-efficient mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.