[asterisk-commits] file: trunk r71988 - in /trunk: CHANGES channels/chan_sip.c funcs/func_channel.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jun 26 18:31:24 CDT 2007
Author: file
Date: Tue Jun 26 18:31:23 2007
New Revision: 71988
URL: http://svn.digium.com/view/asterisk?view=rev&rev=71988
Log:
Add rtpdest option to SIP CHANNEL() dialplan function to return the IP address and port that RTP (be it audio/video/text) is going to.
Modified:
trunk/CHANGES
trunk/channels/chan_sip.c
trunk/funcs/func_channel.c
Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=71988&r1=71987&r2=71988
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Tue Jun 26 18:31:23 2007
@@ -59,6 +59,7 @@
required due to the restructuring of how MWI is handled. See the descriptions
in this file of the "pollmailboxes" and "pollfreq" options to voicemail.conf
for more information.
+ * Added rtpdest option to CHANNEL() dialplan function.
IAX2 changes
------------
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=71988&r1=71987&r2=71988
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Jun 26 18:31:23 2007
@@ -15001,9 +15001,9 @@
static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
{
- struct ast_rtp_quality qos;
struct sip_pvt *p = chan->tech_pvt;
char *all = "", *parse = ast_strdupa(preparse);
+ int res = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(param);
AST_APP_ARG(type);
@@ -15017,51 +15017,68 @@
return 0;
}
- if (ast_strlen_zero(args.param) || strcasecmp(args.param, "rtpqos"))
- return -1;
-
- /* Default arguments of audio,all */
- if (ast_strlen_zero(args.type))
- args.type = "audio";
- if (ast_strlen_zero(args.field))
- args.field = "all";
-
memset(buf, 0, buflen);
- memset(&qos, 0, sizeof(qos));
-
- if (strcasecmp(args.type, "AUDIO") == 0) {
- all = ast_rtp_get_quality(p->rtp, &qos);
- } else if (strcasecmp(args.type, "VIDEO") == 0) {
- all = ast_rtp_get_quality(p->vrtp, &qos);
- } else if (strcasecmp(args.type, "TEXT") == 0) {
- all = ast_rtp_get_quality(p->trtp, &qos);
- }
-
- if (strcasecmp(args.field, "local_ssrc") == 0)
- snprintf(buf, buflen, "%u", qos.local_ssrc);
- else if (strcasecmp(args.field, "local_lostpackets") == 0)
- snprintf(buf, buflen, "%u", qos.local_lostpackets);
- else if (strcasecmp(args.field, "local_jitter") == 0)
- snprintf(buf, buflen, "%.0lf", qos.local_jitter * 1000.0);
- else if (strcasecmp(args.field, "local_count") == 0)
- snprintf(buf, buflen, "%u", qos.local_count);
- else if (strcasecmp(args.field, "remote_ssrc") == 0)
- snprintf(buf, buflen, "%u", qos.remote_ssrc);
- else if (strcasecmp(args.field, "remote_lostpackets") == 0)
- snprintf(buf, buflen, "%u", qos.remote_lostpackets);
- else if (strcasecmp(args.field, "remote_jitter") == 0)
- snprintf(buf, buflen, "%.0lf", qos.remote_jitter * 1000.0);
- else if (strcasecmp(args.field, "remote_count") == 0)
- snprintf(buf, buflen, "%u", qos.remote_count);
- else if (strcasecmp(args.field, "rtt") == 0)
- snprintf(buf, buflen, "%.0lf", qos.rtt * 1000.0);
- else if (strcasecmp(args.field, "all") == 0)
- ast_copy_string(buf, all, buflen);
- else {
- ast_log(LOG_WARNING, "Unrecognized argument '%s' to %s\n", preparse, funcname);
- return -1;
- }
- return 0;
+
+ if (!strcasecmp(args.param, "rtpdest")) {
+ struct sockaddr_in sin;
+
+ if (ast_strlen_zero(args.type))
+ args.type = "audio";
+
+ if (!strcasecmp(args.type, "audio"))
+ ast_rtp_get_peer(p->rtp, &sin);
+ else if (!strcasecmp(args.type, "video"))
+ ast_rtp_get_peer(p->vrtp, &sin);
+ else if (!strcasecmp(args.type, "text"))
+ ast_rtp_get_peer(p->trtp, &sin);
+
+ snprintf(buf, buflen, "%s:%d", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
+ } else if (!strcasecmp(args.param, "rtpqos")) {
+ struct ast_rtp_quality qos;
+
+ memset(&qos, 0, sizeof(qos));
+
+ if (ast_strlen_zero(args.type))
+ args.type = "audio";
+ if (ast_strlen_zero(args.field))
+ args.field = "all";
+
+ if (strcasecmp(args.type, "AUDIO") == 0) {
+ all = ast_rtp_get_quality(p->rtp, &qos);
+ } else if (strcasecmp(args.type, "VIDEO") == 0) {
+ all = ast_rtp_get_quality(p->vrtp, &qos);
+ } else if (strcasecmp(args.type, "TEXT") == 0) {
+ all = ast_rtp_get_quality(p->trtp, &qos);
+ }
+
+ if (strcasecmp(args.field, "local_ssrc") == 0)
+ snprintf(buf, buflen, "%u", qos.local_ssrc);
+ else if (strcasecmp(args.field, "local_lostpackets") == 0)
+ snprintf(buf, buflen, "%u", qos.local_lostpackets);
+ else if (strcasecmp(args.field, "local_jitter") == 0)
+ snprintf(buf, buflen, "%.0lf", qos.local_jitter * 1000.0);
+ else if (strcasecmp(args.field, "local_count") == 0)
+ snprintf(buf, buflen, "%u", qos.local_count);
+ else if (strcasecmp(args.field, "remote_ssrc") == 0)
+ snprintf(buf, buflen, "%u", qos.remote_ssrc);
+ else if (strcasecmp(args.field, "remote_lostpackets") == 0)
+ snprintf(buf, buflen, "%u", qos.remote_lostpackets);
+ else if (strcasecmp(args.field, "remote_jitter") == 0)
+ snprintf(buf, buflen, "%.0lf", qos.remote_jitter * 1000.0);
+ else if (strcasecmp(args.field, "remote_count") == 0)
+ snprintf(buf, buflen, "%u", qos.remote_count);
+ else if (strcasecmp(args.field, "rtt") == 0)
+ snprintf(buf, buflen, "%.0lf", qos.rtt * 1000.0);
+ else if (strcasecmp(args.field, "all") == 0)
+ ast_copy_string(buf, all, buflen);
+ else {
+ ast_log(LOG_WARNING, "Unrecognized argument '%s' to %s\n", preparse, funcname);
+ return -1;
+ }
+ } else {
+ res = -1;
+ }
+ return res;
}
/*! \brief Handle incoming BYE request */
Modified: trunk/funcs/func_channel.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_channel.c?view=diff&rev=71988&r1=71987&r2=71988
==============================================================================
--- trunk/funcs/func_channel.c (original)
+++ trunk/funcs/func_channel.c Tue Jun 26 18:31:23 2007
@@ -181,6 +181,11 @@
" remote_count Number of transmitted packets\n"
" rtt Round trip time\n"
" all All statistics (in a form suited to logging, but not for parsing)\n"
+ "R/O rtpdest Get remote RTP destination information\n"
+ " This option takes one additional argument:\n"
+ " Argument 1:\n"
+ " audio Get audio destination\n"
+ " video Get video destination\n"
"\n"
"chan_iax2 provides the following additional options:\n"
"R/W osptoken Get or set the OSP token information for a call\n"
More information about the asterisk-commits
mailing list