diff --git a/libs/spandsp/src/fax.c b/libs/spandsp/src/fax.c index 1437255284..2849745987 100644 --- a/libs/spandsp/src/fax.c +++ b/libs/spandsp/src/fax.c @@ -150,84 +150,6 @@ static void hdlc_underflow_handler(void *user_data) } /*- End of function --------------------------------------------------------*/ -static int v17_v21_rx(void *user_data, const int16_t amp[], int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v17_rx(&s->fast_modems.v17_rx, amp, len); - fsk_rx(&s->v21_rx, amp, len); - if (t->t30.rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.17 (%.2fdBm0)\n", v17_rx_signal_power(&s->fast_modems.v17_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &v17_rx, &s->fast_modems.v17_rx, (span_rx_fillin_handler_t) &v17_rx_fillin, &s->fast_modems.v17_rx); - } - else if (t->t30.rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must be receiving valid V.21 */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); - } - /*endif*/ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v27ter_rx(&s->fast_modems.v27ter_rx, amp, len); - fsk_rx(&s->v21_rx, amp, len); - if (t->t30.rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.27ter (%.2fdBm0)\n", v27ter_rx_signal_power(&s->fast_modems.v27ter_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &v27ter_rx, &s->fast_modems.v27ter_rx, (span_rx_fillin_handler_t) &v27ter_rx_fillin, &s->fast_modems.v27ter_rx); - } - else if (t->t30.rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must be receiving valid V.21 */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); - } - /*endif*/ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v29_v21_rx(void *user_data, const int16_t amp[], int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v29_rx(&s->fast_modems.v29_rx, amp, len); - fsk_rx(&s->v21_rx, amp, len); - if (t->t30.rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.29 (%.2fdBm0)\n", v29_rx_signal_power(&s->fast_modems.v29_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &v29_rx, &s->fast_modems.v29_rx, (span_rx_fillin_handler_t) &v29_rx_fillin, &s->fast_modems.v29_rx); - } - else if (t->t30.rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must be receiving valid V.21 */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); - } - /*endif*/ - return 0; -} -/*- End of function --------------------------------------------------------*/ - SPAN_DECLARE_NONSTD(int) fax_rx(fax_state_t *s, int16_t *amp, int len) { int i; diff --git a/libs/spandsp/src/fax_modems.c b/libs/spandsp/src/fax_modems.c index 8887f571f8..d2510a4909 100644 --- a/libs/spandsp/src/fax_modems.c +++ b/libs/spandsp/src/fax_modems.c @@ -262,6 +262,7 @@ SPAN_DECLARE(void) fax_modems_start_slow_modem(fax_modems_state_t *s, int which) case FAX_MODEM_V21_RX: fsk_rx_init(&s->v21_rx, &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, &s->hdlc_rx); fsk_rx_signal_cutoff(&s->v21_rx, -39.09f); + //fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); s->rx_frame_received = FALSE; break; case FAX_MODEM_V21_TX: @@ -426,6 +427,7 @@ SPAN_DECLARE(void) fax_modems_set_rx_handler(fax_modems_state_t *s, s->rx_handler = rx_handler; s->rx_fillin_handler = rx_fillin_handler; } + /*endif*/ s->rx_user_data = rx_user_data; s->rx_fillin_user_data = rx_fillin_user_data; } diff --git a/libs/spandsp/src/t31.c b/libs/spandsp/src/t31.c index 467dd30ed0..897bd066e3 100644 --- a/libs/spandsp/src/t31.c +++ b/libs/spandsp/src/t31.c @@ -1756,6 +1756,8 @@ static int restart_modem(t31_state_t *s, int new_modem) s->at_state.transmit = TRUE; break; case FAX_MODEM_V17_RX: + case FAX_MODEM_V27TER_RX: + case FAX_MODEM_V29_RX: if (!s->t38_mode) { fax_modems_start_fast_modem(t, s->modem, s->bit_rate, s->short_train, use_hdlc); @@ -1789,15 +1791,6 @@ static int restart_modem(t31_state_t *s, int new_modem) s->tx.data_started = FALSE; s->at_state.transmit = TRUE; break; - case FAX_MODEM_V27TER_RX: - if (!s->t38_mode) - { - fax_modems_start_fast_modem(t, s->modem, s->bit_rate, s->short_train, use_hdlc); - /* Allow for +FCERROR/+FRH:3 */ - t31_v21_rx(s); - } - s->at_state.transmit = FALSE; - break; case FAX_MODEM_V29_TX: if (s->t38_mode) { @@ -1823,15 +1816,6 @@ static int restart_modem(t31_state_t *s, int new_modem) s->tx.data_started = FALSE; s->at_state.transmit = TRUE; break; - case FAX_MODEM_V29_RX: - if (!s->t38_mode) - { - fax_modems_start_fast_modem(t, s->modem, s->bit_rate, s->short_train, use_hdlc); - /* Allow for +FCERROR/+FRH:3 */ - t31_v21_rx(s); - } - s->at_state.transmit = FALSE; - break; case FAX_MODEM_SILENCE_TX: if (s->t38_mode) { diff --git a/libs/spandsp/src/t38_gateway.c b/libs/spandsp/src/t38_gateway.c index 9da2f0b910..e3993609cc 100644 --- a/libs/spandsp/src/t38_gateway.c +++ b/libs/spandsp/src/t38_gateway.c @@ -196,78 +196,6 @@ static void non_ecm_remove_fill_and_put_bit(void *user_data, int bit); static void non_ecm_push_residue(t38_gateway_state_t *s); static void tone_detected(void *user_data, int tone, int level, int delay); -static int v17_v21_rx(void *user_data, const int16_t amp[], int len) -{ - fax_modems_state_t *s; - - s = (fax_modems_state_t *) user_data; - v17_rx(&s->fast_modems.v17_rx, amp, len); - fsk_rx(&s->v21_rx, amp, len); - if (s->rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.17 (%.2fdBm0)\n", v17_rx_signal_power(&s->fast_modems.v17_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &v17_rx, &s->fast_modems.v17_rx, (span_rx_fillin_handler_t) &v17_rx_fillin, &s->fast_modems.v17_rx); - } - else if (s->rx_signal_present) - { - /* We have received something, and the fast modem has not trained. We must be receiving valid V.21 */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); - } - /*endif*/ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) -{ - fax_modems_state_t *s; - - s = (fax_modems_state_t *) user_data; - v27ter_rx(&s->fast_modems.v27ter_rx, amp, len); - fsk_rx(&s->v21_rx, amp, len); - if (s->rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.27ter (%.2fdBm0)\n", v27ter_rx_signal_power(&s->fast_modems.v27ter_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &v27ter_rx, &s->fast_modems.v27ter_rx, (span_rx_fillin_handler_t) &v27ter_rx_fillin, &s->fast_modems.v27ter_rx); - } - else if (s->rx_signal_present) - { - /* We have received something, and the fast modem has not trained. We must be receiving valid V.21 */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); - } - /*endif*/ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v29_v21_rx(void *user_data, const int16_t amp[], int len) -{ - fax_modems_state_t *s; - - s = (fax_modems_state_t *) user_data; - v29_rx(&s->fast_modems.v29_rx, amp, len); - fsk_rx(&s->v21_rx, amp, len); - if (s->rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.29 (%.2fdBm0)\n", v29_rx_signal_power(&s->fast_modems.v29_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &v29_rx, &s->fast_modems.v29_rx, (span_rx_fillin_handler_t) &v29_rx_fillin, &s->fast_modems.v29_rx); - } - else if (s->rx_signal_present) - { - /* We have received something, and the fast modem has not trained. We must be receiving valid V.21 */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); - } - /*endif*/ - return 0; -} -/*- End of function --------------------------------------------------------*/ - static void tone_detected(void *user_data, int tone, int level, int delay) { t38_gateway_state_t *s; @@ -2044,18 +1972,13 @@ static int restart_rx_modem(t38_gateway_state_t *s) switch (s->core.fast_rx_modem) { case FAX_MODEM_V27TER_RX: - fax_modems_start_fast_modem(t, s->core.fast_rx_modem, s->core.fast_bit_rate, s->core.short_train, FALSE); - s->core.fast_rx_active = s->core.fast_rx_modem; - break; case FAX_MODEM_V29_RX: - fax_modems_start_fast_modem(t, s->core.fast_rx_modem, s->core.fast_bit_rate, s->core.short_train, FALSE); - s->core.fast_rx_active = s->core.fast_rx_modem; - break; case FAX_MODEM_V17_RX: fax_modems_start_fast_modem(t, s->core.fast_rx_modem, s->core.fast_bit_rate, s->core.short_train, FALSE); s->core.fast_rx_active = s->core.fast_rx_modem; break; default: + //fax_modems_start_slow_modem(t, FAX_MODEM_V21_RX); fax_modems_set_rx_handler(t, (span_rx_handler_t) &fsk_rx, &t->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &t->v21_rx); s->core.fast_rx_active = FAX_MODEM_NONE; break;