[asterisk-commits] murf: branch murf/bug_7605 r38729 - in /team/murf/bug_7605: ./ channels/ res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Aug 1 21:03:01 MST 2006


Author: murf
Date: Tue Aug  1 23:03:00 2006
New Revision: 38729

URL: http://svn.digium.com/view/asterisk?rev=38729&view=rev
Log:
Update via svnmerge, turned on automerge


Modified:
    team/murf/bug_7605/   (props changed)
    team/murf/bug_7605/channel.c
    team/murf/bug_7605/channels/chan_jingle.c
    team/murf/bug_7605/res/res_features.c

Propchange: team/murf/bug_7605/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/murf/bug_7605/
------------------------------------------------------------------------------
    automerge-email = murf at digium.com

Propchange: team/murf/bug_7605/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/murf/bug_7605/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Aug  1 23:03:00 2006
@@ -1,1 +1,1 @@
-/trunk:1-38678
+/trunk:1-38728

Modified: team/murf/bug_7605/channel.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_7605/channel.c?rev=38729&r1=38728&r2=38729&view=diff
==============================================================================
--- team/murf/bug_7605/channel.c (original)
+++ team/murf/bug_7605/channel.c Tue Aug  1 23:03:00 2006
@@ -3564,7 +3564,6 @@
 	struct timeval nexteventts = { 0, };
 	char caller_warning = 0;
 	char callee_warning = 0;
-	int to;
 
 	if (c0->_bridge) {
 		ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
@@ -3617,20 +3616,28 @@
 	o0nativeformats = c0->nativeformats;
 	o1nativeformats = c1->nativeformats;
 
-	if (config->timelimit) {
+	if (config->feature_timer) {
+		nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->feature_timer, 1000));
+	} else if (config->timelimit) {
 		nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000));
 		if (caller_warning || callee_warning)
 			nexteventts = ast_tvsub(nexteventts, ast_samp2tv(config->play_warning, 1000));
 	}
 
 	for (/* ever */;;) {
+		struct timeval now;
+		int to;
+
 		to = -1;
-		if (config->timelimit) {
-			struct timeval now;
+
+		if (!ast_tvzero(nexteventts)) {
 			now = ast_tvnow();
 			to = ast_tvdiff_ms(nexteventts, now);
 			if (to < 0)
 				to = 0;
+		}
+
+		if (config->timelimit) {
 			time_left_ms = config->timelimit - ast_tvdiff_ms(now, config->start_time);
 			if (time_left_ms < to)
 				to = time_left_ms;

Modified: team/murf/bug_7605/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_7605/channels/chan_jingle.c?rev=38729&r1=38728&r2=38729&view=diff
==============================================================================
--- team/murf/bug_7605/channels/chan_jingle.c (original)
+++ team/murf/bug_7605/channels/chan_jingle.c Tue Aug  1 23:03:00 2006
@@ -442,7 +442,7 @@
 	return 0;
 }
 
-static int jingle_response(struct jingle *client, ikspak *pak, const char *reasonstr)
+static int jingle_response(struct jingle *client, ikspak *pak, const char *reasonstr, const char *reasonstr2)
 {
 	iks *response, *error = NULL, *reason = NULL;
 	int res = -1;
@@ -490,9 +490,57 @@
 			ast_queue_control(tmp->owner, AST_CONTROL_ANSWER);
 	} else
 		ast_log(LOG_NOTICE, "Whoa, didn't find call!\n");
-	jingle_response(client, pak, NULL);
+	jingle_response(client, pak, NULL, NULL);
 	return 1;
 }
+
+static int jingle_handle_dtmf(struct jingle *client, ikspak *pak)
+{
+	struct jingle_pvt *tmp;
+	iks *dtmfnode = NULL;
+	char *dtmf;
+	/* Make sure our new call doesn't exist yet */
+	for (tmp = client->p; tmp; tmp = tmp->next) {
+		if (iks_find_with_attrib(pak->x, GOOGLE_NODE, GOOGLE_SID, tmp->sid))
+			break;
+	}
+
+	if (tmp) {
+		if(iks_find_with_attrib(pak->x, "dtmf-method", "method", "rtp")) {
+			jingle_response(client,pak,
+					"feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'",
+					"unsupported-dtmf-method xmlns='http://jabber.org/protocol/jingle/info/dtmf#errors'");
+			return -1;
+		}
+		if ((dtmfnode  = iks_find(pak->x, "dtmf"))) {
+			if((dtmf = iks_find_attrib(dtmfnode, "code"))) {
+				if(iks_find_with_attrib(pak->x, "dtmf", "action", "button-up")) {
+					struct ast_frame f = {AST_FRAME_DTMF_BEGIN, };
+					f.subclass = dtmf[0];
+					ast_queue_frame(tmp->owner, &f);
+					ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass);
+				} else if(iks_find_with_attrib(pak->x, "dtmf", "action", "button-down")) {
+					struct ast_frame f = {AST_FRAME_DTMF_END, };
+					f.subclass = dtmf[0];
+					ast_queue_frame(tmp->owner, &f);
+					ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass);
+				} else if(iks_find_attrib(pak->x, "dtmf")) { /* 250 millasecond default */
+					struct ast_frame f = {AST_FRAME_DTMF, };
+					f.subclass = dtmf[0];
+					ast_queue_frame(tmp->owner, &f);
+					ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass);
+				}
+			}
+		}
+		jingle_response(client, pak, NULL, NULL);
+		return 1;
+	} else
+		ast_log(LOG_NOTICE, "Whoa, didn't find call!\n");
+
+	jingle_response(client, pak, NULL, NULL);
+	return 1;
+}
+
 
 static int jingle_hangup_farend(struct jingle *client, ikspak *pak)
 {
@@ -510,7 +558,7 @@
 		ast_queue_hangup(tmp->owner);
 	} else
 		ast_log(LOG_NOTICE, "Whoa, didn't find call!\n");
-	jingle_response(client, pak, NULL);
+	jingle_response(client, pak, NULL, NULL);
 	return 1;
 }
 
@@ -858,7 +906,7 @@
 	while (tmp) {
 		if (iks_find_with_attrib(pak->x, GOOGLE_NODE, GOOGLE_SID, tmp->sid)) {
 			ast_log(LOG_NOTICE, "Ignoring duplicate call setup on SID %s\n", tmp->sid);
-			jingle_response(client, pak, "out-of-order");
+			jingle_response(client, pak, "out-of-order", NULL);
 			return -1;
 		}
 		tmp = tmp->next;
@@ -893,14 +941,14 @@
 		switch (res) {
 		case AST_PBX_FAILED:
 			ast_log(LOG_WARNING, "Failed to start PBX :(\n");
-			jingle_response(client, pak, "service-unavailable");
+			jingle_response(client, pak, "service-unavailable", NULL);
 			break;
 		case AST_PBX_CALL_LIMIT:
 			ast_log(LOG_WARNING, "Failed to start PBX (call limit reached) \n");
-			jingle_response(client, pak, "service-unavailable");
+			jingle_response(client, pak, "service-unavailable", NULL);
 			break;
 		case AST_PBX_SUCCESS:
-			jingle_response(client, pak, NULL);
+			jingle_response(client, pak, NULL, NULL);
 			jingle_create_candidates(client, p,
 					iks_find_attrib(pak->query, GOOGLE_SID),
 					iks_find_attrib(pak->x, "from"));
@@ -1135,9 +1183,52 @@
 
 static int jingle_digit(struct ast_channel *ast, char digit)
 {
-	ast_log(LOG_NOTICE, "XXX Implement jingle digit XXX\n");
-
-	return -1;
+	struct jingle_pvt *p = ast->tech_pvt;
+	struct jingle *client = p->parent;
+	iks *iq, *jingle, *dtmf;
+	char buffer[2] = {digit, '\0'};
+	iq = iks_new("iq");
+	jingle = iks_new("jingle");
+	dtmf = iks_new("dtmf");
+	if(!iq || !jingle || !dtmf) {
+		if(iq)
+			iks_delete(iq);
+		if(jingle)
+			iks_delete(jingle);
+		if(dtmf)
+			iks_delete(dtmf);
+		ast_log(LOG_ERROR, "Did not send dtmf do to memory issue\n");
+		return -1;
+	}
+
+	iks_insert_attrib(iq, "type", "set");
+	iks_insert_attrib(iq, "to", p->from);
+	iks_insert_attrib(iq, "from", client->connection->jid->full);
+	iks_insert_attrib(iq, "id", client->connection->mid);
+	ast_aji_increment_mid(client->connection->mid);
+	iks_insert_attrib(jingle, "xmlns", "http://jabber.org/protocol/jingle");
+	iks_insert_attrib(jingle, "action", "content-info");
+	iks_insert_attrib(jingle, "initiator", p->initiator ? client->connection->jid->full : p->from);
+	iks_insert_attrib(jingle, "sid", p->sid);
+	iks_insert_attrib(dtmf, "xmlns", "http://jabber.org/protocol/jingle/info/dtmf");
+	iks_insert_attrib(dtmf, "code", buffer);
+	iks_insert_node(iq, jingle);
+	iks_insert_node(jingle, dtmf);
+
+	ast_mutex_lock(&p->lock);
+	if(ast->dtmff.frametype == AST_FRAME_DTMF) {
+		ast_verbose("Sending 250ms dtmf!\n");
+	} else if (ast->dtmff.frametype == AST_FRAME_DTMF_BEGIN) {
+		iks_insert_attrib(dtmf, "action", "button-down");
+	} else if (ast->dtmff.frametype == AST_FRAME_DTMF_END) {
+		iks_insert_attrib(dtmf, "action", "button-up");
+	}
+	iks_send(client->connection->p, iq);
+	iks_delete(iq);
+	iks_delete(jingle);
+	iks_delete(dtmf);
+	ast_mutex_unlock(&p->lock);
+	return 0;
 }
 
 static int jingle_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen)
@@ -1333,6 +1424,8 @@
 		ast_log(LOG_DEBUG, "Candidate Added!\n");
 	} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", GOOGLE_ACCEPT)) {
 		jingle_is_answered(client, pak);
+	} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", "content-info")) {
+		jingle_handle_dtmf(client, pak);
 	} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", "terminate")) {
 		jingle_hangup_farend(client, pak);
 	} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", "reject")) {

Modified: team/murf/bug_7605/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_7605/res/res_features.c?rev=38729&r1=38728&r2=38729&view=diff
==============================================================================
--- team/murf/bug_7605/res/res_features.c (original)
+++ team/murf/bug_7605/res/res_features.c Tue Aug  1 23:03:00 2006
@@ -1464,6 +1464,7 @@
 					config->start_sound = NULL;
 					config->firstpass = 0;
 				}
+				config->start_time = ast_tvnow();
 				config->feature_timer = featuredigittimeout;
 				if (option_debug)
 					ast_log(LOG_DEBUG, "Set time limit to %ld\n", config->feature_timer);



More information about the asterisk-commits mailing list