[asterisk-commits] jdixon: branch jdixon/chan_usbradio-1.4 r138567 - /team/jdixon/chan_usbradio-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Aug 17 23:41:42 CDT 2008


Author: jdixon
Date: Sun Aug 17 23:41:42 2008
New Revision: 138567

URL: http://svn.digium.com/view/asterisk?view=rev&rev=138567
Log:
Did more with raw/linear link output

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

Modified: team/jdixon/chan_usbradio-1.4/dev-1.0/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/dev-1.0/apps/app_rpt.c?view=diff&rev=138567&r1=138566&r2=138567
==============================================================================
--- team/jdixon/chan_usbradio-1.4/dev-1.0/apps/app_rpt.c (original)
+++ team/jdixon/chan_usbradio-1.4/dev-1.0/apps/app_rpt.c Sun Aug 17 23:41:42 2008
@@ -22,7 +22,7 @@
 /*! \file
  *
  * \brief Radio Repeater / Remote Base program 
- *  version 0.907 (1.0-dev4) 8/17/08 
+ *  version 0.908 (1.0-dev4) 8/17/08 
  * 
  * \author Jim Dixon, WB6NIL <jim at lambdatel.com>
  *
@@ -150,6 +150,18 @@
  * 3 - Normal except no main repeat audio.
  * 4 - Normal except no main repeat audio during autopatch only
  *
+ * 'mixmode' modes: (defaults to mixmode=0)
+ *
+ * 0 - All channels are output in Linear Mixed (multi-source) mode
+ * 1 - All channels that have the same codec as the 'talker' are output
+ *     to in raw digital mode, others are output in Linear Mixed mode.
+ *     One and only 1 talker has the 'floor' at a time as far as the
+ *     raw output devices are concerned.
+ * 2 - All channels that have the same codec as the 'talker' are output
+ *     to in raw digital mode, as long as there is only 1 and only 1
+ *     linked station wishing to talk. If there are any others, all
+ *     channels go into Linear Mixed mode.
+ *
 */
 
 /*** MODULEINFO
@@ -376,7 +388,7 @@
 /*! Stop the tones from playing */
 void ast_playtones_stop(struct ast_channel *chan);
 
-static  char *tdesc = "Radio Repeater / Remote Base  version 0.907  8/17/2008";
+static  char *tdesc = "Radio Repeater / Remote Base  version 0.908  8/17/2008";
 
 static char *app = "Rpt";
 
@@ -786,8 +798,12 @@
 		int simplexphonedelay;
 		char *statpost_program;
 		char *statpost_url;
+		char mixmode;
 	} p;
 	struct rpt_link links;
+	struct rpt_link *talker;
+	struct ast_frame *fraw;
+	int ntalkers;
 	int unkeytocttimer;
 	time_t lastkeyedtime;
 	time_t lasttxkeyedtime;
@@ -1248,8 +1264,9 @@
 
 static void rpt_do_mix(void)
 {
-	int	n,x;
+	int	n,x,ntalkers;
 	struct ast_frame fr;
+	struct rpt_link *talker;
 	char	buf[(RPT_MIXER_BLOCKSIZE * sizeof(short)) + 
 		    AST_FRIENDLY_OFFSET + 10],remrx,totx,remnomute;
 	struct timeval now;
@@ -1293,6 +1310,12 @@
 				rpt_vars[n].pcq,&rpt_vars[n].pconf_sample);
 			rpt_vars[n].pcqflag = 0;
 		}
+		talker = NULL;
+		/* if this guy still talking, thats it */
+		if (rpt_vars[n].talker && (rpt_vars[n].talker->lastrx)) talker = rpt_vars[n].talker;
+		ntalkers = 0;
+		if (talker) ntalkers = 1;
+		rpt_vars[n].fraw = NULL;
 	        /* go thru all links */
 	        if ((!rpt_vars[n].remote) && (rpt_vars[n].links.next != &rpt_vars[n].links))
 	            for(l = rpt_vars[n].links.next; l != &rpt_vars[n].links; l = l->next)
@@ -1301,6 +1324,12 @@
 			if (!l->ready) continue;
 			if (l->lastrx)
 			{
+				if (!ntalkers)
+				{
+					talker = l;
+					ntalkers++;
+				}
+				if (talker != l) ntalkers++;
 				x = 0;
 				AST_LIST_TRAVERSE(&l->linq, lf,linkrx_list) x++;
 				if (x > 1)
@@ -1308,7 +1337,10 @@
 					lf = AST_LIST_REMOVE_HEAD(&l->linq,linkrx_list);
 					rpt_mixer_put(&rpt_vars[n].conf,lf->flin->data,&l->conf_sample);
 					ast_frfree(lf->flin);
-					ast_frfree(lf->fraw);
+					if (l == talker) 
+						rpt_vars[n].fraw = lf->fraw;
+					else 
+						ast_frfree(lf->fraw);
 					free(lf);
 				}
 			}
@@ -1318,11 +1350,16 @@
 				{
 					lf = AST_LIST_REMOVE_HEAD(&l->linq,linkrx_list);
 					ast_frfree(lf->flin);
-					ast_frfree(lf->fraw);
+					if (l == talker) 
+						rpt_vars[n].fraw = lf->fraw;
+					else 
+						ast_frfree(lf->fraw);
 					free(lf);
 				}
 			}
 		    }
+		rpt_vars[n].talker = talker;
+		rpt_vars[n].ntalkers = ntalkers;
 		/* go thru telem list */
 		rxtelem = rpt_vars[n].rxtele.qe_forw;
 		while(rxtelem != &rpt_vars[n].rxtele)
@@ -1481,14 +1518,44 @@
 	        if ((!rpt_vars[n].remote) && (rpt_vars[n].links.next != &rpt_vars[n].links))
 	            for(l = rpt_vars[n].links.next; l != &rpt_vars[n].links; l = l->next)
 	            {
+			char doraw = 0;
+
         	        if (!l->chan) continue;
 			if (!l->ready) continue;
 	                rpt_mixer_get(&rpt_vars[n].conf,fr.data,
                               &l->conf_sample);
-			f1 = ast_translate(l->write_path,&fr,0);
-	                ast_write(l->chan,f1);
-			ast_frfree(f1);
+
+			if (rpt_vars[n].p.mixmode && rpt_vars[n].talker)
+			{
+				if ((rpt_vars[n].p.mixmode == 2) &&
+					(rpt_vars[n].ntalkers > 1)) doraw = 0;
+				else doraw = 1;
+			}
+
+			if ((!l->lastrx) && (rpt_vars[n].ntalkers < 1)) doraw = 0;
+			if (l == rpt_vars[n].talker) doraw = 0;
+			if (rpt_vars[n].fraw == NULL) doraw = 0;
+			if (l->chan->writeformat != 
+				rpt_vars[n].talker->chan->readformat) doraw = 0;
+			if (l->name[0] == '0') doraw = 0;
+			if (l->phonemode) doraw = 0;
+			if (doraw) /* output raw */
+			{  
+				printf("Rpt %s link %s raw out\n",
+					rpt_vars[n].name,l->name);
+				ast_write(l->chan,rpt_vars[n].fraw);
+
+			}
+			else  /* output linearly */
+			{
+				printf("Rpt %s link %s lin out\n",
+					rpt_vars[n].name,l->name);
+				f1 = ast_translate(l->write_path,&fr,0);
+		                ast_write(l->chan,f1);
+				ast_frfree(f1);
+			}
 	            }
+		if (rpt_vars[n].fraw) ast_frfree(rpt_vars[n].fraw);
 #ifdef	APP_RPT_LOCK_DEBUG 
 		_rpt_mutex_unlock(&rpt_vars[n].lock,&rpt_vars[n],__LINE__);
 #else
@@ -2864,6 +2931,8 @@
 	val = (char *) ast_variable_retrieve(cfg,this,"parrottime");
 	if (val) rpt_vars[n].p.parrottime = atoi(val); 
 	else rpt_vars[n].p.parrottime = PARROTTIME;
+	val = (char *) ast_variable_retrieve(cfg,this,"mixmode");
+	if (val) rpt_vars[n].p.mixmode = atoi(val);
 	val = (char *) ast_variable_retrieve(cfg,this,"rptnode");
 	rpt_vars[n].p.rptnode = val;
 	val = (char *) ast_variable_retrieve(cfg,this,"mars");




More information about the asterisk-commits mailing list