OpenCore AMR codecs integration

This page describes how to add OpenCORE AMR-NB and AMR-WB support into PJSIP.

Building and Installing OpenCORE AMR Library

This instruction applies for all platforms that OpenCORE supports, including Windows. For Windows, you need to use MinGW to build the OpenCORE library.

We tested building the OpenCORE libraries for Linux, MacOS X, Windows (MinGW), and BlackBerry 10 (BB10).

Installing OpenCore binaries

You may install from the binaries packages if they are available for your platform.

Debian/Ubuntu:

$ sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev libvo-amrwbenc-dev

Building and installing from source

If binaries are not available or preferred, you must build and install OpenCore libraries from the source:

  1. Download the latest opencore-amr tarball. We tested with version 0.1.3.

  2. Unpack the tarballs to a directory:

    $ cd my_build_directory
    $ tar xzf opencore-amr-0.1.3.tar.gz
    $
    
  3. Run configure. Add --prefix to install the library to an alternate directory (such as your home folder) instead of to the system wide /usr directory:

    $ ./configure --prefix=/home/foo
    
  4. Obsolete: Or if you’re building for BB10, then download generic-configure-bb10 script in the attachment in the bottom of this page, copy it to the opencore-amr directory, and use it instead. Make sure BB10 environment variables have been set as per BB10 instructions.

    $ chmod +x generic-configure-bb10
    $ ./generic-configure-bb10 --prefix=/home/foo
    
  5. Build and install:

    make && make install
    

Adding AMR-WB Support

The OpenCORE AMR tarball contains AMR-NB encoder and decoder, but only AMR-WB decoder. We have to install AMR-WB encoder separately:

  1. Download the latest vo-amrwbenc tarball. We tested with version 0.1.3

  2. Unpack the tarballs to a directory:

    $ cd my_build_directory
    $ tar xzf vo-amrwbenc-0.1.3.tar.gz
    $
    
  3. Run configure. If you use --prefix, make sure it has the same prefix as the one you used when configuring opencore-amr library:

    $ ./configure --prefix=/home/foo
    
  4. Obsolete: Again if you’re building for BB10, then download generic-configure-bb10 script in the attachment in the bottom of this page, copy it to the opencore-amr directory, and use it instead:

    $ chmod +x generic-configure-bb10
    $ ./generic-configure-bb10 --prefix=/home/foo
    
  5. Build and install:

    $ make && make install
    

Testing The Installation

To verify, make sure include directory in the installation directory contains these files. Suppose you use --prefix=/home/foo, then:

$ ls /home/foo/include
  opencore-amrnb  opencore-amrwb  vo-amrwbenc

Adding AMR Support in PJSIP

Make Build System (MacOS X, Linux, BB10, etc.)

  1. In the pjproject directory, run configure script, optionally specifying the installation directory of OpenCORE codec with --with-opencore-amr option:

    $ ./configure --with-opencore-amr=/home/foo
    
  2. Obsolete: Or if you’re building for BB10, then use configure-bb10 instead. See Getting Started for BB10 instructions for the complete instructions on how to build PJSIP for BB10:

    $ ./configure-bb10 --with-opencore-amr=/home/foo
    
  3. Check the output of configure command, make sure that the codecs are detected:

    checking for OpenCORE AMR installations..
    Using OpenCORE AMR prefix... /home/foo
    ...
    ...
    OpenCORE AMR-NB library found, AMR-NB support enabled
    ...
    ...
    OpenCORE AMR-WB library found, AMR-WB support enabled
    
  4. If the codecs are not enabled, that means the configure script were unable to find some files in the specified directory. Check the screen output again to see what were missing, and rebuild or reinstall the OpenCORE libraries if necessary.

  5. Build PJSIP:

    $ make dep && make clean && make
    
  6. PJSIP is now built with OpenCORE AMR support

Windows

  1. Add your installed OpenCORE directories to Visual Studio include and lib paths. You should know how to do this.

  2. Configure and build pjsip with Visual Studio:

    1. Download the latest pjproject

    2. Add this to your config_site.h:

      #define PJMEDIA_HAS_OPENCORE_AMRNB_CODEC 1
      /* And if you want to have AMR-WB support: */
      #define PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 1
      
    3. Build the pjproject solution.

    4. The AMR-NB (and AMR-WB) codecs are now available ready to be used.

    Note

    On MSVC, there may be linking error such as:

    unresolved external symbol ___chkstk referenced in function _coder
    

    A possible solution is by manually appending _chkstk.o to libvo-amrwbenc.a:

    $ cd <path-to-libvo-amrwbenc.a>
    $ ar x <path-to>/libgcc.a _chkstk.o
    $ ar q libvo-amrwbenc.a _chkstk.o
    

Testing PJSIP For OpenCORE AMR Support

  1. Run pjsua

  2. List the codecs with Cp command from pjsua console:

    >>> Cp
    List of audio codecs:
      ...
      127     AMR/8000/1
      128     AMR-WB/8000/1
      ...
    
    List of video codecs:
      ...
    
    Enter codec id and its new priority (e.g. "speex/16000 200", "H263 200"),
    or empty to cancel.
    Codec name ("*" for all) and priority:
    Done
    >>>