[Freeswitch-svn] [commit] r5199 - in freeswitch/branches/greenlizard: libs/iksemel/src libs/libteletone/src libs/sofia-sip/libsofia-sip-ua/su src src/include src/mod/endpoints/mod_woomera src/mod/formats/mod_shout src/mod/languages/mod_python
Freeswitch SVN
greenlizard at freeswitch.org
Thu May 17 12:45:24 EDT 2007
Author: greenlizard
Date: Thu May 17 12:45:24 2007
New Revision: 5199
Modified:
freeswitch/branches/greenlizard/libs/iksemel/src/ikstack.c
freeswitch/branches/greenlizard/libs/libteletone/src/libteletone.h
freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.c
freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.h
freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_generate.c
freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_generate.h
freeswitch/branches/greenlizard/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c
freeswitch/branches/greenlizard/src/include/switch_cpp.h
freeswitch/branches/greenlizard/src/mod/endpoints/mod_woomera/mod_woomera.c
freeswitch/branches/greenlizard/src/mod/formats/mod_shout/layer3.c
freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py
freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp
freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i
freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp
freeswitch/branches/greenlizard/src/switch_core_io.c
freeswitch/branches/greenlizard/src/switch_core_session.c
freeswitch/branches/greenlizard/src/switch_ivr.c
freeswitch/branches/greenlizard/src/switch_ivr_bridge.c
freeswitch/branches/greenlizard/src/switch_rtp.c
Log:
Sync up changes from trunk version 5186 to 5198, plus other changes related to getting streamfile working
Modified: freeswitch/branches/greenlizard/libs/iksemel/src/ikstack.c
==============================================================================
--- freeswitch/branches/greenlizard/libs/iksemel/src/ikstack.c (original)
+++ freeswitch/branches/greenlizard/libs/iksemel/src/ikstack.c Thu May 17 12:45:24 2007
@@ -196,6 +196,7 @@
if (!s) {
return;
}
+ *sp = NULL;
c = s->meta->next;
while (c) {
tmp = c->next;
@@ -209,5 +210,5 @@
c = tmp;
}
iks_free (s);
- *sp = NULL;
+
}
Modified: freeswitch/branches/greenlizard/libs/libteletone/src/libteletone.h
==============================================================================
--- freeswitch/branches/greenlizard/libs/libteletone/src/libteletone.h (original)
+++ freeswitch/branches/greenlizard/libs/libteletone/src/libteletone.h Thu May 17 12:45:24 2007
@@ -28,6 +28,45 @@
*
* libteletone.h -- Tone Generator/Detector
*
+ *
+ *
+ * Exception:
+ * The author hereby grants the use of this source code under the
+ * following license if and only if the source code is distributed
+ * as part of the openzap library. Any use or distribution of this
+ * source code outside the scope of the openzap library will nullify the
+ * following license and reinact the MPL 1.1 as stated above.
+ *
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LIBTELETONE_H
#define LIBTELETONE_H
Modified: freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.c
==============================================================================
--- freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.c (original)
+++ freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.c Thu May 17 12:45:24 2007
@@ -49,7 +49,47 @@
* public domain for the benefit of all mankind - even the slimy
* ones who might try to proprietize my work and use it to my
* detriment.
+ *
+ *
+ * Exception:
+ * The author hereby grants the use of this source code under the
+ * following license if and only if the source code is distributed
+ * as part of the openzap library. Any use or distribution of this
+ * source code outside the scope of the openzap library will nullify the
+ * following license and reinact the MPL 1.1 as stated above.
+ *
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#include <math.h>
#ifndef _MSC_VER
#include <stdint.h>
Modified: freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.h
==============================================================================
--- freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.h (original)
+++ freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.h Thu May 17 12:45:24 2007
@@ -49,7 +49,47 @@
* public domain for the benefit of all mankind - even the slimy
* ones who might try to proprietize my work and use it to my
* detriment.
+ *
+ *
+ * Exception:
+ * The author hereby grants the use of this source code under the
+ * following license if and only if the source code is distributed
+ * as part of the openzap library. Any use or distribution of this
+ * source code outside the scope of the openzap library will nullify the
+ * following license and reinact the MPL 1.1 as stated above.
+ *
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#ifndef LIBTELETONE_DETECT_H
#define LIBTELETONE_DETECT_H
Modified: freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_generate.c
==============================================================================
--- freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_generate.c (original)
+++ freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_generate.c Thu May 17 12:45:24 2007
@@ -28,7 +28,47 @@
*
* libteletone.c -- Tone Generator
*
+ *
+ *
+ * Exception:
+ * The author hereby grants the use of this source code under the
+ * following license if and only if the source code is distributed
+ * as part of the openzap library. Any use or distribution of this
+ * source code outside the scope of the openzap library will nullify the
+ * following license and reinact the MPL 1.1 as stated above.
+ *
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#include <libteletone.h>
#define SMAX 32767
#define SMIN -32768
Modified: freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_generate.h
==============================================================================
--- freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_generate.h (original)
+++ freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_generate.h Thu May 17 12:45:24 2007
@@ -28,6 +28,45 @@
*
* libteletone.h -- Tone Generator
*
+ *
+ *
+ * Exception:
+ * The author hereby grants the use of this source code under the
+ * following license if and only if the source code is distributed
+ * as part of the openzap library. Any use or distribution of this
+ * source code outside the scope of the openzap library will nullify the
+ * following license and reinact the MPL 1.1 as stated above.
+ *
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LIBTELETONE_GENERATE_H
#define LIBTELETONE_GENERATE_H
Modified: freeswitch/branches/greenlizard/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c
==============================================================================
--- freeswitch/branches/greenlizard/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c (original)
+++ freeswitch/branches/greenlizard/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c Thu May 17 12:45:24 2007
@@ -929,7 +929,7 @@
return 0;
}
-
+#define safe_free(it) if (it) { free(it); it = NULL; }
/** Internal deinitialization */
static
void _su_home_deinit(su_home_t *home)
@@ -965,16 +965,17 @@
}
else if (su_is_preloaded(b, b->sub_nodes[i].sua_data))
continue;
- free(b->sub_nodes[i].sua_data);
+ safe_free(b->sub_nodes[i].sua_data);
+
}
}
if (b->sub_preload && !b->sub_preauto)
- free(b->sub_preload);
+ safe_free(b->sub_preload);
if (b->sub_stats)
- free(b->sub_stats);
+ safe_free(b->sub_stats);
if (!b->sub_auto)
- free(b);
+ safe_free(b);
home->suh_blocks = NULL;
Modified: freeswitch/branches/greenlizard/src/include/switch_cpp.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_cpp.h (original)
+++ freeswitch/branches/greenlizard/src/include/switch_cpp.h Thu May 17 12:45:24 2007
@@ -16,6 +16,9 @@
void console_clean_log(char *msg);
char *api_execute(char *cmd, char *arg);
void api_reply_delete(char *reply);
+switch_status_t process_callback_result(char *raw_result,
+ struct input_callback_state *cb_state,
+ switch_core_session_t *session);
class CoreSession {
private:
Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_woomera/mod_woomera.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_woomera/mod_woomera.c (original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_woomera/mod_woomera.c Thu May 17 12:45:24 2007
@@ -334,7 +334,9 @@
{
const char p = 0;
switch_size_t len = sizeof(p);
- switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, &p, &len);
+ if (tech_pvt->udp_socket && tech_pvt->udpwrite) {
+ switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, &p, &len);
+ }
}
break;
}
Modified: freeswitch/branches/greenlizard/src/mod/formats/mod_shout/layer3.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/formats/mod_shout/layer3.c (original)
+++ freeswitch/branches/greenlizard/src/mod/formats/mod_shout/layer3.c Thu May 17 12:45:24 2007
@@ -826,9 +826,23 @@
int x, y;
if (!mc) {
+ unsigned sanity;
mc = *m++;
- v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
- cb = *m++;
+ if ((unsigned)*scf < 100 && (unsigned)*pretab < 100) {
+ sanity = (((*scf++) + (*pretab++)) << shift);
+
+ //v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
+ if (sanity < 100) {
+ v = gr_info->pow2gain[sanity];
+ cb = *m++;
+ } else {
+ return 1;
+ }
+
+ } else {
+ return 1;
+ }
+
}
{
register short *val = h->table;
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py Thu May 17 12:45:24 2007
@@ -46,6 +46,7 @@
console_clean_log = _freeswitch.console_clean_log
api_execute = _freeswitch.api_execute
api_reply_delete = _freeswitch.api_reply_delete
+process_callback_result = _freeswitch.process_callback_result
class CoreSession(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, CoreSession, name, value)
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp Thu May 17 12:45:24 2007
@@ -27,8 +27,12 @@
sanity_check(-1);
if (PyArg_ParseTuple(funcargs, "s", &s)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "funcargs: %s.", s);
cb_state.funcargs = s;
}
+ else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "could not get funcargs");
+ }
if (!PyCallable_Check(pyfunc)) {
dtmfCallbackFunction = NULL;
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i Thu May 17 12:45:24 2007
@@ -14,75 +14,145 @@
%{
-// status = args->input_callback(session, dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
switch_status_t PythonDTMFCallback(switch_core_session_t *session,
void *input,
switch_input_type_t itype,
- void *buf, // Python function defined in script
+ void *buf,
unsigned int buflen)
{
PyObject *func, *arglist;
PyObject *result;
+ char *resultStr;
+ char *funcargs;
struct input_callback_state *cb_state;
- switch_status_t dres = SWITCH_STATUS_FALSE;
+ switch_file_handle_t *fh = NULL;
PyThreadState *threadState = NULL;
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PythonDTMFCallback CALLED");
if (!buf) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buf pointer is null");
- return dres;
+ return SWITCH_STATUS_FALSE;
}
- // TODO: a struct will be passed, of which one of the members will be
- // the actual callback function
- cb_state = (input_callback_state *) buf;
+ cb_state = (input_callback_state *) buf;
- func = (PyObject *) cb_state->function; // Get Python function
+ func = (PyObject *) cb_state->function;
if (!func) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cb_state->function is null");
- return dres;
+ return SWITCH_STATUS_FALSE;
}
if (!PyCallable_Check(func)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "function not callable");
- return dres;
+ return SWITCH_STATUS_FALSE;
}
- arglist = Py_BuildValue("(si)", input, itype); // Build argument list
+ funcargs = (char *) cb_state->funcargs;
+
+ arglist = Py_BuildValue("(sis)", input, itype, funcargs);
if (!arglist) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error building arglist");
- return dres;
+ return SWITCH_STATUS_FALSE;
}
threadState = (PyThreadState *) cb_state->threadState;
if (!threadState) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error, invalid threadstate");
- return dres;
+ return SWITCH_STATUS_FALSE;
}
- // TODO: the python should return string values just like the javascript
- // user defined function. then in this function, we act on those values
- // by pausing the fh (shit, where is the fh?), fast forwarding, etc.
- // then figure out a freeswitch status to return and return it.
+ PyEval_RestoreThread(threadState); // nasty stuff happens when py interp has no thread state
+ result = PyEval_CallObject(func, arglist);
+ threadState = PyEval_SaveThread();
-
+ Py_DECREF(arglist); // Trash arglist
+ if (result) {
+ resultStr = (char *) PyString_AsString(result);
+ }
+ Py_XDECREF(result);
- PyEval_RestoreThread(threadState);
+ return process_callback_result(resultStr, cb_state, session);
- result = PyEval_CallObject(func, arglist); // Call Python
+}
- threadState = PyEval_SaveThread();
+
+switch_status_t process_callback_result(char *ret,
+ struct input_callback_state *cb_state,
+ switch_core_session_t *session)
+{
+
+ switch_file_handle_t *fh = NULL;
+ fh = (switch_file_handle_t *) cb_state->extra;
+
+ if (!strncasecmp(ret, "speed", 4)) {
+ char *p;
+
+ if ((p = strchr(ret, ':'))) {
+ p++;
+ if (*p == '+' || *p == '-') {
+ int step;
+ if (!(step = atoi(p))) {
+ step = 1;
+ }
+ fh->speed += step;
+ } else {
+ int speed = atoi(p);
+ fh->speed = speed;
+ }
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
+
+ } else if (!strcasecmp(ret, "pause")) {
+ if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
+ switch_clear_flag(fh, SWITCH_FILE_PAUSE);
+ } else {
+ switch_set_flag(fh, SWITCH_FILE_PAUSE);
+ }
+ return SWITCH_STATUS_SUCCESS;
+ } else if (!strcasecmp(ret, "restart")) {
+ unsigned int pos = 0;
+ fh->speed = 0;
+ switch_core_file_seek(fh, &pos, 0, SEEK_SET);
+ return SWITCH_STATUS_SUCCESS;
+ } else if (!strncasecmp(ret, "seek", 4)) {
+ switch_codec_t *codec;
+ unsigned int samps = 0;
+ unsigned int pos = 0;
+ char *p;
+ codec = switch_core_session_get_read_codec(session);
+
+ if ((p = strchr(ret, ':'))) {
+ p++;
+ if (*p == '+' || *p == '-') {
+ int step;
+ if (!(step = atoi(p))) {
+ step = 1000;
+ }
+ if (step > 0) {
+ samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
+ } else {
+ samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
+ }
+ } else {
+ samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, samps, SEEK_SET);
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
- Py_DECREF(arglist); // Trash arglist
- if (result) { // If no errors, return double
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PythonDTMFCallback 5");
- dres = (switch_status_t) PyInt_AsLong(result);
- }
- Py_XDECREF(result);
- return dres;
}
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp Thu May 17 12:45:24 2007
@@ -2876,75 +2876,145 @@
-// status = args->input_callback(session, dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
switch_status_t PythonDTMFCallback(switch_core_session_t *session,
void *input,
switch_input_type_t itype,
- void *buf, // Python function defined in script
+ void *buf,
unsigned int buflen)
{
PyObject *func, *arglist;
PyObject *result;
+ char *resultStr;
+ char *funcargs;
struct input_callback_state *cb_state;
- switch_status_t dres = SWITCH_STATUS_FALSE;
+ switch_file_handle_t *fh = NULL;
PyThreadState *threadState = NULL;
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PythonDTMFCallback CALLED");
if (!buf) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buf pointer is null");
- return dres;
+ return SWITCH_STATUS_FALSE;
}
- // TODO: a struct will be passed, of which one of the members will be
- // the actual callback function
- cb_state = (input_callback_state *) buf;
+ cb_state = (input_callback_state *) buf;
- func = (PyObject *) cb_state->function; // Get Python function
+ func = (PyObject *) cb_state->function;
if (!func) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cb_state->function is null");
- return dres;
+ return SWITCH_STATUS_FALSE;
}
if (!PyCallable_Check(func)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "function not callable");
- return dres;
+ return SWITCH_STATUS_FALSE;
}
- arglist = Py_BuildValue("(si)", input, itype); // Build argument list
+ funcargs = (char *) cb_state->funcargs;
+
+ arglist = Py_BuildValue("(sis)", input, itype, funcargs);
if (!arglist) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error building arglist");
- return dres;
+ return SWITCH_STATUS_FALSE;
}
threadState = (PyThreadState *) cb_state->threadState;
if (!threadState) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error, invalid threadstate");
- return dres;
+ return SWITCH_STATUS_FALSE;
}
- // TODO: the python should return string values just like the javascript
- // user defined function. then in this function, we act on those values
- // by pausing the fh (shit, where is the fh?), fast forwarding, etc.
- // then figure out a freeswitch status to return and return it.
+ PyEval_RestoreThread(threadState); // nasty stuff happens when py interp has no thread state
+ result = PyEval_CallObject(func, arglist);
+ threadState = PyEval_SaveThread();
-
+ Py_DECREF(arglist); // Trash arglist
+ if (result) {
+ resultStr = (char *) PyString_AsString(result);
+ }
+ Py_XDECREF(result);
- PyEval_RestoreThread(threadState);
+ return process_callback_result(resultStr, cb_state, session);
- result = PyEval_CallObject(func, arglist); // Call Python
+}
- threadState = PyEval_SaveThread();
+
+switch_status_t process_callback_result(char *ret,
+ struct input_callback_state *cb_state,
+ switch_core_session_t *session)
+{
+
+ switch_file_handle_t *fh = NULL;
+ fh = (switch_file_handle_t *) cb_state->extra;
+
+ if (!strncasecmp(ret, "speed", 4)) {
+ char *p;
+
+ if ((p = strchr(ret, ':'))) {
+ p++;
+ if (*p == '+' || *p == '-') {
+ int step;
+ if (!(step = atoi(p))) {
+ step = 1;
+ }
+ fh->speed += step;
+ } else {
+ int speed = atoi(p);
+ fh->speed = speed;
+ }
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
+
+ } else if (!strcasecmp(ret, "pause")) {
+ if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
+ switch_clear_flag(fh, SWITCH_FILE_PAUSE);
+ } else {
+ switch_set_flag(fh, SWITCH_FILE_PAUSE);
+ }
+ return SWITCH_STATUS_SUCCESS;
+ } else if (!strcasecmp(ret, "restart")) {
+ unsigned int pos = 0;
+ fh->speed = 0;
+ switch_core_file_seek(fh, &pos, 0, SEEK_SET);
+ return SWITCH_STATUS_SUCCESS;
+ } else if (!strncasecmp(ret, "seek", 4)) {
+ switch_codec_t *codec;
+ unsigned int samps = 0;
+ unsigned int pos = 0;
+ char *p;
+ codec = switch_core_session_get_read_codec(session);
+
+ if ((p = strchr(ret, ':'))) {
+ p++;
+ if (*p == '+' || *p == '-') {
+ int step;
+ if (!(step = atoi(p))) {
+ step = 1000;
+ }
+ if (step > 0) {
+ samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
+ } else {
+ samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
+ }
+ } else {
+ samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, samps, SEEK_SET);
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
- Py_DECREF(arglist); // Trash arglist
- if (result) { // If no errors, return double
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PythonDTMFCallback 5");
- dres = (switch_status_t) PyInt_AsLong(result);
- }
- Py_XDECREF(result);
- return dres;
}
@@ -3104,6 +3174,49 @@
}
+SWIGINTERN PyObject *_wrap_process_callback_result(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ char *arg1 = (char *) 0 ;
+ input_callback_state *arg2 = (input_callback_state *) 0 ;
+ switch_core_session_t *arg3 = (switch_core_session_t *) 0 ;
+ switch_status_t result;
+ int res1 ;
+ char *buf1 = 0 ;
+ int alloc1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ void *argp3 = 0 ;
+ int res3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:process_callback_result",&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "process_callback_result" "', argument " "1"" of type '" "char *""'");
+ }
+ arg1 = buf1;
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_input_callback_state, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "process_callback_result" "', argument " "2"" of type '" "input_callback_state *""'");
+ }
+ arg2 = reinterpret_cast< input_callback_state * >(argp2);
+ res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_switch_core_session_t, 0 | 0 );
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "process_callback_result" "', argument " "3"" of type '" "switch_core_session_t *""'");
+ }
+ arg3 = reinterpret_cast< switch_core_session_t * >(argp3);
+ result = process_callback_result(arg1,arg2,arg3);
+ resultobj = SWIG_NewPointerObj((new switch_status_t(static_cast< const switch_status_t& >(result))), SWIGTYPE_p_switch_status_t, SWIG_POINTER_OWN | 0 );
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ return resultobj;
+fail:
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_new_CoreSession__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
char *arg1 = (char *) 0 ;
@@ -4566,6 +4679,7 @@
{ (char *)"console_clean_log", _wrap_console_clean_log, METH_VARARGS, NULL},
{ (char *)"api_execute", _wrap_api_execute, METH_VARARGS, NULL},
{ (char *)"api_reply_delete", _wrap_api_reply_delete, METH_VARARGS, NULL},
+ { (char *)"process_callback_result", _wrap_process_callback_result, METH_VARARGS, NULL},
{ (char *)"new_CoreSession", _wrap_new_CoreSession, METH_VARARGS, NULL},
{ (char *)"delete_CoreSession", _wrap_delete_CoreSession, METH_VARARGS, NULL},
{ (char *)"CoreSession_session_set", _wrap_CoreSession_session_set, METH_VARARGS, NULL},
Modified: freeswitch/branches/greenlizard/src/switch_core_io.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_io.c (original)
+++ freeswitch/branches/greenlizard/src/switch_core_io.c Thu May 17 12:45:24 2007
@@ -730,7 +730,7 @@
switch_io_event_hook_kill_channel_t *ptr;
switch_status_t status = SWITCH_STATUS_FALSE;
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_INFO, "Kill %s [%s]\n", switch_channel_get_name(session->channel),
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "Kill %s [%s]\n", switch_channel_get_name(session->channel),
SIG_NAMES[sig]);
if (session->endpoint_interface->io_routines->kill_channel) {
Modified: freeswitch/branches/greenlizard/src/switch_core_session.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_session.c (original)
+++ freeswitch/branches/greenlizard/src/switch_core_session.c Thu May 17 12:45:24 2007
@@ -626,7 +626,7 @@
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_io_event_hook_state_change_t *ptr;
-
+
/* If trylock fails the signal is already awake so we needn't bother */
if (switch_mutex_trylock(session->mutex) == SWITCH_STATUS_SUCCESS) {
switch_thread_cond_signal(session->cond);
@@ -644,6 +644,7 @@
}
}
}
+ switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
}
SWITCH_DECLARE(unsigned int) switch_core_session_running(switch_core_session_t *session)
Modified: freeswitch/branches/greenlizard/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr.c (original)
+++ freeswitch/branches/greenlizard/src/switch_ivr.c Thu May 17 12:45:24 2007
@@ -749,7 +749,6 @@
if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
status = SWITCH_STATUS_SUCCESS;
- switch_channel_clear_flag(channel, CF_BYPASS_MEDIA);
switch_core_session_receive_message(session, &msg);
if ((flags & SMF_REBRIDGE)
@@ -765,7 +764,7 @@
switch_channel_clear_state_handler(channel, NULL);
}
}
-
+
switch_core_session_rwunlock(session);
if (other_channel) {
@@ -803,22 +802,21 @@
}
if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
- switch_ivr_parse_all_events(session);
-
+ //switch_ivr_parse_all_events(session);
+ switch_core_session_receive_message(session, &msg);
+
if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
(other_session = switch_core_session_locate(other_uuid))) {
other_channel = switch_core_session_get_channel(other_session);
assert(other_channel != NULL);
-
- switch_ivr_parse_all_events(other_session);
+ //switch_ivr_parse_all_events(other_session);
switch_core_session_receive_message(other_session, &msg);
switch_channel_clear_state_handler(other_channel, NULL);
}
- switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
- switch_core_session_receive_message(session, &msg);
+
if (other_channel) {
switch_channel_clear_state_handler(channel, NULL);
Modified: freeswitch/branches/greenlizard/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_bridge.c (original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_bridge.c Thu May 17 12:45:24 2007
@@ -98,7 +98,7 @@
break;
}
- if (loop_count > 10 && switch_core_session_private_event_count(session_a)) {
+ if (loop_count > 50 && switch_core_session_private_event_count(session_a)) {
switch_channel_set_flag(chan_b, CF_SUSPEND);
msg.string_arg = data->b_uuid;
msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
@@ -491,7 +491,7 @@
switch_channel_set_state_flag(caller_channel, CF_TRANSFER);
switch_channel_set_state_flag(peer_channel, CF_TRANSFER);
-
+
switch_channel_set_state(caller_channel, CS_HIBERNATE);
switch_channel_set_state(peer_channel, CS_HIBERNATE);
Modified: freeswitch/branches/greenlizard/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_rtp.c (original)
+++ freeswitch/branches/greenlizard/src/switch_rtp.c Thu May 17 12:45:24 2007
@@ -129,6 +129,8 @@
switch_sockaddr_t *remote_addr;
rtp_msg_t recv_msg;
srtp_ctx_t *recv_ctx;
+ uint32_t autoadj_window;
+ uint32_t autoadj_tally;
uint16_t seq;
uint16_t rseq;
@@ -430,12 +432,13 @@
rtp_session->pool = pool;
- rtp_session->flags = flags;
rtp_session->te = 101;
switch_mutex_init(&rtp_session->flag_mutex, SWITCH_MUTEX_NESTED, rtp_session->pool);
switch_mutex_init(&rtp_session->dtmf_data.dtmf_mutex, SWITCH_MUTEX_NESTED, rtp_session->pool);
switch_buffer_create_dynamic(&rtp_session->dtmf_data.dtmf_buffer, 128, 128, 0);
+ switch_rtp_set_flag(rtp_session, flags);
+
/* for from address on recvfrom calls */
switch_sockaddr_info_get(&rtp_session->from_addr, NULL, SWITCH_UNSPEC, 0, 0, rtp_session->pool);
@@ -705,7 +708,10 @@
{
switch_set_flag_locked(rtp_session, flags);
-
+ if (flags & SWITCH_RTP_FLAG_AUTOADJ) {
+ rtp_session->autoadj_window = 20;
+ rtp_session->autoadj_tally = 0;
+ }
}
SWITCH_DECLARE(uint8_t) switch_rtp_test_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flags)
@@ -960,30 +966,35 @@
}
-
- if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && switch_sockaddr_get_port(rtp_session->from_addr)) {
-
+ if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && switch_sockaddr_get_port(rtp_session->from_addr)) {
char *tx_host;
char *old_host;
char bufa[30], bufb[30];
tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
-
- if ((switch_sockaddr_get_port(rtp_session->from_addr) != rtp_session->remote_port)
- || strcmp(tx_host, old_host)) {
+ if ((switch_sockaddr_get_port(rtp_session->from_addr) != rtp_session->remote_port) || strcmp(tx_host, old_host)) {
const char *err;
uint32_t old = rtp_session->remote_port;
if (!switch_strlen_zero(tx_host) && switch_sockaddr_get_port(rtp_session->from_addr) > 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
- "Auto Changing port from %s:%u to %s:%u\n", old_host, old, tx_host,
- switch_sockaddr_get_port(rtp_session->from_addr));
- switch_rtp_set_remote_address(rtp_session, tx_host, switch_sockaddr_get_port(rtp_session->from_addr), &err);
+ if (++rtp_session->autoadj_tally >= 10) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ "Auto Changing port from %s:%u to %s:%u\n", old_host, old, tx_host,
+ switch_sockaddr_get_port(rtp_session->from_addr));
+ switch_rtp_set_remote_address(rtp_session, tx_host, switch_sockaddr_get_port(rtp_session->from_addr), &err);
+ }
}
}
- switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
}
+ if (rtp_session->autoadj_window) {
+ if (--rtp_session->autoadj_window == 0) {
+ switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
+ }
+ }
+
+
+
if (bytes && rtp_session->cng_pt && rtp_session->recv_msg.header.pt == rtp_session->cng_pt) {
continue;
}
More information about the Freeswitch-svn
mailing list