1
0
mirror of https://github.com/signalwire/freeswitch.git synced 2025-03-06 02:22:56 +00:00

fix dtmf bug

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4194 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-02-10 23:16:34 +00:00
parent d1d9fd9a23
commit 4a02e80d5e
3 changed files with 6 additions and 4 deletions
src
mod/languages/mod_spidermonkey
switch_ivr.cswitch_rtp.c

@ -1282,7 +1282,7 @@ static JSBool session_get_digits(JSContext *cx, JSObject *obj, uintN argc, jsval
{ {
struct js_session *jss = JS_GetPrivate(cx, obj); struct js_session *jss = JS_GetPrivate(cx, obj);
char *terminators = NULL; char *terminators = NULL;
char *buf; char buf[128] = "";
int digits; int digits;
int32 timeout = 5000; int32 timeout = 5000;
switch_channel_t *channel; switch_channel_t *channel;
@ -1307,8 +1307,8 @@ static JSBool session_get_digits(JSContext *cx, JSObject *obj, uintN argc, jsval
JS_ValueToInt32(cx, argv[2], &timeout); JS_ValueToInt32(cx, argv[2], &timeout);
} }
buf = switch_core_session_alloc(jss->session, digits);
switch_ivr_collect_digits_count(jss->session, buf, digits, digits, terminators, &term, timeout); switch_ivr_collect_digits_count(jss->session, buf, sizeof(buf), digits, terminators, &term, timeout);
*rval = STRING_TO_JSVAL ( JS_NewStringCopyZ(cx, buf) ); *rval = STRING_TO_JSVAL ( JS_NewStringCopyZ(cx, buf) );
return JS_TRUE; return JS_TRUE;
} }

@ -314,7 +314,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
if (switch_channel_has_dtmf(channel)) { if (switch_channel_has_dtmf(channel)) {
char dtmf[128]; char dtmf[128];
switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf)); switch_channel_dequeue_dtmf(channel, dtmf, maxdigits);
for(i =0 ; i < (uint32_t) strlen(dtmf); i++) { for(i =0 ; i < (uint32_t) strlen(dtmf); i++) {
if (!switch_strlen_zero(terminators) && strchr(terminators, dtmf[i]) && terminator != NULL) { if (!switch_strlen_zero(terminators) && strchr(terminators, dtmf[i]) && terminator != NULL) {

@ -838,6 +838,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
rtp_session->dtmf_data.last_digit = 0; rtp_session->dtmf_data.last_digit = 0;
rtp_session->dtmf_data.dc = 0; rtp_session->dtmf_data.dc = 0;
} }
if (duration && end) { if (duration && end) {
if (key != rtp_session->dtmf_data.last_digit) { if (key != rtp_session->dtmf_data.last_digit) {
char digit_str[] = {key, 0}; char digit_str[] = {key, 0};
@ -917,6 +918,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_queue_dtmf(switch_rtp_t *rtp_session,
} }
p++; p++;
} }
status = switch_buffer_write(rtp_session->dtmf_data.dtmf_buffer, dtmf, wr) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_MEMERR; status = switch_buffer_write(rtp_session->dtmf_data.dtmf_buffer, dtmf, wr) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_MEMERR;
switch_mutex_unlock(rtp_session->dtmf_data.dtmf_mutex); switch_mutex_unlock(rtp_session->dtmf_data.dtmf_mutex);