aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-26 23:31:23 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-26 23:31:23 +0000
commitb401a5b5e5dd7f761519b17828ffef1ab467fabb (patch)
treeb424d8bf966c0b174fd8688785b148ea271b5970 /channels
parentd806540826f462e0cb32a71f06544f4415f8818e (diff)
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.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@71988 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c103
1 files changed, 60 insertions, 43 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 54e842bd1..37d7f3010 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -15001,9 +15001,9 @@ static int handle_request_cancel(struct sip_pvt *p, struct sip_request *req)
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 @@ static int acf_channel_read(struct ast_channel *chan, const char *funcname, char
return 0;
}
- if (ast_strlen_zero(args.param) || strcasecmp(args.param, "rtpqos"))
- return -1;
+ memset(buf, 0, buflen);
- /* Default arguments of audio,all */
- if (ast_strlen_zero(args.type))
- args.type = "audio";
- if (ast_strlen_zero(args.field))
- args.field = "all";
+ if (!strcasecmp(args.param, "rtpdest")) {
+ struct sockaddr_in sin;
- 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;
+ 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 0;
+ return res;
}
/*! \brief Handle incoming BYE request */