[asterisk-commits] rizzo: branch rizzo/astobj2 r47364 - /team/rizzo/astobj2/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Nov 9 08:33:33 MST 2006


Author: rizzo
Date: Thu Nov  9 09:33:33 2006
New Revision: 47364

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47364
Log:
a small number of simplifications, almost all applicable to
trunk as well.


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47364&r1=47363&r2=47364
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Thu Nov  9 09:33:33 2006
@@ -3105,6 +3105,8 @@
 		ast_channel_lock(p->owner);
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name);
+		if (p->owner->tech_pvt)	/* i believe that's always */
+			pvt_unref(p->owner->tech_pvt);
 		p->owner->tech_pvt = NULL;
 		ast_channel_unlock(p->owner);
 	}
@@ -3456,6 +3458,8 @@
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 		ast_clear_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER);	/* Really hang up next time */
 		ast_clear_flag(&p->flags[0], SIP_NEEDDESTROY);
+		if (p->owner->tech_pvt)	/* i believe that's always */
+			pvt_unref(p->owner->tech_pvt);
 		p->owner->tech_pvt = NULL;
 		p->owner = NULL;  /* Owner will be gone after we return, so take it away */
 		return 0;
@@ -3997,7 +4001,7 @@
 	tmp->rawwriteformat = fmt;
 	tmp->readformat = fmt;
 	tmp->rawreadformat = fmt;
-	tmp->tech_pvt = i;
+	tmp->tech_pvt = pvt_ref(i);
 
 	tmp->callgroup = i->callgroup;
 	tmp->pickupgroup = i->pickupgroup;
@@ -16836,10 +16840,9 @@
 
 static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan)
 {
-	struct sip_pvt *p;
+	struct sip_pvt *p = chan->tech_pvt;
 	struct ast_udptl *udptl = NULL;
 	
-	p = chan->tech_pvt;
 	if (!p)
 		return NULL;
 	
@@ -16852,9 +16855,8 @@
 
 static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
 {
-	struct sip_pvt *p;
-	
-	p = chan->tech_pvt;
+	struct sip_pvt *p = chan->tech_pvt;
+
 	if (!p)
 		return -1;
 	sip_pvt_lock(p);
@@ -16875,7 +16877,6 @@
 			ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
 		}
 	}
-	/* Reset lastrtprx timer */
 	p->lastrtprx = p->lastrtptx = time(NULL);
 	sip_pvt_unlock(p);
 	return 0;
@@ -16883,10 +16884,9 @@
 
 static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_pvt *pvt, int reinvite)
 {
-	struct sip_pvt *p;
+	struct sip_pvt *p = chan->tech_pvt;
 	int flag = 0;
 	
-	p = chan->tech_pvt;
 	if (!p || !pvt->udptl)
 		return -1;
 	
@@ -16923,10 +16923,6 @@
 				ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
 			}
 		}
-		/* Reset lastrtprx timer */
-		p->lastrtprx = p->lastrtptx = time(NULL);
-		sip_pvt_unlock(p);
-		return 0;
 	} else {	/* If we are handling sending 200 OK to the other side of the bridge */
 		if (ast_test_flag(&p->flags[0], SIP_CAN_REINVITE) && ast_test_flag(&pvt->flags[0], SIP_CAN_REINVITE)) {
 			ast_udptl_get_peer(pvt->udptl, &p->udptlredirip);
@@ -16947,20 +16943,20 @@
 			ast_log(LOG_DEBUG, "T38 changed state to %d on channel %s\n", p->t38.state, chan ? chan->name : "<none>");
 		}
 		transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
-		p->lastrtprx = p->lastrtptx = time(NULL);
-		sip_pvt_unlock(p);
-		return 0;
-	}
+	}
+	p->lastrtprx = p->lastrtptx = time(NULL);
+	sip_pvt_unlock(p);
+	return 0;
 }
 
 
 /*! \brief Returns null if we can't reinvite audio (part of RTP interface) */
 static enum ast_rtp_get_result sip_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
 {
-	struct sip_pvt *p = NULL;
+	struct sip_pvt *p = chan->tech_pvt;
 	enum ast_rtp_get_result res = AST_RTP_TRY_PARTIAL;
 
-	if (!(p = chan->tech_pvt))
+	if (!p)
 		return AST_RTP_GET_FAILED;
 
 	sip_pvt_lock(p);
@@ -16984,10 +16980,10 @@
 /*! \brief Returns null if we can't reinvite video (part of RTP interface) */
 static enum ast_rtp_get_result sip_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
 {
-	struct sip_pvt *p = NULL;
+	struct sip_pvt *p = chan->tech_pvt;
 	enum ast_rtp_get_result res = AST_RTP_TRY_PARTIAL;
 	
-	if (!(p = chan->tech_pvt))
+	if (!p)
 		return AST_RTP_GET_FAILED;
 
 	sip_pvt_lock(p);
@@ -17009,10 +17005,9 @@
 /*! \brief Set the RTP peer for this call */
 static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active)
 {
-	struct sip_pvt *p;
+	struct sip_pvt *p = chan->tech_pvt;
 	int changed = 0;
 
-	p = chan->tech_pvt;
 	if (!p) 
 		return -1;
 	sip_pvt_lock(p);



More information about the asterisk-commits mailing list