[asterisk-commits] crichter: branch crichter/0.4.0 r39296 - in /team/crichter/0.4.0: ./ channels...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Aug 8 02:35:09 MST 2006


Author: crichter
Date: Tue Aug  8 04:35:08 2006
New Revision: 39296

URL: http://svn.digium.com/view/asterisk?rev=39296&view=rev
Log:
Merged revisions 38828,38907,39293 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/team/crichter/0.3.0

........
r38828 | root | 2006-08-03 22:00:19 +0200 (Do, 03 Aug 2006) | 1 line

automerge commit
........
r38907 | root | 2006-08-05 08:00:24 +0200 (Sa, 05 Aug 2006) | 1 line

automerge cancel
........
r39293 | crichter | 2006-08-08 10:24:09 +0200 (Di, 08 Aug 2006) | 14 lines

* added possibility to change echocancel settings during calls
* removed the holded element from the chan_list struct, we know this from the 
  state already
* added a few tweaks to make HOLD/RETRIEVE work again (TRANSFER does not work
  yet)
* added possibility to debug mISDN frames via syslog
* added misdn_lib_port_is_blocked function to check if a port is blocked
* removed ec_training=1 from empty_bc, we don't use ec_training anymore
* removed unused misdn_lib_get_l2_status function
* added the nt bit to dummy misdn_bchannel objects
* setting bc->out_fac_type to FACILITY_NONE defaultly
* removed HANDLER_DEBUG stuff for better readability


........

Modified:
    team/crichter/0.4.0/   (props changed)
    team/crichter/0.4.0/channels/chan_misdn.c
    team/crichter/0.4.0/channels/misdn/fac.c
    team/crichter/0.4.0/channels/misdn/isdn_lib.c
    team/crichter/0.4.0/channels/misdn/isdn_lib.h
    team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c
    team/crichter/0.4.0/res/res_musiconhold.c

Propchange: team/crichter/0.4.0/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Aug  8 04:35:08 2006
@@ -1,1 +1,1 @@
-/team/crichter/0.3.0:1-38802
+/team/crichter/0.3.0:1-39295

Modified: team/crichter/0.4.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_misdn.c?rev=39296&r1=39295&r2=39296&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_misdn.c (original)
+++ team/crichter/0.4.0/channels/chan_misdn.c Tue Aug  8 04:35:08 2006
@@ -136,11 +136,12 @@
 	int need_hangup;
 	int need_busy;
 	
-	int holded; 
 	int orginator;
 
 	int norxtone;
 	int notxtone; 
+
+	int toggle_ec;
 	
 	int incoming_early_audio;
 
@@ -325,10 +326,10 @@
 
 int chan_misdn_jb_empty(struct misdn_bchannel *bc, char *buf, int len);
 
-
 int add_out_calls(int port);
 int add_in_calls(int port);
 
+static int update_ec_config(struct misdn_bchannel *bc);
 
 /*************** Helpers *****************/
 
@@ -952,6 +953,13 @@
 			"  --> state: %s\n"
 			"  --> capability: %s\n"
 			"  --> echo_cancel: %d\n"
+#ifdef WITH_BEROEC
+			"  --> bnec_tail: %d\n"
+			"  --> bnec_nlp: %d\n"
+			"  --> bnec_ah: %d\n"
+			"  --> bnec_td: %d\n"
+			"  --> bnec_zerocoeff: %d\n"
+#endif
 			"  --> notone : rx %d tx:%d\n"
 			"  --> bc_hold: %d holded_bc :%d\n",
 			help->ast->name,
@@ -965,6 +973,14 @@
 			bc_state2str(bc->bc_state),
 			bearer2str(bc->capability),
 			bc->ec_enable,
+
+#ifdef WITH_BEROEC
+			bc->bnec_tail,
+			bc->bnec_nlp,
+			bc->bnec_ah,
+			bc->bnec_td,
+			bc->bnec_zero,
+#endif
 			help->norxtone,help->notxtone,
 			bc->holded, help->holded_bc?1:0
 			);
@@ -1170,9 +1186,11 @@
 			ast_cli(fd, "Toggling EchoCancel %s failed Channel does not exist\n", channame);
 			return 0; 
 		} else {
-			tmp->bc->ec_enable=tmp->bc->ec_enable?0:1;
-
-			if (tmp->bc->ec_enable) {
+			
+			tmp->toggle_ec=tmp->toggle_ec?0:1;
+
+			if (tmp->toggle_ec) {
+				update_ec_config(tmp->bc);
 				manager_ec_enable(tmp->bc);
 			} else {
 				manager_ec_disable(tmp->bc);
@@ -1614,6 +1632,44 @@
 
 
 
+static int update_ec_config(struct misdn_bchannel *bc)
+{
+	int ec;
+	int port=bc->port;
+		
+	misdn_cfg_get( port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
+	
+	if (ec == 1 ) {
+		bc->ec_enable=1;
+	} else if ( ec > 1 ) {
+		bc->ec_enable=1;
+		bc->ec_deftaps=ec;
+	}
+#ifdef WITH_ECHOTRAINING 
+	int ectr;
+	misdn_cfg_get( port, MISDN_CFG_ECHOTRAINING, &ectr, sizeof(int));
+	
+	if ( ectr >= 0 ) {
+		bc->ec_training=ectr;
+	}
+#endif
+
+#ifdef WITH_BEROEC
+	misdn_cfg_get(port, MISDN_CFG_BNECHOCANCEL,&bc->bnec_tail, sizeof(int));
+	misdn_cfg_get(port, MISDN_CFG_BNEC_ANTIHOWL, &bc->bnec_ah, sizeof(int));
+	misdn_cfg_get(port, MISDN_CFG_BNEC_NLP, &bc->bnec_nlp, sizeof(int));
+	misdn_cfg_get(port, MISDN_CFG_BNEC_TD, &bc->bnec_td, sizeof(int));
+	misdn_cfg_get(port, MISDN_CFG_BNEC_ADAPT, &bc->bnec_adapt, sizeof(int));
+	misdn_cfg_get(port, MISDN_CFG_BNEC_ZEROCOEFF, &bc->bnec_zero, sizeof(int));
+
+	if (bc->bnec_tail && bc->ec_enable) {
+		ast_log(LOG_WARNING,"Are you sure you wan't to mix BNEC with Zapec ? This might cause bad audio quality!\n");
+		bc->ec_enable=0;
+	}
+#endif
+	return 0;
+}
+
 
 static int read_config(struct chan_list *ch, int orig) {
 
@@ -1683,41 +1739,9 @@
 	misdn_cfg_get( bc->port, MISDN_CFG_CONTEXT, ch->context, sizeof(ch->context));
 	
 	ast_copy_string (ast->context,ch->context,sizeof(ast->context));	
-	{
-		int ec;
-		
-		misdn_cfg_get( port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
-		
-		if (ec == 1 ) {
-			bc->ec_enable=1;
-		} else if ( ec > 1 ) {
-			bc->ec_enable=1;
-			bc->ec_deftaps=ec;
-		}
-#ifdef WITH_ECHOTRAINING 
-		int ectr;
-		misdn_cfg_get( port, MISDN_CFG_ECHOTRAINING, &ectr, sizeof(int));
-		
-		if ( ectr >= 0 ) {
-			bc->ec_training=ectr;
-		}
-#endif
-
-#ifdef WITH_BEROEC
-		misdn_cfg_get(port, MISDN_CFG_BNECHOCANCEL,&bc->bnec_tail, sizeof(int));
-		misdn_cfg_get(port, MISDN_CFG_BNEC_ANTIHOWL, &bc->bnec_ah, sizeof(int));
-		misdn_cfg_get(port, MISDN_CFG_BNEC_NLP, &bc->bnec_nlp, sizeof(int));
-		misdn_cfg_get(port, MISDN_CFG_BNEC_TD, &bc->bnec_td, sizeof(int));
-		misdn_cfg_get(port, MISDN_CFG_BNEC_ADAPT, &bc->bnec_adapt, sizeof(int));
-		misdn_cfg_get(port, MISDN_CFG_BNEC_ZEROCOEFF, &bc->bnec_zero, sizeof(int));
-
-		if (bc->bnec_tail && bc->ec_enable) {
-			ast_log(LOG_WARNING,"Are you sure you wan't to mix BNEC with Zapec ? This might cause bad audio quality!\n");
-			bc->ec_enable=0;
-		}
-#endif
-	}
-	
+
+	update_ec_config(bc);
+
 	{
 		int eb3;
 		
@@ -2128,7 +2152,7 @@
 	
 	if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast) )) return -1;
 	
-	chan_misdn_log(1, p->bc?p->bc->port:0, "* IND: Got Fixup State:%s Holded:%d L3id:%x\n", misdn_get_ch_state(p), p->holded, p->l3id);
+	chan_misdn_log(1, p->bc?p->bc->port:0, "* IND: Got Fixup State:%s L3id:%x\n", misdn_get_ch_state(p), p->l3id);
 	
 	p->ast = ast ;
 	p->state=MISDN_CONNECTED;
@@ -2502,8 +2526,8 @@
 		return -1;
 	}
 	
-	if (ch->holded ) {
-		chan_misdn_log(5, ch->bc->port, "misdn_write: Returning because holded\n");
+	if (ch->state == MISDN_HOLDED) {
+		chan_misdn_log(8, ch->bc->port, "misdn_write: Returning because holded\n");
 		return 0;
 	}
 	
@@ -3375,7 +3399,6 @@
 	ast_moh_stop(AST_BRIDGED_P(holded_chan->ast));
 
 	holded_chan->state=MISDN_CONNECTED;
-	holded_chan->holded=0;
 	misdn_lib_transfer(holded_chan->bc?holded_chan->bc:holded_chan->holded_bc);
 	ast_channel_masquerade(holded_chan->ast, AST_BRIDGED_P(tmp_ch->ast));
 }
@@ -3586,6 +3609,8 @@
 			case EVENT_FACILITY:
 			case EVENT_DISCONNECT:
 			case EVENT_PORT_ALARM:
+			case EVENT_RETRIEVE:
+			case EVENT_NEW_BC:
 				/*We still handle then, even without calls*/
 				break;
 			case EVENT_RELEASE_COMPLETE:
@@ -3650,6 +3675,15 @@
 		break;
 
 	case EVENT_NEW_BC:
+		if (!ch) {
+			ch=find_holded(cl_te,bc);
+		}
+		
+		if (!ch) {
+			ast_log(LOG_WARNING,"NEW_BC without chan_list?\n");
+			break;
+		}
+
 		if (bc)
 			ch->bc=(struct misdn_bchannel*)user_data;
 		break;
@@ -4175,7 +4209,8 @@
 			if  (ch->state == MISDN_CONNECTED ) {
 				misdn_transfer_bc(ch, holded_ch) ;
 			}
-			misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
+			hangup_chan(ch);
+			release_chan(bc);
 			break;
 		}
 		
@@ -4361,6 +4396,12 @@
 	/***************************/
 	case EVENT_RETRIEVE:
 	{
+		ch=find_holded(cl_te, bc);
+		if (!ch) {
+			ast_log(LOG_WARNING, "Found no Holded channel, cannot Retrieve\n");
+			misdn_lib_send_event(bc, EVENT_RETRIEVE_REJECT);
+			break;
+		}
 		struct ast_channel *hold_ast=AST_BRIDGED_P(ch->ast);
 		ch->state = MISDN_CONNECTED;
 		

Modified: team/crichter/0.4.0/channels/misdn/fac.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/fac.c?rev=39296&r1=39295&r2=39296&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/fac.c (original)
+++ team/crichter/0.4.0/channels/misdn/fac.c Tue Aug  8 04:35:08 2006
@@ -148,6 +148,7 @@
 	case FACILITY_CALLDEFLECT:
 		len = enc_fac_calldeflect(facility, fac.calldeflect_nr, 1);
 		enc_ie_facility(ntmsg, msg, facility, len, bc);
+		break;
 	case FACILITY_CENTREX:
 	case FACILITY_NONE:
 		break;

Modified: team/crichter/0.4.0/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib.c?rev=39296&r1=39295&r2=39296&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib.c (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib.c Tue Aug  8 04:35:08 2006
@@ -11,6 +11,8 @@
  * the GNU General Public License
  */
 
+
+#include <syslog.h>
 #include "isdn_lib_intern.h"
 #include <mISDNuser/isdn_debug.h>
 
@@ -64,6 +66,17 @@
 	}
 	return -1;
 
+}
+
+int misdn_lib_is_port_blocked(int port)
+{	
+	struct misdn_stack *stack=get_misdn_stack();
+	for ( ; stack; stack=stack->next) {
+		if (stack->port == port) {
+			return stack->blocked;
+		}
+	}
+	return -1;
 }
 
 int misdn_lib_is_ptp(int port)
@@ -367,14 +380,12 @@
 	}
 	
 	frm->addr = (stack->upper_id | FLG_MSG_DOWN);
-
-	
 	frm->dinfo = bc->l3_id;
-  
 	frm->len = (dmsg->len) - mISDN_HEADER_LEN;
-	
+				
+	cb_log(4,stack->port,"Sending msg, prim:%x addr:%x dinfo:%x\n",frm->prim,frm->addr,frm->dinfo);
+
 	mISDN_write(midev, dmsg->data, dmsg->len, TIMEOUT_1SEC);
-  
 	free_msg(dmsg);
 
 	return 0;
@@ -528,8 +539,10 @@
 {
 	bc->bframe_len=0;
 	
+
+	bc->in_use= 0;
+
 	bc->channel = 0;
-	bc->in_use = 0;
 
 	bc->sending_complete = 0;
 
@@ -569,8 +582,10 @@
 	bc->ec_enable = 0;
 	bc->ec_deftaps = 128;
 	bc->ec_whenbridged = 0;
+
+#ifdef EC_TRAIN
 	bc->ec_training = 1;
-	
+#endif
 	
 	bc->orig=0;
   
@@ -605,6 +620,7 @@
 	bc->orig_dad[0] = 0;
 	
 	bc->fac_type=FACILITY_NONE;
+	bc->out_fac_type=FACILITY_NONE;
 	
 	bc->te_choose_channel = 0;
 
@@ -638,22 +654,15 @@
 	
 	manager_bchannel_deactivate(bc);
 
-#ifdef WITH_BEROEC
-	if (bc->ec)
-		beroec_destroy(bc->ec);
-	bc->ec=NULL;
-#endif
-
-	if ( misdn_cap_is_speech(bc->capability) && bc->ec_enable) {
-		manager_ec_disable(bc);
-	}
+
+	manager_ec_disable(bc);
+
 
 	mISDN_write_frame(stack->midev, buff, bc->layer_id|FLG_MSG_TARGET|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
 	
 	/*mISDN_clear_stack(stack->midev, bc->b_stid);*/
 
 	
-
 	bc->b_stid = 0;
 	bc_state_change(bc, BCHAN_CLEANED);
 	
@@ -800,18 +809,6 @@
 	return 0;
 }
 
-int misdn_lib_get_l2_status(struct misdn_stack *stack)
-{
-	iframe_t act;
-	
-	act.prim = DL_ESTABLISH | REQUEST;
-
-	act.addr = (stack->upper_id | FLG_MSG_DOWN)  ;
-
-	act.dinfo = 0;
-	act.len = 0;
-	return mISDN_write(stack->midev, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
-}
 
 int misdn_lib_get_short_status(struct misdn_stack *stack)
 {
@@ -1043,7 +1040,6 @@
 		bc_state_change(bc,BCHAN_ERROR);
 		return(-EINVAL);
 	}
-
 
 	ret = mISDN_get_setstack_ind(midev, bc->layer_id);
 
@@ -1301,17 +1297,17 @@
 			Isdnl3Init(&stack->nst);
 		} 
 		
-		
-		
-		if ( stack->nt && stack->ptp) {
-		}
-		
+		stack->l1link=0;
+		stack->l2link=0;
+#if 0	
 		if (!stack->nt) {
-			/*assume L1 is up, we'll get DEACTIVATES soon, for non
-			 * up L1s*/
-			stack->l1link=0;
-		}
-
+			misdn_lib_get_short_status(stack);
+		} else {
+			misdn_lib_get_l1_up(stack);
+			if (!stack->ptp) misdn_lib_get_l1_up(stack);
+			misdn_lib_get_l2_up(stack);
+		}
+#endif
 		misdn_lib_get_short_status(stack);
 		misdn_lib_get_l1_up(stack);
 		misdn_lib_get_l2_up(stack);
@@ -1572,6 +1568,7 @@
 				memset (&dummybc,0,sizeof(dummybc));
 				dummybc.port=stack->port;
 				dummybc.l3_id=frm->dinfo;
+				dummybc.nt=stack->nt;
 				bc=&dummybc; 
 			}
       
@@ -1770,9 +1767,13 @@
 			struct misdn_bchannel *hold_bc=stack_holder_find(stack,bc->l3_id);
 
 			if (hold_bc) {
-				cb_event(EVENT_NEW_BC, hold_bc, bc);
+
 				cb_log(4, stack->port, "REMOVEING Holder\n");
 				stack_holder_remove(stack, hold_bc);
+
+				memcpy(bc,hold_bc,sizeof(struct misdn_bchannel));
+				cb_event(EVENT_NEW_BC, hold_bc, bc);
+
 				free(hold_bc);
 			}
 			
@@ -1925,6 +1926,7 @@
 				memset (&dummybc,0,sizeof(dummybc));
 				dummybc.port=stack->port;
 				dummybc.l3_id=hh->dinfo;
+				dummybc.nt=stack->nt;
 				bc=&dummybc; 
 			}
 	
@@ -2027,6 +2029,7 @@
 			memset (&dummybc,0,sizeof(dummybc));
 			dummybc.port=stack->port;
 			dummybc.l3_id=hh->dinfo;
+			dummybc.nt=stack->nt;
 			bc=&dummybc; 
 		}
 		if (bc ) {
@@ -2555,13 +2558,11 @@
 	
 	struct misdn_stack *stack=find_stack_by_addr(frm->addr);
 
-	
-	cb_log(4,stack?stack->port:0,"handle_frm: frm->addr:%x frm->prim:%x\n",frm->addr,frm->prim);
-	
-  
 	if (!stack || stack->nt) {
 		return 0;
 	}
+	
+	cb_log(4,stack?stack->port:0,"handle_frm: frm->addr:%x frm->prim:%x\n",frm->addr,frm->prim);
 
 	{
 		struct misdn_bchannel *bc;
@@ -2649,7 +2650,7 @@
 	int i ;
 	
 	if (!stack) return 0 ;
-  
+
 	switch (frm->prim) {
 	case PH_ACTIVATE | CONFIRM:
 	case PH_ACTIVATE | INDICATION:
@@ -2790,8 +2791,6 @@
 		case SSTATUS_L1_ACTIVATED:
 			cb_log(3, stack->port, "MGMT: SSTATUS: L1_ACTIVATED \n");
 			stack->l1link=1;
-			if (stack->nt && stack->ptp)
-				misdn_lib_get_l2_up(stack);
 			break;
 
 		case SSTATUS_L1_DEACTIVATED:
@@ -3139,7 +3138,7 @@
 	cb_log(4, stack->port, " --> screen:%d --> pres:%d\n",
 			bc->screen, bc->pres);
 	
-	cb_log(4, stack->port, " --> addr:%x l3id:%x b_stid:%x layer_id:%x\n", bc->pid, bc->addr, bc->l3_id, bc->b_stid, bc->layer_id);
+	cb_log(4, stack->port, " --> addr:%x l3id:%x b_stid:%x layer_id:%x\n", bc->addr, bc->l3_id, bc->b_stid, bc->layer_id);
 	
 	cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_type),fac2str(bc->out_fac_type));
 
@@ -3203,6 +3202,9 @@
 
 	case EVENT_CONNECT:
 	case EVENT_RETRIEVE_ACKNOWLEDGE:
+
+		bc->holded=0;
+		
 		if (stack->nt) {
 			if (bc->channel <=0 ) { /*  else we have the channel already */
 				bc->channel = find_free_chan_in_stack(stack, bc, 0);
@@ -3215,48 +3217,36 @@
 			}
 			/* Its that i generate channels */
 		}
-		
+
 		ret=setup_bc(bc);
 		if (ret == -EINVAL) {
 			cb_log(0,bc->port,"send_event: setup_bc failed\n");
 		}
-		
-		if ( (event == EVENT_CONNECT ) && misdn_cap_is_speech(bc->capability) ) {
-			if ( *bc->crypt_key ) {
-				cb_log(4, stack->port,  " --> ENABLING BLOWFISH channel:%d oad%d:%s dad%d:%s \n", bc->channel, bc->onumplan,bc->oad, bc->dnumplan,bc->dad);
+
+		cb_log(0,bc->port,"After SETUP BC\n");
+
+		
+		if (misdn_cap_is_speech(bc->capability)) {
+			if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) {
+				if ( *bc->crypt_key ) {
+					cb_log(4, stack->port,  " --> ENABLING BLOWFISH channel:%d oad%d:%s dad%d:%s \n", bc->channel, bc->onumplan,bc->oad, bc->dnumplan,bc->dad);
+					
+					manager_ph_control_block(bc,  BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
+				}
 				
-				manager_ph_control_block(bc,  BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
-			}
-			
-			if (!bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
-			
-			if (bc->ec_enable) manager_ec_enable(bc);
-
-#ifdef WITH_BEROEC
-			if (!bec_initialized) bc->bnec_tail=0;
-
-			if (bc->bnec_tail) {
-				bc->ec=beroec_new(bc->bnec_tail, BEROEC_SUBBAND, bc->bnec_ah,
-				bc->bnec_td, bc->bnec_zero, bc->bnec_adapt, bc->bnec_nlp);
-			}
-#endif
-
-
-			
-			if (bc->txgain != 0) {
-				cb_log(4, stack->port,  "--> Changing txgain to %d\n", bc->txgain);
-				manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
-			}
-			
-			if ( bc->rxgain != 0 ) {
-				cb_log(4, stack->port,  "--> Changing rxgain to %d\n", bc->rxgain);
-				manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
-			}
-			
-		}
-		
-		if (event == EVENT_RETRIEVE_ACKNOWLEDGE) {
-			cb_log(0,bc->port,"DO WE NEED TO DO SOMETHING HERE WITH THE BC ?\n");
+				if (!bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
+				manager_ec_enable(bc);
+				
+				if (bc->txgain != 0) {
+					cb_log(4, stack->port,  "--> Changing txgain to %d\n", bc->txgain);
+					manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
+				}
+				
+				if ( bc->rxgain != 0 ) {
+					cb_log(4, stack->port,  "--> Changing rxgain to %d\n", bc->rxgain);
+					manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
+				}
+			}
 		}
 		break;
 
@@ -3328,16 +3318,7 @@
 		
 		if (misdn_cap_is_speech(bc->capability)) {
 			if (  !bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
-			if (bc->ec_enable) manager_ec_enable(bc);
-#ifdef WITH_BEROEC
-			if (!bec_initialized) bc->bnec_tail=0;
-
-			if (bc->bnec_tail) {
-				bc->ec=beroec_new(bc->bnec_tail, BEROEC_SUBBAND, bc->bnec_ah,
-				bc->bnec_td, bc->bnec_zero, bc->bnec_adapt, bc->bnec_nlp);
-			}
-#endif
-
+			manager_ec_enable(bc);
 
 			if ( bc->txgain != 0 ) {
 				cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain);
@@ -3473,22 +3454,18 @@
 	}
 
 	if ( ((frm->addr | ISDN_PID_BCHANNEL_BIT )>> 28 ) == 0x5) {
-#ifdef MISDN_HANDLER_DEBUG
-		cb_log(0,0,"handle_bchan START\n");
+		if (handle_bchan(msg)) {
+			return 0 ;
+		}
+	}	
+
+#ifdef RECV_FRM_SYSLOG_DEBUG
+	syslog(LOG_NOTICE,"mISDN recv: P(%02d): ADDR:%x PRIM:%x DINFO:%x\n",stack->port, frm->addr, frm->prim, frm->dinfo);
 #endif
-		if (handle_bchan(msg)) {
-#ifdef MISDN_HANDLER_DEBUG
-			cb_log(0,0,"handle_bchan STOP\n");
-#endif
-			return 0 ;
-		}
-#ifdef MISDN_HANDLER_DEBUG
-		cb_log(0,0,"handle_bchan NOTSTOP\n");
-#endif	
-	}	
-	
+
 	if (handle_timers(msg)) 
 		return 0 ;
+
 	
 	if (handle_mgmt(msg)) 
 		return 0 ; 
@@ -3500,45 +3477,18 @@
 	if (handle_l1(msg)) 
 		return 0 ;
 	
-#ifdef MISDN_HANDLER_DEBUG
-	cb_log(0,0,"handle_frm_nt START\n");
-#endif
 	if (handle_frm_nt(msg)) {
-#ifdef MISDN_HANDLER_DEBUG
-		cb_log(0,0,"handle_frm_nt STOP\n");
-#endif
 		return 0;
 	}
-#ifdef MISDN_HANDLER_DEBUG
-	cb_log(0,0,"handle_frm_nt NOTSTOP\n");
-	
-	cb_log(0,0,"handle_frm START\n");
-#endif
-	
+
 	if (handle_frm(msg)) {
-#ifdef MISDN_HANDLER_DEBUG
-		cb_log(0,0,"handle_frm STOP\n");
-#endif
-		
 		return 0;
 	}
-#ifdef MISDN_HANDLER_DEBUG
-	cb_log(0,0,"handle_frm NOTSTOP\n");	
-	
-	cb_log(0,0,"handle_err START\n");
-#endif
-	
+
 	if (handle_err(msg)) {
-#ifdef MISDN_HANDLER_DEBUG
-		cb_log(0,0,"handle_err STOP\n");
-#endif
 		return 0 ;
 	}
-#ifdef MISDN_HANDLER_DEBUG
-	cb_log(0,0,"handle_err NOTSTOP\n");
-#endif
-
-	
+
 	cb_log(0, 0, "Unhandled Message: prim %x len %d from addr %x, dinfo %x on this port.\n",frm->prim, frm->len, frm->addr, frm->dinfo);		
 	free_msg(msg);
 	
@@ -3722,7 +3672,6 @@
 				} else {
 					iframe_t *frm = (iframe_t *)msg->data;
 					struct misdn_bchannel *bc = find_bc_by_l3id(stack, frm->dinfo);
-					cb_log(4,stack->port,"Sending msg, prim:%x addr:%x dinfo:%x\n",frm->prim,frm->addr,frm->dinfo);
 					if (bc) send_msg(glob_mgr->midev, bc, msg);
 				}
 			}
@@ -4157,6 +4106,8 @@
 
 	if (!holder->stack_holder) return;
 	
+	holder->stack_holder=0;
+	
 	cb_log(4,stack->port, "*HOLDER: remove %x\n",holder->l3_id);
 	if (!stack || ! stack->holding) return;
   
@@ -4239,29 +4190,58 @@
 
 	struct misdn_stack *stack=get_stack_by_bc(bc);
 	
-	cb_log(1, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d training:%d\n",bc->ec_deftaps, bc->ec_training);
-	
-	switch (bc->ec_deftaps) {
-	case 4:
-	case 8:
-	case 16:
-	case 32:
-	case 64:
-	case 128:
-	case 256:
-	case 512:
-	case 1024:
-		cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps);
-		break;
-	default:
-		cb_log(0, stack->port, "Taps should be power of 2\n");
-		bc->ec_deftaps=128;
-	}
-
-	ec_arr[0]=bc->ec_deftaps;
-	ec_arr[1]=bc->ec_training;
-	
-	manager_ph_control_block(bc,  ECHOCAN_ON,  ec_arr, sizeof(ec_arr));
+	cb_log(1, stack?stack->port:0,"ec_enable\n");
+
+	if (!misdn_cap_is_speech(bc->capability)) {
+		cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n");
+		return;
+	}
+
+#ifdef WITH_BEROEC
+	if (bc->ec) {
+		cb_log(1, stack?stack->port:0, " --> EC already loaded\n");
+		return;
+	}
+
+	if (!bec_initialized) bc->bnec_tail=0;
+
+	if (bc->bnec_tail) {
+		bc->ec=beroec_new(bc->bnec_tail, BEROEC_SUBBAND,
+		bc->bnec_ah,
+		bc->bnec_td, bc->bnec_zero, bc->bnec_adapt, bc->bnec_nlp);
+	}	
+	return ;
+#endif
+
+	if (bc->ec_enable) {
+		cb_log(1, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d training:%d\n",bc->ec_deftaps, bc->ec_training);
+	
+		switch (bc->ec_deftaps) {
+		case 4:
+		case 8:
+		case 16:
+		case 32:
+		case 64:
+		case 128:
+		case 256:
+		case 512:
+		case 1024:
+			cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps);
+			break;
+		default:
+			cb_log(0, stack->port, "Taps should be power of 2\n");
+			bc->ec_deftaps=128;
+		}
+	
+		ec_arr[0]=bc->ec_deftaps;
+#ifdef EC_TRAIN
+		ec_arr[1]=bc->ec_training;
+#else
+		ec_arr[1]=0;
+#endif
+		
+		manager_ph_control_block(bc,  ECHOCAN_ON,  ec_arr, sizeof(ec_arr));
+	}
 }
 
 
@@ -4270,8 +4250,24 @@
 {
 	struct misdn_stack *stack=get_stack_by_bc(bc);
 	
-	cb_log(1, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
-	manager_ph_control(bc,  ECHOCAN_OFF, 0);
+	cb_log(1, stack?stack->port:0,"ec_disable\n");
+
+	if (!misdn_cap_is_speech(bc->capability)) {
+		cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n");
+		return;
+	}
+
+#ifdef WITH_BEROEC
+	if (bc->ec)
+		beroec_destroy(bc->ec);
+	bc->ec=NULL;
+	return;
+#endif
+
+	if ( bc->ec_enable) {
+		cb_log(1, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
+		manager_ph_control(bc,  ECHOCAN_OFF, 0);
+	}
 }
 
 struct misdn_stack* get_misdn_stack() {
@@ -4396,7 +4392,11 @@
 	
 		Isdnl2Init(&stack->nst);
 		Isdnl3Init(&stack->nst);
-	}
-}
-
-
+
+		if (!stack->ptp)
+			misdn_lib_get_l1_up(stack);
+		misdn_lib_get_l2_up(stack);
+	}
+}
+
+

Modified: team/crichter/0.4.0/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib.h?rev=39296&r1=39295&r2=39296&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib.h (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib.h Tue Aug  8 04:35:08 2006
@@ -414,6 +414,7 @@
 int misdn_lib_port_restart(int port);
 int misdn_lib_get_port_info(int port);
 
+int misdn_lib_is_port_blocked(int port);
 int misdn_lib_port_block(int port);
 int misdn_lib_port_unblock(int port);
 

Modified: team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c?rev=39296&r1=39295&r2=39296&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c Tue Aug  8 04:35:08 2006
@@ -879,7 +879,7 @@
 
 void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) 
 {
-
+//#define FACILITY_DECODE
 #ifdef FACILITY_DEBUG
 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
 	FACILITY_t *facility=(FACILITY_t*)((unsigned long)(msg->data+HEADER_LEN)); 

Modified: team/crichter/0.4.0/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/res/res_musiconhold.c?rev=39296&r1=39295&r2=39296&view=diff
==============================================================================
--- team/crichter/0.4.0/res/res_musiconhold.c (original)
+++ team/crichter/0.4.0/res/res_musiconhold.c Tue Aug  8 04:35:08 2006
@@ -219,7 +219,7 @@
 			state->pos %= state->class->total_files;
 
 			/* check to see if this file's format can be opened */
-			if (ast_fileexists(state->class->filearray[state->pos], NULL, NULL) != -1)
+			if (ast_fileexists(state->class->filearray[state->pos], NULL, NULL) > 0)
 				break;
 
 		}



More information about the asterisk-commits mailing list