[Asterisk-cvs] asterisk/channels chan_vpb.c,1.58,1.59

bkramer at lists.digium.com bkramer at lists.digium.com
Thu Jan 13 22:47:27 CST 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv24505

Modified Files:
	chan_vpb.c 
Log Message:
/ added a ring timer so that an incoming call will termintate if it hasnt
/ been answered before the caller hangs up, and the telco doesnt provide a
/ loop-drop event on caller hang up.


Index: chan_vpb.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_vpb.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- chan_vpb.c	10 Jan 2005 22:09:19 -0000	1.58
+++ chan_vpb.c	14 Jan 2005 04:51:20 -0000	1.59
@@ -146,6 +146,7 @@
 
 #define TIMER_PERIOD_RINGBACK 2000
 #define TIMER_PERIOD_BUSY 700
+#define TIMER_PERIOD_RING 4000
 	  
 #define VPB_EVENTS_ALL (VPB_MRING|VPB_MDIGIT|VPB_MDTMF|VPB_MTONEDETECT|VPB_MTIMEREXP|VPB_MPLAY_UNDERFLOW \
 			|VPB_MRECORD_OVERFLOW|VPB_MSTATION_OFFHOOK|VPB_MSTATION_ONHOOK \
@@ -252,6 +253,9 @@
 	void *ringback_timer; 			/* Void pointer for ringback vpb_timer */
 	int ringback_timer_id;			/* unique timer ID for ringback timer */
 
+	void *ring_timer;			/* Void pointer for ring vpb_timer */
+	int ring_timer_id;			/* unique timer ID for ring timer */
+
 	double lastgrunt;			/* time stamp (secs since epoc) of last grunt event */
 
 	ast_mutex_t lock;			/* This one just protects bridge ptr below */
@@ -693,6 +697,8 @@
 		case VPB_RING:
 			if (p->mode == MODE_FXO) {
 				f.subclass = AST_CONTROL_RING;
+				vpb_timer_stop(p->ring_timer);
+				vpb_timer_start(p->ring_timer);
 			} else
 				f.frametype = -1; /* ignore ring on station port. */
 			break;
@@ -713,6 +719,17 @@
 				vpb_timer_stop(p->ringback_timer);
 				vpb_timer_start(p->ringback_timer);
 				f.frametype = -1;
+			} else if (e->data == p->ring_timer_id) {
+				/* We didnt get another ring in time! */
+				if (p->owner->_state != AST_STATE_UP)  {
+					 /* Assume caller has hung up */
+					vpb_timer_stop(p->ring_timer);
+					f.subclass = AST_CONTROL_HANGUP;
+				} else {
+					vpb_timer_stop(p->ring_timer);
+					f.frametype = -1;
+				}
+				
 			} else {
 				f.frametype = -1; /* Ignore. */
 			}
@@ -1333,6 +1350,9 @@
 
 	tmp->ringback_timer_id = vpb_timer_get_unique_timer_id();
 	vpb_timer_open(&tmp->ringback_timer, tmp->handle, tmp->ringback_timer_id, TIMER_PERIOD_RINGBACK);
+
+	tmp->ring_timer_id = vpb_timer_get_unique_timer_id();
+	vpb_timer_open(&tmp->ring_timer, tmp->handle, tmp->ring_timer_id, TIMER_PERIOD_RING);
 	      
 	if (mode == MODE_FXO){
 		vpb_set_event_mask(tmp->handle, VPB_EVENTS_ALL );




More information about the svn-commits mailing list