finish up merge

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5380 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-06-16 03:43:13 +00:00
parent 4ca73d77e0
commit 365b8c515d
4 changed files with 17 additions and 13 deletions

View File

@ -284,7 +284,9 @@ SWITCH_STANDARD_API(tone_detect_session_function)
time_t to = 0;
switch_core_session_t *rsession;
mydata = switch_core_session_strdup(session, cmd);
mydata = strdup(cmd);
assert(mydata != NULL);
if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 3) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID ARGS!\n");
}
@ -296,15 +298,15 @@ SWITCH_STANDARD_API(tone_detect_session_function)
if (argv[4]) {
uint32_t mto;
if (*argv[2] == '+') {
if ((mto = atoi(argv[3]+1)) > 0) {
if (*argv[4] == '+') {
if ((mto = atoi(argv[4]+1)) > 0) {
to = time(NULL) + mto;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
goto done;
}
} else {
if ((to = atoi(argv[3])) < time(NULL)) {
if ((to = atoi(argv[4])) < time(NULL)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
to = 0;
goto done;
@ -317,6 +319,7 @@ SWITCH_STANDARD_API(tone_detect_session_function)
done:
free(mydata);
switch_core_session_rwunlock(rsession);
return SWITCH_STATUS_SUCCESS;
@ -1431,7 +1434,7 @@ static switch_api_interface_t kill_api_interface = {
};
static switch_api_interface_t tone_detect_session_interface = {
/*.interface_name */ "tone_Detect",
/*.interface_name */ "tone_detect",
/*.desc */ "Start Tone Detection on a channel",
/*.function */ tone_detect_session_function,
/*.syntax */

View File

@ -680,14 +680,14 @@ static void tone_detect_session_function(switch_core_session_t *session, char *d
}
if (argv[3]) {
uint32_t mto;
if (*argv[2] == '+') {
if ((mto = atoi(argv[2]+1)) > 0) {
if (*argv[3] == '+') {
if ((mto = atol(argv[3]+1)) > 0) {
to = time(NULL) + mto;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
}
} else {
if ((to = atoi(argv[2])) < time(NULL)) {
if ((to = atol(argv[3])) < time(NULL)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
to = 0;
}

View File

@ -232,7 +232,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
switch_mutex_lock(bp->read_mutex);
switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen);
if (bp->callback) {
if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE || (bp->stop_time && bp->stop_time >= time(NULL))) {
if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE || (bp->stop_time && bp->stop_time <= time(NULL))) {
ok = SWITCH_FALSE;
}
}
@ -516,7 +516,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
}
}
if (bp->stop_time && bp->stop_time >= time(NULL)) {
if (bp->stop_time && bp->stop_time <= time(NULL)) {
ok = SWITCH_FALSE;
}

View File

@ -519,7 +519,8 @@ static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_da
if (cont->list[i].up && teletone_multi_tone_detect(&cont->list[i].mt, frame->data, frame->samples)) {
switch_event_t *event;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "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);
cont->list[i].up = 0;
if (cont->list[i].app) {
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
@ -531,8 +532,6 @@ static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_da
}
}
cont->list[cont->index].up = 0;
if (switch_event_create(&event, SWITCH_EVENT_DETECTED_TONE) == SWITCH_STATUS_SUCCESS) {
switch_event_t *dup;
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Detected-Tone", "%s", cont->list[i].key);
@ -641,6 +640,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi
p = next + 1;
}
} while (next);
cont->list[cont->index].map.freqs[i++] = 0;
if (!ok) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid tone spec!\n");
@ -675,6 +675,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi
}
}
if ((status = switch_core_media_bug_add(session, tone_detect_callback, cont, timeout, bflags, &cont->bug)) != SWITCH_STATUS_SUCCESS) {
return status;
}