[Freeswitch-svn] [commit] r5266 - in freeswitch/branches/greenlizard: . scripts scripts/socket/socket2me src src/include src/mod/applications/mod_dptools src/mod/applications/mod_esf src/mod/endpoints/mod_alsa src/mod/endpoints/mod_dingaling src/mod/endpoints/mod_sofia
Freeswitch SVN
greenlizard at freeswitch.org
Tue Jun 5 12:36:58 EDT 2007
Author: greenlizard
Date: Tue Jun 5 12:36:58 2007
New Revision: 5266
Modified:
freeswitch/branches/greenlizard/ (props changed)
freeswitch/branches/greenlizard/scripts/mytest.py
freeswitch/branches/greenlizard/scripts/socket/socket2me/socket2me.c
freeswitch/branches/greenlizard/src/include/switch_ivr.h
freeswitch/branches/greenlizard/src/include/switch_types.h
freeswitch/branches/greenlizard/src/include/switch_utils.h
freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/branches/greenlizard/src/mod/applications/mod_esf/ (props changed)
freeswitch/branches/greenlizard/src/mod/endpoints/mod_alsa/mod_alsa.c
freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c
freeswitch/branches/greenlizard/src/switch_apr.c
freeswitch/branches/greenlizard/src/switch_ivr_async.c
Log:
merge in changes from trunk 5240 to 5265 plus one trivial change: add comments to mytest.py
Modified: freeswitch/branches/greenlizard/scripts/mytest.py
==============================================================================
--- freeswitch/branches/greenlizard/scripts/mytest.py (original)
+++ freeswitch/branches/greenlizard/scripts/mytest.py Tue Jun 5 12:36:58 2007
@@ -1,18 +1,32 @@
-import sys
-from _freeswitch import *
-print "Hello World"
-print sys.path
-print dir()
-print sys.argv
+# WARNING: May be out of date, please see
+# http://wiki.freeswitch.org/wiki/Mod_python
+# before reporting errors
-uuid = sys.argv[0]
-fs_consol_log("1","test from my python program\n")
-fs_consol_clean("This is fs_consol_clean\n")
-fs_consol_clean("My uuid is " + uuid + "\n")
+import sys, time
+def onDTMF(input, itype, buf, buflen):
+ print "input=",input
+ print "itype=",itype
+ print "buf=",buf
+ print "buflen",buflen
+ if input == "#":
+ return 1
+ else:
+ return 0
+console_log("1","test from my python program\n")
+session.answer()
+session.setDTMFCallback(onDTMF)
+session.set_tts_parms("cepstral", "david")
+session.playFile("/root/test.gsm", "")
+session.speakText("Please enter telephone number with area code and press pound sign. ")
+input = session.getDigits("", 11, "*#", 10000)
+console_log("1","result from get digits is "+ input +"\n")
+phone_number = session.playAndGetDigits(5, 11, 3, 10000, "*#",
+ "/sounds/test.gsm",
+ "/sounds/invalid.gsm",
+ "",
+ "^17771112222$");
+console_log("1","result from play_and_get_digits is "+ phone_number +"\n")
+session.transfer("1000", "XML", "default")
+session.hangup("1")
-session = fs_core_session_locate(uuid)
-
-fs_channel_answer(session)
-
-fs_switch_ivr_session_transfer(session, "1234", "XML", "default")
Modified: freeswitch/branches/greenlizard/scripts/socket/socket2me/socket2me.c
==============================================================================
--- freeswitch/branches/greenlizard/scripts/socket/socket2me/socket2me.c (original)
+++ freeswitch/branches/greenlizard/scripts/socket/socket2me/socket2me.c Tue Jun 5 12:36:58 2007
@@ -248,7 +248,7 @@
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
- sendaddr.sin_addr.s_addr = inet_addr(remote_ip);
+ /*addr.sin_addr.s_addr = inet_addr(remote_ip);*/
addr.sin_port = htons(remote_port);
sendaddr.sin_family = AF_INET;
@@ -316,7 +316,7 @@
continue;
}
- if ((read_bytes = recvfrom(usock, audiobuf, sizeof(audiobuf), 0, (struct sockaddr *) &local_addr, &cliAddrLen)) < 0) {
+ if ((read_bytes = recvfrom(usock, audiobuf, sizeof(audiobuf), 0, (struct sockaddr *) &local_addr, cliAddrLen)) < 0) {
die("recvfrom() failed");
}
Modified: freeswitch/branches/greenlizard/src/include/switch_ivr.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_ivr.h (original)
+++ freeswitch/branches/greenlizard/src/include/switch_ivr.h Tue Jun 5 12:36:58 2007
@@ -25,7 +25,7 @@
*
* Anthony Minessale II <anthmct at yahoo.com>
* Neal Horman <neal at wanlink dot com>
- *
+ * Bret McDanel <trixter AT 0xdecafbad dot com>
*
* switch_ivr.h -- IVR Library
*
@@ -208,11 +208,44 @@
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_stop_record_session(switch_core_session_t *session, char *file);
+/*!
+ \brief Start looking for DTMF inband
+ \param session the session to start looking
+ \return SWITCH_STATUS_SUCCESS if all is well
+*/
SWITCH_DECLARE(switch_status_t) switch_ivr_inband_dtmf_session(switch_core_session_t *session);
+
+/*!
+ \brief Stop looking for DTMF inband
+ \param session the session to stop looking
+ \return SWITCH_STATUS_SUCCESS if all is well
+*/
SWITCH_DECLARE(switch_status_t) switch_ivr_stop_inband_dtmf_session(switch_core_session_t *session);
+
+/*!
+ \brief XXX DESCRIBE ME
+ \param session the session to act on
+ \return SWITCH_STATUS_SUCCESS if all is well - maybe more XXX FIXME
+*/
SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session);
/*!
+ \brief Stop looking for FAX CNG
+ \param session the session to stop looking
+ \return SWITCH_STATUS_SUCCESS if all is well
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_stop_fax_detect_session(switch_core_session_t *session);
+
+/*!
+ \brief Start looking for FAX CNG
+ \param session the session to start looking
+ \return SWITCH_STATUS_SUCCESS if all is well
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_fax_detect_session(switch_core_session_t *session);
+
+
+
+/*!
\brief play a file from the disk to the session
\param session the session to play the file too
\param fh file handle to use (NULL for builtin one)
Modified: freeswitch/branches/greenlizard/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_types.h (original)
+++ freeswitch/branches/greenlizard/src/include/switch_types.h Tue Jun 5 12:36:58 2007
@@ -24,6 +24,7 @@
* Contributor(s):
*
* Anthony Minessale II <anthmct at yahoo.com>
+ * Bret McDanel <trixter AT 0xdecafbad dot com>
*
* switch_types.h -- Data Types
*
@@ -832,6 +833,7 @@
SWITCH_EVENT_CODEC - Codec Change
SWITCH_EVENT_BACKGROUND_JOB - Background Job
SWITCH_EVENT_DETECTED_SPEECH - Detected Speech
+ SWITCH_EVENT_DETECTED_FAX - Detected Fax CNG Tone
SWITCH_EVENT_PRIVATE_COMMAND - A private command event
SWITCH_EVENT_HEARTBEAT - Machine is alive
SWITCH_EVENT_TRAP - Error Trap
@@ -881,6 +883,7 @@
SWITCH_EVENT_CODEC,
SWITCH_EVENT_BACKGROUND_JOB,
SWITCH_EVENT_DETECTED_SPEECH,
+ SWITCH_EVENT_DETECTED_FAX,
SWITCH_EVENT_PRIVATE_COMMAND,
SWITCH_EVENT_HEARTBEAT,
SWITCH_EVENT_TRAP,
Modified: freeswitch/branches/greenlizard/src/include/switch_utils.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_utils.h (original)
+++ freeswitch/branches/greenlizard/src/include/switch_utils.h Tue Jun 5 12:36:58 2007
@@ -175,6 +175,16 @@
*/
#define switch_copy_flags(dest, src, flags) (dest)->flags &= ~(flags); (dest)->flags |= ((src)->flags & (flags))
+#define switch_set_string(_dst, _src) switch_copy_string(_dst, _src, sizeof(_dst))
+
+static __inline__ void switch_clean_string(char *s)
+{ char *p;
+
+ for (p = s; p && *p; p++) { uint8_t x = (uint8_t) *p; if (x < 32 || x > 127) { *p = ' '; }
+ }
+}
+
+
/*!
\brief Free a pointer and set it to NULL unless it already is NULL
Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c Tue Jun 5 12:36:58 2007
@@ -27,6 +27,7 @@
* Ken Rice, Asteria Solutions Group, Inc <ken at asteriasgi.com>
* Michael Murdock <mike at mmurdock dot org>
* Neal Horman <neal at wanlink dot com>
+ * Bret McDanel <trixter AT 0xdecafbad dot com>
*
* mod_dptools.c -- Raw Audio File Streaming Application Module
*
@@ -649,6 +650,30 @@
}
+static void dtm_session_function(switch_core_session_t *session, char *data)
+{
+ switch_ivr_inband_dtmf_session(session);
+}
+
+
+static void stop_dtmf_session_function(switch_core_session_t *session, char *data)
+{
+ switch_ivr_stop_inband_dtmf_session(session);
+}
+
+static void fax_detect_session_function(switch_core_session_t *session, char *data)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Enabling fax detection\n");
+ switch_ivr_fax_detect_session(session);
+}
+
+static void stop_fax_detect_session_function(switch_core_session_t *session, char *data)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Disabling fax detection\n");
+ switch_ivr_stop_fax_detect_session(session);
+}
+
+
static const switch_api_interface_t strepoch_api_interface = {
/*.interface_name */ "strepoch",
/*.desc */ "Convert a date string into epoch time",
@@ -682,6 +707,46 @@
};
+static const switch_application_interface_t fax_detect_application_interface = {
+ /*.interface_name */ "fax_detect",
+ /*.application_function */ fax_detect_session_function,
+ /* long_desc */ "Detect fax send tone",
+ /* short_desc */ "Detect faxes",
+ /* syntax */ "",
+ /* flags */ SAF_NONE,
+ /*.next */ NULL
+};
+
+static const switch_application_interface_t stop_fax_detect_application_interface = {
+ /*.interface_name */ "stop_fax_detect",
+ /*.application_function */ stop_fax_detect_session_function,
+ /* long_desc */ "Stop detecting fax send tones",
+ /* short_desc */ "stop detecting faxes",
+ /* syntax */ "",
+ /* flags */ SAF_NONE,
+ /* next */ &fax_detect_application_interface
+};
+
+static const switch_application_interface_t dtmf_application_interface = {
+ /*.interface_name */ "start_dtmf",
+ /*.application_function */ dtm_session_function,
+ /* long_desc */ "Detect inband dtmf on the session",
+ /* short_desc */ "Detect dtmf",
+ /* syntax */ "",
+ /* flags */ SAF_NONE,
+ /* next */ &stop_fax_detect_application_interface
+};
+
+static const switch_application_interface_t stop_dtmf_application_interface = {
+ /*.interface_name */ "stop_dtmf",
+ /*.application_function */ stop_dtmf_session_function,
+ /* long_desc */ "Stop detecting inband dtmf.",
+ /* short_desc */ "stop inband dtmf.",
+ /* syntax */ "",
+ /* flags */ SAF_NONE,
+ &dtmf_application_interface
+};
+
static const switch_application_interface_t exe_application_interface = {
/*.interface_name */ "execute_extension",
/*.application_function */ exe_function,
@@ -689,7 +754,7 @@
/*.short_desc */ "Execute an extension",
/*.syntax */ "<extension> <dialplan> <context>",
/* flags */ SAF_SUPPORT_NOMEDIA,
- /*.next */
+ /*.next */ &stop_dtmf_application_interface
};
static const switch_application_interface_t sched_transfer_application_interface = {
Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_alsa/mod_alsa.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_alsa/mod_alsa.c (original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_alsa/mod_alsa.c Tue Jun 5 12:36:58 2007
@@ -152,7 +152,8 @@
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
static switch_status_t engage_device(unsigned int samplerate, int codec_ms);
static switch_status_t load_config(void);
-static switch_status_t pa_cmd(char *dest, switch_core_session_t *session, switch_stream_handle_t *stream);
+SWITCH_STANDARD_API(pa_cmd);
+
/*
@@ -1529,7 +1530,7 @@
char *mycmd = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS;
pa_command_t func = NULL;
- int lead = 1, devval = 0;
+ int lead = 1;
char *wcmd = NULL, *action = NULL;
char cmd_buf[1024] = "";
char *http = NULL;
Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c Tue Jun 5 12:36:58 2007
@@ -439,7 +439,7 @@
}
if (f_host && (profile = switch_core_hash_find(globals.profile_hash, f_host))) {
- if (to && (sql = switch_mprintf("select * from jabber_subscriptions where sub_to='%q'", to))) {
+ if (to && (sql = switch_mprintf("select * from jabber_subscriptions where sub_to='%q' and sub_from='%q'", to, from))) {
mdl_execute_sql_callback(profile, profile->mutex, sql, sin_callback, profile);
switch_safe_free(sql);
}
@@ -1599,7 +1599,7 @@
static switch_api_interface_t debug_api_interface = {
/*.interface_name */ "dl_debug",
- /*.desc */ "DingaLing Presence",
+ /*.desc */ "DingaLing Debug",
/*.function */ dl_debug,
/*.syntax */ "dl_debug [true|false]",
/*.next */ NULL
Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c Tue Jun 5 12:36:58 2007
@@ -581,8 +581,9 @@
switch_set_flag(gateway, REG_FLAG_CALLERID);
}
gateway->register_from = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, from_domain);
- gateway->register_contact = switch_core_sprintf(gateway->pool, "sip:%s@%s:%d", extension, profile->sipip, profile->sip_port);
-
+ gateway->register_contact = switch_core_sprintf(gateway->pool, "sip:%s@%s:%d", extension,
+ profile->extsipip ? profile->extsipip : profile->sipip, profile->sip_port);
+
if (!strncasecmp(proxy, "sip:", 4)) {
gateway->register_proxy = switch_core_strdup(gateway->pool, proxy);
gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy + 4);
@@ -600,7 +601,6 @@
}
gateway->freq -= 2;
-
if ((gp = sofia_reg_find_gateway(gateway->name))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", gateway->name);
sofia_reg_release_gateway(gp);
@@ -608,7 +608,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate uri '%s'\n", gateway->register_from);
sofia_reg_release_gateway(gp);
} else if ((gp=sofia_reg_find_gateway(gateway->register_contact))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate contact '%s'\n", gateway->register_from);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate contact '%s'\n", gateway->register_contact);
sofia_reg_release_gateway(gp);
} else {
gateway->next = profile->gateways;
Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c Tue Jun 5 12:36:58 2007
@@ -66,7 +66,7 @@
case REG_STATE_NOREG:
break;
case REG_STATE_REGISTER:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "registered %s\n", gateway_ptr->name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "registered %s\n", gateway_ptr->name);
gateway_ptr->expires = now + gateway_ptr->freq;
gateway_ptr->state = REG_STATE_REGED;
break;
Modified: freeswitch/branches/greenlizard/src/switch_apr.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_apr.c (original)
+++ freeswitch/branches/greenlizard/src/switch_apr.c Tue Jun 5 12:36:58 2007
@@ -339,6 +339,7 @@
{
va_list ap;
int ret;
+ va_start(ap, format);
ret = apr_file_printf(thefile, format, ap);
va_end(ap);
return ret;
Modified: freeswitch/branches/greenlizard/src/switch_ivr_async.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_async.c (original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_async.c Tue Jun 5 12:36:58 2007
@@ -25,6 +25,7 @@
*
* Anthony Minessale II <anthmct at yahoo.com>
* Michael Jerris <mike at jerris.com>
+ * Bret McDanel <bret AT 0xdecafbad dot com>
*
* switch_ivr_async.c -- IVR Library (async operations)
*
@@ -324,6 +325,122 @@
return SWITCH_STATUS_SUCCESS;
}
+
+typedef struct {
+ switch_core_session_t *session;
+ teletone_multi_tone_t mt;
+} switch_fax_detect_t;
+
+static switch_bool_t fax_detect_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
+{
+ switch_fax_detect_t *pvt = (switch_fax_detect_t *) user_data;
+ uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
+ switch_frame_t frame = { 0 };
+ // switch_channel_t *channel = switch_core_session_get_channel(pvt->session);
+
+ // assert(channel != NULL);
+ frame.data = data;
+ frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
+
+ switch (type) {
+ case SWITCH_ABC_TYPE_INIT:
+ break;
+ case SWITCH_ABC_TYPE_CLOSE:
+ break;
+ case SWITCH_ABC_TYPE_READ:
+ if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
+ if(teletone_multi_tone_detect(&pvt->mt, frame.data, frame.samples)) {
+ switch_event_t *event;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX CNG DETECTED\n");
+
+ if (switch_event_create(&event, SWITCH_EVENT_DETECTED_FAX) == SWITCH_STATUS_SUCCESS) {
+ switch_event_t *dup;
+
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "fax", "detected");
+
+ if (switch_event_dup(&dup, event) == SWITCH_STATUS_SUCCESS) {
+ switch_event_fire(&dup);
+ }
+
+
+ if (switch_core_session_queue_event(pvt->session, &event) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Event queue failed!\n");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
+ switch_event_fire(&event);
+ }
+ }
+ }
+ }
+ break;
+ case SWITCH_ABC_TYPE_WRITE:
+ default:
+ break;
+ }
+ return SWITCH_TRUE;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_stop_fax_detect_session(switch_core_session_t *session)
+{
+ switch_media_bug_t *bug;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+
+ assert(channel != NULL);
+ if ((bug = switch_channel_get_private(channel, "fax"))) {
+ switch_channel_set_private(channel, "fax", NULL);
+ switch_core_media_bug_remove(session, &bug);
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
+
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_fax_detect_session(switch_core_session_t *session)
+{
+ switch_channel_t *channel;
+ switch_codec_t *read_codec;
+ switch_media_bug_t *bug;
+ switch_status_t status;
+ switch_fax_detect_t *pvt;
+ teletone_tone_map_t *map;
+ int i;
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+
+ read_codec = switch_core_session_get_read_codec(session);
+ assert(read_codec != NULL);
+
+ if (!(pvt = switch_core_session_alloc(session, sizeof(*pvt)))) {
+ return SWITCH_STATUS_MEMERR;
+ }
+
+ if (!(map = switch_core_session_alloc(session, sizeof(*map)))) {
+ return SWITCH_STATUS_MEMERR;
+ }
+
+ for(i=0;i<TELETONE_MAX_TONES;i++) {
+ map->freqs[i] = 1100.0;
+ }
+ pvt->mt.sample_rate = read_codec->implementation->samples_per_second;
+ pvt->session = session;
+
+ teletone_multi_tone_init(&pvt->mt, map);
+
+ switch_channel_answer(channel);
+
+ if ((status = switch_core_media_bug_add(session, fax_detect_callback, pvt, 0, SMBF_READ_STREAM, &bug)) != SWITCH_STATUS_SUCCESS) {
+ return status;
+ }
+
+ switch_channel_set_private(channel, "fax", bug);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
struct speech_thread_handle {
switch_core_session_t *session;
switch_asr_handle_t *ah;
More information about the Freeswitch-svn
mailing list