[asterisk-commits] oej: branch oej/earlyrtpfix r53096 - in /team/oej/earlyrtpfix: ./ apps/ chann...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Feb 1 14:50:12 MST 2007


Author: oej
Date: Thu Feb  1 15:50:11 2007
New Revision: 53096

URL: http://svn.digium.com/view/asterisk?view=rev&rev=53096
Log:
Update

Modified:
    team/oej/earlyrtpfix/   (props changed)
    team/oej/earlyrtpfix/apps/app_meetme.c
    team/oej/earlyrtpfix/apps/app_queue.c
    team/oej/earlyrtpfix/apps/app_rpt.c
    team/oej/earlyrtpfix/apps/app_userevent.c
    team/oej/earlyrtpfix/channels/chan_h323.c
    team/oej/earlyrtpfix/channels/chan_iax2.c
    team/oej/earlyrtpfix/channels/chan_mgcp.c
    team/oej/earlyrtpfix/channels/chan_misdn.c
    team/oej/earlyrtpfix/channels/chan_sip.c
    team/oej/earlyrtpfix/channels/chan_skinny.c
    team/oej/earlyrtpfix/channels/chan_zap.c
    team/oej/earlyrtpfix/configs/sip.conf.sample
    team/oej/earlyrtpfix/funcs/func_strings.c
    team/oej/earlyrtpfix/main/asterisk.c
    team/oej/earlyrtpfix/main/cdr.c
    team/oej/earlyrtpfix/main/http.c
    team/oej/earlyrtpfix/main/manager.c
    team/oej/earlyrtpfix/main/pbx.c
    team/oej/earlyrtpfix/main/rtp.c
    team/oej/earlyrtpfix/pbx/pbx_dundi.c
    team/oej/earlyrtpfix/pbx/pbx_spool.c
    team/oej/earlyrtpfix/res/res_musiconhold.c

Propchange: team/oej/earlyrtpfix/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.

Propchange: team/oej/earlyrtpfix/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/oej/earlyrtpfix/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Feb  1 15:50:11 2007
@@ -1,1 +1,1 @@
-/branches/1.4:1-53018
+/branches/1.4:1-53095

Modified: team/oej/earlyrtpfix/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/apps/app_meetme.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/apps/app_meetme.c (original)
+++ team/oej/earlyrtpfix/apps/app_meetme.c Thu Feb  1 15:50:11 2007
@@ -1072,6 +1072,7 @@
 		pthread_attr_init(&conf->attr);
 		pthread_attr_setdetachstate(&conf->attr, PTHREAD_CREATE_DETACHED);
 		ast_pthread_create_background(&conf->recordthread, &conf->attr, recordthread, conf);
+		pthread_attr_destroy(&conf->attr);
 	}
 
 	time(&user->jointime);

Modified: team/oej/earlyrtpfix/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/apps/app_queue.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/apps/app_queue.c (original)
+++ team/oej/earlyrtpfix/apps/app_queue.c Thu Feb  1 15:50:11 2007
@@ -542,7 +542,7 @@
 	AST_LIST_UNLOCK(&interfaces);
 
 	if (!curint) {
-		if (option_debug)
+		if (option_debug > 2)
 			ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
 		free(sc);
 		return NULL;
@@ -609,6 +609,7 @@
 		ast_log(LOG_WARNING, "Failed to create update thread!\n");
 		free(sc);
 	}
+	pthread_attr_destroy(&attr);
 
 	return 0;
 }
@@ -921,10 +922,11 @@
 	}
 }
 
-static void rt_handle_member_record(struct call_queue *q, char *interface, const char *membername, const char *penalty_str)
+static void rt_handle_member_record(struct call_queue *q, char *interface, const char *membername, const char *penalty_str, const char *paused_str)
 {
 	struct member *m, *prev_m;
 	int penalty = 0;
+	int paused  = 0;
 
 	if (penalty_str) {
 		penalty = atoi(penalty_str);
@@ -932,6 +934,12 @@
 			penalty = 0;
 	}
 
+	if (paused_str) {
+		paused = atoi(paused_str);
+		if (paused < 0)
+			paused = 0;
+	}
+
 	/* Find the member, or the place to put a new one. */
 	for (m = q->members, prev_m = NULL;
 		m && strcmp(m->interface, interface);
@@ -939,7 +947,7 @@
 
 	/* Create a new one if not found, else update penalty */
 	if (!m) {
-		if ((m = create_queue_member(interface, membername, penalty, 0))) {
+		if ((m = create_queue_member(interface, membername, penalty, paused))) {
 			m->dead = 0;
 			add_to_interfaces(interface);
 			if (prev_m) {
@@ -950,6 +958,8 @@
 		}
 	} else {
 		m->dead = 0;	/* Do not delete this one. */
+		if (paused_str)
+			m->paused = paused;
 		m->penalty = penalty;
 	}
 }
@@ -1073,7 +1083,8 @@
 	while ((interface = ast_category_browse(member_config, interface))) {
 		rt_handle_member_record(q, interface,
 			S_OR(ast_variable_retrieve(member_config, interface, "membername"), interface),
-			ast_variable_retrieve(member_config, interface, "penalty"));
+			ast_variable_retrieve(member_config, interface, "penalty"),
+			ast_variable_retrieve(member_config, interface, "paused"));
 	}
 
 	/* Delete all realtime members that have been deleted in DB. */

Modified: team/oej/earlyrtpfix/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/apps/app_rpt.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/apps/app_rpt.c (original)
+++ team/oej/earlyrtpfix/apps/app_rpt.c Thu Feb  1 15:50:11 2007
@@ -2613,6 +2613,7 @@
         pthread_attr_init(&attr);
         pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 	res = ast_pthread_create(&tele->threadid,&attr,rpt_tele_thread,(void *) tele);
+	pthread_attr_destroy(&attr);
 	if(res < 0){
 		rpt_mutex_lock(&myrpt->lock);
 		remque((struct qlem *) tele); /* We don't like stuck transmitters, remove it from the queue */
@@ -3380,6 +3381,7 @@
 	pthread_attr_init(&attr);
 	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 	ast_pthread_create(&myrpt->rpt_call_thread,&attr,rpt_call,(void *) myrpt);
+	pthread_attr_destroy(&attr);
 	return DC_COMPLETE;
 }
 
@@ -5936,6 +5938,7 @@
 		        pthread_attr_init(&attr);
 		        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 			ast_pthread_create(&myrpt->rpt_call_thread,&attr,rpt_call,(void *)myrpt);
+			pthread_attr_destroy(&attr);
 			return;
 		}
 	}
@@ -7219,6 +7222,7 @@
 	        pthread_attr_init(&attr);
 	        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 		ast_pthread_create(&rpt_vars[i].rpt_thread,&attr,rpt,(void *) &rpt_vars[i]);
+		pthread_attr_destroy(&attr);
 	}
 	usleep(500000);
 	for(;;)
@@ -7254,6 +7258,7 @@
 			        pthread_attr_init(&attr);
 	 		        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 				ast_pthread_create(&rpt_vars[i].rpt_thread,&attr,rpt,(void *) &rpt_vars[i]);
+				pthread_attr_destroy(&attr);
 				ast_log(LOG_WARNING, "rpt_thread restarted on node %s\n", rpt_vars[i].name);
 			}
 

Modified: team/oej/earlyrtpfix/apps/app_userevent.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/apps/app_userevent.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/apps/app_userevent.c (original)
+++ team/oej/earlyrtpfix/apps/app_userevent.c Thu Feb  1 15:50:11 2007
@@ -83,7 +83,7 @@
 		buflen += 2;
 	}
 
-	manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s\r\n", args.eventname, buf);
+	manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, buf);
 
 	ast_module_user_remove(u);
 

Modified: team/oej/earlyrtpfix/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/channels/chan_h323.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/channels/chan_h323.c (original)
+++ team/oej/earlyrtpfix/channels/chan_h323.c Thu Feb  1 15:50:11 2007
@@ -35,7 +35,7 @@
 
 /*** MODULEINFO
 	<depend>openh323</depend>
-	<defaultenabled>no</defaultenabled>
+	<defaultenabled>yes</defaultenabled>
  ***/
 
 #ifdef __cplusplus
@@ -2524,8 +2524,10 @@
 			monitor_thread = AST_PTHREADT_NULL;
 			ast_mutex_unlock(&monlock);
 			ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
+			pthread_attr_destroy(&attr);
 			return -1;
 		}
+		pthread_attr_destroy(&attr);
 	}
 	ast_mutex_unlock(&monlock);
 	return 0;

Modified: team/oej/earlyrtpfix/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/channels/chan_iax2.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/channels/chan_iax2.c (original)
+++ team/oej/earlyrtpfix/channels/chan_iax2.c Thu Feb  1 15:50:11 2007
@@ -6059,6 +6059,8 @@
 	if (ast_pthread_create(&newthread, &attr, dp_lookup_thread, dpr)) {
 		ast_log(LOG_WARNING, "Unable to start lookup thread!\n");
 	}
+
+	pthread_attr_destroy(&attr);
 }
 
 struct iax_dual {
@@ -6133,8 +6135,11 @@
 
 		d->chan1 = chan1m;
 		d->chan2 = chan2m;
-		if (!ast_pthread_create_background(&th, &attr, iax_park_thread, d))
+		if (!ast_pthread_create_background(&th, &attr, iax_park_thread, d)) {
+			pthread_attr_destroy(&attr);
 			return 0;
+		}
+		pthread_attr_destroy(&attr);
 		free(d);
 	}
 	return -1;

Modified: team/oej/earlyrtpfix/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/channels/chan_mgcp.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/channels/chan_mgcp.c (original)
+++ team/oej/earlyrtpfix/channels/chan_mgcp.c Thu Feb  1 15:50:11 2007
@@ -2995,6 +2995,7 @@
 			/*ast_queue_control(sub->owner, AST_CONTROL_ANSWER);*/
 		}
 	}
+	pthread_attr_destroy(&attr);
 }
 
 static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req, struct sockaddr_in *sin)

Modified: team/oej/earlyrtpfix/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/channels/chan_misdn.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/channels/chan_misdn.c (original)
+++ team/oej/earlyrtpfix/channels/chan_misdn.c Thu Feb  1 15:50:11 2007
@@ -2012,7 +2012,7 @@
 	if (newbc->nt) stop_bc_tones(ch);
 
 	ch->state=MISDN_CALLING;
-	
+
 	return 0; 
 }
 
@@ -4174,7 +4174,9 @@
 	break;
 	case EVENT_PROCEEDING:
 	{
-		
+		if (bc->channel) 
+			update_name(ch->ast,bc->port,bc->channel);
+
 		if ( misdn_cap_is_speech(bc->capability) &&
 		     misdn_inband_avail(bc) ) {
 			start_bc_tones(ch);
@@ -4186,6 +4188,10 @@
 	}
 	break;
 	case EVENT_PROGRESS:
+
+		if (bc->channel) 
+			update_name(ch->ast,bc->port,bc->channel);
+
 		if (!bc->nt ) {
 			if ( misdn_cap_is_speech(bc->capability) &&
 			     misdn_inband_avail(bc)
@@ -4202,6 +4208,9 @@
 		
 	case EVENT_ALERTING:
 	{
+		if (bc->channel) 
+			update_name(ch->ast,bc->port,bc->channel);
+
 		ch->state = MISDN_ALERTING;
 		
 		ast_queue_control(ch->ast, AST_CONTROL_RINGING);

Modified: team/oej/earlyrtpfix/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/channels/chan_sip.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/channels/chan_sip.c (original)
+++ team/oej/earlyrtpfix/channels/chan_sip.c Thu Feb  1 15:50:11 2007
@@ -2890,6 +2890,12 @@
 	if (sip_debug_test_pvt(p) || option_debug > 2)
 		ast_verbose("Really destroying SIP dialog '%s' Method: %s\n", p->callid, sip_methods[p->method].text);
 
+	if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
+		update_call_counter(p, DEC_CALL_LIMIT);
+		if (option_debug > 1)
+			ast_log(LOG_DEBUG, "This call did not properly clean up call limits. Call ID %s\n", p->callid);
+	}
+
 	/* Remove link from peer to subscription of MWI */
 	if (p->relatedpeer && p->relatedpeer->mwipvt)
 		p->relatedpeer->mwipvt = NULL;
@@ -3025,8 +3031,10 @@
 	/* incoming and outgoing affects the inUse counter */
 	case DEC_CALL_LIMIT:
 		if ( *inuse > 0 ) {
-			if (ast_test_flag(&fup->flags[0], SIP_INC_COUNT))
+			if (ast_test_flag(&fup->flags[0], SIP_INC_COUNT)) {
 				(*inuse)--;
+				ast_clear_flag(&fup->flags[0], SIP_INC_COUNT);
+			}
 		} else {
 			*inuse = 0;
 		}
@@ -3534,7 +3542,7 @@
 				we simply forget the frames if we get modem frames before the bridge is up.
 				Fax will re-transmit.
 			*/
-			if (p->udptl && ast->_state != AST_STATE_UP) 
+			if (p->udptl && ast->_state == AST_STATE_UP) 
 				res = ast_udptl_write(p->udptl, frame);
 			ast_mutex_unlock(&p->lock);
 		}
@@ -12658,8 +12666,10 @@
 			/* Could not start thread */
 			free(d);	/* We don't need it anymore. If thread is created, d will be free'd
 					   by sip_park_thread() */
+			pthread_attr_destroy(&attr);
 			return 0;
 		}
+		pthread_attr_destroy(&attr);
 	} 
 	return -1;
 }
@@ -15141,9 +15151,13 @@
 		- not registered			AST_DEVICE_UNAVAILABLE
 		- registered				AST_DEVICE_NOT_INUSE
 		- fixed IP (!dynamic)			AST_DEVICE_NOT_INUSE
+	
+	Peers that does not have a known call and can't be reached by OPTIONS
+		- unreachable				AST_DEVICE_UNAVAILABLE
 
 	If we return AST_DEVICE_UNKNOWN, the device state engine will try to find
 	out a state by walking the channel list.
+
 */
 static int sip_devicestate(void *data)
 {
@@ -15167,27 +15181,35 @@
 	if ((p = find_peer(host, NULL, 1))) {
 		if (p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) {
 			/* we have an address for the peer */
-			/* if qualify is turned on, check the status */
-			if (p->maxms && (p->lastms > p->maxms)) {
+		
+			/* Check status in this order
+				- Hold
+				- Ringing
+				- Busy (enforced only by call limit)
+				- Inuse (we have a call)
+				- Unreachable (qualify)
+			   If we don't find any of these state, report AST_DEVICE_NOT_INUSE
+			   for registered devices */
+
+			if (p->onHold)
+				/* First check for hold or ring states */
+				res = AST_DEVICE_ONHOLD;
+			else if (p->inRinging) {
+				if (p->inRinging == p->inUse)
+					res = AST_DEVICE_RINGING;
+				else
+					res = AST_DEVICE_RINGINUSE;
+			} else if (p->call_limit && (p->inUse == p->call_limit))
+				/* check call limit */
+				res = AST_DEVICE_BUSY;
+			else if (p->call_limit && p->inUse)
+				/* Not busy, but we do have a call */
+				res = AST_DEVICE_INUSE;
+			else if (p->maxms && (p->lastms > p->maxms)) 
+				/* We don't have a call. Are we reachable at all? Requires qualify= */
 				res = AST_DEVICE_UNAVAILABLE;
-			} else {
-				/* qualify is not on, or the peer is responding properly */
-				/* check call limit */
-				if (p->call_limit && (p->inUse == p->call_limit))
-					res = AST_DEVICE_BUSY;
-				else if (p->call_limit && p->inUse)
-					res = AST_DEVICE_INUSE;
-				else
-					res = AST_DEVICE_NOT_INUSE;
-				if (p->onHold)
-					res = AST_DEVICE_ONHOLD;
-				else if (p->inRinging) {
-					if (p->inRinging == p->inUse)
-						res = AST_DEVICE_RINGING;
-					else
-						res = AST_DEVICE_RINGINUSE;
-				}
-			}
+			else	/* Default reply if we're registered and have no other data */
+				res = AST_DEVICE_NOT_INUSE;
 		} else {
 			/* there is no address, it's unavailable */
 			res = AST_DEVICE_UNAVAILABLE;

Modified: team/oej/earlyrtpfix/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/channels/chan_skinny.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/channels/chan_skinny.c (original)
+++ team/oej/earlyrtpfix/channels/chan_skinny.c Thu Feb  1 15:50:11 2007
@@ -4302,6 +4302,7 @@
 	if (skinnydebug)
 		ast_verbose("killing accept thread\n");
 	close(as);
+	pthread_attr_destroy(&attr);
 	return 0;
 }
 

Modified: team/oej/earlyrtpfix/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/channels/chan_zap.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/channels/chan_zap.c (original)
+++ team/oej/earlyrtpfix/channels/chan_zap.c Thu Feb  1 15:50:11 2007
@@ -3590,9 +3590,6 @@
 	pthread_t threadid;
 	pthread_attr_t attr;
 	struct ast_channel *chan;
-
-	pthread_attr_init(&attr);
-	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 
 	index = zt_get_index(ast, p, 0);
 	mysig = p->sig;
@@ -4178,6 +4175,8 @@
 						if (res)
 							ast_log(LOG_WARNING, "Unable to start dial recall tone on channel %d\n", p->channel);
 						p->owner = chan;
+						pthread_attr_init(&attr);
+						pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 						if (!chan) {
 							ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", p->channel);
 						} else if (ast_pthread_create(&threadid, &attr, ss_thread, chan)) {
@@ -4195,7 +4194,8 @@
 									!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
 							}
 							p->subs[SUB_THREEWAY].needhold = 1;
-						}		
+						}
+						pthread_attr_destroy(&attr);
 					}
 				} else {
 					/* Already have a 3 way call */
@@ -6686,6 +6686,7 @@
 				"interface %d\n", i->channel);
 		}
 	}
+	pthread_attr_destroy(&attr);
 	return 0;
 }
 
@@ -6908,10 +6909,12 @@
 		if (ast_pthread_create_background(&monitor_thread, &attr, do_monitor, NULL) < 0) {
 			ast_mutex_unlock(&monlock);
 			ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
+			pthread_attr_destroy(&attr);
 			return -1;
 		}
 	}
 	ast_mutex_unlock(&monlock);
+	pthread_attr_destroy(&attr);
 	return 0;
 }
 
@@ -8248,9 +8251,6 @@
 	char plancallingani[256];
 	char calledtonstr[10];
 	
-	pthread_attr_init(&attr);
-	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-
 	gettimeofday(&lastidle, NULL);
 	if (!ast_strlen_zero(pri->idledial) && !ast_strlen_zero(pri->idleext)) {
 		/* Need to do idle dialing, check to be sure though */
@@ -8741,6 +8741,8 @@
 								pbx_builtin_setvar_helper(c, "PRIREDIRECTREASON", redirectingreason2str(e->ring.redirectingreason));
 							
 							ast_mutex_lock(&pri->lock);
+							pthread_attr_init(&attr);
+							pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 							if (c && !ast_pthread_create(&threadid, &attr, ss_thread, c)) {
 								if (option_verbose > 2)
 									ast_verbose(VERBOSE_PREFIX_3 "Accepting overlap call from '%s' to '%s' on channel %d/%d, span %d\n",
@@ -8756,6 +8758,7 @@
 									pri->pvts[chanpos]->call = NULL;
 								}
 							}
+							pthread_attr_destroy(&attr);
 						} else  {
 							ast_mutex_unlock(&pri->lock);
 							/* Release PRI lock while we create the channel */

Modified: team/oej/earlyrtpfix/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/configs/sip.conf.sample?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/configs/sip.conf.sample (original)
+++ team/oej/earlyrtpfix/configs/sip.conf.sample Thu Feb  1 15:50:11 2007
@@ -512,6 +512,7 @@
 					; Call-limits will not be enforced on real-time peers,
 					; since they are not stored in-memory
 ;port=80				; The port number we want to connect to on the remote side
+					; Also used as "defaultport" in combination with "defaultip" settings
 
 ;------------------------------------------------------------------------------
 ; Definitions of locally connected SIP devices

Modified: team/oej/earlyrtpfix/funcs/func_strings.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/funcs/func_strings.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/funcs/func_strings.c (original)
+++ team/oej/earlyrtpfix/funcs/func_strings.c Thu Feb  1 15:50:11 2007
@@ -46,7 +46,7 @@
 static int function_fieldqty(struct ast_channel *chan, char *cmd,
 			     char *parse, char *buf, size_t len)
 {
-	char *varval;
+	char *varsubst, varval[8192] = "", *varval2 = varval;
 	int fieldcount = 0;
 	AST_DECLARE_APP_ARGS(args,
 			     AST_APP_ARG(varname);
@@ -55,8 +55,11 @@
 
 	AST_STANDARD_APP_ARGS(args, parse);
 	if (args.delim) {
-		pbx_retrieve_variable(chan, args.varname, &varval, buf, len, NULL);
-		while (strsep(&varval, args.delim))
+		varsubst = alloca(strlen(args.varname) + 4);
+
+		sprintf(varsubst, "${%s}", args.varname);
+		pbx_substitute_variables_helper(chan, varsubst, varval, sizeof(varval) - 1);
+		while (strsep(&varval2, args.delim))
 			fieldcount++;
 	} else {
 		fieldcount = 1;

Modified: team/oej/earlyrtpfix/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/main/asterisk.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/main/asterisk.c (original)
+++ team/oej/earlyrtpfix/main/asterisk.c Thu Feb  1 15:50:11 2007
@@ -2455,7 +2455,7 @@
 	if (getenv("HOME")) 
 		snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
 	/* Check for options */
-	while ((c = getopt(argc, argv, "mtThfdvVqprRgciInx:U:G:C:L:M:")) != -1) {
+	while ((c = getopt(argc, argv, "mtThfFdvVqprRgciInx:U:G:C:L:M:")) != -1) {
 		switch (c) {
 #if HAVE_WORKING_FORK
 		case 'F':

Modified: team/oej/earlyrtpfix/main/cdr.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/main/cdr.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/main/cdr.c (original)
+++ team/oej/earlyrtpfix/main/cdr.c Thu Feb  1 15:50:11 2007
@@ -860,6 +860,7 @@
 			if (option_debug)
 				ast_log(LOG_DEBUG, "CDR multi-threaded batch processing begins now\n");
 		}
+		pthread_attr_destroy(&attr);
 	}
 }
 

Modified: team/oej/earlyrtpfix/main/http.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/main/http.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/main/http.c (original)
+++ team/oej/earlyrtpfix/main/http.c Thu Feb  1 15:50:11 2007
@@ -539,6 +539,7 @@
 				fclose(ser->f);
 				free(ser);
 			}
+			pthread_attr_destroy(&attr);
 		} else {
 			ast_log(LOG_WARNING, "fdopen failed!\n");
 			close(ser->fd);

Modified: team/oej/earlyrtpfix/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/main/manager.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/main/manager.c (original)
+++ team/oej/earlyrtpfix/main/manager.c Thu Feb  1 15:50:11 2007
@@ -1752,6 +1752,7 @@
 			} else {
 				res = 0;
 			}
+			pthread_attr_destroy(&attr);
 		}
 	} else if (!ast_strlen_zero(app)) {
         	res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);

Modified: team/oej/earlyrtpfix/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/main/pbx.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/main/pbx.c (original)
+++ team/oej/earlyrtpfix/main/pbx.c Thu Feb  1 15:50:11 2007
@@ -1097,8 +1097,7 @@
 	return ret;
 }
 
-/*! \brief  pbx_retrieve_variable: Support for Asterisk built-in variables and
-      functions in the dialplan
+/*! \brief  pbx_retrieve_variable: Support for Asterisk built-in variables
   ---*/
 void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp)
 {
@@ -2585,8 +2584,10 @@
 	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 	if (ast_pthread_create(&t, &attr, pbx_thread, c)) {
 		ast_log(LOG_WARNING, "Failed to create new channel thread\n");
+		pthread_attr_destroy(&attr);
 		return AST_PBX_FAILED;
 	}
+	pthread_attr_destroy(&attr);
 
 	return AST_PBX_SUCCESS;
 }
@@ -5048,8 +5049,10 @@
 			}
 			ast_hangup(chan);
 			res = -1;
+			pthread_attr_destroy(&attr);
 			goto outgoing_exten_cleanup;
 		}
+		pthread_attr_destroy(&attr);
 		res = 0;
 	}
 outgoing_exten_cleanup:
@@ -5151,6 +5154,7 @@
 							if (locked_channel)
 								*locked_channel = chan;
 						}
+						pthread_attr_destroy(&attr);
 					}
 				}
 			} else {
@@ -5209,11 +5213,13 @@
 				ast_channel_unlock(chan);
 			ast_hangup(chan);
 			res = -1;
+			pthread_attr_destroy(&attr);
 			goto outgoing_app_cleanup;
 		} else {
 			if (locked_channel)
 				*locked_channel = chan;
 		}
+		pthread_attr_destroy(&attr);
 		res = 0;
 	}
 outgoing_app_cleanup:

Modified: team/oej/earlyrtpfix/main/rtp.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/main/rtp.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/main/rtp.c (original)
+++ team/oej/earlyrtpfix/main/rtp.c Thu Feb  1 15:50:11 2007
@@ -1067,7 +1067,7 @@
 		}
 		return 0;
 	} else if (rtp_debug_test_addr(&bridged->them))
-			ast_verbose("Sent RTP P2P packet to %s:%d (type %-2.2d, len %-6.6u)\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port), bridged_payload, len - hdrlen);
+			ast_verbose("Sent RTP P2P packet to %s:%u (type %-2.2d, len %-6.6u)\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port), bridged_payload, len - hdrlen);
 
 	return 0;
 }
@@ -1215,7 +1215,7 @@
 		rtp->themssrc = ntohl(rtpheader[2]); /* Record their SSRC to put in future RR */
 	
 	if (rtp_debug_test_addr(&sin))
-		ast_verbose("Got  RTP packet from    %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+		ast_verbose("Got  RTP packet from    %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
 			ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp,res - hdrlen);
 
 	rtpPT = ast_rtp_lookup_pt(rtp, payloadtype);
@@ -1238,7 +1238,7 @@
 				event_end >>= 24;
 				duration = ntohl(*((unsigned int *)(data)));
 				duration &= 0xFFFF;
-				ast_verbose("Got  RTP RFC2833 from   %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u, mark %d, event %08x, end %d, duration %-5.5d) \n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp, res - hdrlen, (mark?1:0), event, ((event_end & 0x80)?1:0), duration);
+				ast_verbose("Got  RTP RFC2833 from   %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u, mark %d, event %08x, end %d, duration %-5.5d) \n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp, res - hdrlen, (mark?1:0), event, ((event_end & 0x80)?1:0), duration);
 			}
 			f = process_rfc2833(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen, seqno);
 		} else if (rtpPT.code == AST_RTP_CISCO_DTMF) {
@@ -2123,11 +2123,11 @@
 		rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (rtp->send_duration));
 		res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
 		if (res < 0) 
-			ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
+			ast_log(LOG_ERROR, "RTP Transmission error to %s:%u: %s\n",
 				ast_inet_ntoa(rtp->them.sin_addr),
 				ntohs(rtp->them.sin_port), strerror(errno));
 		if (rtp_debug_test_addr(&rtp->them))
-			ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+			ast_verbose("Sent RTP DTMF packet to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
 				    ast_inet_ntoa(rtp->them.sin_addr),
 				    ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
 		/* Increment sequence number */
@@ -2171,7 +2171,7 @@
 			ast_inet_ntoa(rtp->them.sin_addr),
 			ntohs(rtp->them.sin_port), strerror(errno));
 	if (rtp_debug_test_addr(&rtp->them))
-		ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+		ast_verbose("Sent RTP DTMF packet to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
 			    ast_inet_ntoa(rtp->them.sin_addr),
 			    ntohs(rtp->them.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
 
@@ -2227,7 +2227,7 @@
 				ast_inet_ntoa(rtp->them.sin_addr),
 				ntohs(rtp->them.sin_port), strerror(errno));
 		if (rtp_debug_test_addr(&rtp->them))
-			ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+			ast_verbose("Sent RTP DTMF packet to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
 				    ast_inet_ntoa(rtp->them.sin_addr),
 				    ntohs(rtp->them.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
 	}
@@ -2507,7 +2507,7 @@
 		if (res <0) 
 			ast_log(LOG_ERROR, "RTP Comfort Noise Transmission error to %s:%d: %s\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
 		if (rtp_debug_test_addr(&rtp->them))
-			ast_verbose("Sent Comfort Noise RTP packet to %s:%d (type %d, seq %d, ts %u, len %d)\n"
+			ast_verbose("Sent Comfort Noise RTP packet to %s:%u (type %d, seq %u, ts %u, len %d)\n"
 					, ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastts,res - hdrlen);		   
 		   
 	}
@@ -2594,7 +2594,7 @@
 		}
 				
 		if (rtp_debug_test_addr(&rtp->them))
-			ast_verbose("Sent RTP packet to      %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+			ast_verbose("Sent RTP packet to      %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
 					ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), codec, rtp->seqno, rtp->lastts,res - hdrlen);
 	}
 
@@ -2746,7 +2746,7 @@
 	int oldcodec0 = codec0, oldcodec1 = codec1;
 	struct sockaddr_in ac1 = {0,}, vac1 = {0,}, ac0 = {0,}, vac0 = {0,};
 	struct sockaddr_in t1 = {0,}, vt1 = {0,}, t0 = {0,}, vt0 = {0,};
-
+	
 	/* Set it up so audio goes directly between the two endpoints */
 
 	/* Test the first channel */
@@ -2864,6 +2864,19 @@
 			if ((fr->subclass == AST_CONTROL_HOLD) ||
 			    (fr->subclass == AST_CONTROL_UNHOLD) ||
 			    (fr->subclass == AST_CONTROL_VIDUPDATE)) {
+				if (fr->subclass == AST_CONTROL_HOLD) {
+					/* If we someone went on hold we want the other side to reinvite back to us */
+					if (who == c0)
+						pr1->set_rtp_peer(c1, NULL, NULL, 0, 0);
+					else
+						pr0->set_rtp_peer(c0, NULL, NULL, 0, 0);
+				} else if (fr->subclass == AST_CONTROL_UNHOLD) {
+					/* If they went off hold they should go back to being direct */
+					if (who == c0)
+						pr1->set_rtp_peer(c1, p0, vp0, codec0, ast_test_flag(p0, FLAG_NAT_ACTIVE));
+					else
+						pr0->set_rtp_peer(c0, p1, vp1, codec1, ast_test_flag(p1, FLAG_NAT_ACTIVE));
+				}
 				ast_indicate_data(other, fr->subclass, fr->data, fr->datalen);
 				ast_frfree(fr);
 			} else {
@@ -2873,9 +2886,14 @@
 				return AST_BRIDGE_COMPLETE;
 			}
 		} else {
-			if ((fr->frametype == AST_FRAME_DTMF) ||
+			if ((fr->frametype == AST_FRAME_DTMF_BEGIN) ||
+			    (fr->frametype == AST_FRAME_DTMF) ||
 			    (fr->frametype == AST_FRAME_VOICE) ||
-			    (fr->frametype == AST_FRAME_VIDEO)) {
+			    (fr->frametype == AST_FRAME_VIDEO) ||
+			    (fr->frametype == AST_FRAME_IMAGE) ||
+			    (fr->frametype == AST_FRAME_HTML) ||
+			    (fr->frametype == AST_FRAME_MODEM) ||
+			    (fr->frametype == AST_FRAME_TEXT)) {
 				ast_write(other, fr);
 			}
 			ast_frfree(fr);
@@ -3082,12 +3100,17 @@
 				break;
 			}
 		} else {
-			/* If this is a DTMF, voice, or video frame write it to the other channel */
-			if ((fr->frametype == AST_FRAME_DTMF) ||
+			if ((fr->frametype == AST_FRAME_DTMF_BEGIN) ||
+			    (fr->frametype == AST_FRAME_DTMF) ||
 			    (fr->frametype == AST_FRAME_VOICE) ||
-			    (fr->frametype == AST_FRAME_VIDEO)) {
+			    (fr->frametype == AST_FRAME_VIDEO) ||
+			    (fr->frametype == AST_FRAME_IMAGE) ||
+			    (fr->frametype == AST_FRAME_HTML) ||
+			    (fr->frametype == AST_FRAME_MODEM) ||
+			    (fr->frametype == AST_FRAME_TEXT)) {
 				ast_write(other, fr);
 			}
+
 			ast_frfree(fr);
 		}
 		/* Swap priority */

Modified: team/oej/earlyrtpfix/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/pbx/pbx_dundi.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/pbx/pbx_dundi.c (original)
+++ team/oej/earlyrtpfix/pbx/pbx_dundi.c Thu Feb  1 15:50:11 2007
@@ -783,8 +783,10 @@
 			memset(&ied, 0, sizeof(ied));
 			dundi_ie_append_cause(&ied, DUNDI_IE_CAUSE, DUNDI_CAUSE_GENERAL, "Out of threads");
 			dundi_send(trans, DUNDI_COMMAND_EIDRESPONSE, 0, 1, &ied);
+			pthread_attr_destroy(&attr);
 			return -1;
 		}
+		pthread_attr_destroy(&attr);
 	} else {
 		ast_log(LOG_WARNING, "Out of memory!\n");
 		memset(&ied, 0, sizeof(ied));
@@ -1009,8 +1011,10 @@
 			memset(&ied, 0, sizeof(ied));
 			dundi_ie_append_cause(&ied, DUNDI_IE_CAUSE, DUNDI_CAUSE_GENERAL, "Out of threads");
 			dundi_send(trans, DUNDI_COMMAND_PRECACHERP, 0, 1, &ied);
+			pthread_attr_destroy(&attr);
 			return -1;
 		}
+		pthread_attr_destroy(&attr);
 	} else {
 		ast_log(LOG_WARNING, "Out of memory!\n");
 		memset(&ied, 0, sizeof(ied));
@@ -1095,8 +1099,10 @@
 			memset(&ied, 0, sizeof(ied));
 			dundi_ie_append_cause(&ied, DUNDI_IE_CAUSE, DUNDI_CAUSE_GENERAL, "Out of threads");
 			dundi_send(trans, DUNDI_COMMAND_DPRESPONSE, 0, 1, &ied);
+			pthread_attr_destroy(&attr);
 			return -1;
 		}
+		pthread_attr_destroy(&attr);
 	} else {
 		ast_log(LOG_WARNING, "Out of memory!\n");
 		memset(&ied, 0, sizeof(ied));

Modified: team/oej/earlyrtpfix/pbx/pbx_spool.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/pbx/pbx_spool.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/pbx/pbx_spool.c (original)
+++ team/oej/earlyrtpfix/pbx/pbx_spool.c Thu Feb  1 15:50:11 2007
@@ -367,6 +367,7 @@
 		ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret);
 		free_outgoing(o);
 	}
+	pthread_attr_destroy(&attr);
 }
 
 static int scan_service(char *fn, time_t now, time_t atime)
@@ -499,6 +500,7 @@
 		ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret);
 		return -1;
 	}
+	pthread_attr_destroy(&attr);
 	return 0;
 }
 

Modified: team/oej/earlyrtpfix/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/team/oej/earlyrtpfix/res/res_musiconhold.c?view=diff&rev=53096&r1=53095&r2=53096
==============================================================================
--- team/oej/earlyrtpfix/res/res_musiconhold.c (original)
+++ team/oej/earlyrtpfix/res/res_musiconhold.c Thu Feb  1 15:50:11 2007
@@ -218,28 +218,29 @@
 	struct moh_files_state *state = chan->music_state;
 	int tries;
 
+	/* Discontinue a stream if it is running already */
+	if (chan->stream) {
+		ast_closestream(chan->stream);
+		chan->stream = NULL;
+	}
+
+	/* If a specific file has been saved, use it */
 	if (state->save_pos) {
 		state->pos = state->save_pos;
 		state->save_pos = 0;
-	}
-
-	state->samples = 0;
-	if (chan->stream) {
-		ast_closestream(chan->stream);
-		chan->stream = NULL;
+	} else if (ast_test_flag(state->class, MOH_RANDOMIZE)) {
+		/* Get a random file and ensure we can open it */
+		for (tries = 0; tries < 20; tries++) {
+			state->pos = rand() % state->class->total_files;
+			if (ast_fileexists(state->class->filearray[state->pos], NULL, NULL) > 0)
+				break;
+		}
+		state->samples = 0;
+	} else {
+		/* This is easy, just increment our position and make sure we don't exceed the total file count */
 		state->pos++;
 		state->pos %= state->class->total_files;
-	}
-
-	if (ast_test_flag(state->class, MOH_RANDOMIZE)) {
-		/* Try 20 times to find something good */
-		for (tries = 0; tries < 20; tries++) {
-			state->pos = rand() % 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) > 0)
-				break;
-		}
+		state->samples = 0;
 	}
 
 	if (!ast_openstream_full(chan, state->class->filearray[state->pos], chan->language, 1)) {



More information about the asterisk-commits mailing list