[svn-commits] rmudgett: branch rmudgett/native_dahdi r394491 - /team/rmudgett/native_dahdi/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jul 16 15:02:53 CDT 2013


Author: rmudgett
Date: Tue Jul 16 15:02:52 2013
New Revision: 394491

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394491
Log:
chan_dahdi: Remove old bridge routine.

Modified:
    team/rmudgett/native_dahdi/channels/chan_dahdi.c

Modified: team/rmudgett/native_dahdi/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/native_dahdi/channels/chan_dahdi.c?view=diff&rev=394491&r1=394490&r2=394491
==============================================================================
--- team/rmudgett/native_dahdi/channels/chan_dahdi.c (original)
+++ team/rmudgett/native_dahdi/channels/chan_dahdi.c Tue Jul 16 15:02:52 2013
@@ -548,8 +548,6 @@
 
 static int restart_monitor(void);
 
-static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
-
 static int dahdi_sendtext(struct ast_channel *c, const char *text);
 
 static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
@@ -988,7 +986,6 @@
 	.answer = dahdi_answer,
 	.read = dahdi_read,
 	.write = dahdi_write,
-	.bridge = dahdi_bridge,
 	.exception = dahdi_exception,
 	.indicate = dahdi_indicate,
 	.fixup = dahdi_fixup,
@@ -6794,374 +6791,6 @@
 	slave->master = master;
 
 	ast_debug(1, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
-}
-
-static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
-{
-	struct ast_channel *who;
-	struct dahdi_pvt *p0, *p1, *op0, *op1;
-	struct dahdi_pvt *master = NULL, *slave = NULL;
-	struct ast_frame *f;
-	int inconf = 0;
-	int nothingok = 1;
-	int ofd0, ofd1;
-	int oi0, oi1, i0 = -1, i1 = -1, t0, t1;
-	int os0 = -1, os1 = -1;
-	int priority = 0;
-	struct ast_channel *oc0, *oc1;
-	enum ast_bridge_result res;
-	struct timeval start = ast_tvnow();
-#ifdef PRI_2BCT
-	int triedtopribridge = 0;
-	q931_call *q931c0;
-	q931_call *q931c1;
-#endif
-
-	/* For now, don't attempt to native bridge if either channel needs DTMF detection.
-	   There is code below to handle it properly until DTMF is actually seen,
-	   but due to currently unresolved issues it's ignored...
-	*/
-
-	if (flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1))
-		return AST_BRIDGE_FAILED_NOWARN;
-
-	ast_channel_lock_both(c0, c1);
-
-	p0 = ast_channel_tech_pvt(c0);
-	p1 = ast_channel_tech_pvt(c1);
-	/* cant do pseudo-channels here */
-	if (!p0 || (!p0->sig) || !p1 || (!p1->sig)) {
-		ast_channel_unlock(c0);
-		ast_channel_unlock(c1);
-		return AST_BRIDGE_FAILED_NOWARN;
-	}
-
-	oi0 = dahdi_get_index(c0, p0, 0);
-	oi1 = dahdi_get_index(c1, p1, 0);
-	if ((oi0 < 0) || (oi1 < 0)) {
-		ast_channel_unlock(c0);
-		ast_channel_unlock(c1);
-		return AST_BRIDGE_FAILED;
-	}
-
-	op0 = p0 = ast_channel_tech_pvt(c0);
-	op1 = p1 = ast_channel_tech_pvt(c1);
-	ofd0 = ast_channel_fd(c0, 0);
-	ofd1 = ast_channel_fd(c1, 0);
-	oc0 = p0->owner;
-	oc1 = p1->owner;
-
-	if (ast_mutex_trylock(&p0->lock)) {
-		/* Don't block, due to potential for deadlock */
-		ast_channel_unlock(c0);
-		ast_channel_unlock(c1);
-		ast_log(LOG_NOTICE, "Avoiding deadlock...\n");
-		return AST_BRIDGE_RETRY;
-	}
-	if (ast_mutex_trylock(&p1->lock)) {
-		/* Don't block, due to potential for deadlock */
-		ast_mutex_unlock(&p0->lock);
-		ast_channel_unlock(c0);
-		ast_channel_unlock(c1);
-		ast_log(LOG_NOTICE, "Avoiding deadlock...\n");
-		return AST_BRIDGE_RETRY;
-	}
-
-	if ((p0->callwaiting && p0->callwaitingcallerid)
-		|| (p1->callwaiting && p1->callwaitingcallerid)) {
-		/*
-		 * Call Waiting Caller ID requires DTMF detection to know if it
-		 * can send the CID spill.
-		 *
-		 * For now, don't attempt to native bridge if either channel
-		 * needs DTMF detection.  There is code below to handle it
-		 * properly until DTMF is actually seen, but due to currently
-		 * unresolved issues it's ignored...
-		 */
-		ast_mutex_unlock(&p0->lock);
-		ast_mutex_unlock(&p1->lock);
-		ast_channel_unlock(c0);
-		ast_channel_unlock(c1);
-		return AST_BRIDGE_FAILED_NOWARN;
-	}
-
-#if defined(HAVE_PRI)
-	if ((dahdi_sig_pri_lib_handles(p0->sig)
-			&& ((struct sig_pri_chan *) p0->sig_pvt)->no_b_channel)
-		|| (dahdi_sig_pri_lib_handles(p1->sig)
-			&& ((struct sig_pri_chan *) p1->sig_pvt)->no_b_channel)) {
-		/*
-		 * PRI nobch channels (hold and call waiting) are equivalent to
-		 * pseudo channels and cannot be done here.
-		 */
-		ast_mutex_unlock(&p0->lock);
-		ast_mutex_unlock(&p1->lock);
-		ast_channel_unlock(c0);
-		ast_channel_unlock(c1);
-		return AST_BRIDGE_FAILED_NOWARN;
-	}
-#endif	/* defined(HAVE_PRI) */
-
-	if ((oi0 == SUB_REAL) && (oi1 == SUB_REAL)) {
-		if (p0->owner && p1->owner) {
-			/* If we don't have a call-wait in a 3-way, and we aren't in a 3-way, we can be master */
-			if (!p0->subs[SUB_CALLWAIT].inthreeway && !p1->subs[SUB_REAL].inthreeway) {
-				master = p0;
-				slave = p1;
-				inconf = 1;
-			} else if (!p1->subs[SUB_CALLWAIT].inthreeway && !p0->subs[SUB_REAL].inthreeway) {
-				master = p1;
-				slave = p0;
-				inconf = 1;
-			} else {
-				ast_log(LOG_WARNING, "Huh?  Both calls are callwaits or 3-ways?  That's clever...?\n");
-				ast_log(LOG_WARNING, "p0: chan %d/%d/CW%d/3W%d, p1: chan %d/%d/CW%d/3W%d\n",
-					p0->channel,
-					oi0, (p0->subs[SUB_CALLWAIT].dfd > -1) ? 1 : 0,
-					p0->subs[SUB_REAL].inthreeway, p0->channel,
-					oi0, (p1->subs[SUB_CALLWAIT].dfd > -1) ? 1 : 0,
-					p1->subs[SUB_REAL].inthreeway);
-			}
-			nothingok = 0;
-		}
-	} else if ((oi0 == SUB_REAL) && (oi1 == SUB_THREEWAY)) {
-		if (p1->subs[SUB_THREEWAY].inthreeway) {
-			master = p1;
-			slave = p0;
-			nothingok = 0;
-		}
-	} else if ((oi0 == SUB_THREEWAY) && (oi1 == SUB_REAL)) {
-		if (p0->subs[SUB_THREEWAY].inthreeway) {
-			master = p0;
-			slave = p1;
-			nothingok = 0;
-		}
-	} else if ((oi0 == SUB_REAL) && (oi1 == SUB_CALLWAIT)) {
-		/* We have a real and a call wait.  If we're in a three way call, put us in it, otherwise,
-		   don't put us in anything */
-		if (p1->subs[SUB_CALLWAIT].inthreeway) {
-			master = p1;
-			slave = p0;
-			nothingok = 0;
-		}
-	} else if ((oi0 == SUB_CALLWAIT) && (oi1 == SUB_REAL)) {
-		/* Same as previous */
-		if (p0->subs[SUB_CALLWAIT].inthreeway) {
-			master = p0;
-			slave = p1;
-			nothingok = 0;
-		}
-	}
-	ast_debug(1, "master: %d, slave: %d, nothingok: %d\n",
-		master ? master->channel : 0, slave ? slave->channel : 0, nothingok);
-	if (master && slave) {
-		/* Stop any tones, or play ringtone as appropriate.  If they're bridged
-		   in an active threeway call with a channel that is ringing, we should
-		   indicate ringing. */
-		if ((oi1 == SUB_THREEWAY) &&
-			p1->subs[SUB_THREEWAY].inthreeway &&
-			p1->subs[SUB_REAL].owner &&
-			p1->subs[SUB_REAL].inthreeway &&
-			(ast_channel_state(p1->subs[SUB_REAL].owner) == AST_STATE_RINGING)) {
-			ast_debug(1,
-				"Playing ringback on %d/%d(%s) since %d/%d(%s) is in a ringing three-way\n",
-				p0->channel, oi0, ast_channel_name(c0), p1->channel, oi1, ast_channel_name(c1));
-			tone_zone_play_tone(p0->subs[oi0].dfd, DAHDI_TONE_RINGTONE);
-			os1 = ast_channel_state(p1->subs[SUB_REAL].owner);
-		} else {
-			ast_debug(1, "Stopping tones on %d/%d(%s) talking to %d/%d(%s)\n",
-				p0->channel, oi0, ast_channel_name(c0), p1->channel, oi1, ast_channel_name(c1));
-			tone_zone_play_tone(p0->subs[oi0].dfd, -1);
-		}
-		if ((oi0 == SUB_THREEWAY) &&
-			p0->subs[SUB_THREEWAY].inthreeway &&
-			p0->subs[SUB_REAL].owner &&
-			p0->subs[SUB_REAL].inthreeway &&
-			(ast_channel_state(p0->subs[SUB_REAL].owner) == AST_STATE_RINGING)) {
-			ast_debug(1,
-				"Playing ringback on %d/%d(%s) since %d/%d(%s) is in a ringing three-way\n",
-				p1->channel, oi1, ast_channel_name(c1), p0->channel, oi0, ast_channel_name(c0));
-			tone_zone_play_tone(p1->subs[oi1].dfd, DAHDI_TONE_RINGTONE);
-			os0 = ast_channel_state(p0->subs[SUB_REAL].owner);
-		} else {
-			ast_debug(1, "Stopping tones on %d/%d(%s) talking to %d/%d(%s)\n",
-				p1->channel, oi1, ast_channel_name(c1), p0->channel, oi0, ast_channel_name(c0));
-			tone_zone_play_tone(p1->subs[oi1].dfd, -1);
-		}
-		if ((oi0 == SUB_REAL) && (oi1 == SUB_REAL)) {
-			if (!p0->echocanbridged || !p1->echocanbridged) {
-				/* Disable echo cancellation if appropriate */
-				dahdi_disable_ec(p0);
-				dahdi_disable_ec(p1);
-			}
-		}
-		dahdi_link(slave, master);
-		master->inconference = inconf;
-	} else if (!nothingok)
-		ast_log(LOG_WARNING, "Can't link %d/%s with %d/%s\n", p0->channel, subnames[oi0], p1->channel, subnames[oi1]);
-
-	update_conf(p0);
-	update_conf(p1);
-	t0 = p0->subs[SUB_REAL].inthreeway;
-	t1 = p1->subs[SUB_REAL].inthreeway;
-
-	ast_mutex_unlock(&p0->lock);
-	ast_mutex_unlock(&p1->lock);
-
-	ast_channel_unlock(c0);
-	ast_channel_unlock(c1);
-
-	/* Native bridge failed */
-	if ((!master || !slave) && !nothingok) {
-		dahdi_enable_ec(p0);
-		dahdi_enable_ec(p1);
-		return AST_BRIDGE_FAILED;
-	}
-
-	ast_verb(3, "Native bridging %s and %s\n", ast_channel_name(c0), ast_channel_name(c1));
-
-	if (!(flags & AST_BRIDGE_DTMF_CHANNEL_0) && (oi0 == SUB_REAL))
-		disable_dtmf_detect(op0);
-
-	if (!(flags & AST_BRIDGE_DTMF_CHANNEL_1) && (oi1 == SUB_REAL))
-		disable_dtmf_detect(op1);
-
-	for (;;) {
-		struct ast_channel *c0_priority[2] = {c0, c1};
-		struct ast_channel *c1_priority[2] = {c1, c0};
-		int ms;
-
-		/* Here's our main loop...  Start by locking things, looking for private parts,
-		   and then balking if anything is wrong */
-
-		ast_channel_lock_both(c0, c1);
-
-		p0 = ast_channel_tech_pvt(c0);
-		p1 = ast_channel_tech_pvt(c1);
-
-		if (op0 == p0)
-			i0 = dahdi_get_index(c0, p0, 1);
-		if (op1 == p1)
-			i1 = dahdi_get_index(c1, p1, 1);
-
-		ast_channel_unlock(c0);
-		ast_channel_unlock(c1);
-
-		ms = ast_remaining_ms(start, timeoutms);
-		if (!ms ||/* Did we timeout? */
-			(op0 != p0) ||/* Did c0 get masqueraded or PRI changed associated B channel? */
-			(op1 != p1) ||/* Did c1 get masqueraded or PRI changed associated B channel? */
-			(ofd0 != ast_channel_fd(c0, 0)) ||/* Did c0 file descriptor change? (This is a redundant test with masquerade and active owner change) */
-			(ofd1 != ast_channel_fd(c1, 0)) ||/* Did c1 file descriptor change? (This is a redundant test with masquerade and active owner change) */
-			(p0->subs[SUB_REAL].owner && (os0 > -1) && (os0 != ast_channel_state(p0->subs[SUB_REAL].owner))) ||/* Did c0 state change? i.e. Did it stop ringing? */
-			(p1->subs[SUB_REAL].owner && (os1 > -1) && (os1 != ast_channel_state(p1->subs[SUB_REAL].owner))) ||/* Did c1 state chagne? i.e. Did it stop ringing? */
-			(oc0 != p0->owner) ||/* Did the p0 active owner change? */
-			(oc1 != p1->owner) ||/* Did the p1 active owner change? */
-			(t0 != p0->subs[SUB_REAL].inthreeway) ||/* Did the p0 three way call status change? */
-			(t1 != p1->subs[SUB_REAL].inthreeway) ||/* Did the p1 three way call status change? */
-			(oi0 != i0) ||/* Did the owner index change? */
-			(oi1 != i1)) {/* Did the owner index change? */
-			ast_debug(1, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n",
-				op0->channel, oi0, op1->channel, oi1);
-			res = AST_BRIDGE_RETRY;
-			goto return_from_bridge;
-		}
-
-#ifdef PRI_2BCT
-		if (!triedtopribridge) {
-			triedtopribridge = 1;
-			if (p0->pri && p0->pri == p1->pri && p0->pri->transfer) {
-				ast_mutex_lock(&p0->pri->lock);
-				switch (p0->sig) {
-				case SIG_PRI_LIB_HANDLE_CASES:
-					q931c0 = ((struct sig_pri_chan *) (p0->sig_pvt))->call;
-					break;
-				default:
-					q931c0 = NULL;
-					break;
-				}
-				switch (p1->sig) {
-				case SIG_PRI_LIB_HANDLE_CASES:
-					q931c1 = ((struct sig_pri_chan *) (p1->sig_pvt))->call;
-					break;
-				default:
-					q931c1 = NULL;
-					break;
-				}
-				if (q931c0 && q931c1) {
-					pri_channel_bridge(q931c0, q931c1);
-				}
-				ast_mutex_unlock(&p0->pri->lock);
-			}
-		}
-#endif
-
-		who = ast_waitfor_n(priority ? c0_priority : c1_priority, 2, &ms);
-		if (!who) {
-			ast_debug(1, "Ooh, empty read...\n");
-			continue;
-		}
-		f = ast_read(who);
-		switch (f ? f->frametype : AST_FRAME_CONTROL) {
-		case AST_FRAME_CONTROL:
-			if (f && f->subclass.integer == AST_CONTROL_PVT_CAUSE_CODE) {
-				ast_channel_hangupcause_hash_set((who == c0) ? c1 : c0, f->data.ptr, f->datalen);
-				break;
-			}
-			*fo = f;
-			*rc = who;
-			res = AST_BRIDGE_COMPLETE;
-			goto return_from_bridge;
-		case AST_FRAME_DTMF_END:
-			if ((who == c0) && p0->pulsedial) {
-				ast_write(c1, f);
-			} else if ((who == c1) && p1->pulsedial) {
-				ast_write(c0, f);
-			} else {
-				*fo = f;
-				*rc = who;
-				res = AST_BRIDGE_COMPLETE;
-				goto return_from_bridge;
-			}
-			break;
-		case AST_FRAME_TEXT:
-			if (who == c0) {
-				ast_write(c1, f);
-			} else {
-				ast_write(c0, f);
-			}
-			break;
-		case AST_FRAME_VOICE:
-			/* Native bridge handles voice frames in hardware. */
-		case AST_FRAME_NULL:
-			break;
-		default:
-			ast_debug(1, "Chan '%s' is discarding frame of frametype:%d\n",
-				ast_channel_name(who), f->frametype);
-			break;
-		}
-		ast_frfree(f);
-
-		/* Swap who gets priority */
-		priority = !priority;
-	}
-
-return_from_bridge:
-	if (op0 == p0)
-		dahdi_enable_ec(p0);
-
-	if (op1 == p1)
-		dahdi_enable_ec(p1);
-
-	if (!(flags & AST_BRIDGE_DTMF_CHANNEL_0) && (oi0 == SUB_REAL))
-		enable_dtmf_detect(op0);
-
-	if (!(flags & AST_BRIDGE_DTMF_CHANNEL_1) && (oi1 == SUB_REAL))
-		enable_dtmf_detect(op1);
-
-	dahdi_unlink(slave, master, 1);
-
-	return res;
 }
 
 static int dahdi_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)




More information about the svn-commits mailing list