[asterisk-commits] tzafrir: branch tzafrir/monitor-rtp r222106 - in /team/tzafrir/monitor-rtp: c...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 5 13:25:07 CDT 2009


Author: tzafrir
Date: Mon Oct  5 13:25:05 2009
New Revision: 222106

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=222106
Log:
Get rid of any remaining RTP_PORT_OFFSET

Complete the previous commit:

* rtp_mon_start and rtp_mon_end can now be set from monitor.conf .
* Remove the setting and (now) useless usage of RTP_PORT_OFFSET.
* Thus there are no more DAHDI-specific parts in this branch.

Modified:
    team/tzafrir/monitor-rtp/channels/chan_dahdi.c
    team/tzafrir/monitor-rtp/configs/monitor.conf.sample
    team/tzafrir/monitor-rtp/doc/monitor-rtp.txt
    team/tzafrir/monitor-rtp/res/res_monitor.c

Modified: team/tzafrir/monitor-rtp/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/tzafrir/monitor-rtp/channels/chan_dahdi.c?view=diff&rev=222106&r1=222105&r2=222106
==============================================================================
--- team/tzafrir/monitor-rtp/channels/chan_dahdi.c (original)
+++ team/tzafrir/monitor-rtp/channels/chan_dahdi.c Mon Oct  5 13:25:05 2009
@@ -8371,12 +8371,6 @@
 	for (v = i->vars ; v ; v = v->next)
 		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) {
 #ifdef HAVE_OPENR2
 		if (i->mfcr2call) {

Modified: team/tzafrir/monitor-rtp/configs/monitor.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/tzafrir/monitor-rtp/configs/monitor.conf.sample?view=diff&rev=222106&r1=222105&r2=222106
==============================================================================
--- team/tzafrir/monitor-rtp/configs/monitor.conf.sample (original)
+++ team/tzafrir/monitor-rtp/configs/monitor.conf.sample Mon Oct  5 13:25:05 2009
@@ -19,7 +19,7 @@
 ; sent.
 ;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

Modified: team/tzafrir/monitor-rtp/doc/monitor-rtp.txt
URL: http://svnview.digium.com/svn/asterisk/team/tzafrir/monitor-rtp/doc/monitor-rtp.txt?view=diff&rev=222106&r1=222105&r2=222106
==============================================================================
--- team/tzafrir/monitor-rtp/doc/monitor-rtp.txt (original)
+++ team/tzafrir/monitor-rtp/doc/monitor-rtp.txt Mon Oct  5 13:25:05 2009
@@ -20,25 +20,19 @@
 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.
 
-In order for calls to be recorded you also need to:
+In order for calls to be recorded you also need to set the channel to be
+monitored. Use one of the following:
 
-1. 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.
-   - Set(AUTO_MONITOR=wav) in the dialplan. As before, the actual value
-     will be ignored.
-   - setvar = AUTO_MONITOR=wav in the channel configuration (sip.conf,
-     iax.conf, chan_dahdi.conf, maybe others).
-2. (If not a DAHDI channel) set a unique port offset in the variable 
-   RTP_PORT_OFFSET . This should be unique for the run-time.
+- An explicit Monitor(wav) in the dialplan. Note that the value used
+  here ('wav') will actually be ignored.
+- Set(AUTO_MONITOR=wav) in the dialplan. As before, the actual value
+  will be ignored.
+- setvar = AUTO_MONITOR=wav in the channel configuration (sip.conf,
+  iax.conf, chan_dahdi.conf, maybe others).
 
-The requirement for RTP_PORT_OFFSET is ugly and should hopefully be
-removed soon.
-
-There are two RTP streams per recorded channel (one for rx and one for
-tx). At the moment the rx stream is sent to port 9000+RTP_PORT_OFFSET
-and the tx stream is sent to port 11000+RTP_PORT_OFFSET (the numbers
-9000 and 11000 can be modified in monitor.conf).
+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
@@ -52,6 +46,10 @@
 
 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
@@ -76,27 +74,24 @@
  [rtp-monitor]
  exten => genrec,1,Answer
  exten => genrec,n,Set(AUTO_MONITOR=wav)
- exten => genrec,n,Set(RTP_PORT_OFFSET=23)
  exten => genrec,n,Dial(Local/answer-rec at rtp-monitor/n)
  exten => genrec,n,Hangup
 
  exten => answer-rec,1,Answer
  exten => answer-rec,n,Set(AUTO_MONITOR=wav)
- exten => answer-rec,n,Set(RTP_PORT_OFFSET=29)
  exten => answer-rec,n,Playback(demo-thanks)
  exten => answer-rec,n,Hangup
      
 
 And now generate a call with:
 
-  asterisk -rx 'channel originate Local/genrec at rtp-monitor/n application Echo'
+  asterisk -rx 'channel originate Local/genrec at rtp-monitor/n application Playback demo-instruct'
   
 
 Bugs
 ----
 Many. Did I mention work in progress?
 
-* The fact that you have to set RTP_PORT_OFFSET for channels.
 * It takes restarting Asterisk or so to re-read monitor.conf .
 * Starting a monitoring with Monitor() can crash Asterisk. Didn't look
   into it yet.

Modified: team/tzafrir/monitor-rtp/res/res_monitor.c
URL: http://svnview.digium.com/svn/asterisk/team/tzafrir/monitor-rtp/res/res_monitor.c?view=diff&rev=222106&r1=222105&r2=222106
==============================================================================
--- team/tzafrir/monitor-rtp/res/res_monitor.c (original)
+++ team/tzafrir/monitor-rtp/res/res_monitor.c Mon Oct  5 13:25:05 2009
@@ -264,8 +264,6 @@
 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;
 /*! Last port for RTP monitoring sessions (set in monitor.conf) */
@@ -390,7 +388,7 @@
 }
 
 static struct ast_filestream *rtp_stream(struct ast_channel *chan,
-		const char *server, in_port_t port, uint32_t ssrc)
+		const char *server, uint32_t ssrc)
 {
 	int sock;
 	struct ast_filestream *fs = NULL;
@@ -398,7 +396,7 @@
 	struct monitor_rtp_state *rtp_state;
 
 	if ((sock = udp_stream(server, 0, &saddr)) < 0) {
-		ast_log(LOG_WARNING, "Failed to create RTP stream to '%s:%d'\n", server, port);
+		ast_log(LOG_WARNING, "Failed to create RTP stream to '%s'\n", server);
 		return NULL;
 	}
 	rtp_state = ast_calloc(1, sizeof(*rtp_state));
@@ -410,8 +408,6 @@
 	rtp_state->ssrc = ssrc;
 	rtp_state->seqno = 0;
 	rtp_state->ts_start = ast_tvnow();
-	ast_log(LOG_NOTICE, "%s: '%s:%d' (ssrc=%ld)\n", __FUNCTION__,
-			server, port, (unsigned long) rtp_state->ssrc);
 	rtp_state->dest = saddr;
 	ast_log(LOG_NOTICE, "%s: sockfd=%d\n", __FUNCTION__, sock);
 	fs = ast_writefile((const char *) rtp_state, PCM_FORMAT, "UDP", 0, sock, 0);
@@ -625,37 +621,27 @@
 	struct ast_channel_monitor *monitor;
 	struct monitor_rtp_state *rtp_state_rx;
 	struct monitor_rtp_state *rtp_state_tx;
-	const char *port_offset;
 	uint32_t rx_ssrc;
 	uint32_t tx_ssrc;
-	int portnum;
 	int ret = -1;
 
 	ast_log(LOG_NOTICE, "START monitor2rtp\n");
 	LOCK_IF_NEEDED(chan, need_lock);
-	port_offset = pbx_builtin_getvar_helper(chan, "RTP_PORT_OFFSET");
-	portnum = atoi(port_offset);
-	if (portnum <= 0) {
-		ast_log(LOG_WARNING, "Bad RTP_PORT_OFFSET='%s'\n", port_offset);
-		goto out;
-	}
 	if (!(monitor = ast_calloc(1, sizeof(*monitor)))) {
 		goto out;
 	}
 	calc_ssrc(chan, &rx_ssrc, &tx_ssrc);
 	ast_log(LOG_NOTICE, "%s: rx_ssrc=%u tx_ssrc=%u\n", __FUNCTION__, rx_ssrc, tx_ssrc);
-	/* RTP uses even port numbers */
-	portnum = (portnum - 1) * 2;
-	/* RX port */
+
 	monitor->read_stream =
-		rtp_stream(chan, rtp_server_name, rtp_portbase_rx + portnum, rx_ssrc);
+		rtp_stream(chan, rtp_server_name, rx_ssrc);
 	if (!monitor->read_stream) {
 		ast_log(LOG_WARNING, "Could not create UDP stream for read\n");
 		goto out;
 	}
-	/* TX port */
+
 	monitor->write_stream =
-		rtp_stream(chan, rtp_server_name, rtp_portbase_tx + portnum, tx_ssrc);
+		rtp_stream(chan, rtp_server_name, tx_ssrc);
 	if (!monitor->write_stream) {
 		ast_log(LOG_WARNING, "Could not create UDP stream for write\n");
 		ast_closestream(monitor->read_stream);
@@ -1288,7 +1274,7 @@
 	for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
 		if (!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")) {
+		} else if (!strcasecmp(v->name, "rtp_mon_start")) {
 			char portstr[BUFSIZ];
 			unsigned int port_value;
 
@@ -1298,9 +1284,9 @@
 				ast_log(LOG_WARNING, "%s:%d: invalid port number '%s'.\n",
 						config_file, v->lineno, v->value);
 			} else {
-				rtp_portbase_rx = port_value;
-			}
-		} else if (!strcasecmp(v->name, "rtp_portbase_tx")) {
+				rtp_mon_start = port_value;
+			}
+		} else if (!strcasecmp(v->name, "rtp_mon_end")) {
 			char portstr[BUFSIZ];
 			unsigned int port_value;
 
@@ -1310,7 +1296,7 @@
 				ast_log(LOG_WARNING, "%s:%d: invalid port number '%s'.\n",
 						config_file, v->lineno, v->value);
 			} else {
-				rtp_portbase_tx = port_value;
+				rtp_mon_end = port_value;
 			}
 		} else if (!strcasecmp(v->name, "reporting_host")) {
 			ast_copy_string(reporting_host, v->value, sizeof(reporting_host));
@@ -1323,8 +1309,9 @@
 			
 		}
 	}
-	ast_log(LOG_DEBUG, "monitor to %s [RX=%d, TX=%d]\n",
-			rtp_server_name, rtp_portbase_rx, rtp_portbase_tx);
+	/* FIXME: check that rtp_mon_end > rtp_mon_start */
+	ast_log(LOG_DEBUG, "monitor to %s [start=%d, end=%d]\n",
+			rtp_server_name, rtp_mon_start, rtp_mon_end);
 	ast_config_destroy(cfg);
 	return 0;
 }




More information about the asterisk-commits mailing list