[svn-commits] mattf: branch mattf/1.6.0-chan_ccs r261696 - /team/mattf/1.6.0-chan_ccs/chann...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu May 6 13:19:18 CDT 2010


Author: mattf
Date: Thu May  6 13:19:15 2010
New Revision: 261696

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=261696
Log:
Merge last patch as far as functional testing.  Brings a link up and calls go well.

Modified:
    team/mattf/1.6.0-chan_ccs/channels/chan_ccs.c
    team/mattf/1.6.0-chan_ccs/channels/chan_mgcp.c

Modified: team/mattf/1.6.0-chan_ccs/channels/chan_ccs.c
URL: http://svnview.digium.com/svn/asterisk/team/mattf/1.6.0-chan_ccs/channels/chan_ccs.c?view=diff&rev=261696&r1=261695&r2=261696
==============================================================================
--- team/mattf/1.6.0-chan_ccs/channels/chan_ccs.c (original)
+++ team/mattf/1.6.0-chan_ccs/channels/chan_ccs.c Thu May  6 13:19:15 2010
@@ -258,27 +258,6 @@
 
 #if 0
 
-static const struct ast_channel_tech ccs_tech_nortp = {
-	.type = "CCS",
-	.description = tdesc,
-	.capabilities = AST_FORMAT_AUDIO_MASK,
-	.requester = ccs_request,
-	.send_digit_begin = ccs_digit_begin,
-	.send_digit_end = ccs_digit_end,
-	.send_text = ccs_sendtext,
-	.call = ccs_call,
-	.hangup = ccs_hangup,
-	.answer = ccs_answer,
-	.read = ccs_read,
-	.write = ccs_write,
-	.bridge = ast_rtp_bridge,
-	.exception = ccs_exception,
-	.indicate = ccs_indicate,
-	.fixup = ccs_fixup,
-	.setoption = ccs_setoption,
-	.func_channel_read = ccs_func_read,
-};
-
 static const struct ast_channel_tech ccs_tech_rtp = {
 	.type = "CCS",
 	.description = tdesc,
@@ -306,11 +285,85 @@
 {
 }
 
-static int ccs_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen)
-{
-}
-
 #endif /* 0 */
+
+static int ccs_indicate(struct ast_channel *chan, int ind, const void *data, size_t datalen)
+{
+	int res = 0;
+	struct ss7 *ss7;
+	struct isup_call *call;
+	struct ccs_chan *p = chan->tech_pvt;
+
+	if (!p) {
+		ast_log(LOG_ERROR, "No tech pvt!\n");
+		return -1;
+	}
+
+	switch (ind) {
+	case AST_CONTROL_ANSWER:
+		ast_log(LOG_ERROR, "Got answer indication!\n");
+		break;
+	case AST_CONTROL_BUSY:
+		ast_log(LOG_ERROR, "Got busy indication!\n");
+		break;
+	case AST_CONTROL_SRCUPDATE:
+		ast_log(LOG_ERROR, "Got SRCUPDATE\n");
+		ast_mutex_lock(&p->lock);
+		if (p->bearer)
+			res = p->bearer->tech->indicate ? p->bearer->tech->indicate(p->bearer, ind, data, datalen) : -1;
+		else
+			res = 0;
+		ast_mutex_unlock(&p->lock);
+		break;
+	case AST_CONTROL_RINGING:
+		ast_debug(1,"Received AST_CONTROL_RINGING on %s\n", chan->name);
+
+		if (!p->alerting && chan->_state != AST_STATE_UP) {
+			p->alerting = 1;
+			ast_mutex_lock(&p->lock);
+			ss7 = p->sig.ss7.ss7->ss7;
+			call = p->sig.ss7.call;
+			isup_cpg(ss7, call, CPG_EVENT_ALERTING);
+			ast_mutex_unlock(&p->lock);
+		}
+
+		break;
+	case AST_CONTROL_PROCEEDING:
+		ast_debug(1,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
+
+		if (!p->proceeding && chan->_state != AST_STATE_UP) {
+			p->proceeding = 1;
+			ast_mutex_lock(&p->lock);
+			ss7 = p->sig.ss7.ss7->ss7;
+			call = p->sig.ss7.call;
+			isup_acm(ss7, call);
+			ast_mutex_unlock(&p->lock);
+		}
+
+		/* don't continue in ast_indicate */
+		res = 0;
+		break;
+	case AST_CONTROL_PROGRESS:
+		ast_debug(1,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
+
+		if (!p->progress && chan->_state != AST_STATE_UP) {
+			p->progress = 1;
+			ast_mutex_lock(&p->lock);
+			ss7 = p->sig.ss7.ss7->ss7;
+			call = p->sig.ss7.call;
+			isup_cpg(ss7, call, CPG_EVENT_INBANDINFO);
+			ast_mutex_unlock(&p->lock);
+		}
+
+		/* don't continue in ast_indicate */
+		res = 0;
+		break;
+	default:
+		ast_log(LOG_ERROR, "Got indication! %d\n", ind);
+	}
+
+	return 0;
+}
 
 static enum ast_rtp_get_result ccs_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
 {
@@ -319,26 +372,33 @@
 	struct ast_rtp_protocol *pr0 = NULL;
 	enum ast_rtp_get_result res;
 
-	//ast_log(LOG_ERROR, "here!\n");
-
 	if (!chan->tech_pvt)
 		return AST_RTP_GET_FAILED;
 
 	p = chan->tech_pvt;
+	
+	ast_mutex_lock(&p->lock);
+
+	if (!p->bearer) {
+		ast_log(LOG_ERROR, "No bearer, bad stuff here...\n");
+		res = AST_RTP_GET_FAILED;
+		goto out;
+	}
+
 	bearer = p->bearer;
-
-	if (!p->bearer) {
-		ast_log(LOG_ERROR, "Bad stuff here...\n");
-		return AST_RTP_GET_FAILED;
-	}
 
 	if (!(pr0 = get_proto(bearer))) {
 		ast_log(LOG_ERROR, "Failed to find RTP protocol\n");
-		return AST_RTP_GET_FAILED;
+		res = AST_RTP_GET_FAILED;
+		goto out;
 	}
 
 	res = pr0->get_rtp_info(bearer, rtp);
 	ast_rtp_setdtmf(*rtp, 0);
+
+out:
+	ast_mutex_unlock(&p->lock);
+
 	return res;
 }
 
@@ -347,25 +407,36 @@
 	struct ccs_chan *p;
 	struct ast_channel *bearer;
 	struct ast_rtp_protocol *pr0 = NULL;
+	int res;
 
 	//ast_log(LOG_ERROR, "here!\n");
 	if (!chan->tech_pvt)
 		return AST_RTP_GET_FAILED;
 
 	p = chan->tech_pvt;
+
+	ast_mutex_lock(&p->lock);
+
+	if (!p->bearer) {
+		ast_log(LOG_ERROR, "No bearer, bad stuff here...\n");
+		res = AST_RTP_GET_FAILED;
+		goto out;
+	}
+
 	bearer = p->bearer;
-
-	if (!p->bearer) {
-		ast_log(LOG_ERROR, "Bad stuff here...\n");
-		return AST_RTP_GET_FAILED;
-	}
 
 	if (!(pr0 = get_proto(bearer))) {
 		ast_log(LOG_ERROR, "Failed to find RTP protocol\n");
-		return AST_RTP_GET_FAILED;
-	}
-
-	return pr0->set_rtp_peer(bearer, rtp, vrtp, trtp, codecs, nat_active);
+		res = AST_RTP_GET_FAILED;
+		goto out;
+	}
+
+	res = pr0->set_rtp_peer(bearer, rtp, vrtp, trtp, codecs, nat_active);
+
+out:
+	ast_mutex_unlock(&p->lock);
+
+	return res;
 }
 
 static struct ast_rtp_protocol ccs_rtp = {
@@ -409,29 +480,41 @@
 	struct ast_frame *f = NULL;
 	int ms = 0;
 
+	if (!p) {
+		ast_log(LOG_ERROR, "No tech pvt!\n");
+		return NULL;
+	}
+
 	if (ccs_debug)
 		ast_log(LOG_ERROR, "read\n");
 
+	ast_mutex_lock(&p->lock);
+
+	if (!p->bearer) {
+		f = &ast_null_frame;
+		goto out;
+	}
+
 	CHECK_FORMATS(ast, p);
 
-	if (p->bearer) {
-		ast_copy_flags(p->bearer, ast, AST_FLAG_EXCEPTION);
-		if (ast_waitfor_nandfds(&p->bearer, 1, NULL, 0, NULL, NULL, &ms)) {
-			f = ast_read(p->bearer);
-		}
-
-		if (f) {
-			if (f->frametype != AST_FRAME_VOICE) {
-				ast_log(LOG_ERROR, "Dropping frame of type %x\n", f->frametype);
-			}
-		} else {
+	ast_copy_flags(p->bearer, ast, AST_FLAG_EXCEPTION);
+
+	if (ast_waitfor_nandfds(&p->bearer, 1, NULL, 0, NULL, NULL, &ms)) {
+		f = ast_read(p->bearer);
+	}
+
+	if (f) {
+		if (f->frametype != AST_FRAME_VOICE) {
+			ast_log(LOG_ERROR, "Dropping frame of type %x\n", f->frametype);
 			f = &ast_null_frame;
 		}
-	} else
+	} else {
 		f = &ast_null_frame;
-
+	}
 
 	CLEANUP(ast,p);
+out:
+	ast_mutex_unlock(&p->lock);
 
 	return f;
 
@@ -443,6 +526,7 @@
 	struct ss7 *ss7;
 	struct isup_call *call;
 
+	ast_log(LOG_ERROR, "Answer got called\n");
 	if (!c) {
 		ast_log(LOG_ERROR, "No tech pvt!\n");
 		return -1;
@@ -453,30 +537,49 @@
 	ss7 = c->sig.ss7.ss7->ss7;
 	call = c->sig.ss7.call;
 
-	ast_mutex_unlock(&c->lock);
-
 	isup_anm(ss7, call);
 
-	ast_setstate(ast, AST_STATE_UP);
+	if (!c->bearer)
+		goto out;
 
 	CLEANUP(ast, c);
 	CHECK_FORMATS(ast, c);
 
+out:
+	ast_mutex_unlock(&c->lock);
+
+	ast_setstate(ast, AST_STATE_UP);
+
 	return 0;
 }
 
 static int ccs_write(struct ast_channel *ast, struct ast_frame *frame)
 {
 	struct ccs_chan *p = ast->tech_pvt;
+	int res = 0;
+
+	if (!p) {
+		ast_log(LOG_ERROR, "No tech pvt!\n");
+		return -1;
+	}
+
+	ast_mutex_lock(&p->lock);
+
+	if (!p->bearer)
+		goto out;
 
 	CHECK_FORMATS(ast, p);
 
 	if (p->bearer) {
-		ast_write(p->bearer, frame);
+		res = ast_write(p->bearer, frame);
 	}
 
 	CLEANUP(ast, p);
-	return 0;
+
+out:
+	ast_mutex_unlock(&p->lock);
+
+	return res;
 }
 
 static int ccs_hangup(struct ast_channel *ast)
@@ -492,7 +595,6 @@
 	ast_mutex_lock(&c->lock);
 
 	bearer = c->bearer;
-
 	c->bearer = NULL;
 
 	c->owner = NULL;
@@ -522,11 +624,13 @@
 		ast_log(LOG_ERROR, "No tech pvt!\n");
 		return -1;
 	}
+	ast_mutex_lock(&p->lock);
+
 	if (!p->bearer) {
+		ast_mutex_unlock(&p->lock);
 		ast_log(LOG_ERROR, "No bearer\n");
 		return -1;
 	}
-	ast_mutex_lock(&p->lock);
 
 	res = ast_set_read_format(p->bearer, ast_best_codec(p->bearer->nativeformats));
 	if (res)
@@ -613,7 +717,7 @@
 	ast_copy_string(c->exten, called_num, sizeof(c->exten));
 
 	/* TODO: Fix exten and context */
-	if (!(c->owner = ast_channel_alloc(1, state, 0, 0, "", c->exten, c->context, 0, "CCS"))) {
+	if (!(c->owner = ast_channel_alloc(1, state, 0, 0, "", c->exten, c->context, 0, "CCS/%s/%d-%d", c->sig.ss7.ss7->name, c->sig.ss7.cic, c->sig.ss7.dpc))) {
 		ast_log(LOG_ERROR, "Could not allocate ast_channel for bearer!\n");
 		return NULL;
 	}
@@ -724,41 +828,6 @@
 			break;
 	}
 }
-
-#if 0
-static struct ast_channel * ccs_new(struct ccs_chan *c)
-{
-	struct ast_channel *tmp = NULL;
-	int icause;
-	int *cause = &icause;
-
-	/* TODO: Fix exten and context */
-	if (!(tmp = ast_channel_alloc(1, AST_STATE_RING, 0, 0, "", c->exten, c->context, 0, "CCS")))
-		return NULL;
-
-	tmp->tech = &ccs_tech;
-
-	tmp->tech_pvt = c;
-	c->owner = tmp;
-
-	c->bearer = ast_request(c->bearer_tech_str, c->nativeformats, c->bearer_dial_str, cause);
-
-	if (!c->bearer) {
-		ast_log(LOG_ERROR, "Unable to request bearer %s/%s\n", c->bearer_tech_str, c->bearer_dial_str);
-		return NULL;
-	}
-
-	if (ast_call(c->bearer, c->bearer_dial_str, 0)) {
-		ast_log(LOG_ERROR, "Failed to call %s/%s/\n", c->bearer_tech_str, c->bearer_dial_str);
-		return NULL;
-	}
-
-	CLEANUP(tmp, c);
-	CHECK_FORMATS(tmp, c);
-
-	return tmp;
-}
-#endif
 
 static void ccs_enable_ec(struct ccs_chan *p)
 {
@@ -1074,7 +1143,9 @@
 					{
 						struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_RINGING, };
 						p->alerting = 1;
+						ast_mutex_lock(&p->lock);
 						ccs_queue_frame(p, &f);
+						ast_mutex_unlock(&p->lock);
 					}
 					break;
 				case CPG_EVENT_PROGRESS:
@@ -1084,7 +1155,9 @@
 						ast_debug(1, "Queuing frame PROGRESS on CIC %d\n", p->sig.ss7.cic);
 						p->progress = 1;
 
+						ast_mutex_lock(&p->lock);
 						ccs_queue_frame(p, &f);
+						ast_mutex_unlock(&p->lock);
 #if XXX
 						if (p->dsp && p->dsp_features) {
 						        ast_dsp_set_features(p->dsp, p->dsp_features);
@@ -1286,6 +1359,9 @@
 				isup_cvr(linkset->ss7, e->cvt.cic, p->sig.ss7.dpc);
 				break;
 			case ISUP_EVENT_REL:
+			{
+				struct ast_channel *owner;
+
 				chanpos = ss7_find_cic(linkset, e->rel.cic, e->rel.opc);
 
 				if (chanpos < 0) {
@@ -1297,29 +1373,27 @@
 
 				ast_mutex_lock(&p->lock);
 
-				if (p->owner) {
-					p->owner->hangupcause = e->rel.cause;
-					ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
-					p->owner = NULL;
+				owner = p->owner;
+				p->owner = NULL;
+
+				if (owner) {
+					owner->hangupcause = e->rel.cause;
 				}
 
 				p->sig.ss7.call = NULL;
 				p->alreadyhungup = 1;
 
-				isup_rlc(ss7, e->rel.call);
-
 				/* End the loopback if we have one */
 				ccs_loopback(p, 0);
-#if 0
-				if (p->bearer) {
-					ast_hangup(p->bearer);
-					p->bearer = NULL;
-				}
-#endif
 
 				ast_mutex_unlock(&p->lock);
 
-				break;
+				isup_rlc(ss7, e->rel.call);
+
+				ast_softhangup_nolock(owner, AST_SOFTHANGUP_DEV);
+
+				break;
+			}
 			case ISUP_EVENT_ACM:
 				chanpos = ss7_find_cic(linkset, e->acm.cic, e->acm.opc);
 				if (chanpos < 0) {
@@ -1339,8 +1413,8 @@
 					}
 
 					ast_mutex_lock(&p->lock);
+					p->proceeding = 1;
 					ccs_queue_frame(p, &f);
-					p->proceeding = 1;
 					/* Send alerting if subscriber is free */
 					if (e->acm.called_party_status_ind == 1) {
 						p->alerting = 1;
@@ -1448,7 +1522,9 @@
 					struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER, };
 
 					p = linkset->pvts[chanpos];
+					ast_mutex_lock(&p->lock);
 					ccs_queue_frame(p, &f);
+					ast_mutex_unlock(&p->lock);
 					ccs_enable_ec(p);
 				}
 				break;
@@ -1998,13 +2074,13 @@
 	.read = ccs_read,
 	.exception = ccs_read,
 	.answer = ccs_answer,
+	.indicate = ccs_indicate,
 	.bridge = ast_rtp_bridge,
 #if 0
 	.send_digit_begin = ccs_digit_begin,
 	.send_digit_end = ccs_digit_end,
 	.send_text = ccs_sendtext,
 	.bridge = ast_rtp_bridge,
-	.indicate = ccs_indicate,
 	.fixup = ccs_fixup,
 	.setoption = ccs_setoption,
 	.func_channel_read = ccs_func_read,

Modified: team/mattf/1.6.0-chan_ccs/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/mattf/1.6.0-chan_ccs/channels/chan_mgcp.c?view=diff&rev=261696&r1=261695&r2=261696
==============================================================================
--- team/mattf/1.6.0-chan_ccs/channels/chan_mgcp.c (original)
+++ team/mattf/1.6.0-chan_ccs/channels/chan_mgcp.c Thu May  6 13:19:15 2010
@@ -934,11 +934,14 @@
 		}
 		ast_queue_control(ast, AST_CONTROL_RINGING);
 	} else {
+		sub->cxmode = MGCP_CX_SENDRECV;
 		if (!sub->rtp) {
 			start_rtp(sub);
 		} else {
 			transmit_modify_request(sub);
 		}
+		ast_setstate(ast, AST_STATE_RINGING);
+		ast_queue_control(ast, AST_CONTROL_RINGING);
 	}
 	ast_mutex_unlock(&sub->lock);
 	return res;




More information about the svn-commits mailing list