[svn-commits] oej: branch oej/tdd-sip r90048 - /team/oej/tdd-sip/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Nov 28 15:22:12 CST 2007


Author: oej
Date: Wed Nov 28 15:22:12 2007
New Revision: 90048

URL: http://svn.digium.com/view/asterisk?view=rev&rev=90048
Log:
Formatting...

TODO:
        We need to create a structure with the TDD stuff and malloc that
        structure when needed. We can't continue to expand the SIP_PVT with
        new variables for every possible scenario out there.

	Look at how we handle REFER. We need to do the same with 
	things like session timers and subscriptions too, things that
	are not needed in each and every in-memory instance of the
	sip_pvt.

Modified:
    team/oej/tdd-sip/channels/chan_sip.c

Modified: team/oej/tdd-sip/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/tdd-sip/channels/chan_sip.c?view=diff&rev=90048&r1=90047&r2=90048
==============================================================================
--- team/oej/tdd-sip/channels/chan_sip.c (original)
+++ team/oej/tdd-sip/channels/chan_sip.c Wed Nov 28 15:22:12 2007
@@ -1,3 +1,8 @@
+/* TODO:
+	We need to create a structure with the TDD stuff and malloc that
+	structure when needed. We can't continue to expand the SIP_PVT with
+	new variables for every possible scenario out there.
+*/
 /*
  * Asterisk -- An open source telephony toolkit.
  *
@@ -19303,35 +19308,37 @@
 	return CLI_SUCCESS;
 }
 
+/*! \brief Callback for TDD phone communication */
 int tty_write_cb(void* data) {
-	struct sip_pvt *p=(struct sip_pvt*)data;
-	int ttysamples=176, packetsamples=160;
-// 1.6 kbytes for 200ms ulaw audio
+	struct sip_pvt *p= (struct sip_pvt*) data;
+	int ttysamples = 176, packetsamples = 160;
+
+/* 1.6 kbytes for 200ms ulaw audio */
 #define HOLDTONELEN 1600
 	int tonebufcharend = p->ttytonebufend;
 
 	if(p->ttyhasholdtone==1)
 		tonebufcharend -= HOLDTONELEN;
 	if(tonebufcharend<0)
-		tonebufcharend=0;
+		tonebufcharend = 0;
 	if (tonebufcharend <= ttysamples ) {
 		if (p->ttycharbuflen > 0) {
 			char texttogen[2];
 
-			texttogen[0]=p->ttycharbuf[0];
-			texttogen[1]='\0';
+			texttogen[0] = p->ttycharbuf[0];
+			texttogen[1] ='\0';
 			int len = tdd_generate(p->tdd, p->ttytonebuf+tonebufcharend+1, texttogen);
 			if (len < 1)
-				ast_log(LOG_DEBUG,"tdd_generate failed!\n");
+				ast_debug(3,"tdd_generate failed!\n");
 			tonebufcharend += len;
 			p->ttytonebufend = tonebufcharend;
 			p->ttycharbuflen -= 1;
-			memmove(p->ttycharbuf,p->ttycharbuf+1,p->ttycharbuflen);
-			ast_log(LOG_DEBUG,"tty text send callback. charbuf:%s\ncharbuf size:%d, tonebuf size:%d\n",p->ttycharbuf,p->ttycharbuflen,p->ttytonebufend);
+			memmove(p->ttycharbuf, p->ttycharbuf+1, p->ttycharbuflen);
+			ast_debug(3, "tty text send callback. charbuf:%s\ncharbuf size:%d, tonebuf size:%d\n", p->ttycharbuf, p->ttycharbuflen, p->ttytonebufend);
 			p->ttyhasholdtone=0;
 			
 			if (p->ttycharbuflen == 0) {
-				// Put in hold tone
+				/* Put in hold tone */
 				tdd_gen_holdtone(p->ttytonebuf + tonebufcharend);
 				p->ttytonebufend += HOLDTONELEN;
 				p->ttyhasholdtone = 1;
@@ -19355,9 +19362,10 @@
 				.samples = readsize,
 			};
 			ast_rtp_write(p->rtp,&wf);
-			memmove(p->ttytonebuf,p->ttytonebuf+readsize,p->ttytonebufend - readsize);
+			memmove(p->ttytonebuf, p->ttytonebuf + readsize, p->ttytonebufend - readsize);
 			p->ttytonebufend -= readsize;
-			if(p->ttytonebufend==0) ast_log(LOG_DEBUG,"Tone buffer empty!");
+			if(p->ttytonebufend==0)
+				ast_debug(3,"Tone buffer empty!");
 		}
 	}
 	return 1;
@@ -19376,16 +19384,16 @@
 		return -1;
 	}
 
-	if (option==AST_OPTION_TDD) {
+	if (option == AST_OPTION_TDD) {
 
 		cp = (char *) data;
 		if (!*cp) { /* turn it off */
-			ast_debug(1, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name);
+			ast_debug(1, "Set option TDD MODE, value: OFF(0) on %s\n", chan->name);
 			if (p->tdd)
 				tdd_free(p->tdd);
 			p->tdd = 0;
-			p->didtdd=0;
-			memset( p->ttycharbuf,'\0',TTYCHARBUFLENGTH-1);
+			p->didtdd = 0;
+			memset(p->ttycharbuf, '\0', TTYCHARBUFLENGTH-1);
 
 			return 0;
 		}
@@ -19393,20 +19401,19 @@
 		ast_debug(1, "Set option TDD MODE, value: ON on %s\n", chan->name);
 				
 		/* Add T140 to channel's format list */
-		if(p->owner) {
+		if(p->owner) 
 		        p->owner->nativeformats |= AST_FORMAT_T140;
-		}
 		
 		/* turn it on */
 		if (!p->didtdd) { /* if havent done it yet */
-			p->didtdd=1;
+			p->didtdd = 1;
 			
-			p->ttytonebuf=ast_malloc(1024*TDD_BYTES_PER_CHAR);
-			p->ttytonebufend=0;
+			p->ttytonebuf = ast_malloc(1024*TDD_BYTES_PER_CHAR);
+			p->ttytonebufend = 0;
 			memset(p->ttycharbuf,'\0',TTYCHARBUFLENGTH-1);
-			p->ttycharbuf[0]='\0';
-			p->ttyhasholdtone=0;
-			p->vcoMode=0;
+			p->ttycharbuf[0] = '\0';
+			p->ttyhasholdtone = 0;
+			p->vcoMode = 0;
 
 !!! Fix this ugly thing...
 			ast_sched_add(sched, 20, tty_write_cb, p);




More information about the svn-commits mailing list