[asterisk-commits] branch crichter/0.3.0 r9377 - /team/crichter/0.3.0/channels/chan_misdn.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Feb 10 07:15:02 MST 2006


Author: crichter
Date: Fri Feb 10 08:14:59 2006
New Revision: 9377

URL: http://svn.digium.com/view/asterisk?rev=9377&view=rev
Log:
* jb can be configured with setopt now
* reload does also misdn_reload now


Modified:
    team/crichter/0.3.0/channels/chan_misdn.c

Modified: team/crichter/0.3.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_misdn.c?rev=9377&r1=9376&r2=9377&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_misdn.c (original)
+++ team/crichter/0.3.0/channels/chan_misdn.c Fri Feb 10 08:14:59 2006
@@ -158,6 +158,8 @@
 
 	int ast_dsp;
 
+	int jb_len;
+	int jb_upper_threshold;
 	struct misdn_jb *jb;
 	
 	struct ast_dsp *dsp;
@@ -595,27 +597,29 @@
 	return NULL;
 }
 
-static int misdn_reload (int fd, int argc, char *argv[])
+
+
+void reload_config(void)
 {
 	int i, cfg_debug;
-	
-	ast_cli(fd, "Reloading mISDN Config\n");
 	chan_misdn_log(-1, 0, "Dynamic Crypting Activation is not support during reload at the moment\n");
 	
 	free_robin_list();
-
 	misdn_cfg_reload();
-
 	misdn_cfg_update_ptp();
-	
 	misdn_cfg_get( 0, MISDN_GEN_TRACEFILE, global_tracefile, BUFFERSIZE);
-	
 	misdn_cfg_get( 0, MISDN_GEN_DEBUG, &cfg_debug, sizeof(int));
+
 	for (i = 0;  i <= max_ports; i++) {
 		misdn_debug[i] = cfg_debug;
 		misdn_debug_only[i] = 0;
 	}
-	
+}
+
+static int misdn_reload (int fd, int argc, char *argv[])
+{
+	ast_cli(fd, "Reloading mISDN Config\n");
+	reload_config();
 	return 0;
 }
 
@@ -1138,6 +1142,40 @@
 }
 
 
+
+
+void config_jitterbuffer(struct chan_list *ch)
+{
+	struct misdn_bchannel *bc=ch->bc;
+	int len=ch->jb_len, threshold=ch->jb_upper_threshold;
+	
+	chan_misdn_log(1,bc->port, "config_jb: Called\n");
+	
+	if ( ! len ) {
+		chan_misdn_log(1,bc->port, "config_jb: Deactivating Jitterbuffer\n");
+		bc->nojitter=1;
+	} else {
+		
+		if (len <=100 || len > 8000) {
+			chan_misdn_log(-1,bc->port,"config_jb: Jitterbuffer out of Bounds, setting to 1000\n");
+			len=1000;
+		}
+		
+		if ( threshold > len ) {
+			chan_misdn_log(-1,bc->port,"config_jb: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n");
+		}
+		
+		if ( ch->jb) {
+			cb_log(0,bc->port,"config_jb: We've got a Jitterbuffer Already on this port.\n");
+			misdn_jb_destroy(ch->jb);
+			ch->jb=NULL;
+		}
+		
+		ch->jb=misdn_jb_init(len, threshold);
+	}
+}
+
+
 static int read_config(struct chan_list *ch, int orig) {
 
 	if (!ch) {
@@ -1181,33 +1219,10 @@
 
 	/*Initialize new Jitterbuffer*/
 	{
-		int jb_len,jb_upper_threshold;
-		misdn_cfg_get( port, MISDN_CFG_JITTERBUFFER, &jb_len, sizeof(int));
-		misdn_cfg_get( port, MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, &jb_upper_threshold, sizeof(int));
-
-		if ( ! jb_len ) {
-			chan_misdn_log(1,bc->port, "read_config: Deactivating Jitterbuffer\n");
-			bc->nojitter=1;
-		} else {
-		
-			if (jb_len <=100 || jb_len > 8000) {
-				chan_misdn_log(-1,bc->port,"read_config: Jitterbuffer out of Bounds, setting to 1000\n");
-				jb_len=1000;
-			}
-			
-			if ( jb_upper_threshold > jb_len ) {
-				chan_misdn_log(-1,bc->port,"read_config: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n");
-			}
-			
-			
-			if ( ch->jb) {
-				cb_log(0,bc->port,"read_config: We've got a Jitterbuffer Already on this port.\n");
-				misdn_jb_destroy(ch->jb);
-				ch->jb=NULL;
-			}
-			
-			ch->jb=misdn_jb_init(jb_len, jb_upper_threshold);
-		}
+		misdn_cfg_get( port, MISDN_CFG_JITTERBUFFER, &ch->jb_len, sizeof(int));
+		misdn_cfg_get( port, MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, &ch->jb_upper_threshold, sizeof(int));
+		
+		config_jitterbuffer(ch);
 	}
 	
 	misdn_cfg_get( bc->port, MISDN_CFG_CONTEXT, ch->context, sizeof(ch->context));
@@ -1763,7 +1778,11 @@
 		break;
 	case -1 :
 		chan_misdn_log(1, p->bc->port, " --> * IND :\t-1! (stop indication) pid:%d\n",p->bc?p->bc->pid:-1);
-		tone_indicate(p, TONE_NONE);
+		
+		if (p->state == MISDN_CONNECTED)
+			start_bc_tones(p);
+		else 
+			tone_indicate(p, TONE_NONE);
 		break;
 
 	case AST_CONTROL_HOLD:
@@ -3733,6 +3752,13 @@
 	return 0;
 }
 
+int reload(void)
+{
+	reload_config();
+
+	return 0;
+}
+
 int usecount(void)
 {
 	int res;
@@ -3806,6 +3832,7 @@
 	int  keyidx=0;
 	int rxgain=0;
 	int txgain=0;
+	int change_jitter=0;
 	
 	if (strcasecmp(chan->tech->type,"mISDN")) {
 		ast_log(LOG_WARNING, "misdn_set_opt makes only sense with chan_misdn channels!\n");
@@ -3840,8 +3867,32 @@
 			break;
 
 		case 'j':
-			chan_misdn_log(1, ch->bc->port, "SETOPT: No jitter\n");
-			ch->bc->nojitter=1;
+			chan_misdn_log(1, ch->bc->port, "SETOPT: jitter\n");
+			tok++;
+			change_jitter=1;
+			
+			switch ( tok[0] ) {
+			case 'b' :
+				ch->jb_len=atoi(++tok);
+				chan_misdn_log(1, ch->bc->port, " --> buffer_len:%d\n",ch->jb_len);
+				break;
+			case 't' :
+				ch->jb_upper_threshold=atoi(++tok);
+				chan_misdn_log(1, ch->bc->port, " --> upper_threshold:%d\n",ch->jb_upper_threshold);
+				break;
+
+			case 'n':
+				ch->bc->nojitter=1;
+				chan_misdn_log(1, ch->bc->port, " --> nojitter\n");
+				break;
+				
+			default:
+				ch->jb_len=1000;
+				ch->jb_upper_threshold=0;
+				chan_misdn_log(1, ch->bc->port, " --> buffer_len:%d (default)\n",ch->jb_len);
+				chan_misdn_log(1, ch->bc->port, " --> upper_threshold:%d (default)\n",ch->jb_upper_threshold);
+			}
+			
 			break;
       
 		case 'v':
@@ -3940,6 +3991,10 @@
 			break;
 		}
 	}
+
+	if (change_jitter)
+		config_jitterbuffer(ch);
+	
 	
 	if (ch->faxdetect || ch->ast_dsp) {
 		



More information about the asterisk-commits mailing list