Долгое время freeswitch обладал фактически эксклюзивной и первой реализацией кодека OPUS. Для Asterisk существовали решения на gihub, но они имели ряд недостатков — не имели возможности настройки через codecs.conf и не использовали информацию из SDP для своей работы.
Во время проведения Astercon 2016 было объявлено что для asterisk 13 и 14 выпущен официальный модуль кодека OPUS.
Данный модуль кодека распространяется в бинарном виде и отправляет анонимную статистику использования на сервера Digium. Такое решение продиктовано лицензионными опасениями Digium и не должно доставить неудобств.
При установке из исходного кода достаточно:
- Установить необходимые пакеты (apt install xmlstarlet libcurl3)
- Выбираем модуль opus (make menuselect)
- Устанавливаем asterisk (make install)
После установки и загрузки можно просмотреть список параметров, которые для нового кодека можно настроить в codecs.conf:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
pbx1*CLI> config show help codec_opus opus opus: [category !~ /.?/] Codec opus module for Asterisk options type -- Must be of type 'opus' sample_rate -- Codec's sample rate. packet_loss -- Encoder's packet loss percentage. complexity -- Encoder's computational complexity. max_bandwidth -- Encoder's maximum bandwidth allowed. signal -- Encoder's signal type. application -- Encoder's application type. max_playback_rate -- Encoder's maximum playback rate. max_ptime -- Encoder's maximum packetization rate. ptime -- Encoder's packetization rate. bitrate -- Encoder's bit rate. cbr -- Encoder's constant bit rate value. fec -- Encoder's forward error correction value. dtx -- Encoder's discontinuous transmission value. |
Просмотреть возможные параметры для каждого конкретного параметра:
1 |
*CLI> config show help codec_opus opus max_bandwidth |
По умолчанию кодек opus настроен следующим образом (также сюда добавлены описания всех параметров):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
[opus] type = opus application = voip ; Encoder's application type. Values: voip (default), audio, low_delay bitrate = sdp ; Encoder's bit rate. ; Can be any number between 500 and 512000 as well as one of the following opus ; values: auto, max, sdp (default) ; When 'sdp' is specified the encoder is configured with the value given on the ; sdp. Choosing a default value of 'auto' if the format attribute is not found. cbr = sdp ; Encoder's constant bit rate value. ; True/False value where 0/false/no represents a variable bit rate and ; 1/true/yes is constant bit rate. Note, a special value of 'sdp' is also ; allowed. When 'sdp' is specified the encoder is configured with the value given ; on the sdp. Choosing a default value of 0 if the format attribute is not found. complexity = 10 ; Encoder's computational complexity. ; Can be any number between 0 and 10, inclusive. Note, 10 equals the highest complexity. fec = sdp ; Encoder's forward error correction value. ; True/False value where 0/false/no represents disabled and 1/true/yes is ; enabled. Note, a special value of 'sdp' is also allowed. When 'sdp' is ; specified the encoder is configured with the value given on the sdp. Choosing a ; default value of 0 if the format attribute is not found. max_bandwidth = full ; Encoder's maximum bandwidth allowed. ; Sets an upper bandwidth bound on the encoder. Can be any of the following: ; narrow, medium, wide, super_wide, full (default) max_playback_rate = sdp ; Encoder's maximum playback rate. ; Any value between 8000 and 48000, inclusive. Although typically it should ; match one of the usual Opus bandwidths. Note, a special value of 'sdp' is also ; allowed. When 'sdp' is specified the encoder is configured with the value given ; on the sdp. Choosing a default value of 48000 if the format attribute is not ; found. max_ptime = sdp ; Encoder's maximum packetization rate. ; The following values are allowed: 3, 5, 10, 20, 40, 60, or 120 (ms) Note, a ; special value of 'sdp' is also allowed. When 'sdp' is specified the encoder is ; configured with the value given on the sdp. Choosing a default value of 120 if ; the format attribute is not found. packet_loss = 0 ; Encoder's packet loss percentage. ; Can be any number between 0 and 100 (inclusive). Higher values result in a ; loss resistant behavior, however this has a cost on the quality (dependent upon ; a given bitrate). ptime = sdp ; Encoder's packetization rate. ; The following values are allowed: 3, 5, 10, 20, 40, 60, or 120 (ms) Note, a ; special value of 'sdp' is also allowed. When 'sdp' is specified the encoder is ; configured with the value given on the sdp. Choosing a default value 20 if the ; format attribute is not found. sample_rate = 48000 ;Codec's sample rate. ; Used to select the default codec. Must be either 8000, 16000, 48000. signal = auto ; Encoder's signal type. ; Aids in mode selection on the encoder: auto, voice, music dtx = sdp ;Encoder's discontinuous transmission value. ; True/False value where 0/false/no represents disabled and 1/true/yes is ;enabled. Note, a special value of 'sdp' is also allowed. When 'sdp' is ;specified the encoder is configured with the value given on the sdp. Choosing a ;default of 0 value if the format attribute is not found. |
Таким образом можно настроить несколько форматов одного кодека меняя имена секций и параметры кодека. Например вот так выглядит opus в narrowband режиме, который можно использовать как конкурента g729:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[opusnb] type = opus application = voip cbr = yes complexity = 10 fec = false max_bandwidth = narrow max_playback_rate = 8000 packet_loss = 20 ptime = 120 sample_rate = 8000 signal = voice dtx = sdp |
Оригинал: http://blog.iqtek.ru/?p=81