{"id":1246,"date":"2018-08-10T18:04:34","date_gmt":"2018-08-10T13:04:34","guid":{"rendered":"http:\/\/alexeyka.zantsev.com\/?p=1246"},"modified":"2019-10-29T16:14:12","modified_gmt":"2019-10-29T11:14:12","slug":"opensips-and-rtpengine","status":"publish","type":"post","link":"https:\/\/alexeyka.zantsev.com\/?p=1246","title":{"rendered":"OpenSIPS and rtpengine"},"content":{"rendered":"<p>Draft for myself<\/p>\n<p>https:\/\/github.com\/sipwise\/rtpengine<\/p>\n<p><code>root@debian-opensips:~\/rtpengine-mr6.3.1# dpkg-checkbuilddeps<br \/>\ndpkg-checkbuilddeps: error: Unmet build dependencies: debhelper (&gt;= 10~) iptables-dev (&gt;= 1.4) libavcodec-dev (&gt;= 6:10) libavfilter-dev (&gt;= 6:10) libavformat-dev (&gt;= 6:10) libavutil-dev (&gt;= 6:10) libbcg729-dev libcurl4-openssl-dev | libcurl4-gnutls-dev | libcurl3-openssl-dev | libcurl3-gnutls-dev libevent-dev (&gt;= 2.0) libglib2.0-dev (&gt;= 2.30) libhiredis-dev libjson-glib-dev libpcap0.8-dev | libpcap-dev libpcre3-dev libswresample-dev (&gt;= 6:10) libxmlrpc-c3-dev (&gt;= 1.16.07) | libxmlrpc-core-c3-dev (&gt;= 1.16.07) markdown<\/code><\/p>\n<p><code>debhelper iptables-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev libbcg729-dev libcurl4-openssl-dev | libcurl4-gnutls-dev | libcurl3-openssl-dev | libcurl3-gnutls-dev libevent-dev libglib2.0-dev libhiredis-dev libjson-glib-dev libpcap0.8-dev | libpcap-dev libpcre3-dev libswresample-dev libxmlrpc-c3-dev | libxmlrpc-core-c3-dev markdown<\/code><\/p>\n<p>Desided to install all:<\/p>\n<p><code>root@debian-opensips:~\/rtpengine-mr6.3.1# apt install debhelper iptables-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev libbcg729-dev libcurl4-openssl-dev libcurl4-gnutls-dev libevent-dev libglib2.0-dev libhiredis-dev libjson-glib-dev libpcap0.8-dev libpcap-dev libpcre3-dev libswresample-dev libxmlrpc-c3-dev libxmlrpc-core-c3-dev markdown<br \/>\nReading package lists... Done<br \/>\nBuilding dependency tree<br \/>\nReading state information... Done<br \/>\nNote, selecting 'libcurl4-openssl-dev' instead of 'libcurl3-openssl-dev'<br \/>\nNote, selecting 'libcurl4-gnutls-dev' instead of 'libcurl3-gnutls-dev'<br \/>\nE: Unable to locate package libbcg729-dev<br \/>\nE: Unable to locate package libxmlrpc-c3-dev<\/code><\/p>\n<p><code>root@debian-opensips:~\/rtpengine-mr6.3.1# apt install debhelper iptables-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev libbcg729-dev libcurl4-openssl-dev libcurl4-gnutls-dev libevent-dev libglib2.0-dev libhiredis-dev libjson-glib-dev libpcap0.8-dev libpcap-dev libpcre3-dev libswresample-dev libxmlrpc-c3-dev libxmlrpc-core-c3-dev markdown<\/code><\/p>\n<p>Download from here https:\/\/deb.sipwise.com\/spce\/mr6.2.1\/pool\/main\/b\/bcg729\/ , instruction about this is here https:\/\/github.com\/sipwise\/rtpengine\/tree\/mr6.3.1<br \/>\nin &#8216;G.729 support&#8217; chapter.<\/p>\n<p><code>root@debian-opensips:~\/rtpengine-mr6.3.1# wget https:\/\/deb.sipwise.com\/spce\/mr6.2.1\/pool\/main\/b\/bcg729\/libbcg729-0_1.0.4+git20180222-0.1~bpo9+1_amd64.deb<br \/>\nroot@debian-opensips:~\/rtpengine-mr6.3.1# wget https:\/\/deb.sipwise.com\/spce\/mr6.2.1\/pool\/main\/b\/bcg729\/libbcg729-dev_1.0.4+git20180222-0.1~bpo9+1_amd64.deb<\/code><\/p>\n<p>Install<br \/>\n<code>root@debian-opensips:~\/rtpengine-mr6.3.1# dpkg -i libbcg729-0_1.0.4+git20180222-0.1~bpo9+1_amd64.deb<br \/>\nroot@debian-opensips:~\/rtpengine-mr6.3.1# dpkg -i libbcg729-dev_1.0.4+git20180222-0.1~bpo9+1_amd64.deb <\/code><\/p>\n<p>Try to install all again:<br \/>\n<code>root@debian-opensips:~\/rtpengine-mr6.3.1# apt install debhelper iptables-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev libbcg729-dev libcurl4-openssl-dev libcurl4-gnutls-dev libevent-dev libglib2.0-dev libhiredis-dev libjson-glib-dev libpcap0.8-dev libpcap-dev libpcre3-dev libswresample-dev libxmlrpc-c3-dev libxmlrpc-core-c3-dev markdown<br \/>\nReading package lists... Done<br \/>\nBuilding dependency tree<br \/>\nReading state information... Done<br \/>\nE: Unable to locate package libxmlrpc-c3-dev<\/code><\/p>\n<p>Trying to install these pkgs:<br \/>\n<code>\tlibxmlrpc-core-c3 libxmlrpc-core-c3-dev<\/code><\/p>\n<p>No such a package in Debian!(( libxmlrpc-c3-dev , trying without it&#8230;<\/p>\n<p>Trying without it and get an error:<\/p>\n<p><code>The following packages have unmet dependencies:<br \/>\nlibcurl4-gnutls-dev : Conflicts: libcurl4-openssl-dev but 7.52.1-5+deb9u6 is to be installed<br \/>\nlibcurl4-openssl-dev : Conflicts: libcurl4-gnutls-dev but 7.52.1-5+deb9u6 is to be installed<\/code><\/p>\n<p>The conflict was because of need either gnutls or openssl. I installed gnutls:<\/p>\n<p><code>apt install debhelper iptables-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev libbcg729-dev libcurl4-gnutls-dev libevent-dev libglib2.0-dev libhiredis-dev libjson-glib-dev libpcap0.8-dev libpcap-dev libpcre3-dev libswresample-dev libxmlrpc-core-c3-dev markdown <\/code><\/p>\n<p>Now dpkg-checkbuilddeps shows no errors! :)<br \/>\nTrying to create packages:<\/p>\n<p><code>\tdpkg-buildpackage<\/code><\/p>\n<p>Success!!!<\/p>\n<pre>-rw-r--r-- 1 root root  87K \u0438\u044e\u043d 20 10:18 ngcp-rtpengine_6.3.1.1+0~mr6.3.1.1_all.deb\n-rw-r--r--  202K  10:18 ngcp-rtpengine-daemon_6.3.1.1+0~mr6.3.1.1_amd64.deb\n-rw-r--r--  934K  10:18 ngcp-rtpengine-daemon-dbgsym_6.3.1.1+0~mr6.3.1.1_amd64.deb\n-rw-r--r--   33K  10:18 ngcp-rtpengine-iptables_6.3.1.1+0~mr6.3.1.1_amd64.deb\n-rw-r--r--  2,3K  10:18 ngcp-rtpengine-iptables-dbgsym_6.3.1.1+0~mr6.3.1.1_amd64.deb\n-rw-r--r--   52K  10:18 ngcp-rtpengine-kernel-dkms_6.3.1.1+0~mr6.3.1.1_all.deb\n-rw-r--r--   80K  10:18 ngcp-rtpengine-kernel-source_6.3.1.1+0~mr6.3.1.1_all.deb\n-rw-r--r--   67K  10:18 ngcp-rtpengine-recording-daemon_6.3.1.1+0~mr6.3.1.1_amd64.deb\n-rw-r--r--  217K  10:18 ngcp-rtpengine-recording-daemon-dbgsym_6.3.1.1+0~mr6.3.1.1_amd64.deb\n-rw-r--r--   50K  10:18 ngcp-rtpengine-utils_6.3.1.1+0~mr6.3.1.1_all.deb<\/pre>\n<p>And  install (as recommended in manual) libavcodec-extra packages from Debian repositories.<\/p>\n<p>Trying to install &#8216; dpkg -i ngcp-rtpengine-kernel-dkms_6.3.1.1+0~mr6.3.1.1_all.deb&#8217;<\/p>\n<p>Get and error about &#8216;dkms&#8217; package abscence.<\/p>\n<p>Trying to install &#8216;dkms&#8217; &#8211; errors about some packages abscence. Offers to do &#8216;apt &#8211;fix-broken install&#8217;. I agree, and it installs many additional packages.<\/p>\n<p>I try to install these created packages again:<\/p>\n<p><code>ngcp-rtpengine-kernel-dkms_6.3.1.1+0~mr6.3.1.1_all.deb<br \/>\nngcp-rtpengine-kernel-source_6.3.1.1+0~mr6.3.1.1_all.deb<\/code><\/p>\n<p><code>ngcp-rtpengine-recording-daemon-dbgsym_6.3.1.1+0~mr6.3.1.1_amd64.deb<br \/>\nngcp-rtpengine-recording-daemon_6.3.1.1+0~mr6.3.1.1_amd64.deb<\/p>\n<p><\/code><code>ngcp-rtpengine-utils_6.3.1.1+0~mr6.3.1.1_all.deb<\/code><\/p>\n<p>At this moment I check installed packages with &#8216;dpkg -l | grep ngcp&#8217; and see that they are alll already installed, marked with &#8216;ii&#8217;, but I go on:<\/p>\n<p><code>ngcp-rtpengine-iptables-dbgsym_6.3.1.1+0~mr6.3.1.1_amd64.deb<br \/>\nngcp-rtpengine-iptables_6.3.1.1+0~mr6.3.1.1_amd64.deb<\/code><\/p>\n<p><code>ngcp-rtpengine-daemon-dbgsym_6.3.1.1+0~mr6.3.1.1_amd64.deb<br \/>\nngcp-rtpengine-daemon_6.3.1.1+0~mr6.3.1.1_amd64.deb<\/p>\n<p><\/code><code>ngcp-rtpengine_6.3.1.1+0~mr6.3.1.1_all.deb<\/code><\/p>\n<p>Maybe some initialization scripts are configured during manual installation:<\/p>\n<p><code>\t\troot@debian-opensips:~# dpkg -i ngcp-rtpengine-daemon_6.3.1.1+0~mr6.3.1.1_amd64.deb<br \/>\n(Reading database ... 66096 files and directories currently installed.)<br \/>\nPreparing to unpack ngcp-rtpengine-daemon_6.3.1.1+0~mr6.3.1.1_amd64.deb ...<br \/>\nUnpacking ngcp-rtpengine-daemon (6.3.1.1+0~mr6.3.1.1) over (6.3.1.1+0~mr6.3.1.1) ...<br \/>\nSetting up ngcp-rtpengine-daemon (6.3.1.1+0~mr6.3.1.1) ...<br \/>\nProcessing triggers for systemd (232-25+deb9u3) ..<\/code><\/p>\n<p>Seems strange that this package hasn&#8217;t been installed as a dependency:<br \/>\n<code>\tapt install ffmpeg<\/code><\/p>\n<p>At this moment, rtpengine supports these codecs:<\/p>\n<p><code>root@debian-opensips:~# rtpengine --codecs<br \/>\nPCMA: fully supported<br \/>\nPCMU: fully supported<br \/>\nG723: fully supported<br \/>\nG722: fully supported<br \/>\nQCELP: supported for decoding only<br \/>\nG729: fully supported<br \/>\nspeex: fully supported<br \/>\nGSM: fully supported<br \/>\niLBC: not supported<br \/>\nopus: fully supported<br \/>\nvorbis: fully supported<br \/>\nac3: fully supported<br \/>\neac3: fully supported<br \/>\nATRAC3: supported for decoding only<br \/>\nATRAC-X: supported for decoding only<br \/>\nEVRC: supported for decoding only<br \/>\nEVRC0: supported for decoding only<br \/>\nEVRC1: supported for decoding only<br \/>\nAMR: fully supported<br \/>\nAMR-WB: fully supported<br \/>\nPCM-S16LE: fully supported<br \/>\nMP3: fully supported<\/code><\/p>\n<p>Very good, but I also need iLBC.<\/p>\n<p>Install package:<\/p>\n<p><code>\tlibavcodec57<\/code><\/p>\n<p>Check:<br \/>\n<code>\t ffmpeg -decoders<br \/>\nffmpeg -encoders<\/code><\/p>\n<p>No success((<\/p>\n<p>Found Debian packages!<br \/>\nRepository:\t\thttp:\/\/www.deb-multimedia.org\/debian-m<\/p>\n<p>Add repo to our system:<\/p>\n<p><code>\tdeb http:\/\/mirror.yandex.ru\/debian-multimedia\/ stable main non-free<br \/>\ndeb-src http:\/\/mirror.yandex.ru\/debian-multimedia\/ stable main non-free<\/code><\/p>\n<p>Add repo&#8217;s gpg:<br \/>\n<code>\twget http:\/\/www.deb-multimedia.org\/pool\/main\/d\/deb-multimedia-keyring\/deb-multimedia-keyring_2016.8.1_all.deb<br \/>\ndpkg -i deb-multimedia-keyring_2016.8.1_all.deb<\/code><\/p>\n<p><code>apt update<br \/>\napt install libilbc2 libilbc-dev<\/code><\/p>\n<p>Voila!<\/p>\n<p><code>root@debian-opensips:~# !532<br \/>\nrtpengine --codecs<br \/>\nPCMA: fully supported<br \/>\nPCMU: fully supported<br \/>\nG723: fully supported<br \/>\nG722: fully supported<br \/>\nQCELP: supported for decoding only<br \/>\nG729: fully supported<br \/>\nspeex: fully supported<br \/>\nGSM: fully supported<br \/>\niLBC: fully supported<br \/>\nopus: fully supported<br \/>\nvorbis: fully supported<br \/>\nac3: fully supported<br \/>\neac3: fully supported<br \/>\nATRAC3: supported for decoding only<br \/>\nATRAC-X: supported for decoding only<br \/>\nEVRC: supported for decoding only<br \/>\nEVRC0: supported for decoding only<br \/>\nEVRC1: supported for decoding only<br \/>\nAMR: fully supported<br \/>\nAMR-WB: fully supported<br \/>\nPCM-S16LE: fully supported<br \/>\nMP3: fully supported<\/code><\/p>\n<p>Rtpengine minimal start command:<br \/>\n<code>\t rtpengine -i enp0s3\/10.145.213.88 -l 10.145.213.88:9876<\/code><\/p>\n<p>For these WARNS in syslog:<br \/>\n<code>\tJun 20 17:35:13 debian-opensips rtpengine[4029]: WARNING: Failed to properly parse UDP command line '4296_1 d7:command4:pinge' from 127.0.0.1:60637, using fallback RE<\/code><\/p>\n<p>found this:<br \/>\n<code>\thttps:\/\/github.com\/sipwise\/rtpengine\/issues\/266<\/code><\/p>\n<p>Advice &#8211; to start with &#8216;&#8211;listen-ng&#8217; option:<br \/>\n<code>\trtpengine -i lo\/127.0.0.1 --listen-udp=127.0.0.1:12221 --listen-ng=127.0.0.1:12222<\/code><br \/>\nor with CLI support:<br \/>\n<code>rtpengine -i enp0s3\/10.145.213.88 --listen-ng=10.145.213.88:12222 --listen-cli=10.145.213.88:12555<\/code><\/p>\n<p>to use it:<br \/>\n<code>rtpengine-ctl -ip 10.145.213.88 -port 12555 list totals<\/code><\/p>\n<p>And modify OpenSIPS config (add new port with NG):<\/p>\n<p><code>modparam(\"rtpengine\", \"rtpengine_sock\", \"udp:localhost:12222\")<\/code><\/p>\n<p>Works!!!<br \/>\n<code>\t# rtpengine, may depend on tm \/\/  (optional) if you want to have rtpengine_manage() fully functional<br \/>\n# rtpengine -i enp0s3\/10.145.213.88 --listen-ng=10.145.213.88:12222<br \/>\nloadmodule \"rtpengine.so\"<br \/>\nmodparam(\"rtpengine\", \"rtpengine_sock\", \"udp:10.145.213.88:12222\")<\/code><\/p>\n<p>Great! OpenSIPS starts without any warnings.<\/p>\n<p>OpenSIPS config:<\/p>\n<p>What flags to use (by Kirill Galinurov):<br \/>\n<code>\t\t$var(rtpengine_flags) = \"RTP\/AVP replace-session-connection replace-origin ICE=remove\"<\/code><\/p>\n<p><code><br \/>\n<\/code><code>\t\trtpengine_offer(\"$var(rtpengine_flags)\");<\/code><\/p>\n<p>My rtpengine re-writes SDP with 127.0.0.1 IP address &#8211; because I started it listening on 127.0.0.1.<br \/>\nBut we need to start it on a non-localhost IP address.<\/p>\n<p>By Kirill Galinurov:<\/p>\n<p><code>\t\t\tRTP_IP[0]=external\/185.128.105.15       # (m) Local IPv4\/6 address for RTP. The format of the value is [NAME\/]IP[!IP].<br \/>\nRTP_IP[1]=internal\/172.20.99.247<\/code><\/p>\n<p>&#8220;loopback is also possible&#8221;:<\/p>\n<p><code>\t\t\tlo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state UNKNOWN qlen 1<br \/>\nlink\/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00<br \/>\ninet 127.0.0.1\/8 scope host lo<br \/>\nvalid_lft forever preferred_lft forever<br \/>\ninet 185.128.105.15\/32 brd 185.128.105.15 scope host lo<br \/>\nvalid_lft forever preferred_lft forever<br \/>\ninet6 ::1\/128 scope host<\/loopback,up,lower_up><\/code><\/p>\n<p>To start re-writing of IP addresses in SDP, don&#8217;t follow rtpengine module docs,<br \/>\nbut just create global onreply_route, and use there rtpengine_answer() function without flags.<br \/>\nAfter that, you&#8217;ll have IP addresses in SDP rewritten.<\/p>\n<p>But still no transcoding at this stage(<\/p>\n<pre>\tif (is_method(\"INVITE\")) {\n\n\t\tlookup(\"location\");\n\n\t\tif (has_body(\"application\/sdp\")) {\n\t\t\t#if (rtpengine_offer(\"RTP\/AVP replace-origin replace-session-connection ICE=remove codec-mask-PCMA codec-strip-PCMU transcode-PCMU\"))\n\t\t\tif (rtpengine_offer(\"RTP\/AVP replace-origin replace-session-connection ICE=remove always-transcode\"))\n\t\t\t#if (rtpengine_offer(\"RTP\/AVP replace-origin replace-session-connection ICE=remove\"))\n\t\t\t\tt_on_reply(\"1\");\n\t\t} else {\n\t\t\tt_on_reply(\"2\");\n\t\t}\n\t}\n\n\tif (is_method(\"ACK\") &amp;&amp; has_body(\"application\/sdp\"))\n\t\trtpengine_answer();\n\n\troute(relay);\n\n\n\nonreply_route\n{\n\tif (has_body(\"application\/sdp\"))\n\t\trtpengine_answer();\n}<\/pre>\n<p>Also check: http:\/\/opensips.org\/pub\/events\/2015-05-12_OpenSIPS-Summit_Amsterdam\/Razva_Crainea-OpenSIPS_Summit2015-EdgeProxy.cfg<br \/>\nAnd comment from Razvan how to use flags: https:\/\/github.com\/OpenSIPS\/opensips\/issues\/1288#issuecomment-367293070<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Draft for myself https:\/\/github.com\/sipwise\/rtpengine root@debian-opensips:~\/rtpengine-mr6.3.1# dpkg-checkbuilddeps dpkg-checkbuilddeps: error: Unmet build dependencies: debhelper (&gt;= 10~) iptables-dev (&gt;= 1.4) libavcodec-dev (&gt;= 6:10) libavfilter-dev (&gt;= 6:10) libavformat-dev (&gt;= 6:10) libavutil-dev (&gt;= 6:10) libbcg729-dev libcurl4-openssl-dev | libcurl4-gnutls-dev | libcurl3-openssl-dev | libcurl3-gnutls-dev libevent-dev (&gt;= 2.0) libglib2.0-dev (&gt;= 2.30) libhiredis-dev libjson-glib-dev libpcap0.8-dev | libpcap-dev libpcre3-dev libswresample-dev (&gt;= 6:10) libxmlrpc-c3-dev (&gt;= 1.16.07) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[208,254],"class_list":["post-1246","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-opensips","tag-rtpengine"],"_links":{"self":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1246"}],"version-history":[{"count":6,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1246\/revisions"}],"predecessor-version":[{"id":1379,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1246\/revisions\/1379"}],"wp:attachment":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}