From 79e9f19cb917383bec39e53b7247b1a72383c8ea Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 29 Jun 2011 18:22:57 -0500 Subject: [PATCH] add execute_on_fax_success, execute_on_fax_failure and execute_on_fax_result channel variables to trigger an app or lua script when a fax result is received --- src/mod/applications/mod_spandsp/mod_spandsp_fax.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index 0cfd55c659..9b36d03cca 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -341,6 +341,7 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Fax successfully managed. How ?\n"); } switch_channel_set_variable(channel, "fax_success", "1"); + } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Fax processing not successful - result (%d) %s.\n", result, t30_completion_code_to_str(result)); @@ -430,6 +431,15 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-remote-station-id", far_ident); switch_event_fire(&event); } + + switch_channel_execute_on(channel, "execute_on_fax_result"); + + if (result == T30_ERR_OK) { + switch_channel_execute_on(channel, "execute_on_fax_success"); + } else { + switch_channel_execute_on(channel, "execute_on_fax_failure"); + } + } static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count)