Repair ability of SendFAX/ReceiveFAX to respond to T.38 switchover.
authorKevin P. Fleming <kpfleming@digium.com>
Thu, 9 Jul 2009 21:20:23 +0000 (21:20 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Thu, 9 Jul 2009 21:20:23 +0000 (21:20 +0000)
Recent changes in T.38 negotiation in Asterisk caused these applications to
not respond when the other endpoint initiated a switchover to T.38; this
resulted in the T.38 switchover failing, and the FAX attempt to be made
using an audio connection, instead of T.38 (which would usually cause the
FAX to fail completely).

This patch corrects this problem, and the applications will now correctly
respond to the T.38 switchover request. In addition, the response will include
the appopriate T.38 session parameters based on what the other end offered
and what our end is capable of.

(closes issue #14849)
Reported by: afosorio

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@205696 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_fax.c
channels/chan_sip.c
include/asterisk/frame.h

index 7c35d84..815bb84 100644 (file)
@@ -459,7 +459,7 @@ static int transmit_audio(fax_session *s)
                                                                                 .version = 0,
                                                                                 .max_datagram = 400,
                                                                                 .rate = AST_T38_RATE_9600,
-                                                                                .rate_management = AST_T38_RATE_MANAGEMENT_TRANSFERED_TCF,
+                                                                                .rate_management = AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF,
                                                                                 .fill_bit_removal = 1,
                                                                                 .transcoding_mmr = 1,
                                };
@@ -476,7 +476,6 @@ static int transmit_audio(fax_session *s)
                   that a frame in old format was already queued before we set chanel format
                   to slinear so it will still be received by ast_read */
                if (inf->frametype == AST_FRAME_VOICE && inf->subclass == AST_FORMAT_SLINEAR) {
-
                        if (fax_rx(&fax, inf->data.ptr, inf->samples) < 0) {
                                /* I know fax_rx never returns errors. The check here is for good style only */
                                ast_log(LOG_WARNING, "fax_rx returned error\n");
@@ -497,6 +496,24 @@ static int transmit_audio(fax_session *s)
                                ast_debug(1, "T38 negotiated, finishing audio loop\n");
                                res = 1;
                                break;
+                       } else if (parameters->request_response == AST_T38_REQUEST_NEGOTIATE) {
+                               if (parameters->version > 0) {
+                                       /* Only T.38 Version 0 is supported at this time */
+                                       parameters->version = 0;
+                               }
+                               if (parameters->max_datagram > 400) {
+                                       /* Limit incoming datagram size to our default */
+                                       /* TODO: this need to come from the udptl stack, not be hardcoded */
+                                       parameters->max_datagram = 400;
+                               }
+                               /* we only support bit rates up to 9.6kbps */
+                               parameters->rate = AST_T38_RATE_9600;
+                               ast_indicate_data(s->chan, AST_CONTROL_T38_PARAMETERS, parameters, sizeof(*parameters));
+                               /* T38 switchover completed */
+                               s->t38parameters = *parameters;
+                               ast_debug(1, "T38 negotiated, finishing audio loop\n");
+                               res = 1;
+                               break;
                        }
                }
 
index 59a4793..6d6078e 100644 (file)
@@ -1545,7 +1545,7 @@ struct sip_auth {
 #define T38FAX_TRANSCODING_MMR                 (1 << 1)        /*!< Default: 0 (unset)*/
 #define T38FAX_TRANSCODING_JBIG                        (1 << 2)        /*!< Default: 0 (unset)*/
 /* Rate management */
-#define T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF  (0 << 3)
+#define T38FAX_RATE_MANAGEMENT_TRANSFERRED_TCF (0 << 3)
 #define T38FAX_RATE_MANAGEMENT_LOCAL_TCF       (1 << 3)        /*!< Unset for transferredTCF (UDPTL), set for localTCF (TPKT) */
 /* UDP Error correction */
 #define T38FAX_UDP_EC_NONE                     (0 << 4)        /*!< two bits, if unset NO t38UDPEC field in T38 SDP*/
@@ -4913,8 +4913,8 @@ static void fill_t38_parameters(int capabilities, struct ast_control_t38_paramet
                parameters->rate = AST_T38_RATE_2400;
        }
 
-       if (capabilities & T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF) {
-               parameters->rate_management = AST_T38_RATE_MANAGEMENT_TRANSFERED_TCF;
+       if (capabilities & T38FAX_RATE_MANAGEMENT_TRANSFERRED_TCF) {
+               parameters->rate_management = AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF;
        } else if (capabilities & T38FAX_RATE_MANAGEMENT_LOCAL_TCF) {
                parameters->rate_management = AST_T38_RATE_MANAGEMENT_LOCAL_TCF;
        }
@@ -5009,7 +5009,7 @@ static void set_t38_capabilities(struct sip_pvt *p)
                        ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_NONE);
                        p->t38.capability |= T38FAX_UDP_EC_NONE;
                }
-               p->t38.capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
+               p->t38.capability |= T38FAX_RATE_MANAGEMENT_TRANSFERRED_TCF;
        }
 }
 
@@ -6447,8 +6447,8 @@ static void interpret_t38_parameters(struct sip_pvt *p, enum ast_control_t38 req
                        p->t38.capability = p->t38.jointcapability |= T38FAX_RATE_2400;
                }
 
-               if (parameters->rate_management == AST_T38_RATE_MANAGEMENT_TRANSFERED_TCF) {
-                       p->t38.capability = p->t38.jointcapability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
+               if (parameters->rate_management == AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF) {
+                       p->t38.capability = p->t38.jointcapability |= T38FAX_RATE_MANAGEMENT_TRANSFERRED_TCF;
                } else if (parameters->rate_management == AST_T38_RATE_MANAGEMENT_LOCAL_TCF) {
                        p->t38.capability = p->t38.jointcapability |= T38FAX_RATE_MANAGEMENT_LOCAL_TCF;
                }
@@ -8600,7 +8600,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
                                if (!strcasecmp(s, "localTCF"))
                                        peert38capability |= T38FAX_RATE_MANAGEMENT_LOCAL_TCF;
                                else if (!strcasecmp(s, "transferredTCF"))
-                                       peert38capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
+                                       peert38capability |= T38FAX_RATE_MANAGEMENT_TRANSFERRED_TCF;
                        } else if ((sscanf(a, "T38FaxUdpEC:%255s", s) == 1)) {
                                found = 1;
                                ast_debug(3, "UDP EC: %s\n", s);
index c2022d6..e648007 100644 (file)
@@ -345,7 +345,7 @@ enum ast_control_t38_rate {
 };
 
 enum ast_control_t38_rate_management {
-       AST_T38_RATE_MANAGEMENT_TRANSFERED_TCF = 0,
+       AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF = 0,
        AST_T38_RATE_MANAGEMENT_LOCAL_TCF,
 };