From 8f3ab72bb2d05279e0583b588a8b34b1a48f8de3 Mon Sep 17 00:00:00 2001 From: file Date: Thu, 6 Aug 2009 17:47:56 +0000 Subject: Merged revisions 210817 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ........ r210817 | file | 2009-08-06 14:47:04 -0300 (Thu, 06 Aug 2009) | 11 lines Accept additional T.38 reinvites after an initial one has been handled. Discussion of this subject has yielded that it is not actually acceptable to change T.38 parameters after the initial reinvite but declining is harsh and can cause the fax to fail when it may be possible to allow it to continue. This patch changes things so that additional T.38 reinvites are accepted but parameter changes ignored. This gives the fax a fighting chance. (closes issue #15610) Reported by: huangtx2009 ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@210818 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_sip.c | 184 ++++++++++++++++++++++++++-------------------------- 1 file changed, 93 insertions(+), 91 deletions(-) (limited to 'channels') diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 5312eaf9d..f3748f115 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -7247,108 +7247,110 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action } if (udptlportno != -1) { - int found = 0, x; + if (p->t38.state != T38_ENABLED) { + int found = 0, x; - old = 0; - memset(&p->t38.their_parms, 0, sizeof(p->t38.their_parms)); + old = 0; + memset(&p->t38.their_parms, 0, sizeof(p->t38.their_parms)); - /* Scan trough the a= lines for T38 attributes and set apropriate fileds */ - iterator = req->sdp_start; - while ((a = get_sdp_iterate(&iterator, req, "a"))[0] != '\0') { - if ((sscanf(a, "T38FaxMaxBuffer:%d", &x) == 1)) { - found = 1; - ast_debug(3, "MaxBufferSize:%d\n", x); - } else if ((sscanf(a, "T38MaxBitRate:%d", &x) == 1) || (sscanf(a, "T38FaxMaxRate:%d", &x) == 1)) { - found = 1; - ast_debug(3, "T38MaxBitRate: %d\n", x); - switch (x) { - case 14400: - p->t38.their_parms.rate = AST_T38_RATE_14400; - break; - case 12000: - p->t38.their_parms.rate = AST_T38_RATE_12000; - break; - case 9600: - p->t38.their_parms.rate = AST_T38_RATE_9600; - break; - case 7200: - p->t38.their_parms.rate = AST_T38_RATE_7200; - break; - case 4800: - p->t38.their_parms.rate = AST_T38_RATE_4800; - break; - case 2400: - p->t38.their_parms.rate = AST_T38_RATE_2400; - break; - } - } else if ((sscanf(a, "T38FaxVersion:%d", &x) == 1)) { - found = 1; - ast_debug(3, "FaxVersion: %d\n", x); - p->t38.their_parms.version = x; - } else if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1) || (sscanf(a, "T38MaxDatagram:%d", &x) == 1)) { - found = 1; - ast_debug(3, "FaxMaxDatagram: %d\n", x); - ast_udptl_set_far_max_datagram(p->udptl, x); - } else if ((strncmp(a, "T38FaxFillBitRemoval", 20) == 0)) { - found = 1; - if (sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1) { - ast_debug(3, "FillBitRemoval: %d\n", x); - if (x == 1) { + /* Scan trough the a= lines for T38 attributes and set apropriate fileds */ + iterator = req->sdp_start; + while ((a = get_sdp_iterate(&iterator, req, "a"))[0] != '\0') { + if ((sscanf(a, "T38FaxMaxBuffer:%d", &x) == 1)) { + found = 1; + ast_debug(3, "MaxBufferSize:%d\n", x); + } else if ((sscanf(a, "T38MaxBitRate:%d", &x) == 1) || (sscanf(a, "T38FaxMaxRate:%d", &x) == 1)) { + found = 1; + ast_debug(3, "T38MaxBitRate: %d\n", x); + switch (x) { + case 14400: + p->t38.their_parms.rate = AST_T38_RATE_14400; + break; + case 12000: + p->t38.their_parms.rate = AST_T38_RATE_12000; + break; + case 9600: + p->t38.their_parms.rate = AST_T38_RATE_9600; + break; + case 7200: + p->t38.their_parms.rate = AST_T38_RATE_7200; + break; + case 4800: + p->t38.their_parms.rate = AST_T38_RATE_4800; + break; + case 2400: + p->t38.their_parms.rate = AST_T38_RATE_2400; + break; + } + } else if ((sscanf(a, "T38FaxVersion:%d", &x) == 1)) { + found = 1; + ast_debug(3, "FaxVersion: %d\n", x); + p->t38.their_parms.version = x; + } else if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1) || (sscanf(a, "T38MaxDatagram:%d", &x) == 1)) { + found = 1; + ast_debug(3, "FaxMaxDatagram: %d\n", x); + ast_udptl_set_far_max_datagram(p->udptl, x); + } else if ((strncmp(a, "T38FaxFillBitRemoval", 20) == 0)) { + found = 1; + if (sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1) { + ast_debug(3, "FillBitRemoval: %d\n", x); + if (x == 1) { + p->t38.their_parms.fill_bit_removal = TRUE; + } + } else { + ast_debug(3, "FillBitRemoval\n"); p->t38.their_parms.fill_bit_removal = TRUE; } - } else { - ast_debug(3, "FillBitRemoval\n"); - p->t38.their_parms.fill_bit_removal = TRUE; - } - } else if ((strncmp(a, "T38FaxTranscodingMMR", 20) == 0)) { - found = 1; - if (sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1) { - ast_debug(3, "Transcoding MMR: %d\n", x); - if (x == 1) { + } else if ((strncmp(a, "T38FaxTranscodingMMR", 20) == 0)) { + found = 1; + if (sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1) { + ast_debug(3, "Transcoding MMR: %d\n", x); + if (x == 1) { + p->t38.their_parms.transcoding_mmr = TRUE; + } + } else { + ast_debug(3, "Transcoding MMR\n"); p->t38.their_parms.transcoding_mmr = TRUE; } - } else { - ast_debug(3, "Transcoding MMR\n"); - p->t38.their_parms.transcoding_mmr = TRUE; - } - } else if ((strncmp(a, "T38FaxTranscodingJBIG", 21) == 0)) { - found = 1; - if (sscanf(a, "T38FaxTranscodingJBIG:%d", &x) == 1) { - ast_debug(3, "Transcoding JBIG: %d\n", x); - if (x == 1) { + } else if ((strncmp(a, "T38FaxTranscodingJBIG", 21) == 0)) { + found = 1; + if (sscanf(a, "T38FaxTranscodingJBIG:%d", &x) == 1) { + ast_debug(3, "Transcoding JBIG: %d\n", x); + if (x == 1) { + p->t38.their_parms.transcoding_jbig = TRUE; + } + } else { + ast_debug(3, "Transcoding JBIG\n"); p->t38.their_parms.transcoding_jbig = TRUE; } - } else { - ast_debug(3, "Transcoding JBIG\n"); - p->t38.their_parms.transcoding_jbig = TRUE; - } - } else if ((sscanf(a, "T38FaxRateManagement:%255s", s) == 1)) { - found = 1; - ast_debug(3, "RateManagement: %s\n", s); - if (!strcasecmp(s, "localTCF")) - p->t38.their_parms.rate_management = AST_T38_RATE_MANAGEMENT_LOCAL_TCF; - else if (!strcasecmp(s, "transferredTCF")) - p->t38.their_parms.rate_management = AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF; - } else if ((sscanf(a, "T38FaxUdpEC:%255s", s) == 1)) { - found = 1; - ast_debug(3, "UDP EC: %s\n", s); - if (!strcasecmp(s, "t38UDPRedundancy")) { - ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_REDUNDANCY); - } else if (!strcasecmp(s, "t38UDPFEC")) { - ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_FEC); - } else { - ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_NONE); + } else if ((sscanf(a, "T38FaxRateManagement:%255s", s) == 1)) { + found = 1; + ast_debug(3, "RateManagement: %s\n", s); + if (!strcasecmp(s, "localTCF")) + p->t38.their_parms.rate_management = AST_T38_RATE_MANAGEMENT_LOCAL_TCF; + else if (!strcasecmp(s, "transferredTCF")) + p->t38.their_parms.rate_management = AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF; + } else if ((sscanf(a, "T38FaxUdpEC:%255s", s) == 1)) { + found = 1; + ast_debug(3, "UDP EC: %s\n", s); + if (!strcasecmp(s, "t38UDPRedundancy")) { + ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_REDUNDANCY); + } else if (!strcasecmp(s, "t38UDPFEC")) { + ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_FEC); + } else { + ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_NONE); + } } } - } - /* Remote party offers T38, we need to update state */ - if ((t38action == SDP_T38_ACCEPT) && - (p->t38.state == T38_LOCAL_REINVITE)) { - change_t38_state(p, T38_ENABLED); - } else if ((t38action == SDP_T38_INITIATE) && - p->owner && p->lastinvite) { - change_t38_state(p, T38_PEER_REINVITE); /* T38 Offered in re-invite from remote party */ + /* Remote party offers T38, we need to update state */ + if ((t38action == SDP_T38_ACCEPT) && + (p->t38.state == T38_LOCAL_REINVITE)) { + change_t38_state(p, T38_ENABLED); + } else if ((t38action == SDP_T38_INITIATE) && + p->owner && p->lastinvite) { + change_t38_state(p, T38_PEER_REINVITE); /* T38 Offered in re-invite from remote party */ + } } } else { change_t38_state(p, T38_DISABLED); -- cgit v1.2.3