]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
put in proper fix for issue #7294 instead of the broken partial fix that was committe...
authorKevin P. Fleming <kpfleming@digium.com>
Fri, 1 Sep 2006 17:35:06 +0000 (17:35 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Fri, 1 Sep 2006 17:35:06 +0000 (17:35 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@41716 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
include/asterisk/rtp.h
rtp.c

index cd7583b8dea442a4bd4b39187a5176a51b87ab6e..aa6e69a896795ba0e91ca8cd36d281e6c73129fb 100644 (file)
@@ -12931,21 +12931,25 @@ static struct ast_rtp *sip_get_vrtp_peer(struct ast_channel *chan)
 static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active)
 {
        struct sip_pvt *p;
+       int changed = 0;
 
        p = chan->tech_pvt;
        if (!p) 
                return -1;
        ast_mutex_lock(&p->lock);
        if (rtp)
-               ast_rtp_get_peer(rtp, &p->redirip);
+               changed |= ast_rtp_get_peer(rtp, &p->redirip);
        else
                memset(&p->redirip, 0, sizeof(p->redirip));
        if (vrtp)
-               ast_rtp_get_peer(vrtp, &p->vredirip);
+               changed |= ast_rtp_get_peer(vrtp, &p->vredirip);
        else
                memset(&p->vredirip, 0, sizeof(p->vredirip));
-       p->redircodecs = codecs;
-       if (codecs && !ast_test_flag(p, SIP_GOTREFER)) {
+       if (codecs && (p->redircodecs != codecs)) {
+               p->redircodecs = codecs;
+               changed = 1;
+       }
+       if (changed && !ast_test_flag(p, SIP_GOTREFER)) {
                if (!p->pendinginvite) {
                        if (option_debug > 2) {
                                char iabuf[INET_ADDRSTRLEN];
index bdb0391fd9ce4e163b103857138b06edb031256f..8ffdf93636fdb13c1c0a0ea26b5fe1e7103a5254 100644 (file)
@@ -96,7 +96,7 @@ struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io
 
 void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
 
-void ast_rtp_get_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
+int ast_rtp_get_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
 
 void ast_rtp_get_us(struct ast_rtp *rtp, struct sockaddr_in *us);
 
diff --git a/rtp.c b/rtp.c
index da759ff0031bfbb27bbd1d2574b6baf36ee49920..ee8e2c6c2bcaee67bada3cfa76d153537349557b 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -1041,11 +1041,17 @@ void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them)
        rtp->rxseqno = 0;
 }
 
-void ast_rtp_get_peer(struct ast_rtp *rtp, struct sockaddr_in *them)
+int ast_rtp_get_peer(struct ast_rtp *rtp, struct sockaddr_in *them)
 {
-       them->sin_family = AF_INET;
-       them->sin_port = rtp->them.sin_port;
-       them->sin_addr = rtp->them.sin_addr;
+       if ((them->sin_family != AF_INET) ||
+           (them->sin_port != rtp->them.sin_port) ||
+           (them->sin_addr.s_addr != rtp->them.sin_addr.s_addr)) {
+               them->sin_family = AF_INET;
+               them->sin_port = rtp->them.sin_port;
+               them->sin_addr = rtp->them.sin_addr;
+               return 1;
+       }
+       return 0;
 }
 
 void ast_rtp_get_us(struct ast_rtp *rtp, struct sockaddr_in *us)