add ignore_ring_ready tone_detect_sleep and tone_detect_expires

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11309 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-01-20 15:39:32 +00:00
parent 439f8111a2
commit effb166bd4
2 changed files with 42 additions and 9 deletions

View File

@ -1197,6 +1197,8 @@ typedef struct {
int hits; int hits;
int sleep; int sleep;
int expires; int expires;
int default_sleep;
int default_expires;
int once; int once;
switch_tone_detect_callback_t callback; switch_tone_detect_callback_t callback;
} switch_tone_detect_t; } switch_tone_detect_t;
@ -1261,8 +1263,8 @@ static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_da
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TONE %s HIT %d/%d\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TONE %s HIT %d/%d\n",
cont->list[i].key, cont->list[i].hits, cont->list[i].total_hits); cont->list[i].key, cont->list[i].hits, cont->list[i].total_hits);
cont->list[i].sleep = 50; cont->list[i].sleep = cont->list[i].default_sleep;
cont->list[i].expires = 250; cont->list[i].expires = cont->list[i].default_expires;
if (cont->list[i].hits >= cont->list[i].total_hits) { if (cont->list[i].hits >= cont->list[i].total_hits) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TONE %s DETECTED\n", cont->list[i].key); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TONE %s DETECTED\n", cont->list[i].key);
@ -1335,6 +1337,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi
char *p, *next; char *p, *next;
int i = 0, ok = 0; int i = 0, ok = 0;
switch_media_bug_flag_t bflags = 0; switch_media_bug_flag_t bflags = 0;
const char *var;
switch_assert(read_codec != NULL); switch_assert(read_codec != NULL);
@ -1419,6 +1422,24 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi
switch_channel_pre_answer(channel); switch_channel_pre_answer(channel);
cont->list[cont->index].default_sleep = 25;
cont->list[cont->index].default_expires = 250;
if ((var = switch_channel_get_variable(channel, "tone_detect_sleep"))) {
int tmp = atoi(var);
if (tmp > 0) {
cont->list[cont->index].default_sleep = tmp;
}
}
if ((var = switch_channel_get_variable(channel, "tone_detect_expires"))) {
int tmp = atoi(var);
if (tmp > 0) {
cont->list[cont->index].default_expires = tmp;
}
}
if (switch_strlen_zero(flags)) { if (switch_strlen_zero(flags)) {
bflags = SMBF_READ_REPLACE; bflags = SMBF_READ_REPLACE;
} else { } else {

View File

@ -82,7 +82,6 @@ typedef struct {
uint8_t ring_ready; uint8_t ring_ready;
uint8_t early_media; uint8_t early_media;
uint8_t answered; uint8_t answered;
uint8_t dead;
uint32_t per_channel_timelimit_sec; uint32_t per_channel_timelimit_sec;
uint32_t per_channel_progress_timelimit_sec; uint32_t per_channel_progress_timelimit_sec;
} originate_status_t; } originate_status_t;
@ -101,6 +100,9 @@ typedef struct {
uint8_t return_ring_ready; uint8_t return_ring_ready;
uint8_t monitor_early_media_ring; uint8_t monitor_early_media_ring;
uint8_t monitor_early_media_fail; uint8_t monitor_early_media_fail;
uint8_t gen_ringback;
uint8_t ignore_early_media;
uint8_t ignore_ring_ready;
} originate_global_t; } originate_global_t;
@ -257,11 +259,13 @@ static switch_bool_t monitor_callback(switch_core_session_t *session, const char
oglobals->progress = 1; oglobals->progress = 1;
} }
if (!oglobals->ring_ready) { if (!oglobals->ring_ready && !oglobals->ignore_ring_ready) {
oglobals->ring_ready = 1; oglobals->ring_ready = 1;
} }
oglobals->early_ok = 1; if (!oglobals->ignore_early_media && !oglobals->early_ok) {
oglobals->early_ok = 1;
}
} }
} }
} }
@ -417,14 +421,14 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
} }
} }
} }
if (!oglobals->monitor_early_media_ring) { if (!oglobals->monitor_early_media_ring) {
if (!oglobals->progress) { if (!oglobals->progress) {
oglobals->progress = 1; oglobals->progress = 1;
} }
if (!oglobals->ring_ready) { if (!oglobals->ring_ready && !oglobals->ignore_ring_ready) {
oglobals->ring_ready = 1; oglobals->ring_ready = 1;
} }
} }
@ -965,6 +969,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
ok = 1; ok = 1;
} else if (!strcasecmp((char *) hi->name, "ignore_early_media")) { } else if (!strcasecmp((char *) hi->name, "ignore_early_media")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *) hi->name, "ignore_ring_ready")) {
ok = 1;
} else if (!strcasecmp((char *) hi->name, "monitor_early_media_ring")) { } else if (!strcasecmp((char *) hi->name, "monitor_early_media_ring")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *) hi->name, "monitor_early_media_fail")) { } else if (!strcasecmp((char *) hi->name, "monitor_early_media_fail")) {
@ -1079,6 +1085,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
if ((var_val = switch_event_get_header(var_event, "ignore_early_media")) && switch_true(var_val)) { if ((var_val = switch_event_get_header(var_event, "ignore_early_media")) && switch_true(var_val)) {
oglobals.early_ok = 0; oglobals.early_ok = 0;
oglobals.ignore_early_media = 1;
}
if ((var_val = switch_event_get_header(var_event, "ignore_ring_ready")) && switch_true(var_val)) {
oglobals.ignore_ring_ready = 1;
} }
if ((var_val = switch_event_get_header(var_event, "monitor_early_media_ring"))) { if ((var_val = switch_event_get_header(var_event, "monitor_early_media_ring"))) {
@ -1553,7 +1564,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
if (ringback_data) { if (ringback_data) {
char *tmp_data = NULL; char *tmp_data = NULL;
oglobals.gen_ringback = 1;
if (switch_is_file_path(ringback_data)) { if (switch_is_file_path(ringback_data)) {
char *ext; char *ext;