term->uuid = NULL;
}
- if (zstr(term->uuid)) {
- switch_channel_t *channel;
- if (switch_ivr_originate(NULL, &session, &cause, dialstring, 0, NULL, NULL, NULL, NULL, var_event, 0, NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to instanciate termination [%s]: %s\n", term->name, switch_channel_cause2str(cause));
- status = SWITCH_STATUS_FALSE;
- goto done;
- }
-
- term->uuid = switch_core_strdup(term->pool, switch_core_session_get_uuid(session));
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Termination [%s] successfully instanciated as [%s] [%s]\n", term->name, dialstring, switch_core_session_get_uuid(session));
- channel = switch_core_session_get_channel(session);
- switch_channel_set_private(channel, PVT_MG_TERM, term);
+ if (zstr(term->uuid)) {
+ switch_channel_t *channel;
+ if (switch_ivr_originate(NULL, &session, &cause, dialstring, 0, NULL, NULL, NULL, NULL, var_event, 0, NULL) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to instanciate termination [%s]: %s\n", term->name, switch_channel_cause2str(cause));
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
- if (term->type == MG_TERM_RTP && term->u.rtp.t38_options) {
- switch_channel_set_private(channel, "t38_options", term->u.rtp.t38_options);
- }
-
- switch_core_event_hook_add_recv_dtmf(session, mg_on_dtmf);
-
- if ((term->type == MG_TERM_TDM) && (term->profile)){
- switch(term->profile->fax_detect_evt_type){
- case MG_FAX_DETECT_EVENT_TYPE_CED:
- {
- switch_core_session_execute_application_async(session, "spandsp_start_fax_detect", "mg_notify ced 120 ced");
- break;
- }
- case MG_FAX_DETECT_EVENT_TYPE_CNG:
- {
- switch_core_session_execute_application_async(session, "spandsp_start_fax_detect", "mg_notify cng 120 cng");
- break;
- }
- case MG_FAX_DETECT_EVENT_TYPE_CNG_CED:
- {
- 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");
- break;
- }
- case MG_FAX_DETECT_EVENT_TYPE_DISABLE:
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FAX detection Disable\n");
- break;
- }
- default:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid FAX detection Event[%d]\n",term->profile->fax_detect_evt_type);
- break;
- }
- }
- }
+ term->uuid = switch_core_strdup(term->pool, switch_core_session_get_uuid(session));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Termination [%s] successfully instanciated as [%s] [%s]\n", term->name, dialstring, switch_core_session_get_uuid(session));
+ channel = switch_core_session_get_channel(session);
+ switch_channel_set_private(channel, PVT_MG_TERM, term);
+
+ if (term->type == MG_TERM_RTP && term->u.rtp.t38_options) {
+ switch_channel_set_private(channel, "t38_options", term->u.rtp.t38_options);
+ }
+
+ switch_core_event_hook_add_recv_dtmf(session, mg_on_dtmf);
+ if (term->type == MG_TERM_TDM){
+ switch_core_session_execute_application_async(session, "spandsp_start_fax_detect", "mg_notify ced 120 ced");
+ switch_core_session_execute_application_async(session, "spandsp_start_fax_detect", "mg_notify cng 120 cng");
+ }
+
+ }
switch_set_flag(term, MGT_ACTIVE);
switch_clear_flag(term, MGT_ALLOCATED);
switch_clear_flag(term, MGT_ACTIVE);
+ switch_clear_flag(term, MG_FAX_NOTIFIED);
if (term->type == MG_TERM_RTP) {
switch_core_hash_delete_wrlock(term->profile->terminations, term->name, term->profile->terminations_rwlock);
for (hi = switch_hash_first(NULL, profile->terminations); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, &key, &keylen, &val);
term = (mg_termination_t *) val;
- if(!term) continue;
- megaco_check_tdm_termination(term);
+ if(!term) continue;
+ if(MG_TERM_RTP == term->type) continue;
+ megaco_check_tdm_termination(term);
}
return SWITCH_STATUS_SUCCESS;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"rtp_ipaddr[%s], local ip[%s]\n", profile->rtp_ipaddr, profile->my_ipaddr);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"fax_detect_evt_type[%s]\n", mg_fax_detect_evt_type2str(profile->fax_detect_evt_type));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"t38_fax_notify[%s]\n",
+ (MG_T38_FAX_NOTIFY_YES == profile->t38_fax_notify)?"ENABLE":"DISABLE");
if(SWITCH_STATUS_FALSE == (status = modify_mg_profile_mid(profile, &profile->mid))){
goto done;
term->u.tdm.channel = tdm_chan_num;
term->u.tdm.span_name = switch_core_strdup(pool, channel_prefix);
switch_set_flag(term, MG_OUT_OF_SERVICE);
+ switch_clear_flag(term, MG_FAX_NOTIFIED);
switch_core_hash_insert_wrlock(profile->terminations, term->name, term, profile->terminations_rwlock);
term->next = profile->physical_terminations;
{ "G.723.1", MEGACO_CODEC_G723_1},
{ "ILBC", MEGACO_CODEC_ILBC },
};
-#endif
+
static switch_xml_config_enum_item_t opt_fax_detect_type_enum[] = {
{ "CED", MG_FAX_DETECT_EVENT_TYPE_CED},
{ "CNG", MG_FAX_DETECT_EVENT_TYPE_CNG},
{ "CED_CNG", MG_FAX_DETECT_EVENT_TYPE_CNG_CED},
{ "DISABLE", MG_FAX_DETECT_EVENT_TYPE_DISABLE},
};
+#endif
+ static switch_xml_config_enum_item_t opt_t38_fax_notify[] = {
+ { "ENABLE", MG_T38_FAX_NOTIFY_YES},
+ { "DISABLE", MG_T38_FAX_NOTIFY_NO},
+ };
+
switch_xml_config_item_t instructions[] = {
SWITCH_CONFIG_ITEM("codec-prefs", SWITCH_CONFIG_STRING, 0, &profile->codec_prefs, "", &switch_config_string_strdup, "", "codec preferences, coma-separated"),
SWITCH_CONFIG_ITEM("license", SWITCH_CONFIG_STRING, 0, &profile->license, "/usr/local/nsg/conf/license.txt", &switch_config_string_strdup, "", "License file"),
SWITCH_CONFIG_ITEM("rtp-ip", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->rtp_ipaddr, "" , &switch_config_string_strdup, "", "rtp ip"),
- SWITCH_CONFIG_ITEM("fax-detect-event-type", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &profile->fax_detect_evt_type, MG_FAX_DETECT_EVENT_TYPE_CNG_CED , &opt_fax_detect_type_enum, "", "fax-detect-event-type"),
+ //SWITCH_CONFIG_ITEM("fax-detect-event-type", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &profile->fax_detect_evt_type, MG_FAX_DETECT_EVENT_TYPE_CNG_CED , &opt_fax_detect_type_enum, "", "fax-detect-event-type"),
+ SWITCH_CONFIG_ITEM("t38-fax-notify", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &profile->t38_fax_notify, MG_T38_FAX_NOTIFY_YES , &opt_t38_fax_notify, "", "t38_fax_notify"),
SWITCH_CONFIG_ITEM_END()
};
return;
}
- 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");
- /* Disable echo cancellation */
- mg_term_set_ec(term, 0);
- } 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");
- /* Disable echo cancellation */
- mg_term_set_ec(term, 0);
- }
+ if (!strcmp(data, "cng")) {
+ if((term->profile) &&
+ (term->profile->t38_fax_notify == MG_T38_FAX_NOTIFY_YES) &&
+ !switch_test_flag(term, MG_FAX_NOTIFIED)){
+ switch_set_flag(term, MG_FAX_NOTIFIED);
+ mg_send_t38_cng_notify(term->profile, term->name);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sent CNG notify\n");
+ }else{
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Not reporting CNG tone "
+ "FAX Notify[%s] MG_FAX_NOTIFIED flag [%s]\n",
+ (MG_T38_FAX_NOTIFY_YES == term->profile->t38_fax_notify)?"ENABLE":"DISABLE",
+ (switch_test_flag(term, MG_FAX_NOTIFIED))?"TRUE":"FALSE");
+ }
+ /* Disable echo cancellation */
+ if(MG_TERM_TDM == term->type){
+ mg_term_set_ec(term, 0);
+ }
+ } else if (!strcmp(data, "ced")) {
+ if((term->profile) &&
+ (term->profile->t38_fax_notify == MG_T38_FAX_NOTIFY_YES) &&
+ !switch_test_flag(term, MG_FAX_NOTIFIED)){
+ switch_set_flag(term, MG_FAX_NOTIFIED);
+ mg_send_t38_ans_notify(term->profile, term->name);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sent CED notify\n");
+ }else{
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Not reporting CED tone "
+ "FAX Notify[%s] MG_FAX_NOTIFIED flag [%s]\n",
+ (MG_T38_FAX_NOTIFY_YES == term->profile->t38_fax_notify)?"ENABLE":"DISABLE",
+ (switch_test_flag(term, MG_FAX_NOTIFIED))?"TRUE":"FALSE");
+ }
+
+ if(MG_TERM_TDM == term->type){
+ mg_term_set_ec(term, 0);
+ }
+ }
+
}
static switch_status_t console_complete_hashtable(switch_hash_t *hash, const char *line, const char *cursor, switch_console_callback_match_t **matches)
MGT_ACTIVE = (1 << 1),
MG_IN_SERVICE = (1 << 2),
MG_OUT_OF_SERVICE = (1 << 3),
+ MG_FAX_NOTIFIED = (1 << 4),
} mg_termination_flags;
+typedef enum {
+ MG_T38_FAX_NOTIFY_NONE,
+ MG_T38_FAX_NOTIFY_YES,
+ MG_T38_FAX_NOTIFY_NO,
+ MG_T38_FAX_NOTIFY_INVALID,
+} mg_t38_fax_notify_t;
+
+
typedef enum {
MGM_AUDIO = 0,
MGM_IMAGE,
int inact_tmr; /* inactivity timer value */
int peer_active; /* inactivity timer value */
uint32_t inact_tmr_task_id; /* FS timer scheduler task-id */
- mg_fax_detect_event_type_t fax_detect_evt_type;
+ mg_t38_fax_notify_t t38_fax_notify;
switch_thread_rwlock_t *contexts_rwlock;
uint32_t next_context_id;