FS-3570 receive side, update libteletone to track duration so it is less likely to double detect and push api changes down to freetdm

This commit is contained in:
Anthony Minessale
2011-09-16 10:05:43 -05:00
parent d9ce90d7b9
commit a65794fb5e
14 changed files with 434 additions and 191 deletions
@@ -92,40 +92,49 @@ static void check_timeouts(void)
void *val;
time_t now;
valet_lot_t *lot;
switch_console_callback_match_t *matches = NULL;
switch_console_callback_match_node_t *m;
switch_hash_index_t *i_hi;
const void *i_var;
void *i_val;
char *i_ext;
valet_token_t *token;
now = switch_epoch_time_now(NULL);
switch_mutex_lock(globals.mutex);
for (hi = switch_hash_first(NULL, globals.hash); hi; hi = switch_hash_next(hi)) {
switch_hash_index_t *i_hi;
const void *i_var;
void *i_val;
char *i_ext;
valet_token_t *token;
switch_hash_this(hi, &var, NULL, &val);
lot = (valet_lot_t *) val;
switch_mutex_lock(lot->mutex);
top:
for (i_hi = switch_hash_first(NULL, lot->hash); i_hi; i_hi = switch_hash_next(i_hi)) {
switch_hash_this(i_hi, &i_var, NULL, &i_val);
i_ext = (char *) i_var;
token = (valet_token_t *) i_val;
if (token->timeout > 0 && (token->timeout < now || token->timeout == 1)) {
switch_core_hash_delete(lot->hash, i_ext);
switch_safe_free(token);
goto top;
}
}
switch_mutex_unlock(lot->mutex);
switch_console_push_match(&matches, (const char *) var);
}
switch_mutex_unlock(globals.mutex);
if (matches) {
for (m = matches->head; m; m = m->next) {
lot = valet_find_lot(m->val);
switch_mutex_lock(lot->mutex);
top:
for (i_hi = switch_hash_first(NULL, lot->hash); i_hi; i_hi = switch_hash_next(i_hi)) {
switch_hash_this(i_hi, &i_var, NULL, &i_val);
i_ext = (char *) i_var;
token = (valet_token_t *) i_val;
if (token->timeout > 0 && (token->timeout < now || token->timeout == 1)) {
switch_core_hash_delete(lot->hash, i_ext);
switch_safe_free(token);
goto top;
}
}
switch_mutex_unlock(lot->mutex);
}
switch_console_free_matches(&matches);
}
}
static int next_id(valet_lot_t *lot, int min, int max, int in)
+9 -15
View File
@@ -2139,8 +2139,8 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
{
switch_inband_dtmf_t *pvt = (switch_inband_dtmf_t *) user_data;
switch_frame_t *frame = NULL;
char digit_str[80];
switch_channel_t *channel = switch_core_session_get_channel(pvt->session);
teletone_hit_type_t hit;
switch (type) {
case SWITCH_ABC_TYPE_INIT:
@@ -2149,20 +2149,14 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
break;
case SWITCH_ABC_TYPE_READ_REPLACE:
if ((frame = switch_core_media_bug_get_read_replace_frame(bug))) {
teletone_dtmf_detect(&pvt->dtmf_detect, frame->data, frame->samples);
teletone_dtmf_get(&pvt->dtmf_detect, digit_str, sizeof(digit_str));
if (digit_str[0]) {
char *p = digit_str;
while (p && *p) {
switch_dtmf_t dtmf = {0};
dtmf.digit = *p;
dtmf.duration = switch_core_default_dtmf_duration(0);
dtmf.source = SWITCH_DTMF_INBAND_AUDIO;
switch_channel_queue_dtmf(channel, &dtmf);
p++;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n",
digit_str);
if ((hit = teletone_dtmf_detect(&pvt->dtmf_detect, frame->data, frame->samples)) == TT_HIT_END) {
switch_dtmf_t dtmf = {0};
teletone_dtmf_get(&pvt->dtmf_detect, &dtmf.digit, &dtmf.duration);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "DTMF DETECTED: [%c][%d]\n",
dtmf.digit, dtmf.duration);
dtmf.source = SWITCH_DTMF_INBAND_AUDIO;
switch_channel_queue_dtmf(channel, &dtmf);
}
switch_core_media_bug_set_read_replace_frame(bug, frame);
}