[Freeswitch-svn] [commit] r5296 - in freeswitch/branches/greenlizard: . conf docs libs/libresample libs/libresample/src libs/libteletone/src scripts/socket/socket2me src src/include src/mod/applications/mod_conference src/mod/codecs/mod_l16 src/mod/endpoints/mod_sofia src/mod/event_handlers/mod_event_socket src/mod/languages/mod_spidermonkey src/mod/languages/mod_spidermonkey_etpan src/mod/languages/mod_spidermonkey_odbc
Freeswitch SVN
greenlizard at freeswitch.org
Fri Jun 8 13:07:49 EDT 2007
Author: greenlizard
Date: Fri Jun 8 13:07:48 2007
New Revision: 5296
Modified:
freeswitch/branches/greenlizard/conf/directory.xml
freeswitch/branches/greenlizard/configure.in
freeswitch/branches/greenlizard/docs/AUTHORS
freeswitch/branches/greenlizard/libs/libresample/.update
freeswitch/branches/greenlizard/libs/libresample/src/resample.c
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/scripts/socket/socket2me/socket2me.c
freeswitch/branches/greenlizard/src/include/switch.h
freeswitch/branches/greenlizard/src/include/switch_cpp.h
freeswitch/branches/greenlizard/src/include/switch_ivr.h
freeswitch/branches/greenlizard/src/include/switch_stun.h
freeswitch/branches/greenlizard/src/include/switch_types.h
freeswitch/branches/greenlizard/src/include/switch_utils.h
freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c
freeswitch/branches/greenlizard/src/mod/codecs/mod_l16/mod_l16.c
freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c
freeswitch/branches/greenlizard/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c
freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
freeswitch/branches/greenlizard/src/switch_caller.c
freeswitch/branches/greenlizard/src/switch_channel.c
freeswitch/branches/greenlizard/src/switch_core_sqldb.c
freeswitch/branches/greenlizard/src/switch_cpp.cpp
freeswitch/branches/greenlizard/src/switch_event.c
freeswitch/branches/greenlizard/src/switch_odbc.c
freeswitch/branches/greenlizard/src/switch_xml.c
Log:
merge in trunk changes from version 5265 to 5295
Modified: freeswitch/branches/greenlizard/conf/directory.xml
==============================================================================
--- freeswitch/branches/greenlizard/conf/directory.xml (original)
+++ freeswitch/branches/greenlizard/conf/directory.xml Fri Jun 8 13:07:48 2007
@@ -35,6 +35,12 @@
<!-- optionally use this instead if you want to store the hash of user:domain:pass-->
<!--<param name="a1-hash" value="c6440e5de50b403206989679159de89a"/>-->
</params>
+ <variables>
+ <!--all variables here will be set on all inbound calls that originate from this user -->
+ <variable name="testing" value="this"/>
+ <!--<variable name="force-contact" value="nat-connectile-dysfunction"/>-->
+ </variables>
+
<vcard>
<!-- insert optional compliant vcard xml here-->
</vcard>
Modified: freeswitch/branches/greenlizard/configure.in
==============================================================================
--- freeswitch/branches/greenlizard/configure.in (original)
+++ freeswitch/branches/greenlizard/configure.in Fri Jun 8 13:07:48 2007
@@ -123,6 +123,8 @@
APR_ADDTO(SWITCH_AM_CFLAGS, -DPIC)
APR_ADDTO(SWITCH_AM_CXXFLAGS, -KPIC)
APR_ADDTO(SWITCH_AM_CXXFLAGS, -DPIC)
+ APR_ADDTO(SWITCH_AM_CXXFLAGS, "-features=extensions")
+
APR_ADDTO(SWITCH_AM_LDFLAGS, -R${prefix}/lib)
elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
APR_ADDTO(SWITCH_AM_CFLAGS, -fPIC)
Modified: freeswitch/branches/greenlizard/docs/AUTHORS
==============================================================================
--- freeswitch/branches/greenlizard/docs/AUTHORS (original)
+++ freeswitch/branches/greenlizard/docs/AUTHORS Fri Jun 8 13:07:48 2007
@@ -32,7 +32,8 @@
Johny Kadarisman <jkr888 at gmail.com> - mod_python fixups.
Michael Murdock <mike at mmurdock dot org> - testing, documentation, bug finding and usability enhancements.
Matt Klein <mklein at nmedia.net>
-
+ Jonas Gauffin <jonas at gauffin dot org> - Bugfixes and additions in mod_spidermonkey_odbc
+
A big THANK YOU goes to:
Justin Cassidy - Build related cleanups and automatic build setup.
Modified: freeswitch/branches/greenlizard/libs/libresample/.update
==============================================================================
--- freeswitch/branches/greenlizard/libs/libresample/.update (original)
+++ freeswitch/branches/greenlizard/libs/libresample/.update Fri Jun 8 13:07:48 2007
@@ -1 +1 @@
-Fri Mar 16 17:17:33 EDT 2007
+Thursday Jun 07 14:24:00 EDT 2007
Modified: freeswitch/branches/greenlizard/libs/libresample/src/resample.c
==============================================================================
--- freeswitch/branches/greenlizard/libs/libresample/src/resample.c (original)
+++ freeswitch/branches/greenlizard/libs/libresample/src/resample.c Fri Jun 8 13:07:48 2007
@@ -87,7 +87,7 @@
/* Just exit if we get invalid factors */
if (minFactor <= 0.0 || maxFactor <= 0.0 || maxFactor < minFactor) {
-#ifdef DEBUG
+#ifdef DEBUG_TRACE
fprintf(stderr,
"libresample: "
"minFactor and maxFactor must be positive real numbers,\n"
@@ -187,7 +187,7 @@
int Nx;
int i, len;
-#ifdef DEBUG
+#ifdef DEBUG_TRACE
fprintf(stderr, "resample_process: in=%d, out=%d lastFlag=%d\n",
inBufferLen, outBufferLen, lastFlag);
#endif
@@ -197,7 +197,7 @@
outSampleCount = 0;
if (factor < hp->minFactor || factor > hp->maxFactor) {
-#ifdef DEBUG
+#ifdef DEBUG_TRACE
fprintf(stderr,
"libresample: factor %f is not between "
"minFactor=%f and maxFactor=%f",
@@ -232,7 +232,7 @@
/* This is the maximum number of samples we can process
per loop iteration */
- #ifdef DEBUG
+ #ifdef DEBUG_TRACE
printf("XSize: %d Xoff: %d Xread: %d Xp: %d lastFlag: %d\n",
hp->XSize, hp->Xoff, hp->Xread, hp->Xp, lastFlag);
#endif
@@ -260,7 +260,7 @@
else
Nx = hp->Xread - 2 * hp->Xoff;
- #ifdef DEBUG
+ #ifdef DEBUG_TRACE
fprintf(stderr, "new len=%d Nx=%d\n", len, Nx);
#endif
@@ -277,7 +277,7 @@
Nwing, LpScl, Imp, ImpD, interpFilt);
}
- #ifdef DEBUG
+ #ifdef DEBUG_TRACE
printf("Nout: %d\n", Nout);
#endif
@@ -297,7 +297,7 @@
for (i=0; i<Nreuse; i++)
hp->X[i] = hp->X[i + (hp->Xp - hp->Xoff)];
- #ifdef DEBUG
+ #ifdef DEBUG_TRACE
printf("New Xread=%d\n", Nreuse);
#endif
@@ -306,7 +306,7 @@
/* Check to see if output buff overflowed (shouldn't happen!) */
if (Nout > hp->YSize) {
- #ifdef DEBUG
+ #ifdef DEBUG_TRACE
printf("Nout: %d YSize: %d\n", Nout, hp->YSize);
#endif
fprintf(stderr, "libresample: Output array overflow!\n");
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 Fri Jun 8 13:07:48 2007
@@ -90,7 +90,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <math.h>
+#include <libteletone_detect.h>
+
#ifndef _MSC_VER
#include <stdint.h>
#endif
@@ -98,7 +99,7 @@
#include <stdio.h>
#include <time.h>
#include <fcntl.h>
-#include <libteletone_detect.h>
+
static teletone_detection_descriptor_t dtmf_detect_row[GRID_FACTOR];
static teletone_detection_descriptor_t dtmf_detect_col[GRID_FACTOR];
@@ -208,8 +209,8 @@
}
int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
- int16_t sample_buffer[],
- int samples)
+ int16_t sample_buffer[],
+ int samples)
{
int sample, limit, j, x = 0;
teletone_process_t v1, famp;
@@ -295,8 +296,8 @@
int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
- int16_t sample_buffer[],
- int samples)
+ int16_t sample_buffer[],
+ int samples)
{
teletone_process_t row_energy[GRID_FACTOR];
teletone_process_t col_energy[GRID_FACTOR];
@@ -426,8 +427,8 @@
int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
- char *buf,
- int max)
+ char *buf,
+ int max)
{
if (max > dtmf_detect_state->current_digits) {
max = dtmf_detect_state->current_digits;
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 Fri Jun 8 13:07:48 2007
@@ -98,11 +98,11 @@
#endif
#include <libteletone.h>
-/*! \file libteletone_detect.h
- \brief Tone Detection Routines
+ /*! \file libteletone_detect.h
+ \brief Tone Detection Routines
- This module is responsible for tone detection specifics
-*/
+ This module is responsible for tone detection specifics
+ */
#ifndef FALSE
#define FALSE 0
@@ -111,17 +111,17 @@
#endif
#endif
-/* Basic DTMF specs:
- *
- * Minimum tone on = 40ms
- * Minimum tone off = 50ms
- * Maximum digit rate = 10 per second
- * Normal twist <= 8dB accepted
- * Reverse twist <= 4dB accepted
- * S/N >= 15dB will detect OK
- * Attenuation <= 26dB will detect OK
- * Frequency tolerance +- 1.5% will detect, +-3.5% will reject
- */
+ /* Basic DTMF specs:
+ *
+ * Minimum tone on = 40ms
+ * Minimum tone off = 50ms
+ * Maximum digit rate = 10 per second
+ * Normal twist <= 8dB accepted
+ * Reverse twist <= 4dB accepted
+ * S/N >= 15dB will detect OK
+ * Attenuation <= 26dB will detect OK
+ * Frequency tolerance +- 1.5% will detect, +-3.5% will reject
+ */
#define DTMF_THRESHOLD 8.0e7
#define DTMF_NORMAL_TWIST 6.3 /* 8dB */
@@ -134,131 +134,131 @@
#define BLOCK_LEN 102
#define M_TWO_PI 2.0*M_PI
-/*! \brief A continer for the elements of a Goertzel Algorithm (The names are from his formula) */
-typedef struct {
- teletone_process_t v2;
- teletone_process_t v3;
- teletone_process_t fac;
-} teletone_goertzel_state_t;
+ /*! \brief A continer for the elements of a Goertzel Algorithm (The names are from his formula) */
+ typedef struct {
+ teletone_process_t v2;
+ teletone_process_t v3;
+ teletone_process_t fac;
+ } teletone_goertzel_state_t;
-/*! \brief A container for a DTMF detection state.*/
-typedef struct {
- int hit1;
- int hit2;
- int hit3;
- int hit4;
- int mhit;
-
- teletone_goertzel_state_t row_out[GRID_FACTOR];
- teletone_goertzel_state_t col_out[GRID_FACTOR];
- teletone_goertzel_state_t row_out2nd[GRID_FACTOR];
- teletone_goertzel_state_t col_out2nd[GRID_FACTOR];
- teletone_process_t energy;
+ /*! \brief A container for a DTMF detection state.*/
+ typedef struct {
+ int hit1;
+ int hit2;
+ int hit3;
+ int hit4;
+ int mhit;
+
+ teletone_goertzel_state_t row_out[GRID_FACTOR];
+ teletone_goertzel_state_t col_out[GRID_FACTOR];
+ teletone_goertzel_state_t row_out2nd[GRID_FACTOR];
+ teletone_goertzel_state_t col_out2nd[GRID_FACTOR];
+ teletone_process_t energy;
- int current_sample;
- char digits[TELETONE_MAX_DTMF_DIGITS + 1];
- int current_digits;
- int detected_digits;
- int lost_digits;
- int digit_hits[16];
-} teletone_dtmf_detect_state_t;
-
-/*! \brief An abstraction to store the coefficient of a tone frequency */
-typedef struct {
- teletone_process_t fac;
-} teletone_detection_descriptor_t;
-
-/*! \brief A container for a single multi-tone detection
-TELETONE_MAX_TONES dictates the maximum simultaneous tones that can be present
-in a multi-tone representation.
-*/
-typedef struct {
- int sample_rate;
-
- teletone_detection_descriptor_t tdd[TELETONE_MAX_TONES];
- teletone_goertzel_state_t gs[TELETONE_MAX_TONES];
- teletone_goertzel_state_t gs2[TELETONE_MAX_TONES];
- int tone_count;
+ int current_sample;
+ char digits[TELETONE_MAX_DTMF_DIGITS + 1];
+ int current_digits;
+ int detected_digits;
+ int lost_digits;
+ int digit_hits[16];
+ } teletone_dtmf_detect_state_t;
+
+ /*! \brief An abstraction to store the coefficient of a tone frequency */
+ typedef struct {
+ teletone_process_t fac;
+ } teletone_detection_descriptor_t;
+
+ /*! \brief A container for a single multi-tone detection
+ TELETONE_MAX_TONES dictates the maximum simultaneous tones that can be present
+ in a multi-tone representation.
+ */
+ typedef struct {
+ int sample_rate;
+
+ teletone_detection_descriptor_t tdd[TELETONE_MAX_TONES];
+ teletone_goertzel_state_t gs[TELETONE_MAX_TONES];
+ teletone_goertzel_state_t gs2[TELETONE_MAX_TONES];
+ int tone_count;
- teletone_process_t energy;
- int current_sample;
+ teletone_process_t energy;
+ int current_sample;
- int min_samples;
- int total_samples;
+ int min_samples;
+ int total_samples;
- int positives;
- int negatives;
- int hits;
-
- int positive_factor;
- int negative_factor;
- int hit_factor;
-
-} teletone_multi_tone_t;
-
-
-/*!
- \brief Initilize a multi-frequency tone detector
- \param mt the multi-frequency tone descriptor
- \param map a representation of the multi-frequency tone
-*/
-void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map);
-
-/*!
- \brief Check a sample buffer for the presence of the mulit-frequency tone described by mt
- \param mt the multi-frequency tone descriptor
- \param sample_buffer an array aof 16 bit signed linear samples
- \param samples the number of samples present in sample_buffer
- \return true when the tone was detected or false when it is not
-*/
-int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
- int16_t sample_buffer[],
- int samples);
-
-/*!
- \brief Initilize a DTMF detection state object
- \param dtmf_detect_state the DTMF detection state to initilize
- \param sample_rate the desired sample rate
-*/
-void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate);
-
-/*!
- \brief Check a sample buffer for the presence of DTMF digits
- \param dtmf_detect_state the detection state object to check
- \param sample_buffer an array aof 16 bit signed linear samples
- \param samples the number of samples present in sample_buffer
- \return true when DTMF was detected or false when it is not
-*/
-int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
- int16_t sample_buffer[],
- int samples);
-/*!
- \brief retrieve any collected digits into a string buffer
- \param dtmf_detect_state the detection state object to check
- \param buf the string buffer to write to
- \param max the maximum length of buf
- \return the number of characters written to buf
-*/
-int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
- char *buf,
- int max);
-
-/*!
- \brief Step through the Goertzel Algorithm for each sample in a buffer
- \param goertzel_state the goertzel state to step the samples through
- \param sample_buffer an array aof 16 bit signed linear samples
- \param samples the number of samples present in sample_buffer
-*/
-void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
+ int positives;
+ int negatives;
+ int hits;
+
+ int positive_factor;
+ int negative_factor;
+ int hit_factor;
+
+ } teletone_multi_tone_t;
+
+
+ /*!
+ \brief Initilize a multi-frequency tone detector
+ \param mt the multi-frequency tone descriptor
+ \param map a representation of the multi-frequency tone
+ */
+ void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map);
+
+ /*!
+ \brief Check a sample buffer for the presence of the mulit-frequency tone described by mt
+ \param mt the multi-frequency tone descriptor
+ \param sample_buffer an array aof 16 bit signed linear samples
+ \param samples the number of samples present in sample_buffer
+ \return true when the tone was detected or false when it is not
+ */
+ int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
+ int16_t sample_buffer[],
+ int samples);
+
+ /*!
+ \brief Initilize a DTMF detection state object
+ \param dtmf_detect_state the DTMF detection state to initilize
+ \param sample_rate the desired sample rate
+ */
+ void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate);
+
+ /*!
+ \brief Check a sample buffer for the presence of DTMF digits
+ \param dtmf_detect_state the detection state object to check
+ \param sample_buffer an array aof 16 bit signed linear samples
+ \param samples the number of samples present in sample_buffer
+ \return true when DTMF was detected or false when it is not
+ */
+ int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
int16_t sample_buffer[],
int samples);
-
-/*!
- \brief Compute the result of the last applied step of the Goertzel Algorithm
- \param goertzel_state the goertzel state to retrieve from
- \return the computed value for consideration in furthur audio tests
-*/
-teletone_process_t teletone_goertzel_result (teletone_goertzel_state_t *goertzel_state);
+ /*!
+ \brief retrieve any collected digits into a string buffer
+ \param dtmf_detect_state the detection state object to check
+ \param buf the string buffer to write to
+ \param max the maximum length of buf
+ \return the number of characters written to buf
+ */
+ int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
+ char *buf,
+ int max);
+
+ /*!
+ \brief Step through the Goertzel Algorithm for each sample in a buffer
+ \param goertzel_state the goertzel state to step the samples through
+ \param sample_buffer an array aof 16 bit signed linear samples
+ \param samples the number of samples present in sample_buffer
+ */
+ void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
+ int16_t sample_buffer[],
+ int samples);
+
+ /*!
+ \brief Compute the result of the last applied step of the Goertzel Algorithm
+ \param goertzel_state the goertzel state to retrieve from
+ \return the computed value for consideration in furthur audio tests
+ */
+ teletone_process_t teletone_goertzel_result (teletone_goertzel_state_t *goertzel_state);
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 Fri Jun 8 13:07:48 2007
@@ -70,6 +70,7 @@
*/
#include <libteletone.h>
+
#define SMAX 32767
#define SMIN -32768
#define normalize_to_16bit(n) if (n > SMAX) n = SMAX; else if (n < SMIN) n = SMIN;
@@ -78,6 +79,25 @@
#pragma warning(disable:4706)
#endif
+int16_t TELETONE_SINES[SINE_TABLE_MAX] = {
+ 0x00c9, 0x025b, 0x03ed, 0x057f, 0x0711, 0x08a2, 0x0a33, 0x0bc4,
+ 0x0d54, 0x0ee4, 0x1073, 0x1201, 0x138f, 0x151c, 0x16a8, 0x1833,
+ 0x19be, 0x1b47, 0x1cd0, 0x1e57, 0x1fdd, 0x2162, 0x22e5, 0x2467,
+ 0x25e8, 0x2768, 0x28e5, 0x2a62, 0x2bdc, 0x2d55, 0x2ecc, 0x3042,
+ 0x31b5, 0x3327, 0x3497, 0x3604, 0x3770, 0x38d9, 0x3a40, 0x3ba5,
+ 0x3d08, 0x3e68, 0x3fc6, 0x4121, 0x427a, 0x43d1, 0x4524, 0x4675,
+ 0x47c4, 0x490f, 0x4a58, 0x4b9e, 0x4ce1, 0x4e21, 0x4f5e, 0x5098,
+ 0x51cf, 0x5303, 0x5433, 0x5560, 0x568a, 0x57b1, 0x58d4, 0x59f4,
+ 0x5b10, 0x5c29, 0x5d3e, 0x5e50, 0x5f5e, 0x6068, 0x616f, 0x6272,
+ 0x6371, 0x646c, 0x6564, 0x6657, 0x6747, 0x6832, 0x691a, 0x69fd,
+ 0x6add, 0x6bb8, 0x6c8f, 0x6d62, 0x6e31, 0x6efb, 0x6fc2, 0x7083,
+ 0x7141, 0x71fa, 0x72af, 0x735f, 0x740b, 0x74b3, 0x7556, 0x75f4,
+ 0x768e, 0x7723, 0x77b4, 0x7840, 0x78c8, 0x794a, 0x79c9, 0x7a42,
+ 0x7ab7, 0x7b27, 0x7b92, 0x7bf9, 0x7c5a, 0x7cb7, 0x7d0f, 0x7d63,
+ 0x7db1, 0x7dfb, 0x7e3f, 0x7e7f, 0x7eba, 0x7ef0, 0x7f22, 0x7f4e,
+ 0x7f75, 0x7f98, 0x7fb5, 0x7fce, 0x7fe2, 0x7ff1, 0x7ffa, 0x7fff
+};
+
int teletone_set_tone(teletone_generation_session_t *ts, int index, ...)
{
@@ -122,8 +142,9 @@
ts->tmp_wait = -1;
ts->handler = handler;
ts->user_data = user_data;
- ts->volume = 1500;
+ ts->volume = -7;
ts->decay_step = 0;
+ ts->decay_factor = 1;
if (buflen) {
if ((ts->buffer = calloc(buflen, sizeof(teletone_audio_t))) == 0) {
return -1;
@@ -181,34 +202,24 @@
int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map)
{
- teletone_process_t period = (1.0 / ts->rate) / ts->channels;
+ /*teletone_process_t period = (1.0 / ts->rate) / ts->channels;*/
int i, c;
int freqlen = 0;
- teletone_process_t tones[TELETONE_MAX_TONES];
- int decay = 0;
+ teletone_dds_state_t tones[TELETONE_MAX_TONES];
+ //int decay = 0;
int duration;
int wait = 0;
- teletone_process_t sample;
-
+ int32_t sample;
+ int32_t dc = 0;
+ float vol = ts->volume;
ts->samples = 0;
-
+ memset(tones, 0, sizeof(tones[0]) * TELETONE_MAX_TONES);
duration = (ts->tmp_duration > -1) ? ts->tmp_duration : ts->duration;
wait = (ts->tmp_wait > -1) ? ts->tmp_wait : ts->wait;
if (map->freqs[0] > 0) {
- if (ts->decay_step) {
- if (ts->decay_factor) {
- decay = (duration - (duration / ts->decay_factor));
- } else {
- decay = 0;
- }
- }
- if (ts->volume < 0) {
- ts->volume = 0;
- }
-
for (freqlen = 0; map->freqs[freqlen] && freqlen < TELETONE_MAX_TONES; freqlen++) {
- tones[freqlen] = (teletone_process_t) map->freqs[freqlen] * (2 * M_PI);
+ teletone_dds_state_set_tone(&tones[freqlen], map->freqs[freqlen], ts->rate, vol);
}
if (ts->channels > 1) {
@@ -220,17 +231,28 @@
return -1;
}
}
+
for (ts->samples = 0; ts->samples < ts->datalen && ts->samples < duration; ts->samples++) {
- if (ts->decay_step && !(ts->samples % ts->decay_step) && ts->volume > 0 && ts->samples > decay) {
- ts->volume += ts->decay_direction;
+ if (ts->decay_direction && ++dc >= ts->decay_step) {
+ float nvol = vol + ts->decay_direction * ts->decay_factor;
+ int j;
+
+ if (nvol <= TELETONE_VOL_DB_MAX && nvol >= TELETONE_VOL_DB_MIN) {
+ vol = nvol;
+ for (j = 0; map->freqs[j] && j < TELETONE_MAX_TONES; j++) {
+ teletone_dds_state_set_tx_level(&tones[j], vol);
+ }
+ dc = 0;
+ }
}
- sample = (teletone_process_t) 128;
+ sample = 128;
for (i = 0; i < freqlen; i++) {
- sample += ((teletone_process_t) 2 * (ts->volume > 0 ? ts->volume : 1) * cos(tones[i] * ts->samples * period));
+ int32_t s = teletone_dds_modulate_sample(&tones[i]);
+ sample += s;
}
- normalize_to_16bit(sample);
+ sample /= freqlen;
ts->buffer[ts->samples] = (teletone_audio_t)sample;
for (c = 1; c < ts->channels; c++) {
@@ -261,7 +283,8 @@
fprintf(ts->debug_stream, "%s%0.2f", i == 0 ? "" : "+",map->freqs[i]);
}
- fprintf(ts->debug_stream, ") [volume %d; samples %d(%dms) x %d channel%s; wait %d(%dms); decay_factor %d; decay_step %d; wrote %d bytes]\n",
+ fprintf(ts->debug_stream,
+ ") [volume %0.2fdB; samples %d(%dms) x %d channel%s; wait %d(%dms); decay_factor %0.2fdB; decay_step %d(%dms); wrote %d bytes]\n",
ts->volume,
duration,
duration / (ts->rate / 1000),
@@ -271,6 +294,7 @@
wait / (ts->rate / 1000),
ts->decay_factor,
ts->decay_step,
+ ts->decay_step / (ts->rate / 1000),
ts->samples * 2);
}
}
@@ -330,18 +354,23 @@
ts->duration = atoi(cur + 2) * (ts->rate / 1000);
break;
case 'v':
- ts->volume = atoi(cur + 2);
+ {
+ float vol = (float)atof(cur + 2);
+ if (vol <= TELETONE_VOL_DB_MAX && vol >= TELETONE_VOL_DB_MIN) {
+ ts->volume = vol;
+ }
+ }
break;
case '>':
- ts->decay_factor = atoi(cur + 2);
+ ts->decay_step = atoi(cur + 2) * (ts->rate / 1000);
ts->decay_direction = -1;
break;
case '<':
- ts->decay_factor = atoi(cur + 2);
+ ts->decay_step = atoi(cur + 2) * (ts->rate / 1000);
ts->decay_direction = 1;
break;
case '+':
- ts->decay_step = atoi(cur + 2);
+ ts->decay_factor = (float)atof(cur + 2);
break;
case 'w':
ts->wait = atoi(cur + 2) * (ts->rate / 1000);
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 Fri Jun 8 13:07:48 2007
@@ -72,27 +72,108 @@
#define LIBTELETONE_GENERATE_H
#ifdef __cplusplus
extern "C" {
+#ifdef _doh
+}
#endif
-#include <stdlib.h>
+#endif
+
#include <stdio.h>
-#include <string.h>
+#include <stdlib.h>
+#ifdef _MSC_VER
+#undef inline
+#define inline __inline
+typedef unsigned __int64 uint64_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int8 uint8_t;
+typedef __int64 int64_t;
+typedef __int32 int32_t;
+typedef __int16 int16_t;
+typedef __int8 int8_t;
+#else
+#include <stdint.h>
+#endif
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <math.h>
+#if !defined(powf)
+extern float powf (float, float);
+#endif
+#include <string.h>
+#include <errno.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
-#include <fcntl.h>
-#include <sys/types.h>
-#include <errno.h>
#include <assert.h>
#include <stdarg.h>
#include <libteletone.h>
+#define TELETONE_VOL_DB_MAX 0
+#define TELETONE_VOL_DB_MIN -63
+
+struct teletone_dds_state {
+ uint32_t phase_rate;
+ uint32_t scale_factor;
+ uint32_t phase_accumulator;
+ int16_t sample;
+ teletone_process_t tx_level;
+};
+typedef struct teletone_dds_state teletone_dds_state_t;
+
+#define SINE_TABLE_MAX 128
+#define SINE_TABLE_LEN (SINE_TABLE_MAX - 1)
+#define MAX_PHASE_ACCUMULATOR 0x10000 * 0x10000
+/* 3.14 == the max power on ulaw (alaw is 3.17) */
+/* 3.02 represents twice the power */
+#define DBM0_MAX_POWER (3.14f + 3.02f)
+
+extern int16_t TELETONE_SINES[SINE_TABLE_MAX];
+
+static inline int16_t teletone_dds_modulate_sample(teletone_dds_state_t *dds)
+{
+ int32_t bitmask = dds->phase_accumulator, sine_index = (bitmask >>= 23) & SINE_TABLE_LEN;
+ int16_t sample;
+
+ if (bitmask & SINE_TABLE_MAX) {
+ sine_index = SINE_TABLE_LEN - sine_index;
+ }
+
+ sample = TELETONE_SINES[sine_index];
+
+ if (bitmask & (SINE_TABLE_MAX * 2)) {
+ sample *= -1;
+ }
+
+ dds->phase_accumulator += dds->phase_rate;
+
+ return (int16_t) (sample * dds->scale_factor >> 15);
+}
+
+static inline void teletone_dds_state_set_tx_level(teletone_dds_state_t *dds, float tx_level)
+{
+ dds->scale_factor = (int) (powf(10.0f, (tx_level - DBM0_MAX_POWER) / 20.0f) * (32767.0f * 1.414214f));
+}
+
+static inline void teletone_dds_state_set_tone(teletone_dds_state_t *dds, teletone_process_t tone, uint32_t rate, float tx_level)
+{
+ dds->phase_accumulator = 0;
+ dds->phase_rate = (int32_t) ((tone * MAX_PHASE_ACCUMULATOR) / rate);
+
+
+ if (dds->tx_level != tx_level || !dds->scale_factor) {
+ teletone_dds_state_set_tx_level(dds, tx_level);
+ }
+
+ dds->tx_level = tx_level;
+}
+
/*! \file libteletone_generate.h
- \brief Tone Generation Routines
+ \brief Tone Generation Routines
- This module is responsible for tone generation specifics
+ This module is responsible for tone generation specifics
*/
typedef int16_t teletone_audio_t;
@@ -120,13 +201,13 @@
/*! Number of loops to repeat the entire set of instructions*/
int LOOPS;
/*! Number to mutiply total samples by to determine when to begin ascent or decent e.g. 0=beginning 4=(last 25%) */
- int decay_factor;
+ float decay_factor;
/*! Direction to perform volume increase/decrease 1/-1*/
int decay_direction;
/*! Number of samples between increase/decrease of volume */
int decay_step;
/*! Volume factor of the tone */
- int volume;
+ float volume;
/*! Debug on/off */
int debug;
/*! FILE stream to write debug data to */
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 Fri Jun 8 13:07:48 2007
@@ -284,7 +284,7 @@
for (;;) {
struct sockaddr_in local_addr = {0};
- int cliAddrLen = sizeof(local_addr);
+ size_t cliAddrLen = sizeof(local_addr);
unsigned char audiobuf[1024], rawbuf[1024], outbuf[1024];
short *usebuf = NULL;
int tx, tx_bytes, bigger, sample_count;
@@ -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");
}
@@ -371,7 +371,7 @@
cliAddrLen = sizeof(sendaddr);
- if (sendto(usock, usebuf, tx_bytes, 0, (struct sockaddr *) &sendaddr, sizeof(sendaddr)) != sample_count) {
+ if (sendto(usock, usebuf, tx_bytes, 0, (struct sockaddr *) &sendaddr, sizeof(sendaddr)) != tx_bytes) {
die("sendto() sent a different number of bytes than expected");
}
}
Modified: freeswitch/branches/greenlizard/src/include/switch.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch.h (original)
+++ freeswitch/branches/greenlizard/src/include/switch.h Fri Jun 8 13:07:48 2007
@@ -53,8 +53,10 @@
#define __EXTENSIONS__ 1
#ifndef MACOSX
#ifndef _XOPEN_SOURCE
+#ifndef __cplusplus
#define _XOPEN_SOURCE 600
#endif
+#endif
#ifndef __BSD_VISIBLE
#define __BSD_VISIBLE 1
#endif
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 Fri Jun 8 13:07:48 2007
@@ -41,7 +41,7 @@
void store_file_handle(switch_file_handle_t *fh);
public:
CoreSession(char *uuid);
- CoreSession(switch_core_session_t *session);
+ CoreSession(switch_core_session_t *new_session);
~CoreSession();
switch_core_session_t *session;
switch_channel_t *channel;
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 Fri Jun 8 13:07:48 2007
@@ -562,7 +562,7 @@
typedef enum {
SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 << 0),
SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 << 1),
- SWITCH_IVR_MENU_FLAG_STACK = (1 << 2),
+ SWITCH_IVR_MENU_FLAG_STACK = (1 << 2)
} switch_ivr_menu_flags;
/* Actions are either set in switch_ivr_menu_bind_function or returned by a callback */
typedef enum {
@@ -575,7 +575,7 @@
SWITCH_IVR_ACTION_BACK, /* Go back 1 menu. */
SWITCH_IVR_ACTION_TOMAIN, /* Go back to the top level menu. */
SWITCH_IVR_ACTION_TRANSFER, /* Transfer caller to another ext. */
- SWITCH_IVR_ACTION_NOOP, /* No operation */
+ SWITCH_IVR_ACTION_NOOP /* No operation */
} switch_ivr_action_t;
struct switch_ivr_menu;
typedef switch_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t, void *);
Modified: freeswitch/branches/greenlizard/src/include/switch_stun.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_stun.h (original)
+++ freeswitch/branches/greenlizard/src/include/switch_stun.h Fri Jun 8 13:07:48 2007
@@ -106,12 +106,12 @@
typedef struct {
int16_t type;
uint16_t length;
- char value[];
+ char value[1];
} switch_stun_packet_attribute_t;
typedef struct {
switch_stun_packet_header_t header;
- uint8_t first_attribute[];
+ uint8_t first_attribute[1];
} switch_stun_packet_t;
typedef struct {
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 Fri Jun 8 13:07:48 2007
@@ -161,7 +161,7 @@
SST_POSTAL_ADDRESS,
SST_ACCOUNT_NUMBER,
SST_NAME_SPELLED,
- SST_NAME_PHONETIC,
+ SST_NAME_PHONETIC
} switch_say_type_t;
typedef enum {
@@ -196,7 +196,7 @@
SWITCH_ABC_TYPE_READ,
SWITCH_ABC_TYPE_WRITE,
SWITCH_ABC_TYPE_WRITE_REPLACE,
- SWITCH_ABC_TYPE_CLOSE,
+ SWITCH_ABC_TYPE_CLOSE
} switch_abc_type_t;
typedef struct {
@@ -332,7 +332,7 @@
typedef enum {
SWITCH_PRIORITY_NORMAL,
SWITCH_PRIORITY_LOW,
- SWITCH_PRIORITY_HIGH,
+ SWITCH_PRIORITY_HIGH
} switch_priority_t;
/*!
@@ -702,7 +702,7 @@
</pre>
*/
typedef enum {
- SWITCH_DIRECTORY_FLAG_FREE_POOL = (1 << 0),
+ SWITCH_DIRECTORY_FLAG_FREE_POOL = (1 << 0)
} switch_directory_flag_t;
@@ -732,7 +732,7 @@
</pre>
*/
typedef enum {
- SWITCH_TIMER_FLAG_FREE_POOL = (1 << 0),
+ SWITCH_TIMER_FLAG_FREE_POOL = (1 << 0)
} switch_timer_flag_t;
@@ -786,7 +786,7 @@
} switch_file_flag_t;
typedef enum {
- SWITCH_IO_FLAG_NOOP = 0,
+ SWITCH_IO_FLAG_NOOP = 0
} switch_io_flag_t;
/* make sure this is synced with the EVENT_NAMES array in switch_event.c
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 Fri Jun 8 13:07:48 2007
@@ -177,11 +177,17 @@
#define switch_set_string(_dst, _src) switch_copy_string(_dst, _src, sizeof(_dst))
-static __inline__ void switch_clean_string(char *s)
-{ char *p;
+static inline char *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 = ' ';
+ }
+ }
- for (p = s; p && *p; p++) { uint8_t x = (uint8_t) *p; if (x < 32 || x > 127) { *p = ' '; }
- }
+ return s;
}
Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c Fri Jun 8 13:07:48 2007
@@ -720,6 +720,7 @@
imember->mux_resampler->from_len, imember->mux_resampler->to, imember->mux_resampler->to_size, 0);
switch_float_to_short(imember->mux_resampler->to, out, len);
len = imember->mux_resampler->to_len * 2;
+
switch_buffer_write(imember->resample_buffer, out, len);
if (switch_buffer_inuse(imember->resample_buffer) >= bytes) {
imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, bytes);
@@ -1406,8 +1407,7 @@
if ((talking || energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK)) {
if (member->read_resampler) {
int16_t *bptr = (int16_t *) read_frame->data;
- int len = (int) read_frame->datalen;;
-
+ int len = (int) read_frame->datalen;
member->read_resampler->from_len = switch_short_to_float(bptr, member->read_resampler->from, (int) len / 2);
member->read_resampler->to_len =
switch_resample_process(member->read_resampler, member->read_resampler->from,
@@ -1477,8 +1477,8 @@
switch_timer_t timer = { 0 };
switch_codec_t *read_codec = switch_core_session_get_read_codec(member->session);
uint32_t interval = read_codec->implementation->microseconds_per_frame / 1000;
- //uint32_t samples = switch_bytes_per_frame(member->conference->rate, member->conference->interval);
- uint32_t samples = switch_bytes_per_frame(read_codec->implementation->samples_per_second, interval);
+ uint32_t csamples = switch_bytes_per_frame(member->conference->rate, member->conference->interval);
+ uint32_t samples = switch_bytes_per_frame(member->conference->rate, interval);
uint32_t low_count = 0, bytes = samples * 2;
call_list_t *call_list = NULL, *cp = NULL;
@@ -1549,8 +1549,8 @@
&& switch_channel_ready(channel)) {
char dtmf[128] = "";
uint8_t file_frame[CONF_BUFFER_SIZE] = { 0 };
- switch_size_t file_data_len = samples * 2;
- switch_size_t file_sample_len = samples;
+ switch_size_t file_data_len = csamples * 2;
+ switch_size_t file_sample_len = csamples;
char *digit;
switch_event_t *event;
caller_control_action_t *caller_action = NULL;
@@ -4135,11 +4135,14 @@
if (switch_resample_create(resampler,
read_codec->implementation->samples_per_second,
read_codec->implementation->samples_per_second * 20,
- conference->rate, conference->rate * 20, member.pool) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to crete resampler!\n");
+ conference->rate,
+ conference->rate * 20,
+ member.pool) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
goto done;
}
+
/* Setup an audio buffer for the resampled audio */
if (switch_buffer_create_dynamic(&member.resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX)
!= SWITCH_STATUS_SUCCESS) {
@@ -4151,7 +4154,8 @@
if (switch_core_codec_init(&member.write_codec,
"L16",
NULL,
- read_codec->implementation->samples_per_second,
+ //read_codec->implementation->samples_per_second,
+ conference->rate,
read_codec->implementation->microseconds_per_frame / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
Modified: freeswitch/branches/greenlizard/src/mod/codecs/mod_l16/mod_l16.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/codecs/mod_l16/mod_l16.c (original)
+++ freeswitch/branches/greenlizard/src/mod/codecs/mod_l16/mod_l16.c Fri Jun 8 13:07:48 2007
@@ -88,7 +88,7 @@
static const switch_codec_implementation_t raw_32k_60ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
+ /*.ianacode */ 119,
/*.iananame */ "L16",
/*.fmtp */ NULL,
/*.samples_per_second = */ 32000,
@@ -109,7 +109,7 @@
static const switch_codec_implementation_t raw_32k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
+ /*.ianacode */ 119,
/*.iananame */ "L16",
/*.fmtp */ NULL,
/*.samples_per_second = */ 32000,
@@ -130,7 +130,7 @@
static const switch_codec_implementation_t raw_32k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
+ /*.ianacode */ 119,
/*.iananame */ "L16",
/*.fmtp */ NULL,
/*.samples_per_second = */ 32000,
@@ -151,7 +151,7 @@
static const switch_codec_implementation_t raw_32k_10ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
+ /*.ianacode */ 119,
/*.iananame */ "L16",
/*.fmtp */ NULL,
/*.samples_per_second = */ 32000,
@@ -172,7 +172,7 @@
static const switch_codec_implementation_t raw_22k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
+ /*.ianacode */ 118,
/*.iananame */ "L16",
/*.fmtp */ NULL,
/*.samples_per_second = */ 22050,
@@ -193,7 +193,7 @@
static const switch_codec_implementation_t raw_16k_120ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
+ /*.ianacode */ 117,
/*.iananame */ "L16",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
@@ -214,7 +214,7 @@
static const switch_codec_implementation_t raw_16k_60ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
+ /*.ianacode */ 117,
/*.iananame */ "L16",
/*.fmtp */ NULL,
/*.samples_per_second */ 16000,
@@ -235,7 +235,7 @@
static const switch_codec_implementation_t raw_16k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
+ /*.ianacode */ 117,
/*.iananame */ "L16",
/*.fmtp */ NULL,
/*.samples_per_second */ 16000,
@@ -256,7 +256,7 @@
static const switch_codec_implementation_t raw_16k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
+ /*.ianacode */ 117,
/*.iananame */ "L16",
/*.fmtp */ NULL,
/*.samples_per_second = */ 16000,
@@ -277,7 +277,7 @@
static const switch_codec_implementation_t raw_16k_10ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
+ /*.ianacode */ 117,
/*.iananame */ "L16",
/*.fmtp */ NULL,
/*.samples_per_second = */ 16000,
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 Fri Jun 8 13:07:48 2007
@@ -1844,11 +1844,10 @@
if (profile->ndlb & PFLAG_NDLB_TO_IN_200_CONTACT) {
tech_pvt->reply_contact = tech_pvt->to_uri;
} else {
- tech_pvt->to_uri = switch_core_session_strdup(session, profile->url);
+ tech_pvt->reply_contact = switch_core_session_strdup(session, profile->url);
}
} else {
- tech_pvt->to_uri = switch_core_session_strdup(session, profile->url);
- tech_pvt->reply_contact = tech_pvt->to_uri;
+ tech_pvt->reply_contact = switch_core_session_strdup(session, profile->url);
}
}
Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c Fri Jun 8 13:07:48 2007
@@ -1145,19 +1145,24 @@
for (i = 0; i < tech_pvt->num_codecs; i++) {
const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
-
+ uint32_t codec_rate = imp->samples_per_second;
if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO) {
continue;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d]/[%s:%d]\n",
- rm_encoding, map->rm_pt, imp->iananame, imp->ianacode);
+
+ if (map->rm_pt == 9) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Oh sure! You say 8000, but you mean 16000! This is, of course, stupid!\n");
+ codec_rate = 8000;
+ }
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u]/[%s:%d:%u]\n",
+ rm_encoding, map->rm_pt, (int)map->rm_rate, imp->iananame, imp->ianacode, codec_rate);
if (map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else {
match = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;
}
- if (match && (map->rm_rate == imp->samples_per_second)) {
+ if (match && (map->rm_rate == codec_rate)) {
if (ptime && ptime * 1000 != imp->microseconds_per_frame) {
near_match = imp;
match = 0;
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 Fri Jun 8 13:07:48 2007
@@ -24,7 +24,7 @@
* Contributor(s):
*
* Anthony Minessale II <anthmct at yahoo.com>
- * Ken Rice, Asteria Solutions Group, Inc <ken at asteriasgi.com>
+ * Ken Rice, krice at suspicious.org (work sponsored by CopperCom, Inc and Asteria Solutions Group, Inc)
* Paul D. Tinsley <pdt at jackhammer.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
* Marcel Barbulescu <marcelbarbulescu at gmail.com>
@@ -275,14 +275,14 @@
uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_handle_t * nh, sip_t const *sip, sofia_regtype_t regtype, char *key,
uint32_t keylen, switch_event_t **v_event)
{
- sip_from_t const *from = NULL;
+ sip_to_t const *to = NULL;
sip_expires_t const *expires = NULL;
sip_authorization_t const *authorization = NULL;
sip_contact_t const *contact = NULL;
char *sql;
switch_event_t *s_event;
- const char *from_user = NULL;
- const char *from_host = NULL;
+ const char *to_user = NULL;
+ const char *to_host = NULL;
char contact_str[1024] = "";
char buf[512];
uint8_t stale = 0, forbidden = 0;
@@ -304,14 +304,14 @@
expires = sip->sip_expires;
authorization = sip->sip_authorization;
contact = sip->sip_contact;
- from = sip->sip_from;
+ to = sip->sip_to;
- if (from) {
- from_user = from->a_url->url_user;
- from_host = from->a_url->url_host;
+ if (to) {
+ to_user = to->a_url->url_user;
+ to_host = to->a_url->url_host;
}
- if (!from_user || !from_host) {
+ if (!to_user || !to_host) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete from header\n");
nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), TAG_END());
return 1;
@@ -322,8 +322,8 @@
display = contact->m_display;
if (switch_strlen_zero(display)) {
- if (from) {
- display = from->a_display;
+ if (to) {
+ display = to->a_display;
if (switch_strlen_zero(display)) {
display = "\"user\"";
}
@@ -385,7 +385,7 @@
}
if (auth_res != AUTH_OK && !stale) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "send %s for [%s@%s]\n", forbidden ? "forbidden" : "challange", from_user, from_host);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "send %s for [%s@%s]\n", forbidden ? "forbidden" : "challange", to_user, to_host);
if (auth_res == AUTH_FORBIDDEN) {
nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS(nua), TAG_END());
} else {
@@ -412,10 +412,10 @@
switch_mutex_unlock(profile->ireg_mutex);
auth_str =
- switch_mprintf("Digest realm=\"%q\", nonce=\"%q\",%s algorithm=MD5, qop=\"auth\"", from_host, uuid_str, stale ? " stale=\"true\"," : "");
+ switch_mprintf("Digest realm=\"%q\", nonce=\"%q\",%s algorithm=MD5, qop=\"auth\"", to_host, uuid_str, stale ? " stale=\"true\"," : "");
if (regtype == REG_REGISTER) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Requesting Registration from: [%s@%s]\n", from_user, from_host);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Requesting Registration from: [%s@%s]\n", to_user, to_host);
nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), SIPTAG_WWW_AUTHENTICATE_STR(auth_str), TAG_END());
} else if (regtype == REG_INVITE) {
nua_respond(nh, SIP_407_PROXY_AUTH_REQUIRED, NUTAG_WITH_THIS(nua), SIPTAG_PROXY_AUTHENTICATE_STR(auth_str), TAG_END());
@@ -427,22 +427,22 @@
reg:
if (exptime) {
- if (!sofia_reg_find_reg_url(profile, from_user, from_host, buf, sizeof(buf))) {
+ if (!sofia_reg_find_reg_url(profile, to_user, to_host, buf, sizeof(buf))) {
sql = switch_mprintf("insert into sip_registrations values ('%q','%q','%q','%q', '%q', %ld)",
- from_user, from_host, contact_str, cd ? "Registered(NATHACK)" : "Registered", rpid, (long) time(NULL) + (long) exptime * 2);
+ to_user, to_host, contact_str, cd ? "Registered(NATHACK)" : "Registered", rpid, (long) time(NULL) + (long) exptime * 2);
} else {
sql =
switch_mprintf
("update sip_registrations set contact='%q', expires=%ld, rpid='%q' where user='%q' and host='%q'",
- contact_str, (long) time(NULL) + (long) exptime * 2, rpid, from_user, from_host);
+ contact_str, (long) time(NULL) + (long) exptime * 2, rpid, to_user, to_host);
}
if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_REGISTER) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile-name", "%s", profile->name);
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from-user", "%s", from_user);
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from-host", "%s", from_host);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from-user", "%s", to_user);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from-host", "%s", to_host);
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "contact", "%s", contact_str);
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "rpid", "%s", rpid);
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "expires", "%ld", (long) exptime);
@@ -456,26 +456,26 @@
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "Register:\nFrom: [%s@%s]\nContact: [%s]\nExpires: [%ld]\n", from_user, from_host, contact_str, (long) exptime);
+ "Register:\nFrom: [%s@%s]\nContact: [%s]\nExpires: [%ld]\n", to_user, to_host, contact_str, (long) exptime);
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "sip");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->url);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", rpid);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", from_user, from_host);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, to_host);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Registered");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_fire(&event);
}
} else {
- if ((sql = switch_mprintf("delete from sip_subscriptions where user='%q' and host='%q'", from_user, from_host))) {
+ if ((sql = switch_mprintf("delete from sip_subscriptions where user='%q' and host='%q'", to_user, to_host))) {
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
switch_safe_free(sql);
sql = NULL;
}
- if ((sql = switch_mprintf("delete from sip_registrations where user='%q' and host='%q'", from_user, from_host))) {
+ if ((sql = switch_mprintf("delete from sip_registrations where user='%q' and host='%q'", to_user, to_host))) {
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
switch_safe_free(sql);
sql = NULL;
@@ -483,7 +483,7 @@
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_OUT) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "sip");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->url);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s+%s@%s", SOFIA_CHAT_PROTO, from_user, from_host);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s+%s@%s", SOFIA_CHAT_PROTO, to_user, to_host);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "unavailable");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", rpid);
@@ -495,7 +495,7 @@
if (switch_event_create(&event, SWITCH_EVENT_ROSTER) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "sip");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", from_user, from_host);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, to_host);
switch_event_fire(&event);
}
Modified: freeswitch/branches/greenlizard/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/branches/greenlizard/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Fri Jun 8 13:07:48 2007
@@ -129,19 +129,24 @@
if (!switch_test_flag(l, LFLAG_EVENTS)) {
continue;
}
-
- if (l->event_list[(uint8_t) SWITCH_EVENT_ALL]) {
+
+ if (l->event_list[SWITCH_EVENT_ALL]) {
send = 1;
- } else if ((l->event_list[(uint8_t) event->event_id])) {
+ } else if ((l->event_list[event->event_id])) {
if (event->event_id != SWITCH_EVENT_CUSTOM || (event->subclass && switch_core_hash_find(l->event_hash, event->subclass->name))) {
send = 1;
}
+ } else {
+ int x;
+ for(x = 0; x <= SWITCH_EVENT_ALL; x++) {
+ printf("%d ", l->event_list[x]);
+ }
}
if (send && switch_test_flag(l, LFLAG_MYEVENTS)) {
char *uuid = switch_event_get_header(event, "unique-id");
if (!uuid || strcmp(uuid, switch_core_session_get_uuid(l->session))) {
- send = 1;
+ send = 0;
}
}
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Fri Jun 8 13:07:48 2007
@@ -2114,7 +2114,9 @@
{"dialplan", PROFILE_DIALPLAN, JSPROP_READONLY | JSPROP_PERMANENT},
{"caller_id_name", PROFILE_CID_NAME, JSPROP_READONLY | JSPROP_PERMANENT},
{"caller_id_num", PROFILE_CID_NUM, JSPROP_READONLY | JSPROP_PERMANENT},
+ {"caller_id_number", PROFILE_CID_NUM, JSPROP_READONLY | JSPROP_PERMANENT},
{"network_addr", PROFILE_IP, JSPROP_READONLY | JSPROP_PERMANENT},
+ {"network_address", PROFILE_IP, JSPROP_READONLY | JSPROP_PERMANENT},
{"ani", PROFILE_ANI, JSPROP_READONLY | JSPROP_PERMANENT},
{"aniii", PROFILE_ANI_II, JSPROP_READONLY | JSPROP_PERMANENT},
{"destination", PROFILE_DEST, JSPROP_READONLY | JSPROP_PERMANENT},
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c Fri Jun 8 13:07:48 2007
@@ -128,7 +128,7 @@
if (file) {
snprintf(buf, B64BUFFLEN, "\n\n--%s\nContent-Type: application/octet-stream\n"
"Content-Transfer-Encoding: base64\n"
- "Content-Description: Sound attachment.\n" "Content-Disposition: attachment; filename=\"%s\"\n\n", bound, file);
+ "Content-Description: Sound attachment.\n" "Content-Disposition: attachment; filename=\"%s\"\n\n", bound, (argc > 5) ? JS_GetStringBytes(JS_ValueToString(cx,argv[5])) : switch_cut_path(file));
if (!write_buf(fd, buf))
return JS_FALSE;
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c Fri Jun 8 13:07:48 2007
@@ -52,6 +52,7 @@
goto err;
}
+ memset(new_obj, 0, sizeof(odbc_obj_t));
if (!(new_obj->handle = switch_odbc_handle_new(dsn, username, password))) {
goto err;
}
@@ -79,12 +80,12 @@
{
odbc_obj_t *obj = *objp;
- if (obj->handle) {
- switch_odbc_handle_destroy(&obj->handle);
- }
if (obj->stmt) {
SQLFreeHandle(SQL_HANDLE_STMT, obj->stmt);
}
+ if (obj->handle) {
+ switch_odbc_handle_destroy(&obj->handle);
+ }
switch_safe_free(obj->colbuf);
switch_safe_free(obj->code);
switch_safe_free(obj);
@@ -180,6 +181,40 @@
return JS_TRUE;
}
+static JSBool odbc_execute(JSContext * cx, JSObject * obj, uintN argc, jsval *argv, jsval *rval)
+{
+ odbc_obj_t *odbc_obj = (odbc_obj_t *) JS_GetPrivate(cx, obj);
+ char *sql;
+ JSBool tf = JS_FALSE;
+ SQLHSTMT stmt;
+
+ if (argc < 1) {
+ goto done;
+ }
+
+ if (switch_odbc_handle_get_state(odbc_obj->handle) != SWITCH_ODBC_STATE_CONNECTED) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database is not connected!\n");
+ goto done;
+ }
+
+ sql = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+
+ if (switch_odbc_handle_exec(odbc_obj->handle, sql, &stmt) != SWITCH_ODBC_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[ODBC] Execute failed for: %s\n", sql);
+ goto done;
+ }
+
+ SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+
+ tf = JS_TRUE;
+
+ done:
+
+ *rval = BOOLEAN_TO_JSVAL(tf);
+
+ return JS_TRUE;
+}
+
static JSBool odbc_exec(JSContext * cx, JSObject * obj, uintN argc, jsval *argv, jsval *rval)
{
odbc_obj_t *odbc_obj = (odbc_obj_t *) JS_GetPrivate(cx, obj);
@@ -202,8 +237,8 @@
sql = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
-
if (switch_odbc_handle_exec(odbc_obj->handle, sql, &odbc_obj->stmt) != SWITCH_ODBC_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[ODBC] query failed: %s\n", sql);
goto done;
}
@@ -265,7 +300,7 @@
return JS_TRUE;
}
-static char *escape_data(char *in)
+static char *escape_data(char *in, char escapeChar)
{
switch_size_t nlen = strlen(in);
uint32_t qc = 0;
@@ -275,6 +310,9 @@
if (*p == '"') {
qc += 2;
}
+ if (*p == '\'') {
+ qc += 2;
+ }
}
nlen += qc + 1;
@@ -287,7 +325,10 @@
qc = 0;
for (p = in; p && *p; p++) {
if (*p == '"') {
- *r++ = '\\';
+ *r++ = escapeChar;
+ }
+ if (*p == '\'') {
+ *r++ = escapeChar;
}
*r++ = *p;
if (++qc > nlen) {
@@ -338,7 +379,7 @@
SQLGetData(odbc_obj->stmt, x, SQL_C_CHAR, odbc_obj->colbuf, odbc_obj->cblen, NULL);
if (strchr((char *) odbc_obj->colbuf, '"')) { /* please don't */
- esc = (SQLCHAR *) escape_data((char *) odbc_obj->colbuf);
+ esc = (SQLCHAR *) escape_data((char *) odbc_obj->colbuf, '\\');
data = esc;
}
@@ -373,6 +414,8 @@
static JSFunctionSpec odbc_methods[] = {
{"connect", odbc_connect, 1},
{"exec", odbc_exec, 1},
+ {"query", odbc_exec, 1},
+ {"execute", odbc_execute, 1},
{"numRows", odbc_num_rows, 1},
{"nextRow", odbc_next_row, 1},
{"getData", odbc_get_data, 1},
Modified: freeswitch/branches/greenlizard/src/switch_caller.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_caller.c (original)
+++ freeswitch/branches/greenlizard/src/switch_caller.c Fri Jun 8 13:07:48 2007
@@ -51,17 +51,17 @@
if (!context) {
context = "default";
}
- profile->username = switch_core_strdup(pool, switch_str_nil(username));
- profile->dialplan = switch_core_strdup(pool, switch_str_nil(dialplan));
- profile->caller_id_name = switch_core_strdup(pool, switch_str_nil(caller_id_name));
- profile->caller_id_number = switch_core_strdup(pool, switch_str_nil(caller_id_number));
- profile->network_addr = switch_core_strdup(pool, switch_str_nil(network_addr));
- profile->ani = switch_core_strdup(pool, switch_str_nil(ani));
- profile->aniii = switch_core_strdup(pool, switch_str_nil(aniii));
- profile->rdnis = switch_core_strdup(pool, switch_str_nil(rdnis));
- profile->source = switch_core_strdup(pool, switch_str_nil(source));
- profile->context = switch_core_strdup(pool, switch_str_nil(context));
- profile->destination_number = switch_core_strdup(pool, switch_str_nil(destination_number));
+ profile->username = switch_clean_string(switch_core_strdup(pool, switch_str_nil(username)));
+ profile->dialplan = switch_clean_string(switch_core_strdup(pool, switch_str_nil(dialplan)));
+ profile->caller_id_name = switch_clean_string(switch_core_strdup(pool, switch_str_nil(caller_id_name)));
+ profile->caller_id_number = switch_clean_string(switch_core_strdup(pool, switch_str_nil(caller_id_number)));
+ profile->network_addr = switch_clean_string(switch_core_strdup(pool, switch_str_nil(network_addr)));
+ profile->ani = switch_clean_string(switch_core_strdup(pool, switch_str_nil(ani)));
+ profile->aniii = switch_clean_string(switch_core_strdup(pool, switch_str_nil(aniii)));
+ profile->rdnis = switch_clean_string(switch_core_strdup(pool, switch_str_nil(rdnis)));
+ profile->source = switch_clean_string(switch_core_strdup(pool, switch_str_nil(source)));
+ profile->context = switch_clean_string(switch_core_strdup(pool, switch_str_nil(context)));
+ profile->destination_number = switch_clean_string(switch_core_strdup(pool, switch_str_nil(destination_number)));
switch_set_flag(profile, SWITCH_CPF_SCREEN);
}
Modified: freeswitch/branches/greenlizard/src/switch_channel.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_channel.c (original)
+++ freeswitch/branches/greenlizard/src/switch_channel.c Fri Jun 8 13:07:48 2007
@@ -389,7 +389,7 @@
switch_mutex_lock(channel->profile_mutex);
switch_core_hash_delete(channel->variables, varname);
if (!switch_strlen_zero(value)) {
- switch_core_hash_insert_dup(channel->variables, varname, switch_core_session_strdup(channel->session, value));
+ switch_core_hash_insert_dup(channel->variables, varname, switch_clean_string(switch_core_session_strdup(channel->session, value)));
} else {
switch_core_hash_delete(channel->variables, varname);
}
Modified: freeswitch/branches/greenlizard/src/switch_core_sqldb.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_sqldb.c (original)
+++ freeswitch/branches/greenlizard/src/switch_core_sqldb.c Fri Jun 8 13:07:48 2007
@@ -64,9 +64,10 @@
if (errmsg) {
begin_retries--;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg);
if (strstr(errmsg, "cannot start a transaction within a transaction")) {
again = 1;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL Retry [%s]\n", errmsg);
}
switch_core_db_free(errmsg);
Modified: freeswitch/branches/greenlizard/src/switch_cpp.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_cpp.cpp (original)
+++ freeswitch/branches/greenlizard/src/switch_cpp.cpp Fri Jun 8 13:07:48 2007
@@ -6,6 +6,7 @@
#endif
#define sanity_check(x) do { if (!session) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0)
+#define sanity_check_noreturn do { if (!session) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return;}} while(0)
#define init_vars() do { session = NULL; channel = NULL; uuid = NULL; tts_name = NULL; voice_name = NULL; memset(&args, 0, sizeof(args)); ap = NULL;} while(0)
CoreSession::CoreSession(char *nuuid)
@@ -17,12 +18,12 @@
}
}
-CoreSession::CoreSession(switch_core_session_t *session_p)
+CoreSession::CoreSession(switch_core_session_t *new_session)
{
init_vars();
- channel = switch_core_session_get_channel(session_p);
- switch_core_session_read_lock(session_p);
- this->session = session_p;
+ session = new_session;
+ channel = switch_core_session_get_channel(session);
+ switch_core_session_read_lock(session);
}
CoreSession::~CoreSession()
@@ -56,13 +57,13 @@
void CoreSession::hangup(char *cause)
{
- sanity_check();
+ sanity_check_noreturn;
switch_channel_hangup(channel, switch_channel_str2cause(cause));
}
void CoreSession::setVariable(char *var, char *val)
{
- sanity_check();
+ sanity_check_noreturn;
switch_channel_set_variable(channel, var, val);
}
@@ -75,7 +76,7 @@
void CoreSession::execute(char *app, char *data)
{
const switch_application_interface_t *application_interface;
- sanity_check();
+ sanity_check_noreturn;
if ((application_interface = switch_loadable_module_get_application_interface(app))) {
begin_allow_threads();
@@ -104,7 +105,7 @@
void *buf,
uint32_t buflen)
{
- sanity_check();
+ sanity_check_noreturn;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "CoreSession::setDTMFCallback.");
if (cb) {
args.buf = buf;
@@ -133,7 +134,7 @@
void CoreSession::set_tts_parms(char *tts_name_p, char *voice_name_p)
{
- sanity_check();
+ sanity_check_noreturn;
switch_safe_free(tts_name);
switch_safe_free(voice_name);
tts_name = strdup(tts_name_p);
Modified: freeswitch/branches/greenlizard/src/switch_event.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_event.c (original)
+++ freeswitch/branches/greenlizard/src/switch_event.c Fri Jun 8 13:07:48 2007
@@ -133,6 +133,7 @@
"CODEC",
"BACKGROUND_JOB",
"DETECTED_SPEECH",
+ "DETECTED_FAX",
"PRIVATE_COMMAND",
"HEARTBEAT",
"TRAP",
Modified: freeswitch/branches/greenlizard/src/switch_odbc.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_odbc.c (original)
+++ freeswitch/branches/greenlizard/src/switch_odbc.c Fri Jun 8 13:07:48 2007
@@ -38,6 +38,8 @@
SQLHENV env;
SQLHDBC con;
switch_odbc_state_t state;
+ char odbc_driver[256];
+ BOOL is_firebird;
};
@@ -110,6 +112,8 @@
SQLINTEGER err;
int16_t mlen;
unsigned char msg[200], stat[10];
+ SQLSMALLINT valueLength = 0;
+ int i = 0;
if (handle->env == SQL_NULL_HANDLE) {
result = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &handle->env);
@@ -156,13 +160,25 @@
}
SQLFreeHandle(SQL_HANDLE_ENV, handle->env);
return SWITCH_ODBC_FAIL;
- } else {
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connected to [%s]\n", handle->dsn);
- handle->state = SWITCH_ODBC_STATE_CONNECTED;
- return SWITCH_ODBC_SUCCESS;
+ result = SQLGetInfo(handle->con, SQL_DRIVER_NAME, (SQLCHAR*)handle->odbc_driver, 255, &valueLength);
+ if ( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO)
+ {
+ for (i = 0; i < valueLength; ++i)
+ handle->odbc_driver[i] = (char)toupper(handle->odbc_driver[i]);
}
+ //Firebird do not support "SELECT 1"
+ if (strstr(handle->odbc_driver, "FIREBIRD") != 0 || strstr(handle->odbc_driver, "FB32") != 0 || strstr(handle->odbc_driver, "FB64") != 0)
+ handle->is_firebird = TRUE;
+ else
+ handle->is_firebird = FALSE;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connected to [%s]\n", handle->dsn);
+ handle->state = SWITCH_ODBC_STATE_CONNECTED;
+ return SWITCH_ODBC_SUCCESS;
+
}
static int db_is_up(switch_odbc_handle_t *handle)
@@ -172,9 +188,16 @@
SQLINTEGER m = 0;
int result;
switch_event_t *event;
- switch_odbc_status_t recon;
+ switch_odbc_status_t recon = 0;
char *err_str = NULL;
- SQLCHAR sql[] = "select 1";
+ SQLCHAR sql[255];
+
+ //Firebird do not support "SELECT 1"
+ sql[0] = 0;
+ if (handle->is_firebird)
+ strcpy((char*)sql, "select first 1 * from RDB$RELATIONS");
+ else
+ strcpy((char*)sql, "select 1");
if (!handle) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "No DB Handle\n");
@@ -197,10 +220,15 @@
goto done;
error:
-
- recon = switch_odbc_handle_connect(handle);
err_str = switch_odbc_handle_get_error(handle, stmt);
+ // No need to reconnect if we can get the string anyway.
+ if (err_str == 0)
+ {
+ recon = switch_odbc_handle_connect(handle);
+ err_str = switch_odbc_handle_get_error(handle, stmt);
+ }
+
if (switch_event_create(&event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Failure-Message", "The sql server is not responding for DSN %s [%s]",
switch_str_nil(handle->dsn), switch_str_nil(err_str));
Modified: freeswitch/branches/greenlizard/src/switch_xml.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_xml.c (original)
+++ freeswitch/branches/greenlizard/src/switch_xml.c Fri Jun 8 13:07:48 2007
@@ -60,6 +60,9 @@
#ifdef HAVE_MMAP
#include <sys/mman.h>
+#ifdef __sun
+extern int madvise(caddr_t, size_t, int);
+#endif
#endif
#define SWITCH_XML_WS "\t\r\n " // whitespace
More information about the Freeswitch-svn
mailing list