[asterisk-commits] branch mogorman/asterisk-xmpp r10605 - in /team/mogorman/asterisk-xmpp: chann...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Feb 20 22:06:33 MST 2006


Author: mogorman
Date: Mon Feb 20 23:06:32 2006
New Revision: 10605

URL: http://svn.digium.com/view/asterisk?rev=10605&view=rev
Log:
should have worked.

Modified:
    team/mogorman/asterisk-xmpp/channels/chan_xmpp.c
    team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h

Modified: team/mogorman/asterisk-xmpp/channels/chan_xmpp.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/channels/chan_xmpp.c?rev=10605&r1=10604&r2=10605&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_xmpp.c Mon Feb 20 23:06:32 2006
@@ -205,18 +205,91 @@
 {
 	char *data, sid[100];
 	struct xmpp_pvt *p = client->xmpps;
+	struct ast_channel *bridgepeer = NULL;
+	struct hostent *hp;
+	struct ast_hostent ahp;
+	char iabuf[INET_ADDRSTRLEN];
+	struct sockaddr_in sin;
 
 	ast_verbose("ONLY A Little further %s\n",(iks_find_attrib(pak->x,"id")));
 	data = iks_find_attrib(pak->x,"id");
 	data = data + 9;
 	ast_copy_string(sid,data,sizeof(sid));
+
 	while(p) {
 		if(!strcasecmp(p->sid,sid)) {
 			break;
 		}
 		p = p->next;
 	}
-
+	
+	hp = ast_gethostbyname(p->candidates->ip, &ahp);
+        sin.sin_family = AF_INET;
+	memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
+	sin.sin_port = htons(client->candidates->port);
+	if (p->rtp && sin.sin_port) {
+		ast_rtp_set_peer(p->rtp, &sin);
+		ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(iabuf,sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+	}
+	
+	if (!p->owner)  /* There's no open channel owning us */
+		return 0;
+	if (!(p->owner->nativeformats & p->jointcapability & AST_FORMAT_AUDIO_MASK)) {
+		const unsigned slen=512;
+		char s1[slen], s2[slen];
+		ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %s and not %s\n", 
+				ast_getformatname_multiple(s1, slen, p->jointcapability),
+				ast_getformatname_multiple(s2, slen, p->owner->nativeformats));
+		p->owner->nativeformats = ast_codec_choose(&client->prefs, p->jointcapability, 1);
+		ast_set_read_format(p->owner, p->owner->readformat);
+		ast_set_write_format(p->owner, p->owner->writeformat);
+	}
+	if ((bridgepeer=ast_bridged_channel(p->owner))) {
+	//	/* We have a bridge */
+	//	/* Turn on/off music on hold if we are holding/unholding */
+	//	if (sin.sin_addr.s_addr && !sendonly) {
+	//		ast_moh_stop(bridgepeer);
+	//	
+	//		/* Activate a re-invite */
+	//		ast_queue_frame(p->owner, &ast_null_frame);
+	//	} else {
+	//		/* No address for RTP, we're on hold */
+	//		
+	//		ast_moh_start(bridgepeer, NULL);
+	//		if (sendonly)
+	//			ast_rtp_stop(p->rtp);
+	//		/* Activate a re-invite */
+	//		ast_queue_frame(p->owner, &ast_null_frame);
+	//	}
+	}
+
+//	/* Manager Hold and Unhold events must be generated, if necessary */
+//	if (sin.sin_addr.s_addr && !sendonly) {
+//		append_history(p, "Unhold", "%s", req->data);
+//
+//		if (global_callevents && ast_test_flag(p, SIP_CALL_ONHOLD)) {
+//			manager_event(EVENT_FLAG_CALL, "Unhold",
+//				"Channel: %s\r\n"
+//				"Uniqueid: %s\r\n",
+//				p->owner->name, 
+//				p->owner->uniqueid);
+//
+//		}
+//		ast_clear_flag(p, SIP_CALL_ONHOLD);
+//	} else {
+//		/* No address for RTP, we're on hold */
+//		append_history(p, "Hold", "%s", req->data);
+//
+//		if (global_callevents && !ast_test_flag(p, SIP_CALL_ONHOLD)) {
+//			manager_event(EVENT_FLAG_CALL, "Hold",
+//				"Channel: %s\r\n"
+//				"Uniqueid: %s\r\n",
+//				p->owner->name, 
+//				p->owner->uniqueid);
+//		}
+//		ast_set_flag(p, SIP_CALL_ONHOLD);
+//	}
+//	
 	return 1;
 }
 

Modified: team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h?rev=10605&r1=10604&r2=10605&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h (original)
+++ team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h Mon Feb 20 23:06:32 2006
@@ -97,6 +97,8 @@
 	struct axi_candidate *candidates;
 	struct ast_channel *owner;		/* Master Channel */
 	struct ast_rtp *rtp;          /*!< RTP Session */
+	int jointcapability;			/*!< Supported capability at both ends (codecs ) */
+
 	struct xmpp_pvt *next;			/* Next entity */
 };
 



More information about the asterisk-commits mailing list