From 76edb0b94ed2289d393c5de1bdb553e9a18f99c9 Mon Sep 17 00:00:00 2001 From: kapil Date: Tue, 14 Aug 2012 15:41:05 -0400 Subject: [PATCH] add ced detection --- src/mod/applications/mod_spandsp/mod_spandsp_fax.c | 12 ++++++++---- src/mod/endpoints/mod_media_gateway/media_gateway.c | 1 + .../mod_media_gateway/media_gateway_stack.h | 2 ++ .../endpoints/mod_media_gateway/mod_media_gateway.c | 4 +++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index 975aca1fc8..b79331ab15 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -2147,6 +2147,8 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session, switch_media_bug_flag_t bflags = 0; const char *var; switch_codec_implementation_t read_impl = { 0 }; + switch_bool_t set_private = SWITCH_TRUE; + switch_core_session_get_read_impl(session, &read_impl); if (timeout) { @@ -2154,8 +2156,9 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session, } if (cont) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Max Tones Reached!\n"); - return SWITCH_STATUS_FALSE; + //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Max Tones Reached!\n"); + set_private = SWITCH_FALSE; + cont = NULL; } if (!cont && !(cont = switch_core_session_alloc(session, sizeof(*cont)))) { @@ -2218,8 +2221,9 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session, cont->bug_running = 0; return status; } - - switch_channel_set_private(channel, "_fax_tone_detect_", cont); + + if (set_private) + switch_channel_set_private(channel, "_fax_tone_detect_", cont); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway.c b/src/mod/endpoints/mod_media_gateway/media_gateway.c index e3d9d7aafe..87201b4dbb 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway.c @@ -184,6 +184,7 @@ switch_status_t megaco_activate_termination(mg_termination_t *term) if (term->type == MG_TERM_TDM) { switch_core_session_execute_application_async(session, "spandsp_start_fax_detect", "mg_notify cng 120 cng"); + switch_core_session_execute_application_async(session, "spandsp_start_fax_detect", "mg_notify ced 120 ced"); } } diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h index d06e796c54..e603e2c531 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h @@ -168,6 +168,8 @@ switch_status_t mg_send_term_service_change(char *span_name, char *chan_number, switch_status_t mg_send_t38_cng_notify(megaco_profile_t* mg_profile, const char* term_name); +switch_status_t mg_send_t38_ans_notify(megaco_profile_t* mg_profile, const char* term_name); +switch_status_t mg_send_t38_v21flag_notify(megaco_profile_t* mg_profile, const char* term_name); switch_status_t sng_mgco_cfg(megaco_profile_t* profile); diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index 2afd7a778c..a905a445e1 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -39,7 +39,9 @@ SWITCH_STANDARD_APP(mg_notify_function) if (!strcmp(data, "cng")) { mg_send_t38_cng_notify(term->profile, term->name); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sent CNG notify\n"); - switch_channel_set_variable(channel, "mg_cng_detected", "true"); + } else if (!strcmp(data, "ced")) { + mg_send_t38_ans_notify(term->profile, term->name); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sent CED notify\n"); } }