Skip to content

Commit

Permalink
rtp_media_server: adding module
Browse files Browse the repository at this point in the history
  • Loading branch information
jchavanton committed Nov 13, 2018
1 parent 96aa799 commit 47e35db
Show file tree
Hide file tree
Showing 15 changed files with 1,995 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Makefile.groups
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ mod_list_rabbitmq=rabbitmq
# - modules depending on libphonenumber library
mod_list_phonenum=phonenum

# - modules depending on oRTP and mediastreamer2 libraries
mod_list_rtp_media=rtp_media_server

# - all modules
mod_list_all=$(sort $(mod_list_basic) $(mod_list_extra) \
$(mod_list_db) $(mod_list_dbuid) \
Expand Down Expand Up @@ -239,7 +242,8 @@ mod_list_all=$(sort $(mod_list_basic) $(mod_list_extra) \
$(mod_list_erlang) $(mod_list_systemd) \
$(mod_list_http_async) $(mod_list_nsq) \
$(mod_list_rabbitmq) $(mod_list_jsdt)) \
$(mod_list_phonenum)
$(mod_list_phonenum) \
$(mod_list_rtp_media)



Expand Down
13 changes: 13 additions & 0 deletions src/modules/rtp_media_server/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include ../../Makefile.defs
auto_gen=
NAME=rtp_media_server.so

DEFS+=-I$(LOCALBASE)/lib

ORTPLIBS=-lortp
BCUNITLIBS=-lbcunit
MS2LIBS=-lmediastreamer_voip -lmediastreamer_base

LIBS=$(ORTPLIBS) $(BCUNITLIBS) $(MS2LIBS)
DEFS+=-DKAMAILIO_MOD_INTERFACE
include ../../Makefile.modules
56 changes: 56 additions & 0 deletions src/modules/rtp_media_server/config_example/kamailio.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

debug=3
log_stderror=yes
memdbg=5
memlog=5

# number of SIP routing processes
children=5

loadmodule "ctl"
loadmodule "tm"
loadmodule "tmx"
loadmodule "sl"
loadmodule "rr"
loadmodule "pv"
loadmodule "textops"
loadmodule "siputils"
loadmodule "xlog"
loadmodule "nathelper"
loadmodule "rtp_media_server"
modparam("rtp_media_server", "log_file_name", "/tmp/rms_transfer.log")
modparam("tm", "wt_timer", 1000)
listen=udp:147.75.39.121:5090

event_route[rms:start] {
xnotice("[rms:start] play ...\n");
rms_play("./voice_file/Bach_10s_8000.wav", "rms:after_play");
};

event_route[rms:after_play] {
xnotice("[rms:after_play] play done...\n");
rms_hangup();
};

route {
if (t_precheck_trans()) {
t_check_trans();
exit;
}
t_check_trans();

xnotice("[$rm][$ci]\n");
if (is_method("INVITE") && !has_totag()) {
fix_nated_contact();
if (!rms_answer()) {
t_reply("503", "server error");
xerr("rtp_media_server error!\n");
exit;
}
}
if (is_method("BYE")){
rms_media_stop();
}
exit;
}

4 changes: 4 additions & 0 deletions src/modules/rtp_media_server/doc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docs = rtp_media_server.xml

docbook_dir = ../../../../doc/docbook
include $(docbook_dir)/Makefile.module
42 changes: 42 additions & 0 deletions src/modules/rtp_media_server/doc/rtp_media_server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [

<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
%docentities;

]>

<book xmlns:xi="http://www.w3.org/2001/XInclude">
<bookinfo>
<title>rtp_media_server Module</title>
<productname class="trade">&kamailio;</productname>
<authorgroup>
<author>
<firstname>Julien</firstname>
<surname>Chavanton</surname>
<email>jchavanton@gmail.com</email>
</author>
<author>
<firstname>Julien</firstname>
<surname>Chavanton</surname>
<affiliation><orgname>flowroute.com</orgname></affiliation>
<email>jchavanton@gmail.com</email>
</author>
<editor>
<firstname>Julien</firstname>
<surname>Chavanton</surname>
<affiliation><orgname>flowroute.com</orgname></affiliation>
<email>jchavanton@gmail.com</email>
</editor>
</authorgroup>
<copyright>
<year>2017-2018</year>
<holder>Flowroute.com</holder>
</copyright>
</bookinfo>
<toc></toc>

<xi:include href="rtp_media_server_admin.xml"/>
</book>
193 changes: 193 additions & 0 deletions src/modules/rtp_media_server/doc/rtp_media_server_admin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [

<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
%docentities;

]>

<chapter>
<title>&adminguide;</title>

<section>
<title>Overview</title>
<para>
rtp_media_server module is adding RTP and media processing functionalities to Kamailio
</para>
<para>
Kamailio is providing SIP signaling including and enpoint with Dialog state, SDP parsing and scripting language
</para><para>
oRTP: is providing Real-time Transport Protocol (RFC 3550)
</para><para>
mediastreamer2: is providing mediaprocessing functionnalities using graphs and filters, many modules are available
to support various features, it should be relatively simple to integrated them.
</para><para>
mediastreamer2 is also providing a framework to create custom mediaprocessing modules.
</para>
</section>

<section>
<title>Dependencies</title>
<section>
<title>&kamailio; Modules</title>
<para>
The module depends on the following modules (in the other words
the listed modules must be loaded before this module):
<itemizedlist>
<listitem>
<para><emphasis>tm</emphasis> - accounting module</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>External Libraries or Applications</title>
<para>
The following libraries or applications must be installed
before running &kamailio; with this module loaded:
</para><para>
If you want to build oRTP and mediastreamer from source, you can use the provided script for Debian "install_bc.sh".
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>oRTP</emphasis> git://git.linphone.org/ortp.git
</para>
<para>
oRTP is a library implemeting Real-time Transport Protocol (RFC 3550), distributed under GNU GPLv2 or proprietary license.
</para>
</listitem>
<listitem>
<para>
<emphasis>mediastreamer2</emphasis> git clone git://git.linphone.org/mediastreamer2.git
</para>
<para>
Mediastreamer2 is a powerful and lightweight streaming engine specialized for voice/video telephony applications.
</para>
</listitem>
</itemizedlist>
</section>
</section>

<section>
<title>Parameters</title>
<section>
<title><varname>log_file_name</varname> (string)</title>
<para>
oRTP and MediaStreamer2 log file settings
the log mask is not configurable :
MESSAGE | WARNING | ERROR | FATAL
levels are activated.
</para>
<para>
Default value is not-set (no logging to file).
</para>
<example>
<title>log_file_name example</title>
<programlisting format="linespecific">
...
modparam("rtp_media_server", "log_file_name", "/var/log/rms/rms_ortp.log")
...
</programlisting></example>
</section>
</section>

<section>
<title>Functions</title>

<section id="rtp_media_server.f.rms_answer">
<title><varname>rms_answer</varname> ()</title>
<para>
Create a session and a call leg and call the event_route[rms:start]
config example
</para>
<example>
<title>usage example</title>
<programlisting format="linespecific">
...
event_route[rms:start] {
xnotice("[rms:start] play ...\n");
rms_play("/tmp/reference_8000.wav", "rms:after_play");
};

event_route[rms:after_play] {
xnotice("[rms:after_play] play done...\n");
rms_hangup();
};

route {
if (t_precheck_trans()) {
t_check_trans();
exit;
}
t_check_trans();
if (is_method("INVITE") &amp;&amp; !has_totag()) {
if (!rms_answer()) {
t_reply("503", "server error");
}
}

if (is_method("BYE")){
xnotice("BYE RECEIVED [$ci]\n");
rms_media_stop();
}
...
</programlisting></example>
</section>

<section id="rtp_media_server.f.rms_hangup">
<title><varname>rms_hangup</varname> ()</title>
<para>
Send a BYE, delete the RTP session and the media ressources.
</para>
<example>
<title>usage example</title>
<programlisting format="linespecific">
...
rms_hangup();
...
</programlisting></example>
</section>

<section id="rtp_media_server.f.rms_media_stop">
<title><varname>rms_media_stop</varname> ()</title>
<para>
This should be called on reception of a BYE, this will
delete the RTP session and the media ressources.
and reply "200 OK".
</para>
<para>
If the SIP session is not found "481 Call/Transaction Does Not Exist"
is returned.
</para>
<example>
<title>usage example</title>
<programlisting format="linespecific">
...
if (is_method("BYE")){
rms_media_stop();
}
...
</programlisting></example>
</section>

<section id="rtp_media_server.f.rms_play">
<title><varname>rms_play</varname> ()</title>
<para>
Play a wav file, a resampler is automaticaly configured to resample
and convert stereo to mono if needed.
</para><para>
The second parameter is the event route that will be called when the file was played.
</para>
<example>
<title>usage example</title>
<programlisting format="linespecific">
...
rms_play("file.wav", "event_route_name");
...
</programlisting></example>
</section>
</section>
</chapter>
45 changes: 45 additions & 0 deletions src/modules/rtp_media_server/install_bc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# https://github.com/jchavanton/rtp_media_server.git
apt-get install automake autogen autoconf libtool pkg-config
# bcunit
git clone https://github.com/BelledonneCommunications/bcunit.git
cd bcunit
git checkout 29c556fa8ac1ab21fba1291231ffa8dea43cf32a
./autogen.sh
./configure
make
make install
cd ..

# bctoolbox
apt-get install libmbedtls-dev
git clone https://github.com/BelledonneCommunications/bctoolbox.git
cd bctoolbox
git checkout 971953a9fa4058e9c8a40ca4a3fa12d832445255
./autogen.sh
./configure
make
make install
cd ..

# oRTP
git clone https://github.com/BelledonneCommunications/ortp.git
git checkout 6e13ef49a55cdd19dae395c38cfff7ffa518a089
cd ortp
./autogen.sh
./configure
make
make install
cd ..

# mediastreamer2
apt-get install intltool libspeex-dev libspeexdsp-dev
git clone https://github.com/BelledonneCommunications/mediastreamer2.git
cd mediastreamer2
git checkout d935123fc497d19a24019c6e7ae4fe0c5f19d55a
./autogen.sh
./configure --disable-sound --disable-video --enable-tools=no --disable-tests
make
make install
cd ..

ldconfig

0 comments on commit 47e35db

Please sign in to comment.