]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
skypiax: MODSKYPIAX-66 added channel variable 'skype_get_inband_dtmf', you set it...
authorGiovanni Maruzzelli <gmaruzz@gmail.com>
Thu, 18 Feb 2010 16:24:07 +0000 (16:24 +0000)
committerGiovanni Maruzzelli <gmaruzz@gmail.com>
Thu, 18 Feb 2010 16:24:07 +0000 (16:24 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16690 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_skypiax/Makefile.am
src/mod/endpoints/mod_skypiax/mod_skypiax.c
src/mod/endpoints/mod_skypiax/skypiax.h

index 017576fc5c209fa1c60e3af6fde3e014e4305bf0..b068add211992d3a2b6a40a50031ad7d65ec7c84 100644 (file)
@@ -2,6 +2,6 @@ include $(top_srcdir)/build/modmake.rulesam
 MODNAME=mod_skypiax
 mod_LTLIBRARIES = mod_skypiax.la
 mod_skypiax_la_SOURCES  = mod_skypiax.c skypiax_protocol.c
-mod_skypiax_la_CFLAGS   = $(AM_CFLAGS) -DSKYPIAX_SVN_VERSION=\"`cat $(switch_builddir)/.version`\"
+mod_skypiax_la_CFLAGS   = $(AM_CFLAGS) -DSKYPIAX_SVN_VERSION=\"`cat $(switch_builddir)/.version`\" -I../../../../libs/spandsp/src -I../../../..//libs/tiff-3.8.2/libtiff
 mod_skypiax_la_LIBADD   = $(switch_builddir)/libfreeswitch.la
-mod_skypiax_la_LDFLAGS  = -avoid-version -module -no-undefined -shared -lX11
+mod_skypiax_la_LDFLAGS  = -L../../../../libs/spandsp/src -avoid-version -module -no-undefined -shared -lX11 -lspandsp
index 8c24479ded64584cbae623e9e3d0bf6b941d5350..393e2ef359235fdf242de01edccbe9a175233d33 100644 (file)
@@ -276,6 +276,10 @@ switch_status_t skypiax_tech_init(private_t * tech_pvt, switch_core_session_t *s
        switch_core_timer_sync(&tech_pvt->timer_write);
 #endif // TIMER_WRITE
 
+    dtmf_rx_init(&tech_pvt->dtmf_state, NULL, NULL);
+    dtmf_rx_parms(&tech_pvt->dtmf_state, 0, 10, 10, -99);
+
+
        DEBUGA_SKYPE("skypiax_tech_init SUCCESS\n", SKYPIAX_P_LOG);
        return SWITCH_STATUS_SUCCESS;
 }
@@ -676,6 +680,12 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
        switch_channel_t *channel = NULL;
        private_t *tech_pvt = NULL;
        switch_byte_t *data;
+        char digit_str[256];
+       short *frame_16_khz;
+       short frame_8_khz[160]; 
+       int i;
+       int a;
+
 
        channel = switch_core_session_get_channel(session);
        switch_assert(channel != NULL);
@@ -722,6 +732,50 @@ tech_pvt->begin_to_read=1;
                                continue;
                        }
                        *frame = &tech_pvt->read_frame;
+
+
+                       if (switch_true(switch_channel_get_variable(channel, "skype_get_inband_dtmf"))) {
+
+                               frame_16_khz = tech_pvt->read_frame.data;
+
+                               a = 0;
+                               for (i = 0; i < tech_pvt->read_frame.datalen / sizeof(short); i++) {
+                                       frame_8_khz[a] = frame_16_khz[i];
+                                       i++;
+                                       a++;
+                               }
+                               //DEBUGA_SKYPE("a=%d i=%d\n", SKYPIAX_P_LOG, a, i);
+
+                               memset(digit_str, 0, sizeof(digit_str));
+                               //dtmf_rx(&tech_pvt->dtmf_state, (int16_t *) tech_pvt->read_frame.data,tech_pvt->read_frame.datalen/sizeof(short) );
+                               dtmf_rx(&tech_pvt->dtmf_state, (int16_t *) frame_8_khz, 160);
+                               dtmf_rx_get(&tech_pvt->dtmf_state, digit_str, sizeof(digit_str));
+
+
+                               if (digit_str[0]) {
+                                       switch_time_t new_dtmf_timestamp = switch_time_now();
+                                       if ((new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp) > 350000) {     //FIXME: make it configurable
+                                               char *p = digit_str;
+                                               switch_channel_t *channel = switch_core_session_get_channel(session);
+
+                                               while (p && *p) {
+                                                       switch_dtmf_t dtmf;
+                                                       dtmf.digit = *p;
+                                                       dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
+                                                       switch_channel_queue_dtmf(channel, &dtmf);
+                                                       p++;
+                                               }
+                                               NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPIAX_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp,
+                                                               (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
+                                               tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
+                                       }
+                               }
+                       }
+
+
+
+
+
 #if SWITCH_BYTE_ORDER == __BIG_ENDIAN
                        if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
                                switch_swap_linear((*frame)->data, (int) (*frame)->datalen / 2);
index fc70c7a3ee59207dc0880096794f73ae02972d75..f367a2fab2c91b4072e6ccdcaffbb4febd8d9138 100644 (file)
 #include <X11/Xatom.h>
 #endif //WIN32
 
+#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
+#include <spandsp.h>
+#include <spandsp/version.h>
+
+
 #ifdef _MSC_VER
 //Windows macro  for FD_SET includes a warning C4127: conditional expression is constant
 #pragma warning(push)
@@ -281,6 +286,9 @@ struct private_object {
        switch_timer_t timer_write;
 int begin_to_write;
 int begin_to_read;
+                 dtmf_rx_state_t dtmf_state;
+        switch_time_t old_dtmf_timestamp;
+
 };
 
 typedef struct private_object private_t;