aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-03-25 17:29:47 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-03-25 17:29:47 +0000
commit54dd42ee90813afb9e1796344206f3a9cd5e6b3a (patch)
treea994a552e0bec6ef42cc4b21a861ee301e58db6e /channels
parentaca5c91a7c62e4b4ea26d7f75108b086dbae17dd (diff)
Add new rtpsource options to the CHANNEL function.
This adds rtpsource options analogous to the rtpdest functions that already exist. In addition, this fixes potential crashes which could result due to trying to read values from nonexistent RTP streams. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@254551 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/sip/dialplan_functions.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/channels/sip/dialplan_functions.c b/channels/sip/dialplan_functions.c
index 473199c71..297f9f5da 100644
--- a/channels/sip/dialplan_functions.c
+++ b/channels/sip/dialplan_functions.c
@@ -28,6 +28,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/channel.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/pbx.h"
+#include "asterisk/acl.h"
#include "include/sip.h"
#include "include/globals.h"
@@ -76,19 +77,54 @@ int sip_acf_channel_read(struct ast_channel *chan, const char *funcname, char *p
ast_copy_string(buf, (p->t38.state == T38_DISABLED) ? "0" : "1", buflen);
} else if (!strcasecmp(args.param, "rtpdest")) {
struct sockaddr_in sin;
+ struct ast_rtp_instance *stream;
if (ast_strlen_zero(args.type))
args.type = "audio";
if (!strcasecmp(args.type, "audio"))
- ast_rtp_instance_get_remote_address(p->rtp, &sin);
+ stream = p->rtp;
else if (!strcasecmp(args.type, "video"))
- ast_rtp_instance_get_remote_address(p->vrtp, &sin);
+ stream = p->vrtp;
else if (!strcasecmp(args.type, "text"))
- ast_rtp_instance_get_remote_address(p->trtp, &sin);
+ stream = p->trtp;
else
return -1;
+ if (!stream) {
+ return -1;
+ }
+
+ ast_rtp_instance_get_remote_address(stream, &sin);
+ snprintf(buf, buflen, "%s:%d", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
+ } else if (!strcasecmp(args.param, "rtpsource")) {
+ struct sockaddr_in sin;
+ struct ast_rtp_instance *stream;
+
+ if (ast_strlen_zero(args.type))
+ args.type = "audio";
+
+ if (!strcasecmp(args.type, "audio"))
+ stream = p->rtp;
+ else if (!strcasecmp(args.type, "video"))
+ stream = p->vrtp;
+ else if (!strcasecmp(args.type, "text"))
+ stream = p->trtp;
+ else
+ return -1;
+
+ if (!stream) {
+ return -1;
+ }
+
+ ast_rtp_instance_get_local_address(stream, &sin);
+
+ if (!sin.sin_addr.s_addr) {
+ struct sockaddr_in dest_sin;
+ ast_rtp_instance_get_remote_address(stream, &dest_sin);
+ ast_ouraddrfor(&dest_sin.sin_addr, &sin.sin_addr);
+ }
+
snprintf(buf, buflen, "%s:%d", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
} else if (!strcasecmp(args.param, "rtpqos")) {
struct ast_rtp_instance *rtp = NULL;