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

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Feb 20 22:56:49 MST 2006


Author: mogorman
Date: Mon Feb 20 23:56:48 2006
New Revision: 10608

URL: http://svn.digium.com/view/asterisk?rev=10608&view=rev
Log:
broken.

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=10608&r1=10607&r2=10608&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_xmpp.c Mon Feb 20 23:56:48 2006
@@ -95,9 +95,13 @@
 static const struct ast_channel_tech xmpp_tech = {
 	.type = type,
 	.description = tdesc,
-	.capabilities = -1,
+	.capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
 	.requester = xmpp_request,
 	.send_digit = xmpp_digit,
+//	.requester = xmpp_request_call,
+//	.devicestate = xmpp_devicestate,
+//	.transfer = xmpp_transfer,
+	.bridge = ast_rtp_bridge,
 	.call = xmpp_call,
 	.hangup = xmpp_hangup,
 	.answer = xmpp_answer,
@@ -114,17 +118,17 @@
 static struct sched_context *sched;	/*!< The scheduling context */
 static struct io_context *io;		/*!< The IO context */
 static struct in_addr __ourip;
-///*----- RTP interface functions */
-//static int xmpp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, int codecs, int nat_active);
-//static struct ast_rtp *xmpp_get_rtp_peer(struct ast_channel *chan);
-//static int xmpp_get_codec(struct ast_channel *chan);
-//
-//static struct ast_rtp_protocol xmpp_rtp = {
-//	type: "XMPP",
-//	get_rtp_info: xmpp_get_rtp_peer,
-//	set_rtp_peer: xmpp_set_rtp_peer,
-//	get_codec: xmpp_get_codec,
-//};
+/*----- RTP interface functions */
+static int xmpp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, int codecs, int nat_active);
+static struct ast_rtp *xmpp_get_rtp_peer(struct ast_channel *chan);
+static int xmpp_get_codec(struct ast_channel *chan);
+
+static struct ast_rtp_protocol xmpp_rtp = {
+	type: "XMPP",
+	get_rtp_info: xmpp_get_rtp_peer,
+	set_rtp_peer: xmpp_set_rtp_peer,
+	get_codec: xmpp_get_codec,
+};
 
 static int flipflop = 0;
 
@@ -199,6 +203,46 @@
 	ast_mutex_unlock(&rand_lock);
 	
 	return val;
+}
+
+static struct ast_rtp *xmpp_get_rtp_peer(struct ast_channel *chan)
+{
+	struct xmpp_pvt *p;
+	struct ast_rtp *rtp = NULL;
+	p = chan->tech_pvt;
+	if (!p)
+		return NULL;
+	ast_mutex_lock(&p->lock);
+	if (p->rtp)
+		rtp =  p->rtp;
+	ast_mutex_unlock(&p->lock);
+	return rtp;
+}
+
+static int xmpp_get_codec(struct ast_channel *chan)
+{
+	struct xmpp_pvt *p = chan->tech_pvt;
+	return p->peercapability;
+}
+
+static int xmpp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, int codecs, int nat_active)
+{
+	struct xmpp_pvt *p;
+
+	p = chan->tech_pvt;
+	if (!p) 
+		return -1;
+	ast_mutex_lock(&p->lock);
+
+/*	if (rtp)
+		ast_rtp_get_peer(rtp, &p->redirip);
+	else
+		memset(&p->redirip, 0, sizeof(p->redirip));
+	p->redircodecs = codecs; */
+
+	/* Reset lastrtprx timer */
+	ast_mutex_unlock(&p->lock);
+	return 0;
 }
 
 static int xmpp_bridge_call(struct axi_client *client,ikspak *pak)
@@ -571,8 +615,11 @@
 static int xmpp_answer2(struct axi_client *client,ikspak *pak)
 {
 	struct xmpp_pvt *p ,*tmp = client->xmpps;
+	struct ast_channel *chan;
 	iks *accept, *codec;
 	codec = iks_child(iks_child(iks_child(pak->x)));
+	chan = ast_channel_alloc(1);
+	chan->tech = &xmpp_tech;
 	while(tmp) {
 		if(iks_find_with_attrib(pak->x,GOOGLE_NODE,GOOGLE_SID,tmp->sid))
 		{
@@ -681,11 +728,42 @@
 {
 }
 
+static struct ast_frame *xmpp_rtp_read(struct ast_channel *ast, struct xmpp_pvt *p)
+{
+	struct ast_frame *f;
+	if (!p->rtp) {
+		return &ast_null_frame;
+	}
+	f = ast_rtp_read(p->rtp);
+        if (p->owner) {
+		/* We already hold the channel lock */
+		if (f->frametype == AST_FRAME_VOICE) {
+			if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
+				if (option_debug)
+					ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+				p->owner->nativeformats = (p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
+				ast_set_read_format(p->owner, p->owner->readformat);
+				ast_set_write_format(p->owner, p->owner->writeformat);
+			}
+/*			if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
+				f = ast_dsp_process(p->owner, p->vad, f);
+				if (option_debug && f && (f->frametype == AST_FRAME_DTMF))
+					ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+		        } */
+		}
+        }
+	return f;
+}
+
 static struct ast_frame  *xmpp_read(struct ast_channel *ast)
 {
-	static struct ast_frame null = { AST_FRAME_NULL, };
-
-	return &null;
+	struct ast_frame *fr;
+	struct xmpp_pvt *p = ast->tech_pvt;
+	
+	ast_mutex_lock(&p->lock);
+	fr = xmpp_rtp_read(ast, p);
+	ast_mutex_unlock(&p->lock);
+	return fr;
 }
 
 static int xmpp_write(struct ast_channel *ast, struct ast_frame *f)
@@ -1031,7 +1109,7 @@
 	}
 
 	if (ast_find_ourip(&__ourip, bindaddr)) {
-		ast_log(LOG_WARNING, "Unable to get own IP address, SIP disabled\n");
+		ast_log(LOG_WARNING, "Unable to get own IP address, XMPP disabled\n");
 		return 0;
 	}
 	
@@ -1041,6 +1119,7 @@
 		ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
 		return -1;
 	}
+
 	ast_cli_register(&cli_show_xmpps);
 	return 0;
 }

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=10608&r1=10607&r2=10608&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h (original)
+++ team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h Mon Feb 20 23:56:48 2006
@@ -98,6 +98,7 @@
 	struct ast_channel *owner;		/* Master Channel */
 	struct ast_rtp *rtp;          /*!< RTP Session */
 	int jointcapability;			/*!< Supported capability at both ends (codecs ) */
+	int peercapability;
 
 	struct xmpp_pvt *next;			/* Next entity */
 };



More information about the asterisk-commits mailing list