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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Nov 16 18:55:30 CST 2008


Author: jdixon
Date: Sun Nov 16 18:55:30 2008
New Revision: 157233

URL: http://svn.digium.com/view/asterisk?view=rev&rev=157233
Log:
Added support for UNCOMP IRLP and level adjustment

Modified:
    team/jdixon/chan_usbradio-1.4/dev-temp/app_rpt.c

Modified: team/jdixon/chan_usbradio-1.4/dev-temp/app_rpt.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/dev-temp/app_rpt.c?view=diff&rev=157233&r1=157232&r2=157233
==============================================================================
--- team/jdixon/chan_usbradio-1.4/dev-temp/app_rpt.c (original)
+++ team/jdixon/chan_usbradio-1.4/dev-temp/app_rpt.c Sun Nov 16 18:55:30 2008
@@ -1,5 +1,7 @@
 /* #define	NEW_ASTERISK */
 /* #define OLD_ASTERISK */
+
+#define	rpt_free(p) __ast_free(p,__FILE__,__LINE__,__PRETTY_FUNCTION__)
 
 /*
  * Asterisk -- An open source telephony toolkit.
@@ -22,7 +24,7 @@
 /*! \file
  *
  * \brief Radio Repeater / Remote Base program 
- *  version 0.169 11/14/08 
+ *  version 0.170 11/16/08 
  * 
  * \author Jim Dixon, WB6NIL <jim at lambdatel.com>
  *
@@ -408,7 +410,7 @@
 /*! Stop the tones from playing */
 void ast_playtones_stop(struct ast_channel *chan);
 
-static  char *tdesc = "Radio Repeater / Remote Base  version 0.169  11/14/2008";
+static  char *tdesc = "Radio Repeater / Remote Base  version 0.170  11/16/2008";
 
 static char *app = "Rpt";
 
@@ -2167,8 +2169,8 @@
 		perror("asterisk");
 		exit(0);
 	}
-	ast_free(astr);
-	ast_free(str);
+	rpt_free(astr);
+	rpt_free(str);
 	return;
 }
 
@@ -3122,14 +3124,14 @@
 			ast_cli(fd, "User linking commands............................: %s\n", link_ena);
 			ast_cli(fd, "User functions...................................: %s\n\n", user_funs);
 
-			for(j = 0; j < numoflinks; j++){ /* ast_free() all link names */
-				ast_free(listoflinks[j]);
+			for(j = 0; j < numoflinks; j++){ /* rpt_free() all link names */
+				rpt_free(listoflinks[j]);
 			}
 			if(called_number){
-				ast_free(called_number);
+				rpt_free(called_number);
 			}
 			if(lastdtmfcommand){
-				ast_free(lastdtmfcommand);
+				rpt_free(lastdtmfcommand);
 			}
 		        return RESULT_SUCCESS;
 		}
@@ -3219,7 +3221,7 @@
 				t = s;
 				s = s->next;
 				remque((struct qelem *)t);
-				ast_free(t);
+				rpt_free(t);
 			}			
 			return RESULT_SUCCESS;
 		}
@@ -3933,7 +3935,7 @@
 			break;
 	}
 	if(p)
-		ast_free(p);
+		rpt_free(p);
 	if(!res)
 		res = play_tone_pair(chan, 0, 0, 100, 0); /* This is needed to ensure the last tone segment is timed correctly */
 	
@@ -4133,7 +4135,7 @@
 		res = -1;
 	}
 	if(telemetry_save)
-		ast_free(telemetry_save);
+		rpt_free(telemetry_save);
 	return res;
 }
 
@@ -4212,7 +4214,7 @@
 			break;
         }
 	if(wait_times_save)
-       		ast_free(wait_times_save);
+       		rpt_free(wait_times_save);
 	return interval;
 }                                                                                                                  
 
@@ -4433,7 +4435,7 @@
 				}
 			}
 		}
-		ast_free(tpl_copy);
+		rpt_free(tpl_copy);
 		return;
 	}
 	if (!strcasecmp(strs[0],"LASTNODEKEY"))
@@ -4506,7 +4508,7 @@
 	    remque((struct qelem *)mytele);
 	    ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
 	    rpt_mutex_unlock(&myrpt->lock);
-	    ast_free(mytele);
+	    rpt_free(mytele);
 	    pthread_exit(NULL);
 	}
 
@@ -4520,8 +4522,8 @@
                 	ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",
 			__LINE__, mytele->mode); /*@@@@@@@@@@@*/
                 	rpt_mutex_unlock(&myrpt->lock);
-			ast_free(nodename);
-                	ast_free(mytele);
+			rpt_free(nodename);
+                	rpt_free(mytele);
                 	pthread_exit(NULL);
         	}
 		else{
@@ -4546,10 +4548,10 @@
 		remque((struct qelem *)mytele);
 		ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
 		rpt_mutex_unlock(&myrpt->lock);
-		ast_free(nodename);
+		rpt_free(nodename);
 		if(id_malloc)
-			ast_free(ident);
-		ast_free(mytele);		
+			rpt_free(ident);
+		rpt_free(mytele);		
 		pthread_exit(NULL);
 	}
 #ifdef	AST_CDR_FLAG_POST_DISABLED
@@ -4591,10 +4593,10 @@
 		remque((struct qelem *)mytele);
 		rpt_mutex_unlock(&myrpt->lock);
 		ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
-		ast_free(nodename);
+		rpt_free(nodename);
 		if(id_malloc)
-			ast_free(ident);
-		ast_free(mytele);		
+			rpt_free(ident);
+		rpt_free(mytele);		
 		ast_hangup(mychannel);
 		pthread_exit(NULL);
 	}
@@ -4735,7 +4737,7 @@
 			if(ct_copy)
 			{
 				res = telem_lookup(myrpt,mychannel, myrpt->name, ct_copy);
-				ast_free(ct_copy);
+				rpt_free(ct_copy);
 			}
 			else
 				res = -1;
@@ -4788,7 +4790,7 @@
 			if(ct_copy)
 			{
 				res = telem_lookup(myrpt,mychannel, myrpt->name, ct_copy);
-				ast_free(ct_copy);
+				rpt_free(ct_copy);
 			}
 			else
 				res = -1;
@@ -4810,10 +4812,10 @@
 				remque((struct qelem *)mytele);
 				rpt_mutex_unlock(&myrpt->lock);
 				ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
-				ast_free(nodename);
+				rpt_free(nodename);
 				if(id_malloc)
-					ast_free(ident);
-				ast_free(mytele);		
+					rpt_free(ident);
+				rpt_free(mytele);		
 				ast_hangup(mychannel);
 				pthread_exit(NULL);
 			}
@@ -4823,7 +4825,7 @@
 				if(ct_copy)
 				{
 					res = telem_lookup(myrpt,mychannel, myrpt->name, ct_copy);
-					ast_free(ct_copy);
+					rpt_free(ct_copy);
 				}
 				else
 					res = -1;
@@ -4851,10 +4853,10 @@
 				remque((struct qelem *)mytele);
 				rpt_mutex_unlock(&myrpt->lock);
 				ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
-				ast_free(nodename);
+				rpt_free(nodename);
 				if(id_malloc)
-					ast_free(ident);
-				ast_free(mytele);		
+					rpt_free(ident);
+				rpt_free(mytele);		
 				ast_hangup(mychannel);
 				pthread_exit(NULL);
 			}
@@ -4921,7 +4923,7 @@
 			ct_copy = ast_strdup(ct);
 			if(ct_copy){
 				res = telem_lookup(myrpt,mychannel, myrpt->name, ct_copy);
-				ast_free(ct_copy);
+				rpt_free(ct_copy);
 			}
 			else
 				res = -1;
@@ -5387,10 +5389,10 @@
 				myrpt->active_telem = NULL;
 				rpt_mutex_unlock(&myrpt->lock);
 				ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
-				ast_free(nodename);
+				rpt_free(nodename);
 				if(id_malloc)
-					ast_free(ident);
-				ast_free(mytele);		
+					rpt_free(ident);
+				rpt_free(mytele);		
 				ast_hangup(mychannel);
 				pthread_exit(NULL);
 			}
@@ -5445,7 +5447,7 @@
 			l1 = l;
 			l = l->next;
 			remque((struct qelem *)l1);
-			ast_free(l1);
+			rpt_free(l1);
 		}			
 		imdone = 1;
 		break;
@@ -5527,7 +5529,7 @@
 		}
 		wait_interval(myrpt, DLY_TELEM, mychannel);
 		res = saynode(myrpt,mychannel,p);
-		ast_free(p);
+		rpt_free(p);
 		imdone = 1;
 		break;		
 
@@ -5716,7 +5718,7 @@
 					}
 				}
 			}
-			ast_free(tpl_working);
+			rpt_free(tpl_working);
 		}
 	    	imdone = 1;
 		break;
@@ -5764,10 +5766,10 @@
 	remque((struct qelem *)mytele);
 	myrpt->active_telem = NULL;
 	rpt_mutex_unlock(&myrpt->lock);
-	ast_free(nodename);
+	rpt_free(nodename);
 	if(id_malloc)
-		ast_free(ident);
-	ast_free(mytele);		
+		rpt_free(ident);
+	rpt_free(mytele);		
 	ast_hangup(mychannel);
 #ifdef  APP_RPT_LOCK_DEBUG
 	{
@@ -6172,15 +6174,15 @@
 			ast_callerid_parse(instr, &name, &loc);
 			if(loc){
 				if(mychannel->cid.cid_num)
-					ast_free(mychannel->cid.cid_num);
+					rpt_free(mychannel->cid.cid_num);
 				mychannel->cid.cid_num = ast_strdup(loc);
 			}
 			if(name){
 				if(mychannel->cid.cid_name)
-					ast_free(mychannel->cid.cid_name);
+					rpt_free(mychannel->cid.cid_name);
 				mychannel->cid.cid_name = ast_strdup(name);
 			}
-			ast_free(instr);
+			rpt_free(instr);
 		}
 	}
 
@@ -6574,7 +6576,7 @@
 	tele = strchr(deststr, '/');
 	if (!tele){
 		ast_log(LOG_WARNING,"link3:Dial number (%s) must be in format tech/number\n",deststr);
-		ast_free(l);
+		rpt_free(l);
 		return -1;
 	}
 	*tele++ = 0;
@@ -6617,7 +6619,7 @@
 			ast_log(LOG_NOTICE, "rpt (remote) initiating call to %s/%s on %s\n",
 		deststr, tele, l->chan->name);
 		if(l->chan->cid.cid_num)
-			ast_free(l->chan->cid.cid_num);
+			rpt_free(l->chan->cid.cid_num);
 		l->chan->cid.cid_num = ast_strdup(myrpt->name);
 		ast_call(l->chan,tele,2000);
 	}
@@ -6632,7 +6634,7 @@
 			sprintf(str,"LINKFAIL,%s/%s",deststr,tele);
 			donodelog(myrpt,str);
 		}
-		ast_free(l);
+		rpt_free(l);
 		return -1;
 	}
 	/* allocate a pseudo-channel thru asterisk */
@@ -6640,7 +6642,7 @@
 	if (!l->pchan){
 		ast_log(LOG_WARNING,"rpt connect: Sorry unable to obtain pseudo channel\n");
 		ast_hangup(l->chan);
-		ast_free(l);
+		rpt_free(l);
 		return -1;
 	}
 	ast_set_read_format(l->pchan, AST_FORMAT_SLINEAR);
@@ -6659,7 +6661,7 @@
 		ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
 		ast_hangup(l->chan);
 		ast_hangup(l->pchan);
-		ast_free(l);
+		rpt_free(l);
 		return -1;
 	}
 	rpt_mutex_lock(&myrpt->lock);
@@ -7066,7 +7068,7 @@
 						break;
 				}
 			}
-		ast_free(lparam);
+		rpt_free(lparam);
 		}
 	}
 					
@@ -11160,7 +11162,7 @@
 					printf("loginuser %s level %s\n",myrpt->loginuser,myrpt->loginlevel);
 				rpt_telemetry(myrpt,REMLOGIN,NULL);
 			}
-			ast_free(cp);
+			rpt_free(cp);
 			return DC_COMPLETEQUIET;
 		case 100: /* RX PL Off */
 			myrpt->rxplon = 0;
@@ -11587,7 +11589,7 @@
 			ast_verbose(VERBOSE_PREFIX_3 "rpt (attempt_reconnect) initiating call to %s/%s on %s\n",
 				deststr, tele, l->chan->name);
 		if(l->chan->cid.cid_num)
-			ast_free(l->chan->cid.cid_num);
+			rpt_free(l->chan->cid.cid_num);
 		l->chan->cid.cid_num = ast_strdup(myrpt->name);
                 ast_call(l->chan,tele,999); 
 
@@ -12814,7 +12816,7 @@
 				/* hang-up on call to device */
 				if (l->chan) ast_hangup(l->chan);
 				ast_hangup(l->pchan);
-				ast_free(l);
+				rpt_free(l);
 				rpt_mutex_lock(&myrpt->lock);
 				/* re-start link traversal */
 				l = myrpt->links.next;
@@ -13094,7 +13096,7 @@
 				}
 				/* hang-up on call to device */
 				ast_hangup(l->pchan);
-				ast_free(l);
+				rpt_free(l);
                                 rpt_mutex_lock(&myrpt->lock);
 				break;
 			}
@@ -13118,7 +13120,7 @@
 		}
                 /* hang-up on call to device */
                 ast_hangup(l->pchan);
-                ast_free(l);
+                rpt_free(l);
                 rpt_mutex_lock(&myrpt->lock);
                 break;
             }
@@ -13177,7 +13179,7 @@
 			rpt_mutex_unlock(&myrpt->lock);
 			statpost(myrpt,str);
 			rpt_mutex_lock(&myrpt->lock);
-			ast_free(str);
+			rpt_free(str);
 		}
 		if (myrpt->keyposttimer)
 		{
@@ -13786,13 +13788,30 @@
 					/* hang-up on call to device */
 					ast_hangup(l->chan);
 					ast_hangup(l->pchan);
-					ast_free(l);
+					rpt_free(l);
 					rpt_mutex_lock(&myrpt->lock);
 					break;
 				}
 				if (f->frametype == AST_FRAME_VOICE)
 				{
 					int ismuted,n1;
+
+					if (l->chan && 
+					    ((!strncasecmp(l->chan->name,"irlp",4)) ||
+						(!strncasecmp(l->chan->name,"echolink",8))))
+					{
+						int x1;
+						short *sp;
+						float s;
+
+						sp = (short *)f->data;
+						for(x1 = 0; x1 < f->datalen / 2; x1++)
+						{
+							s = (sp[x1] >> 1) - 
+							    ((sp[x1] >> 3) + (sp[x1] >> 5));
+							sp[x1] = s;
+						}
+					}
 
 					l->rxlingertimer = RX_LINGER_TIME;
 
@@ -14065,7 +14084,7 @@
 						/* hang-up on call to device */
 						ast_hangup(l->chan);
 						ast_hangup(l->pchan);
-						ast_free(l);
+						rpt_free(l);
 						rpt_mutex_lock(&myrpt->lock);
 						break;
 					}
@@ -14087,6 +14106,20 @@
 				}
 				if (f->frametype == AST_FRAME_VOICE)
 				{
+					if (l->chan && 
+					    ((!strncasecmp(l->chan->name,"irlp",4)) ||
+						(!strncasecmp(l->chan->name,"echolink",8))))
+
+					{
+						int x1;
+						short *sp;
+
+						sp = (short *) f->data;
+						for(x1 = 0; x1 < f->datalen / 2; x1++)
+						{
+							sp[x1] += (sp[x1] << 1);
+						}
+					}
 					/* foop */
 					if (l->chan && (l->lastrx || (!altlink(myrpt,l))) && 
 					    ((l->newkey < 2) || l->lasttx ||
@@ -14122,9 +14155,19 @@
 			}
 			if (f->frametype == AST_FRAME_VOICE)
 			{
+				struct ast_frame *fs;
+				short *sp;
+				int x1;
+
 				if (myrpt->monstream) 
 					ast_writestream(myrpt->monstream,f);
 
+				fs = ast_frdup(f);
+				sp = (short *)fs->data;
+				for(x1 = 0; x1 < fs->datalen / 2; x1++)
+				{
+					sp[x1] += (sp[x1] << 1);
+				}
 				l = myrpt->links.next;
 				/* go thru all the links */
 				while(l != &myrpt->links)
@@ -14132,9 +14175,21 @@
 					/* foop */
 					if (l->chan && altlink(myrpt,l) && (!l->lastrx) && ((l->newkey < 2) || l->lasttx ||
 					    strncasecmp(l->chan->name,"IAX",3)))
-						ast_write(l->chan,f);
+					    {
+						if (l->chan && 
+						    ((!strncasecmp(l->chan->name,"irlp",4)) ||
+							(!strncasecmp(l->chan->name,"echolink",8))))
+						{
+							ast_write(l->chan,fs);
+						} 
+						else
+						{
+							ast_write(l->chan,f);
+						}
+					    }
 					l = l->next;
 				}
+				ast_frfree(fs);
 			}
 			if (f->frametype == AST_FRAME_CONTROL)
 			{
@@ -14263,7 +14318,7 @@
 		if (l->chan) ast_hangup(l->chan);
 		ast_hangup(l->pchan);
 		l = l->next;
-		ast_free(ll);
+		rpt_free(ll);
 	}
 	if (myrpt->xlink  == 1) myrpt->xlink = 2;
 	rpt_mutex_unlock(&myrpt->lock);
@@ -14446,7 +14501,7 @@
 			space = strchr(nodep->str,' ');
 			if (!space) 
 			{
-				ast_free(nodep);
+				rpt_free(nodep);
 				continue;
 			}
 			*space = 0;
@@ -14458,18 +14513,18 @@
 			if (fd == -1)
 			{
 				ast_log(LOG_ERROR,"Cannot open node log file %s for write",space + 1);
-				ast_free(nodep);
+				rpt_free(nodep);
 				continue;
 			}
 			if (write(fd,space + 1,strlen(space + 1)) !=
 				strlen(space + 1))
 			{
 				ast_log(LOG_ERROR,"Cannot write node log file %s for write",space + 1);
-				ast_free(nodep);
+				rpt_free(nodep);
 				continue;
 			}
 			close(fd);
-			ast_free(nodep);
+			rpt_free(nodep);
 		}
 		usleep(2000000);
 	}
@@ -14720,7 +14775,7 @@
 		template=strsep(&s,"|");
 		if(!template) {
 			ast_log(LOG_WARNING, "An announce template must be defined\n");
-			ast_free(orig_s);
+			rpt_free(orig_s);
 			return -1;
 		} 
   
@@ -14753,7 +14808,7 @@
 		}
 		if(atoi(priority) < 0) {
 			ast_log(LOG_WARNING, "Priority '%s' must be a number > 0\n", priority);
-			ast_free(orig_s);
+			rpt_free(orig_s);
 			return -1;
 		}
 		/* At this point we have a priority and maybe an extension and a context */
@@ -14788,7 +14843,7 @@
 
 		rpt_telemetry(myrpt,REV_PATCH,tmp);
 
-		ast_free(orig_s);
+		rpt_free(orig_s);
 
 		return 0;
 
@@ -16183,15 +16238,15 @@
 				if(remoteon){
 					if(loginuser){
 						astman_append(s, "LogInUser: %s\r\n", loginuser);
-						ast_free(loginuser);
+						rpt_free(loginuser);
 					}
 					if(loginlevel){
 						astman_append(s, "LogInLevel: %s\r\n", loginlevel);
-						ast_free(loginlevel);
+						rpt_free(loginlevel);
 					}
 					if(freq){
 						astman_append(s, "Freq: %s\r\n", freq);
-						ast_free(freq);
+						rpt_free(freq);
 					}
 					reportfmstuff = 0;
 					switch(remmode){
@@ -16441,14 +16496,14 @@
 			astman_append(s, "UserLinkingCommands: %s\r\n", link_ena);
 			astman_append(s, "UserFunctions: %s\r\n", user_funs);
 
-			for(j = 0; j < numoflinks; j++){ /* ast_free() all link names */
-				ast_free(listoflinks[j]);
+			for(j = 0; j < numoflinks; j++){ /* rpt_free() all link names */
+				rpt_free(listoflinks[j]);
 			}
 			if(called_number){
-				ast_free(called_number);
+				rpt_free(called_number);
 			}
 			if(lastdtmfcommand){
-				ast_free(lastdtmfcommand);
+				rpt_free(lastdtmfcommand);
 			}
 			astman_append(s, "\r\n"); /* We're Done! */
 		        return 0;
@@ -16491,7 +16546,7 @@
 	/* Check for Command */
 	if(ast_strlen_zero(cmd)){
 		astman_send_error(s, m, "RptStatus missing command");
-		ast_free(str);
+		rpt_free(str);
 		return 0;
 	}
 	/* Try to find the command in the table */
@@ -16502,7 +16557,7 @@
 
 	if(!mct[i].cmd){ /* Found or not found ? */
 		astman_send_error(s, m, "RptStatus unknown command");
-		ast_free(str);
+		rpt_free(str);
 		return 0;
 	}
 	else
@@ -16515,19 +16570,19 @@
 			if((res = snprintf(str, len, "Nodes: ")) > -1)
 				len -= res;
 			else{
-				ast_free(str);
+				rpt_free(str);
 				return 0;
 			}
 			for(i = 0; i < nrpts; i++){
 				if(i < nrpts - 1){
 					if((res = snprintf(str+strlen(str), len, "%s,",rpt_vars[i].name)) < 0){
-						ast_free(str);
+						rpt_free(str);
 						return 0;
 					}
 				}
 				else{
 					if((res = snprintf(str+strlen(str), len, "%s",rpt_vars[i].name)) < 0){
-						ast_free(str);
+						rpt_free(str);
 						return 0;
 					}
 				}
@@ -16555,14 +16610,14 @@
 
 		case	MGRCMD_NODESTAT:
 			res = rpt_manager_do_stats(s,m,str);
-			ast_free(str);
+			rpt_free(str);
 			return res;
 
 		default:
 			astman_send_error(s, m, "RptStatus invalid command");
 			break;
 	}
-	ast_free(str);
+	rpt_free(str);
 	return 0;
 }
 




More information about the svn-commits mailing list