diff --git a/libs/spandsp/src/fax.c b/libs/spandsp/src/fax.c index ea6a1d523a..d3dff3fe97 100644 --- a/libs/spandsp/src/fax.c +++ b/libs/spandsp/src/fax.c @@ -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; diff --git a/libs/spandsp/src/spandsp/fax.h b/libs/spandsp/src/spandsp/fax.h index 01dbb80d80..499b2b3b25 100644 --- a/libs/spandsp/src/spandsp/fax.h +++ b/libs/spandsp/src/spandsp/fax.h @@ -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. diff --git a/libs/spandsp/src/spandsp/t30.h b/libs/spandsp/src/spandsp/t30.h index 6216f41bfd..fce40ba8d3 100644 --- a/libs/spandsp/src/spandsp/t30.h +++ b/libs/spandsp/src/spandsp/t30.h @@ -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. diff --git a/libs/spandsp/src/t30.c b/libs/spandsp/src/t30.c index 539e760e27..e9a8c7d0d3 100644 --- a/libs/spandsp/src/t30.c +++ b/libs/spandsp/src/t30.c @@ -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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t38_gateway.c b/libs/spandsp/src/t38_gateway.c index 646c3fee9a..50ea06f500 100644 --- a/libs/spandsp/src/t38_gateway.c +++ b/libs/spandsp/src/t38_gateway.c @@ -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; diff --git a/libs/spandsp/src/t38_terminal.c b/libs/spandsp/src/t38_terminal.c index 03f8ede658..b00606b2b8 100644 --- a/libs/spandsp/src/t38_terminal.c +++ b/libs/spandsp/src/t38_terminal.c @@ -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 --------------------------------------------------------*/