[asterisk-commits] tzafrir: branch tzafrir/monitor-rtp r214075 - /team/tzafrir/monitor-rtp/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Aug 25 14:46:23 CDT 2009
Author: tzafrir
Date: Tue Aug 25 14:46:20 2009
New Revision: 214075
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=214075
Log:
A low-level function to write stream to RTP
Modified:
team/tzafrir/monitor-rtp/res/res_monitor.c
Modified: team/tzafrir/monitor-rtp/res/res_monitor.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/tzafrir/monitor-rtp/res/res_monitor.c?view=diff&rev=214075&r1=214074&r2=214075
==============================================================================
--- team/tzafrir/monitor-rtp/res/res_monitor.c (original)
+++ team/tzafrir/monitor-rtp/res/res_monitor.c Tue Aug 25 14:46:20 2009
@@ -266,6 +266,9 @@
static in_port_t rtp_portbase_rx = 9000;
static in_port_t rtp_portbase_tx = 11000;
+/* FIXME: Should be moved to some header file: */
+#define PCM_FORMAT "rtpmonitor"
+
/*!
* \brief Change state of monitored channel
* \param chan
@@ -322,6 +325,37 @@
return -errno;
}
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;
}
/*! \brief Start monitoring a channel
More information about the asterisk-commits
mailing list