Menu

[howto] opus on raspbx 2018-04-04

2018-08-12
2018-09-12
  • Walter Sonius

    Walter Sonius - 2018-08-12

    UPDATE:2018-09-07
    RasPBX maintainer includes Opus & PLC support with Asterisk 13.23.0 upgrade on current Stretch based image!

    ORIGINALPOST:
    This howto will describe a solution to get opus translation (encode/decode) support along the already (dumb) passthrough format support in RasPBX 2018-04-04 (asterisk 13.22.0/freepbx 14.03.13). Extended features like Opus FEC(Forward error correction) / PLC(Packet loss concealment) may/will need additional patching not yet described/tested!

    With RasPBX its current implementation (2018-04-04) its only possible to make opus to opus calls, since translating from/to other codecs (g722>opus/opus>g722) misses the opus codec. Therefor features like conferences/musiconhold/queues/anouncements/etc with other native codec than opus will not work (silent).

    The multi cpu architecture supported Asterisk has a little different codebase for x86(pc-hardware) compared to arm(raspberry-pi) when it comes to Opus support. During the compiling of Asterisk on "x86" enabled with Opus support it will download pre-compiled x86 binaries from digium (since there is no source code included) and include it in your application. For "arm" these pre-compiled binaries are missing even so its source-code, so there is no easy/direct way of enabling opus and compile it. Searching different sourceforge discussions show that things are awkwardly missing.

    sohail
    Alaa
    Guido Harlow
    Guido Harlow

    It first looked impossible, but when noticing that there was a native debian arm asterisk-opus package in some repo I was convinced it was possible. Additional searching lead up to missing opus source code for asterisk on github and build instructions for freepbx for debian.
    First I tested it on debian8 x86-64 than on debian9 on x86-64 (php7 problems fixed by adding debian8 apt sources). Than tried it compiling again using the exact Asterisk version which RasPBX was using, also with success. Than I went to Raspbian 9 stretch lite on raspberry pi 3 (notice I'm still not talking RasPBX yet as a distro but pure debian/raspbian)! After some minor differences/changes it also started working. Than finally I tried to compile Asterisk on RasPBX 2018-04-04 and only copy the custom compiled "codec_opus_open_source.so" module to /usr/lib/asterisk/modules/, than enabled in FreePBX webinterface "checkbox opus codec" in asterisk_sip settings did a "fwconsole restart" which finally brought me to this modest successfull howto of today.

    There is probably a lot of optimization needed, since the beginning first couple of seconds in a call are bad quality but eventually the quality will maxout to 4.9. Also use 16bit sources of audio otherwise additional codec resampling 8>16bit viceversa has to be done. Tested with softphone linphone on both Ubuntu18.04 mate 64 and Apple IOS 10.

    In the second post a step by step guide is included, for freepbx on raspbian-lite (no RasPBX) which is just a combination of freepbx build plans and Alexander Traud its github page.

    In the third post a step by step guide for RasPBX is included.

    In the fourth posts just some thoughts/optimisation idea's.

    The following 'asterisk -r' console commands will be showed "before" and "after" adding opus opensource codec module:

    core show codecs
    core show translation
    module show like opus
    module show like codec_resample
    

    Before adding opus codec module:

    core show codecs
    Disclaimer: this command is for informational purposes only.
        It does not indicate anything about your configuration.
          ID TYPE  NAME         FORMAT           DESCRIPTION
    ------------------------------------------------------------------------------------------------
          30 image png          png              (PNG Image)
           5 audio g726         g726             (G.726 RFC3551)
           3 audio alaw         alaw             (G.711 a-law)
           1 audio g723         g723             (G.723.1)
          19 audio speex        speex            (SpeeX)
          20 audio speex        speex16          (SpeeX 16khz)
          21 audio speex        speex32          (SpeeX 32khz)
          23 audio g722         g722             (G722)
          24 audio siren7       siren7           (ITU G.722.1 (Siren7, licensed from Polycom))
          31 video h261         h261             (H.261 video)
          32 video h263         h263             (H.263 video)
           7 audio adpcm        adpcm            (Dialogic ADPCM)
          41 audio silk         silk8            (SILK Codec (8 KHz))
          42 audio silk         silk12           (SILK Codec (12 KHz))
          43 audio silk         silk16           (SILK Codec (16 KHz))
          44 audio silk         silk24           (SILK Codec (24 KHz))
          27 audio g719         g719             (ITU G.719)
          33 video h263p        h263p            (H.263+ video)
          34 video h264         h264             (H.264 video)
          18 audio g729         g729             (G.729A)
           8 audio slin         slin             (16 bit Signed Linear PCM)
           9 audio slin         slin12           (16 bit Signed Linear PCM (12kHz))
          10 audio slin         slin16           (16 bit Signed Linear PCM (16kHz))
          11 audio slin         slin24           (16 bit Signed Linear PCM (24kHz))
          12 audio slin         slin32           (16 bit Signed Linear PCM (32kHz))
          13 audio slin         slin44           (16 bit Signed Linear PCM (44kHz))
          14 audio slin         slin48           (16 bit Signed Linear PCM (48kHz))
          15 audio slin         slin96           (16 bit Signed Linear PCM (96kHz))
          16 audio slin         slin192          (16 bit Signed Linear PCM (192kHz))
           2 audio ulaw         ulaw             (G.711 u-law)
          17 audio lpc10        lpc10            (LPC10)
          26 audio testlaw      testlaw          (G.711 test-law)
          40 audio none         none             (<Null> codec)
          37 video vp9          vp9              (VP9 video)
          36 video vp8          vp8              (VP8 video)
           4 audio gsm          gsm              (GSM)
          35 video mpeg4        mpeg4            (MPEG4 video)
          22 audio ilbc         ilbc             (iLBC)
          38 text  red          red              (T.140 Realtime Text with redundancy)
          39 text  t140         t140             (Passthrough T.140 Realtime Text)
          28 audio opus         opus             (Opus Codec)
          29 image jpeg         jpeg             (JPEG image)
           6 audio g726aal2     g726aal2         (G.726 AAL2)
          25 audio siren14      siren14          (ITU G.722.1 Annex C, (Siren14, licensed from Polycom))
    
    core show translation
             Translation times between formats (in microseconds) for one second of data
              Source Format (Rows) Destination Format (Columns)
    
               ulaw  alaw   gsm  g726 g726aal2 adpcm slin8 slin12 slin16 slin24 slin32 slin44 slin48 slin96 slin192 lpc10 speex8 speex16 speex32  ilbc  g722 testlaw
         ulaw     -  9150 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000
         alaw  9150     - 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000
          gsm 15000 15000     - 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000
         g726 15000 15000 15000     -    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000
     g726aal2 15000 15000 15000 15000        - 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000
        adpcm 15000 15000 15000 15000    15000     -  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000
        slin8  6000  6000  6000  6000     6000  6000     -   8000   8000   8000   8000   8000   8000   8000    8000  6000   6000   14000   14000  6000  8250    6000
       slin12 14500 14500 14500 14500    14500 14500  8500      -   8000   8000   8000   8000   8000   8000    8000 14500  14500   14000   14000 14500 14000   14500
       slin16 14500 14500 14500 14500    14500 14500  8500   8500      -   8000   8000   8000   8000   8000    8000 14500  14500    6000   14000 14500  6000   14500
       slin24 14500 14500 14500 14500    14500 14500  8500   8500   8500      -   8000   8000   8000   8000    8000 14500  14500   14500   14000 14500 14500   14500
       slin32 14500 14500 14500 14500    14500 14500  8500   8500   8500   8500      -   8000   8000   8000    8000 14500  14500   14500    6000 14500 14500   14500
       slin44 14500 14500 14500 14500    14500 14500  8500   8500   8500   8500   8500      -   8000   8000    8000 14500  14500   14500   14500 14500 14500   14500
       slin48 14500 14500 14500 14500    14500 14500  8500   8500   8500   8500   8500   8500      -   8000    8000 14500  14500   14500   14500 14500 14500   14500
       slin96 14500 14500 14500 14500    14500 14500  8500   8500   8500   8500   8500   8500   8500      -    8000 14500  14500   14500   14500 14500 14500   14500
      slin192 14500 14500 14500 14500    14500 14500  8500   8500   8500   8500   8500   8500   8500   8500       - 14500  14500   14500   14500 14500 14500   14500
        lpc10 15000 15000 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000     -  15000   23000   23000 15000 17250   15000
       speex8 15000 15000 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000      -   23000   23000 15000 17250   15000
      speex16 23500 23500 23500 23500    23500 23500 17500  17500   9000  17000  17000  17000  17000  17000   17000 23500  23500       -   23000 23500 15000   23500
      speex32 23500 23500 23500 23500    23500 23500 17500  17500  17500  17500   9000  17000  17000  17000   17000 23500  23500   23500       - 23500 23500   23500
         ilbc 15000 15000 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000     - 17250   15000
         g722 15600 15600 15600 15600    15600 15600  9600  17500   9000  17000  17000  17000  17000  17000   17000 15600  15600   15000   23000 15600     -   15600
      testlaw 15000 15000 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250       -
    
    module show like opus
    Module                         Description                              Use Count  Status      Support Level
    res_format_attr_opus.so        Opus Format Attribute Module             1          Running              core
    1 modules loaded
    
    module show like codec_resample
    Module                         Description                              Use Count  Status      Support Level
    codec_resample.so              SLIN Resampling Codec                    0          Running              core
    1 modules loaded
    

    After adding opus codec module support:

    Disclaimer: this command is for informational purposes only.
        It does not indicate anything about your configuration.
          ID TYPE  NAME         FORMAT           DESCRIPTION
    ------------------------------------------------------------------------------------------------
          30 image png          png              (PNG Image)
           5 audio g726         g726             (G.726 RFC3551)
           3 audio alaw         alaw             (G.711 a-law)
           1 audio g723         g723             (G.723.1)
          19 audio speex        speex            (SpeeX)
          20 audio speex        speex16          (SpeeX 16khz)
          21 audio speex        speex32          (SpeeX 32khz)
          23 audio g722         g722             (G722)
          24 audio siren7       siren7           (ITU G.722.1 (Siren7, licensed from Polycom))
          31 video h261         h261             (H.261 video)
          32 video h263         h263             (H.263 video)
           7 audio adpcm        adpcm            (Dialogic ADPCM)
          41 audio silk         silk8            (SILK Codec (8 KHz))
          42 audio silk         silk12           (SILK Codec (12 KHz))
          43 audio silk         silk16           (SILK Codec (16 KHz))
          44 audio silk         silk24           (SILK Codec (24 KHz))
          27 audio g719         g719             (ITU G.719)
          33 video h263p        h263p            (H.263+ video)
          34 video h264         h264             (H.264 video)
          18 audio g729         g729             (G.729A)
           8 audio slin         slin             (16 bit Signed Linear PCM)
           9 audio slin         slin12           (16 bit Signed Linear PCM (12kHz))
          10 audio slin         slin16           (16 bit Signed Linear PCM (16kHz))
          11 audio slin         slin24           (16 bit Signed Linear PCM (24kHz))
          12 audio slin         slin32           (16 bit Signed Linear PCM (32kHz))
          13 audio slin         slin44           (16 bit Signed Linear PCM (44kHz))
          14 audio slin         slin48           (16 bit Signed Linear PCM (48kHz))
          15 audio slin         slin96           (16 bit Signed Linear PCM (96kHz))
          16 audio slin         slin192          (16 bit Signed Linear PCM (192kHz))
           2 audio ulaw         ulaw             (G.711 u-law)
          17 audio lpc10        lpc10            (LPC10)
          26 audio testlaw      testlaw          (G.711 test-law)
          40 audio none         none             (<Null> codec)
          37 video vp9          vp9              (VP9 video)
          36 video vp8          vp8              (VP8 video)
           4 audio gsm          gsm              (GSM)
          35 video mpeg4        mpeg4            (MPEG4 video)
          22 audio ilbc         ilbc             (iLBC)
          38 text  red          red              (T.140 Realtime Text with redundancy)
          39 text  t140         t140             (Passthrough T.140 Realtime Text)
          28 audio opus         opus             (Opus Codec)
          29 image jpeg         jpeg             (JPEG image)
           6 audio g726aal2     g726aal2         (G.726 AAL2)
          25 audio siren14      siren14          (ITU G.722.1 Annex C, (Siren14, licensed from Polycom))
             Translation times between formats (in microseconds) for one second of data
              Source Format (Rows) Destination Format (Columns)
    
               ulaw  alaw   gsm  g726 g726aal2 adpcm slin8 slin12 slin16 slin24 slin32 slin44 slin48 slin96 slin192 lpc10 speex8 speex16 speex32  ilbc  g722 testlaw  opus
         ulaw     -  9150 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000 15000
         alaw  9150     - 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000 15000
          gsm 15000 15000     - 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000 15000
         g726 15000 15000 15000     -    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000 15000
     g726aal2 15000 15000 15000 15000        - 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000 15000
        adpcm 15000 15000 15000 15000    15000     -  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250   15000 15000
        slin8  6000  6000  6000  6000     6000  6000     -   8000   8000   8000   8000   8000   8000   8000    8000  6000   6000   14000   14000  6000  8250    6000  6000
       slin12 14500 14500 14500 14500    14500 14500  8500      -   8000   8000   8000   8000   8000   8000    8000 14500  14500   14000   14000 14500 14000   14500  5999
       slin16 14500 14500 14500 14500    14500 14500  8500   8500      -   8000   8000   8000   8000   8000    8000 14500  14500    6000   14000 14500  6000   14500  5999
       slin24 14500 14500 14500 14500    14500 14500  8500   8500   8500      -   8000   8000   8000   8000    8000 14500  14500   14500   14000 14500 14500   14500  5999
       slin32 14500 14500 14500 14500    14500 14500  8500   8500   8500   8500      -   8000   8000   8000    8000 14500  14500   14500    6000 14500 14500   14500 13999
       slin44 14500 14500 14500 14500    14500 14500  8500   8500   8500   8500   8500      -   8000   8000    8000 14500  14500   14500   14500 14500 14500   14500 13999
       slin48 14500 14500 14500 14500    14500 14500  8500   8500   8500   8500   8500   8500      -   8000    8000 14500  14500   14500   14500 14500 14500   14500  5999
       slin96 14500 14500 14500 14500    14500 14500  8500   8500   8500   8500   8500   8500   8500      -    8000 14500  14500   14500   14500 14500 14500   14500 14499
      slin192 14500 14500 14500 14500    14500 14500  8500   8500   8500   8500   8500   8500   8500   8500       - 14500  14500   14500   14500 14500 14500   14500 14499
        lpc10 15000 15000 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000     -  15000   23000   23000 15000 17250   15000 15000
       speex8 15000 15000 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000      -   23000   23000 15000 17250   15000 15000
      speex16 23500 23500 23500 23500    23500 23500 17500  17500   9000  17000  17000  17000  17000  17000   17000 23500  23500       -   23000 23500 15000   23500 14999
      speex32 23500 23500 23500 23500    23500 23500 17500  17500  17500  17500   9000  17000  17000  17000   17000 23500  23500   23500       - 23500 23500   23500 22999
         ilbc 15000 15000 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000     - 17250   15000 15000
         g722 15600 15600 15600 15600    15600 15600  9600  17500   9000  17000  17000  17000  17000  17000   17000 15600  15600   15000   23000 15600     -   15600 14999
      testlaw 15000 15000 15000 15000    15000 15000  9000  17000  17000  17000  17000  17000  17000  17000   17000 15000  15000   23000   23000 15000 17250       - 15000
         opus 15000 15000 15000 15000    15000 15000  9000   8999   8999   8999  16999  16999   8999  16999   16999 15000  15000   14999   22999 15000 14999   15000     -
    Module                         Description                              Use Count  Status      Support Level
    codec_opus_open_source.so      Opus Coder/Decoder                       0          Running           unknown
    res_format_attr_opus.so        Opus Format Attribute Module             1          Running              core
    2 modules loaded
    raspbx*CLI> module show like codec_resample
    Module                         Description                              Use Count  Status      Support Level
    codec_resample.so              SLIN Resampling Codec                    0          Running              core
    1 modules loaded
    

    Example of RasPBX webinterface Asterisk Info log showing a active conference room call with two extensions which hear Announcements and Music On hold or talk to each other, which can be paused on both sides to test moh/interruption/resample/resume:

    Chan_Sip Info
    Chan_Sip Channel(s)
    
    Peer             User/ANR         Call ID          Format           Hold     Last Message    Expiry     Peer      
    192.168.90.254   301              1154109372       (opus)           No       Rx: ACK                    301       
    192.168.90.249   302              8-JL02Cdux       (ulaw)           No       Rx: ACK                    302       
    2 active SIP dialogs
    
     

    Last edit: Walter Sonius 2018-09-12
  • Walter Sonius

    Walter Sonius - 2018-08-12

    Notice:
    The following steps we're needed on pure raspbian-lite 9 stretch not RasPBX, doing these steps on RasPBX will install additional database and other unneeded/conflicting packages and slow down RasPBX hugly! Its actually a replacement of RasPBX, if you do all steps. RasPBX only steps will follow in post 3, along side further improvements.

    So this is just a prove of concept, its a good idea to compile it on a seperate SDCARD and copy back the needed module(s) to your current RasPBX system, that way it will stay fast/clean.

    Most of these steps are from Alexander Traud github page and FreePBX documentation.

    sudo apt-get update
    sudo apt-get upgrade
    sudo raspi-config #timezone
    sudo nano /etc/apt/sources.list
    #deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
    sudo apt-get update
    apt-get install -y openssh-server apache2 mysql-server mysql-client mongodb bison flex php5 php5-curl php5-cli php5-mysql php-pear php5-gd curl sox libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev libspandsp-dev sudo libmyodbc subversion libtool-bin python-dev dirmngr tcpdump nmap vlan net-tools libopus-dev libopusfile-dev build-essential autoconf libssl-dev libncurses-dev libnewt-dev libxml2-dev libsqlite3-dev uuid-dev libjansson-dev libblocksruntime-dev xmlstarlet
    
    #pdo_mysql driver error choose php5 instead php7!
    sudo update-alternatives --config php
    
    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
    sudo apt-get install -y nodejs
    
    #continue rest as root user
    sudo -s
    pear install Console_Getopt
    
    cd /usr/src
    #wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-14-current.tar.gz
    #http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-13.22.0.tar.gz
    #raspbx version???
    wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13.22.0.tar.gz
    wget -O jansson.tar.gz https://github.com/akheron/jansson/archive/v2.7.tar.gz
    
    cd /usr/src
    tar vxfz jansson.tar.gz
    rm -f jansson.tar.gz
    cd jansson-*
    autoreconf -i
    ./configure
    make
    make install
    
    cd /usr/src
    tar xvfz asterisk-13.22.0.tar.gz
    rm -f asterisk-13.22.0.tar.gz
    cd asterisk-13.22.0
    contrib/scripts/get_mp3_source.sh
    contrib/scripts/install_prereq install #pkgconfig conflict
    #phone countrycode libvpb1 austrialia 61 > nl 31
    
    wget github.com/traud/asterisk-opus/archive/asterisk-13.7.tar.gz
    tar zxf asterisk-13.7.tar.gz
    rm asterisk-13.7.tar.gz
    cp --verbose asterisk-opus*/include/asterisk/* include/asterisk
    cp --verbose asterisk-opus*/codecs/* codecs
    cp --verbose asterisk-opus*/res/* res
    
    ./configure --with-pjproject-bundled
    
    #configure: WARNING: "CPU armv7l not recognized - proceed with caution!"
    #configure: Package configured for: 
    #configure: OS type  : linux-gnueabihf
    #configure: Host CPU : armv7l
    #configure: build-cpu:vendor:os: armv7l : unknown : linux-gnueabihf :
    #configure: host-cpu:vendor:os: armv7l : unknown : linux-gnueabihf :
    
    make menuselect #enable Add-ons > format_mp3 / Codec Translators > --Unspecified-- codec_opus_open_source / last 3 menu items > SLN16 
    make -j4
    
    ###Stop here if you are on RasPBX instead of Raspbian-lite
    make install
    make config
    ldconfig
    update-rc.d -f asterisk remove
    
    useradd -m asterisk
    chown asterisk. /var/run/asterisk
    chown -R asterisk. /etc/asterisk
    chown -R asterisk. /var/{lib,log,spool}/asterisk
    chown -R asterisk. /usr/lib/asterisk
    rm -rf /var/www/html
    
    sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.ini
    cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
    sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
    sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
    service apache2 restart
    
    cat >> /etc/odbcinst.ini << EOF
    [MySQL]
    Description = ODBC for MySQL
    Driver = /usr/lib/arm-linux-gnueabihf/odbc/libmyodbc.so
    Setup = /usr/lib/arm-linux-gnueabihf/odbc/libodbcmyS.so
    FileUsage = 1
    
    EOF
    
    cat >> /etc/odbc.ini << EOF
    [MySQL-asteriskcdrdb]
    Description=MySQL connection to 'asteriskcdrdb' database
    driver=MySQL
    server=localhost
    database=asteriskcdrdb
    Port=3306
    Socket=/var/run/mysqld/mysqld.sock
    option=3
    
    EOF
    
    cd /usr/src
    wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-14.0-latest.tgz
    tar vxfz freepbx-14.0-latest.tgz
    rm -f freepbx-14.0-latest.tgz
    cd freepbx
    touch /etc/asterisk/ari.conf
    ./start_asterisk start
    sleep 15
    ./install -n
    
    a2enmod rewrite
    service apache2 restart
    
    #After reboot pi
    fwconsole start
    Asterisk>Advanced settings> conference confbridgen>netme sub apply netme>confbrige sub apply
    

    Getting the build related packages only and following the asterisk compile instructions until "make -j4" will leave you with the following files after successfull build, don't do make install on RasPBX:

    ls -l codecs/*opus*.so
    -rwxr-xr-x 1 root root 245016 Aug 12 00:30 codecs/codec_opus_open_source.so
    ls -l res/*opus*.so
    -rwxr-xr-x 1 root root 207884 Aug 12 00:40 res/res_format_attr_opus.so
    

    By only copying "codec_opus_open_source.so" to your current "/usr/lib/asterisk/modules" folder and enabling Opus checkbox in freepbx sip settings webinterface and restarting the system made it work.

    If you only copy the codec module to a clean RasPBX system make sure its updated and using the same versions as the one you compiled for, no other packages are needed see attachment post 3.

     

    Last edit: Walter Sonius 2018-08-15
  • Walter Sonius

    Walter Sonius - 2018-08-12

    RasPBX 18-04-04 only steps, probably still more packages than needed but it works all steps may require less than an hour on Pi3:

    raspi-config #enlarge boot partition 7>A1 & reboot
    
    raspbx-upgrade #will update asterisk to 13.22.0
    #press 'y' and 'q' when asked
    #don't forget to update FreePBX modules from the webinterface aswell!
    #Admin>Module Admin> "Check Online / Upgrade all / Process / Confirm" or
    #fwconsole ma upgradeall
    
    apt-get install bison flex php5 php5-curl php5-cli php5-mysql php-pear php5-gd curl sox libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev automake libtool autoconf git unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev libspandsp-dev libmyodbc libtool-bin python-dev dirmngr libopus-dev libopusfile-dev build-essential autoconf libssl-dev libncurses-dev libnewt-dev libxml2-dev libsqlite3-dev uuid-dev libjansson-dev libblocksruntime-dev xmlstarlet
    
    cd /usr/src
    wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13.22.0.tar.gz
    tar xvfz asterisk-13.22.0.tar.gz
    rm -f asterisk-13.22.0.tar.gz
    cd asterisk-13.22.0
    contrib/scripts/get_mp3_source.sh
    contrib/scripts/install_prereq install #pkgconfig conflict
    #phone countrycode austrialia 61 > nl 31 > your country?
    
    wget github.com/traud/asterisk-opus/archive/asterisk-13.7.tar.gz
    tar zxf asterisk-13.7.tar.gz
    rm asterisk-13.7.tar.gz
    cp --verbose asterisk-opus*/include/asterisk/* include/asterisk
    cp --verbose asterisk-opus*/codecs/* codecs
    cp --verbose asterisk-opus*/res/* res
    
    ./configure --with-pjproject-bundled
    
    make menuselect #enable / Add-ons > format_mp3 / Codec Translators > --Unspecified-- codec_opus_open_source 
    make -j4 #On pi3 takes about 20 Minutes
    
    md5sum codecs/codec_opus_open_source.so 30de7a431a273ff66d4b71d0542132fb
    cp codecs/codec_opus_open_source.so /usr/lib/asterisk/modules/
    
    #FreePBXwebinterface
    Settings> Asterisk IAX/SIP settings > "Codec Settings/Codecs" 
    Checkbox opus
    
    #ssh / console
    fwconsole restart
    
    asterisk -r # check output of following commands
    core show codecs
    core show translation
    module show like opus
    module show like codec_resample
    

    Now its time to setup a conference room with some music on hold and two extensions each using a other codec. Only tested sip protocol.

    PS:Also previous Debian 8 Jessie based version of RasPBX with FreePBX 13.0.195.4 / asterisk 13.17.1 works with these steps. However it requires its own Asterisk version specific opus module. See attachments:

    md5sum codecs/codec_opus_open_source.so 1c43a27ac3ff86b2514c4b471524d64f
    
     

    Last edit: Walter Sonius 2018-08-24
    • D.K.

      D.K. - 2018-08-23

      @Walter Sonius 👍
      Thanks for your excellent guide. It worked for me.
      Tried on pi2 (home) and pi3 (remote). What I did:
      Downloaded the module “codec_opus_open_source.so” that you have provided.
      cd /usr/lib/asterisk/modules/
      wget https://sourceforge.net/p/raspbx/discussion/tutorials/thread/855b8b02/c915/attachment/codec_opus_open_source.so

      Enabled the Opus codec in FreePBX, > Setting > Asterisk Sip Setting > General Sip Setting > Audio Codec.
      And finally
      fwconsole restart

      Tested using Jitsi on Mac and Linphone on iPhone. 🙌

       
      • Walter Sonius

        Walter Sonius - 2018-08-24

        Good to hear you got it working and thanks for summarizing the steps.

         
  • Gernot

    Gernot - 2018-09-07

    Finally, with the help of Walter's amazing instructions, the Opus codec has found it's way into the RasPBX Asterisk build. With version 13.23.0 the codec_opus_opensource.so module is included in the asterisk13 package. Users get it automatically when upgrading a Stretch based image.
    When building the module I've also applied the experimental PLC patch to Asterisk. According to some user comments this patch might have undesired effects on other codecs. In case anyone has problems please report them here. If necessary, I can disable the patch again on one of the next builds.

    Thanks again to Walter for his very detailed instructions, which made it easy for me to add the module.

     
    • Walter Sonius

      Walter Sonius - 2018-09-12

      Thanks for including support in current RasPBX build, especially Alexander Traud for his detailed and updated github page. I wouldn't have done it without it.

      I do have to test though if upgrading to a newer Asterisk will overwrite custom compiled opus module or just reject the old one since it has a different version fingerprint?

       

Log in to post a comment.