]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FAX tweaks
authorSteve Underwood <steveu@coppice.org>
Sat, 28 Jun 2014 18:11:25 +0000 (02:11 +0800)
committerSteve Underwood <steveu@coppice.org>
Sat, 28 Jun 2014 18:11:25 +0000 (02:11 +0800)
libs/spandsp/src/fax.c
libs/spandsp/src/spandsp/fax.h
libs/spandsp/src/spandsp/t30.h
libs/spandsp/src/t30.c
libs/spandsp/src/t38_gateway.c
libs/spandsp/src/t38_terminal.c

index ea6a1d523ae7f7af8e28cc6c04cabeaa5917d678..d3dff3fe97a9b7d6f10d280a1b9ace72751088c0 100644 (file)
@@ -394,7 +394,7 @@ SPAN_DECLARE(logging_state_t *) fax_get_logging_state(fax_state_t *s)
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party)
+SPAN_DECLARE(int) fax_restart(fax_state_t *s, bool calling_party)
 {
     v8_parms_t v8_parms;
 
@@ -420,7 +420,7 @@ SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party)
     v8_parms.nsf = -1;
     v8_parms.t66 = -1;
     v8_restart(&s->v8, calling_party, &v8_parms);
-    t30_restart(&s->t30);
+    t30_restart(&s->t30, calling_party);
 #if defined(LOG_FAX_AUDIO)
     {
         char buf[100 + 1];
@@ -455,7 +455,7 @@ SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party)
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party)
+SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, bool calling_party)
 {
     v8_parms_t v8_parms;
 
index 01dbb80d8028c586b61f88ee4cc94ce0fb31895c..499b2b3b25d9f6f8e90d6f368fc53db2b92ec177 100644 (file)
@@ -108,7 +108,7 @@ SPAN_DECLARE(logging_state_t *) fax_get_logging_state(fax_state_t *s);
     \param calling_party True if the context is for a calling party. False if the
            context is for an answering party.
     \return 0 for OK, else -1. */
-SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party);
+SPAN_DECLARE(int) fax_restart(fax_state_t *s, bool calling_party);
 
 /*! Initialise a FAX context.
     \brief Initialise a FAX context.
@@ -117,7 +117,7 @@ SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party);
            context is for an answering party.
     \return A pointer to the FAX context, or NULL if there was a problem.
 */
-SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party);
+SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, bool calling_party);
 
 /*! Release a FAX context.
     \brief Release a FAX context.
index 6216f41bfd9381bbc034d84337b1067bab89cbdc..fce40ba8d36777c016f261bb714fed312301964e 100644 (file)
@@ -213,7 +213,7 @@ typedef void (*t30_set_handler_t)(void *user_data, int type, int bit_rate, int s
     \brief T.30 send HDLC handler.
     \param user_data An opaque pointer.
     \param msg The HDLC message.
-    \param len The length of the message.
+    \param len The length of the message. -1 to flush the HDLC queue.
 */
 typedef void (*t30_send_hdlc_handler_t)(void *user_data, const uint8_t msg[], int len);
 
@@ -526,7 +526,7 @@ extern "C"
     \param send_hdlc_user_data
     \return A pointer to the context, or NULL if there was a problem. */
 SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s,
-                                     int calling_party,
+                                     bool calling_party,
                                      t30_set_handler_t set_rx_type_handler,
                                      void *set_rx_type_user_data,
                                      t30_set_handler_t set_tx_type_handler,
@@ -549,8 +549,10 @@ SPAN_DECLARE(int) t30_free(t30_state_t *s);
 /*! Restart a T.30 context.
     \brief Restart a T.30 context.
     \param s The T.30 context.
+    \param calling_party True if the context is for a calling party. False if the
+           context is for an answering party.
     \return 0 for OK, else -1. */
-SPAN_DECLARE(int) t30_restart(t30_state_t *s);
+SPAN_DECLARE(int) t30_restart(t30_state_t *s, bool calling_party);
 
 /*! Check if a T.30 call is still active. This may be used to regularly poll
     if the job has finished.
index 539e760e27712a74ad946b340fe0056627f2cf97..e9a8c7d0d3be307dd4a7eabf8693fb9d84e63933 100644 (file)
@@ -410,15 +410,15 @@ static const struct
     uint8_t dcs_code;
 } fallback_sequence[] =
 {
-    {14400, T30_MODEM_V17,      T30_SUPPORT_V17,    DISBIT6},
-    {12000, T30_MODEM_V17,      T30_SUPPORT_V17,    (DISBIT6 | DISBIT4)},
-    { 9600, T30_MODEM_V17,      T30_SUPPORT_V17,    (DISBIT6 | DISBIT3)},
-    { 9600, T30_MODEM_V29,      T30_SUPPORT_V29,    DISBIT3},
+    {14400, T30_MODEM_V17,      T30_SUPPORT_V17,    (DISBIT6                    )},
+    {12000, T30_MODEM_V17,      T30_SUPPORT_V17,    (DISBIT6 | DISBIT4          )},
+    { 9600, T30_MODEM_V17,      T30_SUPPORT_V17,    (DISBIT6 |           DISBIT3)},
+    { 9600, T30_MODEM_V29,      T30_SUPPORT_V29,    (                    DISBIT3)},
     { 7200, T30_MODEM_V17,      T30_SUPPORT_V17,    (DISBIT6 | DISBIT4 | DISBIT3)},
-    { 7200, T30_MODEM_V29,      T30_SUPPORT_V29,    (DISBIT4 | DISBIT3)},
-    { 4800, T30_MODEM_V27TER,   T30_SUPPORT_V27TER, DISBIT4},
-    { 2400, T30_MODEM_V27TER,   T30_SUPPORT_V27TER, 0},
-    {    0, 0,                  0,                  0}
+    { 7200, T30_MODEM_V29,      T30_SUPPORT_V29,    (          DISBIT4 | DISBIT3)},
+    { 4800, T30_MODEM_V27TER,   T30_SUPPORT_V27TER, (          DISBIT4          )},
+    { 2400, T30_MODEM_V27TER,   T30_SUPPORT_V27TER, (0                          )},
+    {    0, 0,                  0,                  (0                          )}
 };
 
 static void queue_phase(t30_state_t *s, int phase);
@@ -6587,8 +6587,10 @@ SPAN_DECLARE(void) t30_remote_interrupts_allowed(t30_state_t *s, int state)
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t30_restart(t30_state_t *s)
+SPAN_DECLARE(int) t30_restart(t30_state_t *s, bool calling_party)
 {
+    release_resources(s);
+    s->calling_party = calling_party;
     s->phase = T30_PHASE_IDLE;
     s->next_phase = T30_PHASE_IDLE;
     s->current_fallback = 0;
@@ -6602,7 +6604,6 @@ SPAN_DECLARE(int) t30_restart(t30_state_t *s)
     memset(&s->far_dis_dtc_frame, 0, sizeof(s->far_dis_dtc_frame));
     t30_build_dis_or_dtc(s);
     memset(&s->rx_info, 0, sizeof(s->rx_info));
-    release_resources(s);
     /* The page number is only reset at call establishment */
     s->rx_page_number = 0;
     s->tx_page_number = 0;
@@ -6627,7 +6628,7 @@ SPAN_DECLARE(int) t30_restart(t30_state_t *s)
 /*- End of function --------------------------------------------------------*/
 
 SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s,
-                                     int calling_party,
+                                     bool calling_party,
                                      t30_set_handler_t set_rx_type_handler,
                                      void *set_rx_type_user_data,
                                      t30_set_handler_t set_tx_type_handler,
@@ -6641,7 +6642,6 @@ SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s,
             return NULL;
     }
     memset(s, 0, sizeof(*s));
-    s->calling_party = calling_party;
     s->set_rx_type_handler = set_rx_type_handler;
     s->set_rx_type_user_data = set_rx_type_user_data;
     s->set_tx_type_handler = set_tx_type_handler;
@@ -6670,7 +6670,7 @@ SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s,
     s->local_min_scan_time_code = T30_MIN_SCAN_0MS;
     span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
     span_log_set_protocol(&s->logging, "T.30");
-    t30_restart(s);
+    t30_restart(s, calling_party);
     return s;
 }
 /*- End of function --------------------------------------------------------*/
index 646c3fee9a8ada56ffd550ea981a37ad05a9db40..50ea06f500c2a2b7bac9e524b1a4f9f029cb303a 100644 (file)
@@ -604,26 +604,19 @@ static void monitor_control_messages(t38_gateway_state_t *s,
         uint8_t dcs_code;
     } modem_codes[] =
     {
-        {14400, FAX_MODEM_V17_RX,       DISBIT6},
-        {12000, FAX_MODEM_V17_RX,       (DISBIT6 | DISBIT4)},
-        { 9600, FAX_MODEM_V17_RX,       (DISBIT6 | DISBIT3)},
-        { 9600, FAX_MODEM_V29_RX,       DISBIT3},
+        {14400, FAX_MODEM_V17_RX,       (DISBIT6                    )},
+        {12000, FAX_MODEM_V17_RX,       (DISBIT6 | DISBIT4          )},
+        { 9600, FAX_MODEM_V17_RX,       (DISBIT6 |           DISBIT3)},
+        { 9600, FAX_MODEM_V29_RX,       (                    DISBIT3)},
         { 7200, FAX_MODEM_V17_RX,       (DISBIT6 | DISBIT4 | DISBIT3)},
-        { 7200, FAX_MODEM_V29_RX,       (DISBIT4 | DISBIT3)},
-        { 4800, FAX_MODEM_V27TER_RX,    DISBIT4},
-        { 2400, FAX_MODEM_V27TER_RX,    0},
-        {    0, FAX_MODEM_NONE,         0}
+        { 7200, FAX_MODEM_V29_RX,       (          DISBIT4 | DISBIT3)},
+        { 4800, FAX_MODEM_V27TER_RX,    (          DISBIT4          )},
+        { 2400, FAX_MODEM_V27TER_RX,    (0                          )},
+        {    0, FAX_MODEM_NONE,         (0                          )}
     };
     static const int minimum_scan_line_times[8] =
     {
-        20,
-        5,
-        10,
-        0,
-        40,
-        0,
-        0,
-        0
+        20,  5, 10,  0, 40,  0,  0,  0
     };
     int dcs_code;
     int i;
index 03f8ede658a5763e08424308b165cc8373a40230..b00606b2b822ae3e5b6a338a8eb1e6a241e1fc78 100644 (file)
@@ -1517,7 +1517,7 @@ SPAN_DECLARE(int) t38_terminal_restart(t38_terminal_state_t *s,
                                        bool calling_party)
 {
     t38_terminal_t38_fe_restart(s);
-    t30_restart(&s->t30);
+    t30_restart(&s->t30, calling_party);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
@@ -1557,7 +1557,7 @@ SPAN_DECLARE(t38_terminal_state_t *) t38_terminal_init(t38_terminal_state_t *s,
     t30_set_iaf_mode(&s->t30, s->t38_fe.iaf);
     t30_set_supported_modems(&s->t30,
                              T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17 | T30_SUPPORT_IAF);
-    t30_restart(&s->t30);
+    t30_restart(&s->t30, calling_party);
     return s;
 }
 /*- End of function --------------------------------------------------------*/