[svn-commits] tzafrir: branch tzafrir/monitor-rtp-14 r222536 - in /team/tzafrir/monitor-rtp...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Oct 7 11:42:07 CDT 2009


Author: tzafrir
Date: Wed Oct  7 11:42:03 2009
New Revision: 222536

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=222536
Log:
iFinish getting rid of RTP_PORT_OFFSET

* Get rid of setting RTP_PORT_OFFSET in chan_dahdi
* Proper configuration reading and reload as in trunk
* Copy (mostly) documentation from trunk.

Added:
    team/tzafrir/monitor-rtp-14/doc/monitor-rtp.txt   (with props)
Modified:
    team/tzafrir/monitor-rtp-14/channels/chan_dahdi.c
    team/tzafrir/monitor-rtp-14/configs/monitor.conf.sample
    team/tzafrir/monitor-rtp-14/res/res_monitor.c

Modified: team/tzafrir/monitor-rtp-14/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/tzafrir/monitor-rtp-14/channels/chan_dahdi.c?view=diff&rev=222536&r1=222535&r2=222536
==============================================================================
--- team/tzafrir/monitor-rtp-14/channels/chan_dahdi.c (original)
+++ team/tzafrir/monitor-rtp-14/channels/chan_dahdi.c Wed Oct  7 11:42:03 2009
@@ -5828,12 +5828,6 @@
 		ast_log(LOG_DEBUG, "setvar: '%s' => '%s'\n", v->name, v->value);
 		pbx_builtin_setvar_helper(tmp, v->name, v->value);
 	}
-	{
-		char	port_offset[BUFSIZ];
-
-		snprintf(port_offset, sizeof(port_offset), "%d", GET_CHANNEL(i));
-		pbx_builtin_setvar_helper(tmp, "RTP_PORT_OFFSET", port_offset);
-	}
 	if (startpbx) {
 		if (ast_pbx_start(tmp)) {
 			ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);

Modified: team/tzafrir/monitor-rtp-14/configs/monitor.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/tzafrir/monitor-rtp-14/configs/monitor.conf.sample?view=diff&rev=222536&r1=222535&r2=222536
==============================================================================
--- team/tzafrir/monitor-rtp-14/configs/monitor.conf.sample (original)
+++ team/tzafrir/monitor-rtp-14/configs/monitor.conf.sample Wed Oct  7 11:42:03 2009
@@ -9,16 +9,22 @@
 ;
 [general]
 ; 
-; The following two values are required for RTP monitoring:
-; Recording server: hostname (FIXME: also support IP address) for the target
-; recording server.
+; If the following is set, recorded audio is sent as RTP streams to a
+; remote server rather than saving it to local files. The file name /
+; pattern parameter of Monitor is likewise ignored.
+; The parameter is the hostname (FIXME: also support IP addresses) of
+; the server to which we send the streams.
+; This value can not be changed on reload.
 ;rtp_server = newton
 ;
-; My local host name. Must be resolvable to an IP address that the recording
-; server can use (e.g. not "localhost").
+; My local host name. Use it to override the system default, if needed.
+; This should be the name of the IP address from which the packets are
+; sent.
+; As with rtp_server, it can't be an IP address and can't change on
+; reload.
 ;reporting_host  = myhostname
 
-; Used to set base ports for the DAHDI channel-offset based allocation of
-; RTP ports. The defaults are generally safe to use:
-;rtp_portbase_rx = 9000
-;rtp_portbase_tx = 11000
+; The rang of RTP ports to use. Similar to rtpstart and rtpend in rtp.conf .
+; The defaults are:
+;rtp_mon_start = 9000
+;rtp_mon_end   = 9999

Added: team/tzafrir/monitor-rtp-14/doc/monitor-rtp.txt
URL: http://svnview.digium.com/svn/asterisk/team/tzafrir/monitor-rtp-14/doc/monitor-rtp.txt?view=auto&rev=222536
==============================================================================
--- team/tzafrir/monitor-rtp-14/doc/monitor-rtp.txt (added)
+++ team/tzafrir/monitor-rtp-14/doc/monitor-rtp.txt Wed Oct  7 11:42:03 2009
@@ -1,0 +1,99 @@
+Asterisk RTP Monitoring
+=======================
+
+This document describes using the Monitoring To RTP feature of Asterisk.
+Note that this feature is still work in progress. 
+
+"RTP Monitoring" adds an extra backend to the current Monitor
+(recording) code: rather than recoding calls to files, send them as RTP
+streams over the network to a resording server. The RTP streams are
+proided with extra meta-data through dummy SIP INVITE (at the beginning)
+and BYE (in the end of the call) messages.
+
+
+Usage
+-----
+RTP monitoring is configured through monitor.conf (a file currently only
+used for this feature). See a sample/reference file in the configs
+directory.
+
+In order for recording to work, 'rtp_server' under [general]' must be
+set. Set it to the server to which you wish to send recordings.
+If it is not set, monitoring is recorded as usual to files.
+
+In order for calls to be recorded you also need to set the channel to be
+monitored. Use one of the following:
+
+- An explicit Monitor(wav) in the dialplan. Note that the value used
+  here ('wav') will actually be ignored.
+- setvar = AUTO_MONITOR=wav in the channel configuration (sip.conf,
+  iax.conf, chan_dahdi.conf, maybe others).
+
+RTP ports used in the streams (both source and target) will be allocated in
+the range 'rtp_mon_start' - 'rtp_port_end' (by default: 9000-9999,
+configurable in monitor.conf).
+
+
+Oreka / Orecx
+-------------
+Support for recording the produced streams of this plugin has been added
+in recent SVN versions (try using at least rev. 641) of orkaudio. In
+order to use it, add the following line inside the <VoIpPlugin> tag in
+/etc/orkaudio/config.xml
+
+  <DahdiIntercept>yes</DahdiIntercept>
+
+I hope it will be renamed to something along the lines of
+'AsteriskIntercept' as the code should not have anything DAHDI-specific.
+
+If you record calls from more than one Asterisk server, you may need to adjust
+the range of RTP ports (FIXME: is this really needed?). See 'rtp_mon_start'
+and 'rtp_mon_end' in monitor.conf .
+
+
+Wireshark
+---------
+The generated streams can be shown in wireshark. Either capture in it
+directly or capture in tcpdump:
+
+  tcpdump -s 0 -w recordings.cap #add custom filter here
+
+In Wireshark use Statistics => RTP => Show All Streams
+This opens a window in which each stream is shown (there are two such
+streams per recorded channel).
+
+
+Testing
+-------
+The following can be used to generate a call without any other channels
+about in the system:
+
+In extensions.conf:
+
+ [rtp-monitor]
+ exten => genrec,1,Answer
+ exten => genrec,n,Monitor(wav,,b)
+ exten => genrec,n,Dial(Local/answer-rec at rtp-monitor/n)
+ exten => genrec,n,Hangup
+
+ exten => answer-rec,1,Answer
+ exten => answer-rec,n,Monitor(wav,,b)
+ exten => answer-rec,n,Playback(demo-thanks)
+ exten => answer-rec,n,Hangup
+     
+
+And now generate a call with:
+
+  asterisk -rx 'originate Local/genrec at rtp-monitor/n application Playback demo-instruct'
+  
+
+TODO
+----
+* We can't change the monitor host (and hence enable/disable monitoring)
+  on reload.
+* In a normal Hangup, the channel's CDR gets destroyed before the
+  channel's monitors are destroyed. Which means that the CDR data is not
+  availalable when we send the BYE. This was not the case in 1.4 .
+  There is an ugly and very partial workaround in the code for that.
+* Support IP addresses for rtp_server and reporting_host
+* No 'monitor' CLI commands (show config)

Propchange: team/tzafrir/monitor-rtp-14/doc/monitor-rtp.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/tzafrir/monitor-rtp-14/doc/monitor-rtp.txt
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/tzafrir/monitor-rtp-14/doc/monitor-rtp.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/tzafrir/monitor-rtp-14/res/res_monitor.c
URL: http://svnview.digium.com/svn/asterisk/team/tzafrir/monitor-rtp-14/res/res_monitor.c?view=diff&rev=222536&r1=222535&r2=222536
==============================================================================
--- team/tzafrir/monitor-rtp-14/res/res_monitor.c (original)
+++ team/tzafrir/monitor-rtp-14/res/res_monitor.c Wed Oct  7 11:42:03 2009
@@ -73,9 +73,6 @@
 /* Used for sending metadata to recording server: */
 static int sip_socket = -1;
 static struct sockaddr_in sip_server_addr;
-
-static in_port_t rtp_portbase_rx = 9000;
-static in_port_t rtp_portbase_tx = 11000;
 
 /*! First port for RTP monitoring sessions (set in monitor.conf) */
 static int rtp_mon_start = 9000;
@@ -207,18 +204,6 @@
 	
 }
 
-static int get_ipaddr(const char *str, struct in_addr *addr)
-{
-	struct ast_hostent he;
-
-	if(!ast_gethostbyname(str, &he)) {
-		ast_log(LOG_NOTICE, "Failed to resolve hostname '%s'\n", str);
-		return 0;
-	}
-	memcpy(&(addr->s_addr), he.hp.h_addr, sizeof(addr->s_addr));
-	return 1;
-}
-
 
 /* Create a UDP stream.
  *
@@ -352,7 +337,7 @@
 		}
 	}
 #endif /* ifdef RTP_MONITOR_DEBUG */
-	if(!get_ipaddr(reporting_host, &(my_addr.sin_addr))) {
+	if (ast_get_ip(&(my_addr), reporting_host)) {
 		ast_log(LOG_WARNING, "Bad reporting_host: '%s'\n", reporting_host);
 		return -1;
 	}
@@ -1070,7 +1055,7 @@
 	return do_pause_or_unpause(s, m, MONITOR_ACTION_UNPAUSE);
 }
 	
-static int reload_config(enum channelreloadreason reason)
+static int reload_config(enum channelreloadreason reason, int startup)
 {
 	struct ast_config	*cfg;
 	struct ast_variable	*v;
@@ -1081,33 +1066,37 @@
 		ast_log(LOG_NOTICE, "Unable to load config %s. No monitoring to RTP\n", config_file);
 		return 0;
 	}
-	rtp_server_name[0] = '\0';
+	if (startup) {
+		rtp_server_name[0] = '\0';
+	}
 	for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
-		if (!strcasecmp(v->name, "rtp_server")) {
+		if (startup && !strcasecmp(v->name, "rtp_server")) {
 			ast_copy_string(rtp_server_name, v->value, sizeof(rtp_server_name));
-		} else if (!strcasecmp(v->name, "rtp_portbase_rx")) {
-			char		portstr[BUFSIZ];
-			unsigned int	port_value;
+		} else if (!strcasecmp(v->name, "rtp_mon_start")) {
+			char portstr[BUFSIZ];
+			unsigned int port_value;
 
 			ast_copy_string(portstr, v->value, sizeof(portstr));
-			if ((sscanf(v->value, "%u", &port_value) != 1) /* TBD: || (port_value > MAXPORTNUM) */) {
+			if ((sscanf(v->value, "%u", &port_value) != 1)
+					/* TBD: || (port_value > MAXPORTNUM) */ ) {
 				ast_log(LOG_WARNING, "%s:%d: invalid port number '%s'.\n",
-					config_file, v->lineno, v->value);
+						config_file, v->lineno, v->value);
 			} else {
-				rtp_portbase_rx = port_value;
-			}
-		} else if (!strcasecmp(v->name, "rtp_portbase_tx")) {
-			char		portstr[BUFSIZ];
-			unsigned int	port_value;
+				rtp_mon_start = port_value;
+			}
+		} else if (!strcasecmp(v->name, "rtp_mon_end")) {
+			char portstr[BUFSIZ];
+			unsigned int port_value;
 
 			ast_copy_string(portstr, v->value, sizeof(portstr));
-			if ((sscanf(v->value, "%u", &port_value) != 1) /* TBD: || (port_value > MAXPORTNUM) */) {
+			if ((sscanf(v->value, "%u", &port_value) != 1)
+					/* TBD: || (port_value > MAXPORTNUM) */) {
 				ast_log(LOG_WARNING, "%s:%d: invalid port number '%s'.\n",
-					config_file, v->lineno, v->value);
+						config_file, v->lineno, v->value);
 			} else {
-				rtp_portbase_tx = port_value;
-			}
-		} else if (!strcasecmp(v->name, "reporting_host")) {
+				rtp_mon_end = port_value;
+			}
+		} else if (startup && !strcasecmp(v->name, "reporting_host")) {
 			ast_copy_string(reporting_host, v->value, sizeof(reporting_host));
 		} else {
 			ast_log(LOG_NOTICE, "%s:%d: Bad config option '%s' - (ignoring)\n",
@@ -1115,14 +1104,20 @@
 		}
 	}
 	ast_log(LOG_DEBUG, "monitor to %s [RX=%d, TX=%d]\n",
-		rtp_server_name, rtp_portbase_rx, rtp_portbase_tx);
+		rtp_server_name, rtp_mon_start, rtp_mon_end);
 	ast_config_destroy(cfg);
 	return 0;
 }
 
+static int reload_module(void)
+{
+	reload_config(CHANNEL_MODULE_LOAD, 0);
+	return 0;
+}
+
 static int load_module(void)
 {
-	if(reload_config(CHANNEL_MODULE_LOAD))
+	if(reload_config(CHANNEL_MODULE_LOAD, 1))
 		return AST_MODULE_LOAD_DECLINE;
 	if(rtp_server_name[0] != '\0') {
 		if((sip_socket = sip_stream(rtp_server_name, 5060, &sip_server_addr)) < 0) {
@@ -1168,4 +1163,5 @@
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Call Monitoring Resource",
 		.load = load_module,
 		.unload = unload_module,
+		.reload = reload_module,
 		);




More information about the svn-commits mailing list