[Freeswitch-svn] [commit] r8126 - in freeswitch/trunk/src: . include include/private mod/applications/mod_commands mod/endpoints/mod_alsa mod/endpoints/mod_dingaling mod/endpoints/mod_iax mod/endpoints/mod_portaudio mod/endpoints/mod_sofia mod/languages/mod_spidermonkey
Freeswitch SVN
anthm at freeswitch.org
Fri Apr 18 13:03:35 EDT 2008
Author: anthm
Date: Fri Apr 18 13:03:34 2008
New Revision: 8126
Modified:
freeswitch/trunk/src/include/private/switch_core_pvt.h
freeswitch/trunk/src/include/switch_core.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c
freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_core_io.c
freeswitch/trunk/src/switch_ivr_async.c
freeswitch/trunk/src/switch_rtp.c
Log:
make dtmf duration defaults tweakable
Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core_pvt.h (original)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h Fri Apr 18 13:03:34 2008
@@ -184,6 +184,8 @@
switch_log_level_t hard_log_level;
char *mailer_app;
char *mailer_app_args;
+ uint32_t max_dtmf_duration;
+ uint32_t default_dtmf_duration;
};
extern struct switch_runtime runtime;
Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h (original)
+++ freeswitch/trunk/src/include/switch_core.h Fri Apr 18 13:03:34 2008
@@ -1598,6 +1598,8 @@
SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload);
SWITCH_DECLARE(switch_bool_t) switch_check_network_list_ip(const char *ip_str, const char *list_name);
SWITCH_DECLARE(void) switch_time_set_monotonic(switch_bool_t enable);
+SWITCH_DECLARE(uint32_t) switch_core_max_dtmf_duration(uint32_t duration);
+SWITCH_DECLARE(uint32_t) switch_core_default_dtmf_duration(uint32_t duration);
///\}
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Fri Apr 18 13:03:34 2008
@@ -1137,7 +1137,9 @@
SCSC_LAST_SPS,
SCSC_RECLAIM,
SCSC_MAX_SESSIONS,
- SCSC_SYNC_CLOCK
+ SCSC_SYNC_CLOCK,
+ SCSC_MAX_DTMF_DURATION,
+ SCSC_DEFAULT_DTMF_DURATION
} switch_session_ctl_t;
typedef struct apr_pool_t switch_memory_pool_t;
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Fri Apr 18 13:03:34 2008
@@ -562,7 +562,7 @@
return SWITCH_STATUS_SUCCESS;
}
-#define CTL_SYNTAX "[hupall|pause|resume|shutdown|sync_clock|reclaim_mem|max_sessions [num]|loglevel [level]]"
+#define CTL_SYNTAX "[hupall|pause|resume|shutdown|sync_clock|reclaim_mem|max_sessions|max_dtmf_duration [num]|loglevel [level]]"
SWITCH_STANDARD_API(ctl_function)
{
int argc;
@@ -597,6 +597,18 @@
}
switch_core_session_ctl(SCSC_MAX_SESSIONS, &arg);
stream->write_function(stream, "+OK max sessions: %d\n", arg);
+ } else if (!strcasecmp(argv[0], "max_dtmf_duration")) {
+ if (argc > 1) {
+ arg = atoi(argv[1]);
+ }
+ switch_core_session_ctl(SCSC_MAX_DTMF_DURATION, &arg);
+ stream->write_function(stream, "+OK max dtmf duration: %d\n", arg);
+ } else if (!strcasecmp(argv[0], "default_dtmf_duration")) {
+ if (argc > 1) {
+ arg = atoi(argv[1]);
+ }
+ switch_core_session_ctl(SCSC_DEFAULT_DTMF_DURATION, &arg);
+ stream->write_function(stream, "+OK default dtmf duration: %d\n", arg);
} else if (!strcasecmp(argv[0], "loglevel")) {
if (argc > 1) {
if (*argv[1] > 47 && *argv[1] < 58) {
Modified: freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c Fri Apr 18 13:03:34 2008
@@ -1212,7 +1212,7 @@
static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *stream)
{
char *dtmf_str = argv[0];
- switch_dtmf_t dtmf = {0, SWITCH_DEFAULT_DTMF_DURATION};
+ switch_dtmf_t dtmf = {0, switch_core_default_dtmf_duration(0)};
if (switch_strlen_zero(dtmf_str)) {
stream->write_function(stream, "No DTMF Supplied!\n");
Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Fri Apr 18 13:03:34 2008
@@ -2706,7 +2706,7 @@
if (msg) {
if (*msg == '+') {
char *p = msg + 1;
- switch_dtmf_t dtmf = { 0, SWITCH_DEFAULT_DTMF_DURATION };
+ switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) };
while (p && *p) {
dtmf.digit = *p;
switch_channel_queue_dtmf(channel, &dtmf);
Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c Fri Apr 18 13:03:34 2008
@@ -1126,7 +1126,7 @@
break;
case IAX_EVENT_DTMF:
if (channel) {
- switch_dtmf_t dtmf = { (char) iaxevent->subclass , SWITCH_DEFAULT_DTMF_DURATION };
+ switch_dtmf_t dtmf = { (char) iaxevent->subclass , switch_core_default_dtmf_duration(0) };
if (globals.debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n", dtmf.digit, switch_channel_get_name(channel));
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c Fri Apr 18 13:03:34 2008
@@ -1203,7 +1203,7 @@
static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *stream)
{
char *dtmf_str = argv[0];
- switch_dtmf_t dtmf = {0, SWITCH_DEFAULT_DTMF_DURATION};
+ switch_dtmf_t dtmf = {0, switch_core_default_dtmf_duration(0)};
if (switch_strlen_zero(dtmf_str)) {
stream->write_function(stream, "No DTMF Supplied!\n");
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Fri Apr 18 13:03:34 2008
@@ -2382,7 +2382,7 @@
const char *signal_ptr;
const char *rec_header;
const char *clientcode_header;
- switch_dtmf_t dtmf = { 0, SWITCH_DEFAULT_DTMF_DURATION };
+ switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) };
if (session) {
/* Get the channel */
@@ -2408,7 +2408,7 @@
int tmp;
signal_ptr += 9;
if ((tmp = atoi(signal_ptr)) <= 0) {
- tmp = SWITCH_DEFAULT_DTMF_DURATION;
+ tmp = switch_core_default_dtmf_duration(0);
}
dtmf.duration = tmp * 8;
}
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Fri Apr 18 13:03:34 2008
@@ -761,7 +761,7 @@
static JSBool dtmf_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
switch_dtmf_t *dtmf;
- int32 duration = SWITCH_DEFAULT_DTMF_DURATION;
+ int32 duration = switch_core_default_dtmf_duration(0);
char *ename;
if (argc > 0) {
@@ -774,7 +774,7 @@
if (argc > 1) {
JS_ValueToInt32(cx, argv[1], &duration);
if (duration <= 0) {
- duration = SWITCH_DEFAULT_DTMF_DURATION;
+ duration = switch_core_default_dtmf_duration(0);
}
}
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Fri Apr 18 13:03:34 2008
@@ -226,12 +226,12 @@
switch_dtmf_t *dt;
int x = 0;
- if (new_dtmf.duration > SWITCH_MAX_DTMF_DURATION) {
+ if (new_dtmf.duration > switch_core_max_dtmf_duration(0)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n",
switch_channel_get_name(channel), new_dtmf.digit, new_dtmf.duration);
- new_dtmf.duration = SWITCH_MAX_DTMF_DURATION;
+ new_dtmf.duration = switch_core_max_dtmf_duration(0);
} else if (!new_dtmf.duration) {
- new_dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
+ new_dtmf.duration = switch_core_default_dtmf_duration(0);
}
switch_zmalloc(dt, sizeof(*dt));
@@ -259,7 +259,7 @@
SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(switch_channel_t *channel, const char *dtmf_string)
{
char *p;
- switch_dtmf_t dtmf = {0, SWITCH_DEFAULT_DTMF_DURATION};
+ switch_dtmf_t dtmf = {0, switch_core_default_dtmf_duration(0)};
int sent = 0, dur;
char *string;
int i, argc;
@@ -273,8 +273,8 @@
argc = switch_separate_string(string, '+', argv, (sizeof(argv) / sizeof(argv[0])));
for(i = 0; i < argc; i++) {
- dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
- dur = SWITCH_DEFAULT_DTMF_DURATION / 8;
+ dtmf.duration = switch_core_default_dtmf_duration(0);
+ dur = switch_core_default_dtmf_duration(0) / 8;
if ((p = strchr(argv[i], '@'))) {
*p++ = '\0';
if ((dur = atoi(p)) > 50) {
@@ -282,11 +282,11 @@
}
}
- if (dtmf.duration > SWITCH_MAX_DTMF_DURATION) {
+ if (dtmf.duration > switch_core_max_dtmf_duration(0)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "EXECSSIVE DTMF DIGIT LEN %c %d\n", dtmf.digit, dtmf.duration);
- dtmf.duration = SWITCH_MAX_DTMF_DURATION;
+ dtmf.duration = switch_core_max_dtmf_duration(0);
} else if (!dtmf.duration) {
- dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
+ dtmf.duration = switch_core_default_dtmf_duration(0);
}
@@ -320,12 +320,12 @@
*dtmf = *dt;
free(dt);
- if (dtmf->duration > SWITCH_MAX_DTMF_DURATION) {
+ if (dtmf->duration > switch_core_max_dtmf_duration(0)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n",
switch_channel_get_name(channel), dtmf->digit, dtmf->duration);
- dtmf->duration = SWITCH_MAX_DTMF_DURATION;
+ dtmf->duration = switch_core_max_dtmf_duration(0);
} else if (!dtmf->duration) {
- dtmf->duration = SWITCH_DEFAULT_DTMF_DURATION;
+ dtmf->duration = switch_core_default_dtmf_duration(0);
}
status = SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Fri Apr 18 13:03:34 2008
@@ -812,6 +812,28 @@
switch_mutex_unlock(runtime.global_mutex);
}
+SWITCH_DECLARE(uint32_t) switch_core_max_dtmf_duration(uint32_t duration)
+{
+ if (duration) {
+ if (duration > SWITCH_MAX_DTMF_DURATION) {
+ duration = SWITCH_MAX_DTMF_DURATION;
+ }
+ runtime.max_dtmf_duration = duration;
+ }
+ return runtime.max_dtmf_duration;
+}
+
+SWITCH_DECLARE(uint32_t) switch_core_default_dtmf_duration(uint32_t duration)
+{
+ if (duration) {
+ if (duration < SWITCH_DEFAULT_DTMF_DURATION) {
+ duration = SWITCH_DEFAULT_DTMF_DURATION;
+ }
+ runtime.default_dtmf_duration = duration;
+ }
+ return runtime.default_dtmf_duration;
+}
+
SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switch_bool_t console, const char **err)
{
switch_xml_t xml = NULL, cfg = NULL;
@@ -824,6 +846,8 @@
runtime.hard_log_level = SWITCH_LOG_DEBUG;
runtime.mailer_app = "sendmail";
runtime.mailer_app_args = "-t";
+ runtime.max_dtmf_duration = SWITCH_MAX_DTMF_DURATION;
+ runtime.default_dtmf_duration = SWITCH_DEFAULT_DTMF_DURATION;
/* INIT APR and Create the pool context */
if (apr_initialize() != SWITCH_STATUS_SUCCESS) {
@@ -898,6 +922,16 @@
runtime.mailer_app_args = switch_core_strdup(runtime.memory_pool, val);
} else if (!strcasecmp(var, "sessions-per-second")) {
switch_core_sessions_per_second(atoi(val));
+ } else if (!strcasecmp(var, "max_dtmf_duration")) {
+ int tmp = atoi(val);
+ if (tmp > 0) {
+ switch_core_max_dtmf_duration((uint32_t)tmp);
+ }
+ } else if (!strcasecmp(var, "default_dtmf_duration")) {
+ int tmp = atoi(val);
+ if (tmp > 0) {
+ switch_core_default_dtmf_duration((uint32_t)tmp);
+ }
} else if (!strcasecmp(var, "disable-monotonic-timing")) {
switch_time_set_monotonic(SWITCH_FALSE);
} else if (!strcasecmp(var, "max-sessions")) {
@@ -1137,6 +1171,12 @@
case SCSC_LAST_SPS:
*val = runtime.sps_last;
break;
+ case SCSC_MAX_DTMF_DURATION:
+ *val = switch_core_max_dtmf_duration(*val);
+ break;
+ case SCSC_DEFAULT_DTMF_DURATION:
+ *val = switch_core_default_dtmf_duration(*val);
+ break;
case SCSC_SPS:
switch_mutex_lock(runtime.throttle_mutex);
if (*val > 0) {
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Fri Apr 18 13:03:34 2008
@@ -952,12 +952,12 @@
new_dtmf = *dtmf;
- if (new_dtmf.duration > SWITCH_MAX_DTMF_DURATION) {
+ if (new_dtmf.duration > switch_core_max_dtmf_duration(0)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n",
switch_channel_get_name(session->channel), new_dtmf.digit, new_dtmf.duration);
- new_dtmf.duration = SWITCH_MAX_DTMF_DURATION;
+ new_dtmf.duration = switch_core_max_dtmf_duration(0);
} else if (!new_dtmf.duration) {
- new_dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
+ new_dtmf.duration = switch_core_default_dtmf_duration(0);
}
for (ptr = session->event_hooks.recv_dtmf; ptr; ptr = ptr->next) {
@@ -982,12 +982,12 @@
new_dtmf = *dtmf;
- if (new_dtmf.duration > SWITCH_MAX_DTMF_DURATION) {
+ if (new_dtmf.duration > switch_core_max_dtmf_duration(0)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n",
switch_channel_get_name(session->channel), new_dtmf.digit, new_dtmf.duration);
- new_dtmf.duration = SWITCH_MAX_DTMF_DURATION;
+ new_dtmf.duration = switch_core_max_dtmf_duration(0);
} else if (!new_dtmf.duration) {
- new_dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
+ new_dtmf.duration = switch_core_default_dtmf_duration(0);
}
@@ -1012,7 +1012,7 @@
SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core_session_t *session, const char *dtmf_string)
{
char *p;
- switch_dtmf_t dtmf = {0, SWITCH_DEFAULT_DTMF_DURATION};
+ switch_dtmf_t dtmf = {0, switch_core_default_dtmf_duration(0)};
int sent = 0, dur;
char *string;
int i, argc;
@@ -1042,8 +1042,8 @@
}
for(i = 0; i < argc; i++) {
- dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
- dur = SWITCH_DEFAULT_DTMF_DURATION / 8;
+ dtmf.duration = switch_core_default_dtmf_duration(0);
+ dur = switch_core_default_dtmf_duration(0) / 8;
if ((p = strchr(argv[i], '@'))) {
*p++ = '\0';
if ((dur = atoi(p)) > 50) {
@@ -1052,12 +1052,12 @@
}
- if (dtmf.duration > SWITCH_MAX_DTMF_DURATION) {
+ if (dtmf.duration > switch_core_max_dtmf_duration(0)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n",
switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration);
- dtmf.duration = SWITCH_MAX_DTMF_DURATION;
+ dtmf.duration = switch_core_max_dtmf_duration(0);
} else if (!dtmf.duration) {
- dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
+ dtmf.duration = switch_core_default_dtmf_duration(0);
}
for (p = argv[i]; p && *p; p++) {
Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c (original)
+++ freeswitch/trunk/src/switch_ivr_async.c Fri Apr 18 13:03:34 2008
@@ -845,7 +845,7 @@
while(p && *p) {
switch_dtmf_t dtmf;
dtmf.digit = *p;
- dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
+ dtmf.duration = switch_core_default_dtmf_duration(0);
switch_channel_queue_dtmf(channel, &dtmf);
p++;
}
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Fri Apr 18 13:03:34 2008
@@ -1467,8 +1467,8 @@
if ((rdigit = malloc(sizeof(*rdigit))) != 0) {
*rdigit = *dtmf;
- if (rdigit->duration < SWITCH_DEFAULT_DTMF_DURATION) {
- rdigit->duration = SWITCH_DEFAULT_DTMF_DURATION;
+ if (rdigit->duration < switch_core_default_dtmf_duration(0)) {
+ rdigit->duration = switch_core_default_dtmf_duration(0);
}
if ((switch_queue_trypush(rtp_session->dtmf_data.dtmf_queue, rdigit)) != SWITCH_STATUS_SUCCESS) {
@@ -1492,8 +1492,8 @@
if ((rdigit = malloc(sizeof(*rdigit))) != 0) {
*rdigit = *dtmf;
- if (rdigit->duration < SWITCH_DEFAULT_DTMF_DURATION) {
- rdigit->duration = SWITCH_DEFAULT_DTMF_DURATION;
+ if (rdigit->duration < switch_core_default_dtmf_duration(0)) {
+ rdigit->duration = switch_core_default_dtmf_duration(0);
}
if ((switch_queue_trypush(rtp_session->dtmf_data.dtmf_inqueue, rdigit)) != SWITCH_STATUS_SUCCESS) {
More information about the Freeswitch-svn
mailing list