]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add ignore_ring_ready tone_detect_sleep and tone_detect_expires
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 20 Jan 2009 15:39:32 +0000 (15:39 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 20 Jan 2009 15:39:32 +0000 (15:39 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11309 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_ivr_async.c
src/switch_ivr_originate.c

index 3b8554e30f311919a7b7f2f814d57481f1e241d7..e90e0380ed45c451f4b5a68b2428fe85a4cf4f6e 100644 (file)
@@ -1197,6 +1197,8 @@ typedef struct {
        int hits;
        int sleep;
        int expires;
+       int default_sleep;
+       int default_expires;
        int once;
        switch_tone_detect_callback_t callback;
 } 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", 
                                                                          cont->list[i].key, cont->list[i].hits, cont->list[i].total_hits);
-                                       cont->list[i].sleep = 50;
-                                       cont->list[i].expires = 250;
+                                       cont->list[i].sleep = cont->list[i].default_sleep;
+                                       cont->list[i].expires = cont->list[i].default_expires;
                                        
                                        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);
@@ -1335,6 +1337,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi
        char *p, *next;
        int i = 0, ok = 0;
        switch_media_bug_flag_t bflags = 0;
+       const char *var;
 
        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);
 
+       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)) {
                bflags = SMBF_READ_REPLACE;
        } else {
index e684a9f6ca191e62951f45c43419084f13ef7bc1..860e468a3ce686ea2e741c1b358ed9ddd712bd02 100644 (file)
@@ -82,7 +82,6 @@ typedef struct {
        uint8_t ring_ready;
        uint8_t early_media;
        uint8_t answered;
-       uint8_t dead;
        uint32_t per_channel_timelimit_sec;
        uint32_t per_channel_progress_timelimit_sec;
 } originate_status_t;
@@ -101,6 +100,9 @@ typedef struct {
        uint8_t return_ring_ready;
        uint8_t monitor_early_media_ring;
        uint8_t monitor_early_media_fail;
+       uint8_t gen_ringback;
+       uint8_t ignore_early_media;
+       uint8_t ignore_ring_ready;
 } originate_global_t;
 
 
@@ -257,11 +259,13 @@ static switch_bool_t monitor_callback(switch_core_session_t *session, const char
                                        oglobals->progress = 1;
                                }
                        
-                               if (!oglobals->ring_ready) {
+                               if (!oglobals->ring_ready && !oglobals->ignore_ring_ready) {
                                        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->progress) {
                                        oglobals->progress = 1;
                                }
                        
-                               if (!oglobals->ring_ready) {
+                               if (!oglobals->ring_ready && !oglobals->ignore_ring_ready) {
                                        oglobals->ring_ready = 1;
                                }
                        }
@@ -965,6 +969,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                        ok = 1;
                                } else if (!strcasecmp((char *) hi->name, "ignore_early_media")) {
                                        ok = 1;
+                               } else if (!strcasecmp((char *) hi->name, "ignore_ring_ready")) {
+                                       ok = 1;
                                } else if (!strcasecmp((char *) hi->name, "monitor_early_media_ring")) {
                                        ok = 1;
                                } 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)) {
                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"))) {
@@ -1553,7 +1564,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                if (ringback_data) {
                                                        char *tmp_data = NULL;
 
-                                                       
+                                                       oglobals.gen_ringback = 1;
+
                                                        if (switch_is_file_path(ringback_data)) {
                                                                char *ext;