[asterisk-commits] rmudgett: branch rmudgett/call_waiting r257250 - /team/rmudgett/call_waiting/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 14 10:55:27 CDT 2010


Author: rmudgett
Date: Wed Apr 14 10:55:24 2010
New Revision: 257250

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=257250
Log:
Merged revision 257248 from
https://origsvn.digium.com/svn/asterisk/be/branches/C.3-bier

..........
  r257248 | rmudgett | 2010-04-13 18:47:30 -0500 (Tue, 13 Apr 2010) | 8 lines

  Audio path not setup on incoming ISDN call waiting call routed to POTS port.

  Call waiting on a BRI PTP/PTMP trunk to a POTS phone does not connect
  properly and results in no audio when the B channel has become available.

  Setup the B channel audio path when send/receive CONNECT and receive
  CONNECT_ACKNOWLEDGE.

Modified:
    team/rmudgett/call_waiting/channels/chan_dahdi.c
    team/rmudgett/call_waiting/channels/sig_pri.c
    team/rmudgett/call_waiting/channels/sig_pri.h

Modified: team/rmudgett/call_waiting/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/call_waiting/channels/chan_dahdi.c?view=diff&rev=257250&r1=257249&r2=257250
==============================================================================
--- team/rmudgett/call_waiting/channels/chan_dahdi.c (original)
+++ team/rmudgett/call_waiting/channels/chan_dahdi.c Wed Apr 14 10:55:24 2010
@@ -1071,6 +1071,8 @@
 	 * \note The "group" bitmapped group string read in from chan_dahdi.conf
 	 */
 	ast_group_t group;
+	/*! \brief Default call PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW. */
+	int law_default;
 	/*! \brief Active PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW */
 	int law;
 	int confno;					/*!< Our conference */
@@ -2215,7 +2217,8 @@
 		p->dsp = NULL;
 	}
 
-	law = DAHDI_LAW_DEFAULT;
+	p->law = p->law_default;
+	law = p->law_default;
 	res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETLAW, &law);
 	if (res < 0)
 		ast_log(LOG_WARNING, "Unable to set law on channel %d to default: %s\n", p->channel, strerror(errno));
@@ -2409,6 +2412,54 @@
 			break;
 	}
 	return dahdi_new(p, state, startpbx, SUB_REAL, newlaw, transfercapability, requestor ? requestor->linkedid : "");
+}
+#endif	/* defined(HAVE_PRI) */
+
+static int set_actual_gain(int fd, float rxgain, float txgain, float rxdrc, float txdrc, int law);
+
+#if defined(HAVE_PRI)
+/*!
+ * \internal
+ * \brief Open the PRI channel media path.
+ * \since 1.8
+ *
+ * \param p Channel private control structure.
+ *
+ * \return Nothing
+ */
+static void my_pri_open_media(void *p)
+{
+	struct dahdi_pvt *pvt = p;
+	int res;
+	int dfd;
+	int set_val;
+
+	dfd = pvt->subs[SUB_REAL].dfd;
+
+	/* Open the media path. */
+	set_val = 1;
+	res = ioctl(dfd, DAHDI_AUDIOMODE, &set_val);
+	if (res < 0) {
+		ast_log(LOG_WARNING, "Unable to enable audio mode on channel %d (%s)\n",
+			pvt->channel, strerror(errno));
+	}
+
+	/* Set correct companding law for this call. */
+	res = dahdi_setlaw(dfd, pvt->law);
+	if (res < 0) {
+		ast_log(LOG_WARNING, "Unable to set law on channel %d\n", pvt->channel);
+	}
+
+	/* Set correct gain for this call. */
+	if (pvt->digital) {
+		res = set_actual_gain(dfd, 0, 0, pvt->rxdrc, pvt->txdrc, pvt->law);
+	} else {
+		res = set_actual_gain(dfd, pvt->rxgain, pvt->txgain, pvt->rxdrc, pvt->txdrc,
+			pvt->law);
+	}
+	if (res < 0) {
+		ast_log(LOG_WARNING, "Unable to set gains on channel %d\n", pvt->channel);
+	}
 }
 #endif	/* defined(HAVE_PRI) */
 
@@ -2731,6 +2782,9 @@
 	old_chan->dialing = 0;
 	old_chan->digital = 0;
 	old_chan->outgoing = 0;
+
+	/* More stuff to transfer to the new channel. */
+	new_chan->law = old_chan->law;
 }
 
 static int sig_pri_tone_to_dahditone(enum sig_pri_tone tone)
@@ -3023,6 +3077,7 @@
 	.update_span_devstate = dahdi_pri_update_span_devstate,
 	.module_ref = my_module_ref,
 	.module_unref = my_module_unref,
+	.open_media = my_pri_open_media,
 };
 #endif	/* defined(HAVE_PRI) */
 
@@ -4180,7 +4235,7 @@
 	if (slavechannel < 1) {
 		p->confno = zi.confno;
 	}
-	memcpy(&c->curconf, &zi, sizeof(c->curconf));
+	c->curconf = zi;
 	ast_debug(1, "Added %d to conference %d/%d\n", c->dfd, c->curconf.confmode, c->curconf.confno);
 	return 0;
 }
@@ -4851,13 +4906,8 @@
 
 #ifdef HAVE_PRI
 	if (dahdi_sig_pri_lib_handles(p->sig)) {
-		struct dahdi_params ps;
-
-		memset(&ps, 0, sizeof(ps));
-		if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &ps)) {
-			ast_log(LOG_ERROR, "Could not get params\n");
-		}
-		res = sig_pri_call(p->sig_pvt, ast, rdest, timeout, (ps.curlaw == DAHDI_LAW_MULAW) ? PRI_LAYER_1_ULAW : PRI_LAYER_1_ALAW);
+		res = sig_pri_call(p->sig_pvt, ast, rdest, timeout,
+			(p->law == DAHDI_LAW_ALAW) ? PRI_LAYER_1_ALAW : PRI_LAYER_1_ULAW);
 		ast_mutex_unlock(&p->lock);
 		return res;
 	}
@@ -5737,7 +5787,8 @@
 		}
 		revert_fax_buffers(p, ast);
 		dahdi_setlinear(p->subs[SUB_REAL].dfd, 0);
-		law = DAHDI_LAW_DEFAULT;
+		p->law = p->law_default;
+		law = p->law_default;
 		res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETLAW, &law);
 		dahdi_disable_ec(p);
 		update_conf(p);
@@ -5908,7 +5959,8 @@
 
 		revert_fax_buffers(p, ast);
 
-		law = DAHDI_LAW_DEFAULT;
+		p->law = p->law_default;
+		law = p->law_default;
 		res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETLAW, &law);
 		if (res < 0)
 			ast_log(LOG_WARNING, "Unable to set law on channel %d to default: %s\n", p->channel, strerror(errno));
@@ -8887,12 +8939,10 @@
 {
 	struct ast_channel *tmp;
 	format_t deflaw;
-	int res;
 	int x;
 	int features;
 	struct ast_str *chan_name;
 	struct ast_variable *v;
-	struct dahdi_params ps;
 
 	if (i->subs[idx].owner) {
 		ast_log(LOG_WARNING, "Channel %d already has a %s call\n", i->channel,subnames[idx]);
@@ -8923,21 +8973,29 @@
 	}
 #endif	/* defined(HAVE_PRI) */
 	ast_channel_cc_params_init(tmp, i->cc_params);
-	memset(&ps, 0, sizeof(ps));
-	res = ioctl(i->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &ps);
-	if (res) {
-		ast_log(LOG_WARNING, "Unable to get parameters, assuming MULAW: %s\n", strerror(errno));
-		ps.curlaw = DAHDI_LAW_MULAW;
-	}
-	if (ps.curlaw == DAHDI_LAW_ALAW)
-		deflaw = AST_FORMAT_ALAW;
-	else
-		deflaw = AST_FORMAT_ULAW;
 	if (law) {
-		if (law == DAHDI_LAW_ALAW)
+		i->law = law;
+		if (law == DAHDI_LAW_ALAW) {
 			deflaw = AST_FORMAT_ALAW;
-		else
+		} else {
 			deflaw = AST_FORMAT_ULAW;
+		}
+	} else {
+		switch (i->sig) {
+		case SIG_PRI_LIB_HANDLE_CASES:
+			/* Make sure companding law is known. */
+			i->law = (i->law_default == DAHDI_LAW_ALAW)
+				? DAHDI_LAW_ALAW : DAHDI_LAW_MULAW;
+			break;
+		default:
+			i->law = i->law_default;
+			break;
+		}
+		if (i->law_default == DAHDI_LAW_ALAW) {
+			deflaw = AST_FORMAT_ALAW;
+		} else {
+			deflaw = AST_FORMAT_ULAW;
+		}
 	}
 	ast_channel_set_fd(tmp, 0, i->subs[idx].dfd);
 	tmp->nativeformats = deflaw;
@@ -11500,6 +11558,7 @@
 					destroy_dahdi_pvt(tmp);
 					return NULL;
 				}
+				tmp->law_default = p.curlaw;
 				tmp->law = p.curlaw;
 				tmp->span = p.spanno;
 				span = p.spanno - 1;
@@ -12391,6 +12450,13 @@
 		return -1;
 	}
 	chan->no_b_channel = 1;
+
+	/*
+	 * Pseudo channel companding law.
+	 * Needed for outgoing call waiting calls.
+	 * XXX May need to make this determined by switchtype or user option.
+	 */
+	pvt->law_default = DAHDI_LAW_ALAW;
 
 	pvt->sig = pri->sig;
 	pvt->outsigmod = -1;
@@ -15110,7 +15176,7 @@
 			ast_cli(a->fd, "TDD: %s\n", tmp->tdd ? "yes" : "no");
 			ast_cli(a->fd, "Relax DTMF: %s\n", tmp->dtmfrelax ? "yes" : "no");
 			ast_cli(a->fd, "Dialing/CallwaitCAS: %d/%d\n", tmp->dialing, tmp->callwaitcas);
-			ast_cli(a->fd, "Default law: %s\n", tmp->law == DAHDI_LAW_MULAW ? "ulaw" : tmp->law == DAHDI_LAW_ALAW ? "alaw" : "unknown");
+			ast_cli(a->fd, "Default law: %s\n", tmp->law_default == DAHDI_LAW_MULAW ? "ulaw" : tmp->law_default == DAHDI_LAW_ALAW ? "alaw" : "unknown");
 			ast_cli(a->fd, "Fax Handled: %s\n", tmp->faxhandled ? "yes" : "no");
 			ast_cli(a->fd, "Pulse phone: %s\n", tmp->pulsedial ? "yes" : "no");
 			ast_cli(a->fd, "Gains (RX/TX): %.2f/%.2f\n", tmp->rxgain, tmp->txgain);

Modified: team/rmudgett/call_waiting/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/call_waiting/channels/sig_pri.c?view=diff&rev=257250&r1=257249&r2=257250
==============================================================================
--- team/rmudgett/call_waiting/channels/sig_pri.c (original)
+++ team/rmudgett/call_waiting/channels/sig_pri.c Wed Apr 14 10:55:24 2010
@@ -801,6 +801,26 @@
 	}
 
 	return c;
+}
+
+/*!
+ * \internal
+ * \brief Open the PRI channel media path.
+ * \since 1.8
+ *
+ * \param p Channel private control structure.
+ *
+ * \return Nothing
+ */
+static void sig_pri_open_media(struct sig_pri_chan *p)
+{
+	if (p->no_b_channel) {
+		return;
+	}
+
+	if (p->calls->open_media) {
+		p->calls->open_media(p->chan_pvt);
+	}
 }
 
 struct ast_channel *sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_channel *requestor, int transfercapability)
@@ -3698,6 +3718,7 @@
 #endif	/* defined(HAVE_PRI_CALL_WAITING) */
 				sig_pri_handle_subcmds(pri, chanpos, e->e, e->answer.channel,
 					e->answer.subcmds, e->answer.call);
+				sig_pri_open_media(pri->pvts[chanpos]);
 				pri_queue_control(pri->pvts[chanpos], AST_CONTROL_ANSWER, pri);
 				/* Enable echo cancellation if it's not on already */
 				sig_pri_set_dialing(pri->pvts[chanpos], 0);
@@ -3746,6 +3767,7 @@
 				sig_pri_span_devstate_changed(pri);
 				sig_pri_handle_subcmds(pri, chanpos, e->e, e->connect_ack.channel,
 					e->connect_ack.subcmds, e->connect_ack.call);
+				sig_pri_open_media(pri->pvts[chanpos]);
 				sig_pri_unlock_private(pri->pvts[chanpos]);
 				break;
 #endif	/* defined(HAVE_PRI_CALL_WAITING) */
@@ -4879,6 +4901,7 @@
 	if (!pri_grab(p, p->pri)) {
 		p->proceeding = 1;
 		sig_pri_set_dialing(p, 0);
+		sig_pri_open_media(p);
 		res = pri_answer(p->pri->pri, p->call, 0, !p->digital);
 		pri_rel(p->pri);
 	} else {

Modified: team/rmudgett/call_waiting/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/call_waiting/channels/sig_pri.h?view=diff&rev=257250&r1=257249&r2=257250
==============================================================================
--- team/rmudgett/call_waiting/channels/sig_pri.h (original)
+++ team/rmudgett/call_waiting/channels/sig_pri.h Wed Apr 14 10:55:24 2010
@@ -118,6 +118,8 @@
 	const char *(* const get_orig_dialstring)(void *pvt);
 	void (* const make_cc_dialstring)(void *pvt, char *buf, size_t buf_size);
 	void (* const update_span_devstate)(struct sig_pri_pri *pri);
+
+	void (* const open_media)(void *pvt);
 
 	/*! Reference the parent module. */
 	void (*module_ref)(void);




More information about the asterisk-commits mailing list