finish up merge
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5380 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
4ca73d77e0
commit
365b8c515d
|
@ -284,7 +284,9 @@ SWITCH_STANDARD_API(tone_detect_session_function)
|
||||||
time_t to = 0;
|
time_t to = 0;
|
||||||
switch_core_session_t *rsession;
|
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) {
|
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");
|
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]) {
|
if (argv[4]) {
|
||||||
uint32_t mto;
|
uint32_t mto;
|
||||||
if (*argv[2] == '+') {
|
if (*argv[4] == '+') {
|
||||||
if ((mto = atoi(argv[3]+1)) > 0) {
|
if ((mto = atoi(argv[4]+1)) > 0) {
|
||||||
to = time(NULL) + mto;
|
to = time(NULL) + mto;
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
} else {
|
} 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");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
|
||||||
to = 0;
|
to = 0;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -317,6 +319,7 @@ SWITCH_STANDARD_API(tone_detect_session_function)
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
|
free(mydata);
|
||||||
switch_core_session_rwunlock(rsession);
|
switch_core_session_rwunlock(rsession);
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
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 = {
|
static switch_api_interface_t tone_detect_session_interface = {
|
||||||
/*.interface_name */ "tone_Detect",
|
/*.interface_name */ "tone_detect",
|
||||||
/*.desc */ "Start Tone Detection on a channel",
|
/*.desc */ "Start Tone Detection on a channel",
|
||||||
/*.function */ tone_detect_session_function,
|
/*.function */ tone_detect_session_function,
|
||||||
/*.syntax */
|
/*.syntax */
|
||||||
|
|
|
@ -680,14 +680,14 @@ static void tone_detect_session_function(switch_core_session_t *session, char *d
|
||||||
}
|
}
|
||||||
if (argv[3]) {
|
if (argv[3]) {
|
||||||
uint32_t mto;
|
uint32_t mto;
|
||||||
if (*argv[2] == '+') {
|
if (*argv[3] == '+') {
|
||||||
if ((mto = atoi(argv[2]+1)) > 0) {
|
if ((mto = atol(argv[3]+1)) > 0) {
|
||||||
to = time(NULL) + mto;
|
to = time(NULL) + mto;
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
|
||||||
}
|
}
|
||||||
} else {
|
} 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");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
|
||||||
to = 0;
|
to = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
||||||
switch_mutex_lock(bp->read_mutex);
|
switch_mutex_lock(bp->read_mutex);
|
||||||
switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen);
|
switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen);
|
||||||
if (bp->callback) {
|
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;
|
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;
|
ok = SWITCH_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)) {
|
if (cont->list[i].up && teletone_multi_tone_detect(&cont->list[i].mt, frame->data, frame->samples)) {
|
||||||
switch_event_t *event;
|
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 (cont->list[i].app) {
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
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) {
|
if (switch_event_create(&event, SWITCH_EVENT_DETECTED_TONE) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_t *dup;
|
switch_event_t *dup;
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Detected-Tone", "%s", cont->list[i].key);
|
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;
|
p = next + 1;
|
||||||
}
|
}
|
||||||
} while (next);
|
} while (next);
|
||||||
|
cont->list[cont->index].map.freqs[i++] = 0;
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid tone spec!\n");
|
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) {
|
if ((status = switch_core_media_bug_add(session, tone_detect_callback, cont, timeout, bflags, &cont->bug)) != SWITCH_STATUS_SUCCESS) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue