Revision
16690
Author
gmaruzz
Date
2010-02-18 10:24:07 -0600 (Thu, 18 Feb 2010)

Log Message

skypiax: MODSKYPIAX-66 added channel variable 'skype_get_inband_dtmf', you set it to 'true' if you want to mod_skypiax to detect inband DTMFs coming from skype, eg: skypein/skypeout calls

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/Makefile.am (16689 => 16690)


--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/Makefile.am	2010-02-18 16:01:07 UTC (rev 16689)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/Makefile.am	2010-02-18 16:24:07 UTC (rev 16690)
@@ -2,6 +2,6 @@
 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

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (16689 => 16690)


--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	2010-02-18 16:01:07 UTC (rev 16689)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	2010-02-18 16:24:07 UTC (rev 16690)
@@ -276,6 +276,10 @@
 	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,7 +680,13 @@
 	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 @@
 				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);

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h (16689 => 16690)


--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h	2010-02-18 16:01:07 UTC (rev 16689)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h	2010-02-18 16:24:07 UTC (rev 16690)
@@ -43,6 +43,11 @@
 #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 @@
 	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;