From: Kevin P. Fleming Date: Fri, 1 Sep 2006 17:35:06 +0000 (+0000) Subject: put in proper fix for issue #7294 instead of the broken partial fix that was committe... X-Git-Tag: 1.2.12~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abb4e3a3a4e1635542128f689b60d6cca7e76a5d;p=thirdparty%2Fasterisk.git put in proper fix for issue #7294 instead of the broken partial fix that was committed, and thereby also fix issue #7438 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@41716 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index cd7583b8de..aa6e69a896 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -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]; diff --git a/include/asterisk/rtp.h b/include/asterisk/rtp.h index bdb0391fd9..8ffdf93636 100644 --- a/include/asterisk/rtp.h +++ b/include/asterisk/rtp.h @@ -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 da759ff003..ee8e2c6c2b 100644 --- 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)