[asterisk-commits] tzafrir: branch tzafrir/monitor-rtp-14 r213892 - /team/tzafrir/monitor-rtp-14...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 24 18:27:55 CDT 2009


Author: tzafrir
Date: Mon Aug 24 18:27:51 2009
New Revision: 213892

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=213892
Log:
A low-level function to write stream to RTP

Modified:
    team/tzafrir/monitor-rtp-14/res/res_monitor.c

Modified: team/tzafrir/monitor-rtp-14/res/res_monitor.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/tzafrir/monitor-rtp-14/res/res_monitor.c?view=diff&rev=213892&r1=213891&r2=213892
==============================================================================
--- team/tzafrir/monitor-rtp-14/res/res_monitor.c (original)
+++ team/tzafrir/monitor-rtp-14/res/res_monitor.c Mon Aug 24 18:27:51 2009
@@ -75,6 +75,8 @@
 
 static in_port_t rtp_portbase_rx = 9000;
 static in_port_t rtp_portbase_tx = 11000;
+#define	PCM_FORMAT	"rtpmonitor"
+
 static char *monitor_synopsis = "Monitor a channel";
 
 static char *monitor_descrip = "Monitor([file_format[:urlbase]|[fname_base]|[options]]):\n"
@@ -179,6 +181,37 @@
 	return sock;
 }
 
+static struct ast_filestream *rtp_stream(struct ast_channel *chan, const char *server, in_port_t port, uint32_t ssrc)
+{
+	int sock;
+	struct ast_filestream *fs = NULL;
+	struct sockaddr_in saddr;
+	struct monitor_rtp_state *rtp_state;
+
+	if((sock = udp_stream(server, port, &saddr)) < 0) {
+		ast_log(LOG_WARNING, "Failed to create RTP stream to '%s:%d'\n", server, port);
+		return NULL;
+	}
+	rtp_state = ast_calloc(1, sizeof(*rtp_state));
+	if(!rtp_state) {
+		ast_log(LOG_NOTICE, "Failed to allocate memory for rtp_state\n");
+		close(sock);
+		return NULL;
+	}
+	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);
+	if(!fs) {
+		ast_log(LOG_WARNING, "No such format '%s'\n", PCM_FORMAT);
+		ast_free(rtp_state);
+	}
+	return fs;
+}
+
 /* Start monitoring a channel */
 int ast_monitor_start(	struct ast_channel *chan, const char *format_spec,
 		const char *fname_base, int need_lock)




More information about the asterisk-commits mailing list