diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.c b/src/mod/applications/mod_spandsp/mod_spandsp.c index b6ff1771de..08bcf5e17d 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp.c @@ -64,6 +64,11 @@ SWITCH_STANDARD_APP(spanfax_rx_function) mod_spandsp_fax_process_fax(session, data, FUNCTION_RX); } +SWITCH_STANDARD_APP(spanfax_stop_function) +{ + mod_spandsp_fax_stop_fax(session); +} + SWITCH_STANDARD_APP(dtmf_session_function) { spandsp_inband_dtmf_session(session); @@ -740,6 +745,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) SAF_SUPPORT_NOMEDIA | SAF_NO_LOOPBACK); SWITCH_ADD_APP(app_interface, "txfax", "FAX Transmit Application", "FAX Transmit Application", spanfax_tx_function, SPANFAX_TX_USAGE, SAF_SUPPORT_NOMEDIA | SAF_NO_LOOPBACK); + SWITCH_ADD_APP(app_interface, "stopfax", "Stop FAX Application", "Stop FAX Application", spanfax_stop_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "spandsp_stop_dtmf", "stop inband dtmf", "Stop detecting inband dtmf.", stop_dtmf_session_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "spandsp_start_dtmf", "Detect dtmf", "Detect inband dtmf on the session", dtmf_session_function, "", SAF_MEDIA_TAP); diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.h b/src/mod/applications/mod_spandsp/mod_spandsp.h index 5f5a038c43..ac40fa2d9b 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.h +++ b/src/mod/applications/mod_spandsp/mod_spandsp.h @@ -132,6 +132,7 @@ void mod_spandsp_dsp_shutdown(void); void mod_spandsp_fax_event_handler(switch_event_t *event); void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *data, mod_spandsp_fax_application_mode_t app_mode); +void mod_spandsp_fax_stop_fax(switch_core_session_t *session); switch_bool_t t38_gateway_start(switch_core_session_t *session, const char *app, const char *data); switch_status_t spandsp_stop_inband_dtmf_session(switch_core_session_t *session); diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index c76fda6637..026917b58f 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -1347,6 +1347,14 @@ static pvt_t *pvt_init(switch_core_session_t *session, mod_spandsp_fax_applicati return pvt; } +void mod_spandsp_fax_stop_fax(switch_core_session_t *session) +{ + pvt_t *pvt = switch_channel_get_private(switch_core_session_get_channel(session), "_fax_pvt"); + if (pvt) { + pvt->done = 1; + } +} + void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *data, mod_spandsp_fax_application_mode_t app_mode) { pvt_t *pvt; @@ -1365,7 +1373,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat pvt = pvt_init(session, app_mode); - + switch_channel_set_private(channel, "_fax_pvt", pvt); buf = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE); @@ -1478,6 +1486,8 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat int tx = 0; switch_status_t status; + switch_ivr_parse_all_events(session); + /* if we are in T.38 mode, we should: 1- initialize the ptv->t38_state stuff, if not done and then set some callbacks when reading frames.