[asterisk-commits] file: branch file/chan_jingle2 r369025 - /team/file/chan_jingle2/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 15 11:29:48 CDT 2012


Author: file
Date: Fri Jun 15 11:29:45 2012
New Revision: 369025

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369025
Log:
Incorporate more review feedback.

Modified:
    team/file/chan_jingle2/channels/chan_jingle2.c

Modified: team/file/chan_jingle2/channels/chan_jingle2.c
URL: http://svnview.digium.com/svn/asterisk/team/file/chan_jingle2/channels/chan_jingle2.c?view=diff&rev=369025&r1=369024&r2=369025
==============================================================================
--- team/file/chan_jingle2/channels/chan_jingle2.c (original)
+++ team/file/chan_jingle2/channels/chan_jingle2.c Fri Jun 15 11:29:45 2012
@@ -31,7 +31,6 @@
 	<depend>iksemel</depend>
 	<depend>res_jabber</depend>
 	<use type="external">openssl</use>
-	<defaultenabled>yes</defaultenabled>
 	<support_level>core</support_level>
  ***/
 
@@ -639,8 +638,9 @@
 		}
 	}
 
-	if (state == AST_STATE_RING)
+	if (state == AST_STATE_RING) {
 		ast_channel_rings_set(chan, 1);
+	}
 
 	ast_channel_adsicpe_set(chan, AST_ADSI_UNAVAILABLE);
 
@@ -757,7 +757,7 @@
 		if (!(local_candidate = iks_new("candidate"))) {
 			res = -1;
 			ast_log(LOG_ERROR, "Unable to allocate IKS candidate stanza for ICE-UDP transport\n");
-			goto end;
+			break;
 		}
 
 		snprintf(tmp, sizeof(tmp), "%d", candidate->id);
@@ -785,7 +785,6 @@
 		candidates[i++] = local_candidate;
 	}
 
-end:
 	ao2_iterator_destroy(&it);
 	ao2_ref(local_candidates, -1);
 
@@ -2030,6 +2029,7 @@
 {
 	iks *content;
 	unsigned int changed = 0;
+	struct ast_channel *chan;
 
 	/* Look at the content in the session initiation */
 	for (content = iks_child(iks_child(pak->x)); content; content = iks_next(content)) {
@@ -2098,23 +2098,22 @@
 		}
 	}
 
-	/* Update the channel if the formats have changed */
-	if (changed) {
-		struct ast_channel *chan;
-
-		if ((chan = jingle_session_lock_full(session))) {
-			struct ast_format fmt;
-
-			ast_format_cap_copy(ast_channel_nativeformats(chan), session->jointcap);
-			ast_codec_choose(&session->prefs, session->jointcap, 1, &fmt);
-			ast_set_read_format(chan, &fmt);
-			ast_set_write_format(chan, &fmt);
-
-			ast_channel_unlock(chan);
-			ast_channel_unref(chan);
-		}
-		ao2_unlock(session);
-	}
+	if (!changed) {
+		return 0;
+	}
+
+	if ((chan = jingle_session_lock_full(session))) {
+		struct ast_format fmt;
+
+		ast_format_cap_copy(ast_channel_nativeformats(chan), session->jointcap);
+		ast_codec_choose(&session->prefs, session->jointcap, 1, &fmt);
+		ast_set_read_format(chan, &fmt);
+		ast_set_write_format(chan, &fmt);
+
+		ast_channel_unlock(chan);
+		ast_channel_unref(chan);
+	}
+	ao2_unlock(session);
 
 	return 0;
 }
@@ -2236,20 +2235,25 @@
 		return;
 	}
 
-	if ((chan = jingle_session_lock_full(session))) {
-		if (iks_find_with_attrib(pak->query, "ringing", "xmlns", JINGLE_RTP_INFO_NS)) {
-			ast_queue_control(chan, AST_CONTROL_RINGING);
-			if (ast_channel_state(chan) != AST_STATE_UP) {
-				ast_setstate(chan, AST_STATE_RINGING);
-			}
-		} else if (iks_find_with_attrib(pak->query, "hold", "xmlns", JINGLE_RTP_INFO_NS)) {
-			ast_queue_control(chan, AST_CONTROL_HOLD);
-		} else if (iks_find_with_attrib(pak->query, "unhold", "xmlns", JINGLE_RTP_INFO_NS)) {
-			ast_queue_control(chan, AST_CONTROL_UNHOLD);
-		}
-		ast_channel_unlock(chan);
-		ast_channel_unref(chan);
-	}
+	if (!(chan = jingle_session_lock_full(session))) {
+		ao2_unlock(session);
+		jingle_send_response(endpoint->connection, pak);
+		return;
+	}
+
+	if (iks_find_with_attrib(pak->query, "ringing", "xmlns", JINGLE_RTP_INFO_NS)) {
+		ast_queue_control(chan, AST_CONTROL_RINGING);
+		if (ast_channel_state(chan) != AST_STATE_UP) {
+			ast_setstate(chan, AST_STATE_RINGING);
+		}
+	} else if (iks_find_with_attrib(pak->query, "hold", "xmlns", JINGLE_RTP_INFO_NS)) {
+		ast_queue_control(chan, AST_CONTROL_HOLD);
+	} else if (iks_find_with_attrib(pak->query, "unhold", "xmlns", JINGLE_RTP_INFO_NS)) {
+		ast_queue_control(chan, AST_CONTROL_UNHOLD);
+	}
+
+	ast_channel_unlock(chan);
+	ast_channel_unref(chan);
 	ao2_unlock(session);
 
 	jingle_send_response(endpoint->connection, pak);
@@ -2259,6 +2263,8 @@
 static void jingle_action_session_terminate(struct jingle_endpoint *endpoint, struct jingle_session *session, ikspak *pak)
 {
 	struct ast_channel *chan;
+	iks *reason, *text;
+	int cause = AST_CAUSE_NORMAL;
 
 	if (!session) {
 		jingle_send_error_response(endpoint->connection, pak, "cancel", "item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'",
@@ -2266,30 +2272,31 @@
 		return;
 	}
 
-	if ((chan = jingle_session_lock_full(session))) {
-		iks *reason, *text;
-		int cause = AST_CAUSE_NORMAL;
-
-		/* Pull the reason text from the session-terminate message and translate it into a cause code */
-		if ((reason = iks_find(pak->query, "reason")) && (text = iks_child(reason))) {
-			int i;
-
-			/* Get the appropriate cause code mapping for this reason */
-			for (i = 0; i < ARRAY_LEN(jingle_reason_mappings); i++) {
-				if (!strcasecmp(jingle_reason_mappings[i].reason, iks_name(text))) {
-					cause = jingle_reason_mappings[i].cause;
-					break;
-				}
+	if (!(chan = jingle_session_lock_full(session))) {
+		ao2_unlock(session);
+		jingle_send_response(endpoint->connection, pak);
+		return;
+	}
+
+	/* Pull the reason text from the session-terminate message and translate it into a cause code */
+	if ((reason = iks_find(pak->query, "reason")) && (text = iks_child(reason))) {
+		int i;
+
+		/* Get the appropriate cause code mapping for this reason */
+		for (i = 0; i < ARRAY_LEN(jingle_reason_mappings); i++) {
+			if (!strcasecmp(jingle_reason_mappings[i].reason, iks_name(text))) {
+				cause = jingle_reason_mappings[i].cause;
+				break;
 			}
 		}
-
-		ast_debug(3, "Hanging up channel '%s' due to session terminate message with cause '%d'\n", ast_channel_name(chan), cause);
-		ast_queue_hangup_with_cause(chan, cause);
-		session->gone = 1;
-
-		ast_channel_unlock(chan);
-		ast_channel_unref(chan);
-	}
+	}
+
+	ast_debug(3, "Hanging up channel '%s' due to session terminate message with cause '%d'\n", ast_channel_name(chan), cause);
+	ast_queue_hangup_with_cause(chan, cause);
+	session->gone = 1;
+
+	ast_channel_unlock(chan);
+	ast_channel_unref(chan);
 	ao2_unlock(session);
 
 	jingle_send_response(endpoint->connection, pak);




More information about the asterisk-commits mailing list