[svn-commits] jdixon: branch jdixon/chan_usbradio-1.4 r139340 - /team/jdixon/chan_usbradio-...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Aug 21 17:01:40 CDT 2008


Author: jdixon
Date: Thu Aug 21 17:01:40 2008
New Revision: 139340

URL: http://svn.digium.com/view/asterisk?view=rev&rev=139340
Log:
New version with inbound connections working pretty much entirely

Modified:
    team/jdixon/chan_usbradio-1.4/dev-1.0/channels/chan_echolink.c

Modified: team/jdixon/chan_usbradio-1.4/dev-1.0/channels/chan_echolink.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/dev-1.0/channels/chan_echolink.c?view=diff&rev=139340&r1=139339&r2=139340
==============================================================================
--- team/jdixon/chan_usbradio-1.4/dev-1.0/channels/chan_echolink.c (original)
+++ team/jdixon/chan_usbradio-1.4/dev-1.0/channels/chan_echolink.c Thu Aug 21 17:01:40 2008
@@ -31,9 +31,9 @@
 /*** MODULEINFO
  ***/
 
-/* Version 0.3, 08/20/2008
+/* Version 0.4, 08/21/2008
 Echolink channel driver for Asterisk/app_rpt.
-This is a third attempt.
+This is a second attempt.
 A lot more has to be added,
 Here is what comes to mind first:
 
@@ -108,6 +108,8 @@
 #include "asterisk/options.h"
 #include "asterisk/utils.h"
 #include "asterisk/app.h"
+#include "asterisk/dsp.h"
+#include "asterisk/translate.h"
 
 #define	MAX_RXKEY_TIME 4
 
@@ -239,7 +241,9 @@
 	struct el_rxqast rxqast;
         struct el_rxqel rxqel;
 	char firstsent;
+	struct ast_dsp *dsp;
 	struct ast_module_user *u;
+	struct ast_trans_pvt *xpath;
 };
 
 struct rtcp_sdes_request_item {
@@ -385,6 +389,13 @@
     *ap++ = l = strlen(line);
     memcpy(ap,line,l); 
     ap += l;
+
+    /* enable DTMF keypad */
+    *ap++ = 8;
+    *ap++ = 3;
+    *ap++ = 1;
+    *ap++ = 'D';
+    *ap++ = '1';
 
     *ap++ = 0;
     *ap++ = 0;
@@ -567,6 +578,8 @@
 
 static void el_destroy(struct el_pvt *p)
 {
+	if (p->dsp) ast_dsp_free(p->dsp);
+	if (p->xpath) ast_translator_free_path(p->xpath);
 	ast_module_user_remove(p->u);
 	ast_free(p);
 }
@@ -604,8 +617,31 @@
                 p->rxqel.qe_forw = &p->rxqel;
                 p->rxqel.qe_back = &p->rxqel;
                 
+		p->keepalive = KEEPALIVE_TIME;
 		p->instp = instances[n];
 		p->instp->confp = p;  /* save for conference mode */
+		if (!p->instp->confmode)
+		{
+			p->dsp = ast_dsp_new();
+			if (!p->dsp)
+			{
+				ast_log(LOG_ERROR,"Cannot get DSP!!\n");
+				return NULL;
+			}
+#ifdef  NEW_ASTERISK
+	                ast_dsp_set_features(p->dsp,DSP_FEATURE_DIGIT_DETECT);
+	                ast_dsp_set_digitmode(p->dsp,DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_RELAXDTMF);
+#else
+	                ast_dsp_set_features(p->dsp,DSP_FEATURE_DTMF_DETECT);
+	                ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_RELAXDTMF);
+#endif
+			p->xpath = ast_translator_build_path(AST_FORMAT_SLINEAR,AST_FORMAT_GSM);
+			if (!p->xpath)
+			{
+				ast_log(LOG_ERROR,"Cannot get translator!!\n");
+				return NULL;
+			}
+		}
 	}
 	return p;
 }
@@ -795,6 +831,7 @@
    struct el_instance *instp = (*(struct el_node **)nodep)->instp;
 
    if ((which == leaf) || (which == postorder)) {
+
       if ((*(struct el_node **)nodep)->countdown >= 0)
          (*(struct el_node **)nodep)->countdown --;
   
@@ -803,6 +840,7 @@
          strncpy(instp->el_node_test.call,(*(struct el_node **)nodep)->call,EL_CALL_SIZE);
          ast_log(LOG_NOTICE,"countdown for %s(%s) negative\n",instp->el_node_test.call,instp->el_node_test.ip);
       }
+      memset(sdes_packet,0,sizeof(sdes_packet));
       sdes_length = rtcp_make_sdes(sdes_packet,sizeof(sdes_packet),
 	instp->mycall,instp->myname);
 
@@ -952,11 +990,10 @@
         struct sockaddr_in sin;
 	struct el_pvt *p = ast->tech_pvt;
 	struct el_instance *instp = p->instp;
-	struct ast_frame fr;
+	struct ast_frame fr,*f1, *f2;
 	struct el_rxqast *qpast;
-	int n;
+	int n,m,x;
         struct el_rxqel *qpel;
-        int m;
 	char buf[GSM_FRAME_SIZE + AST_FRIENDLY_OFFSET];
 
 	if (ast->_state != AST_STATE_UP) {
@@ -1013,7 +1050,27 @@
 			fr.mallocd=0;
 			fr.delivery.tv_sec = 0;
 			fr.delivery.tv_usec = 0;
-			ast_queue_frame(ast,&fr);
+
+			x = 0;
+			if (p->dsp && (!instp->confmode))
+			{
+				f2 = ast_translate(p->xpath,&fr,0);
+				f1 = ast_dsp_process(NULL,p->dsp,f2);
+				ast_frfree(f2);
+				if ((f1->frametype == AST_FRAME_DTMF_END) ||
+					(f1->frametype == AST_FRAME_DTMF_BEGIN))
+				{
+					if ((f1->subclass != 'm') && (f1->subclass != 'u'))
+					{
+						if (f1->frametype == AST_FRAME_DTMF_END)
+							ast_log(LOG_NOTICE,"Echolink %s Got DTMF char %c from IP %s\n",p->stream,f1->subclass,p->ip);
+						ast_queue_frame(ast,f1);
+						x = 1;
+					}
+				}
+				ast_frfree(f1);
+			} 
+			if (!x) ast_queue_frame(ast,&fr);
 		}
 	}
 	if (p->rxkey == 1) {
@@ -1054,7 +1111,6 @@
               strncpy(instp->el_node_test.ip, qpel->fromip, EL_IP_SIZE);
 
               ast_free(qpel);
-              p->keepalive = KEEPALIVE_TIME;
               twalk(el_node_list, send_audio_all_but_one);
 
               if (instp->fdr >= 0)
@@ -1069,7 +1125,6 @@
                 return 0;
            }
            if (p->txkey || p->txindex)  {
-                p->keepalive = KEEPALIVE_TIME;
                 memcpy(instp->audio_all.data + (GSM_FRAME_SIZE * p->txindex++), frame->data,GSM_FRAME_SIZE);
            }      
            if (p->txindex >= BLOCKING_FACTOR) {
@@ -1086,7 +1141,6 @@
            }
         }
 
-	if (p->txkey) return 0;
 	if (p->keepalive--) return 0;
 	p->keepalive = KEEPALIVE_TIME;
 




More information about the svn-commits mailing list