[asterisk-commits] file: trunk r114049 - in /trunk: CHANGES channels/chan_local.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 10 15:28:41 CDT 2008


Author: file
Date: Thu Apr 10 15:28:40 2008
New Revision: 114049

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114049
Log:
A 'b' option has been added which causes chan_local to return the actual channel that is behind it when queried. This is useful for transfer scenarios as the actual channel will be transferred, not the Local channel. If you have been using Local channels as queue members and having issues when the agent did a blind transfer this option may solve the issue.

Modified:
    trunk/CHANGES
    trunk/channels/chan_local.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=114049&r1=114048&r2=114049
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Apr 10 15:28:40 2008
@@ -257,6 +257,9 @@
      SIP call to Voicemail by putting a Local channel in the middle.  This
      feature is enabled by using the 'j' option in the Dial string to the Local
      channel in conjunction with the existing 'n' option for local channels.
+  * A 'b' option has been added which causes chan_local to return the actual channel
+     that is behind it when queried. This is useful for transfer scenarios as the
+     actual channel will be transferred, not the Local channel.
 
 Zaptel channel driver (chan_zap) Changes
 ----------------------------------------

Modified: trunk/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_local.c?view=diff&rev=114049&r1=114048&r2=114049
==============================================================================
--- trunk/channels/chan_local.c (original)
+++ trunk/channels/chan_local.c Thu Apr 10 15:28:40 2008
@@ -74,6 +74,7 @@
 static int local_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
 static int local_sendtext(struct ast_channel *ast, const char *text);
 static int local_devicestate(void *data);
+static struct ast_channel *local_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge);
 
 /* PBX interface structure for channel registration */
 static const struct ast_channel_tech local_tech = {
@@ -95,6 +96,7 @@
 	.send_html = local_sendhtml,
 	.send_text = local_sendtext,
 	.devicestate = local_devicestate,
+	.bridged_channel = local_bridgedchannel,
 };
 
 struct local_pvt {
@@ -116,6 +118,7 @@
 #define LOCAL_ALREADY_MASQED  (1 << 2) /*!< Already masqueraded */
 #define LOCAL_LAUNCHED_PBX    (1 << 3) /*!< PBX was launched */
 #define LOCAL_NO_OPTIMIZATION (1 << 4) /*!< Do not optimize using masquerading */
+#define LOCAL_BRIDGE          (1 << 5) /*!< Report back the "true" channel as being bridged to */
 
 static AST_LIST_HEAD_STATIC(locals, local_pvt);
 
@@ -165,6 +168,28 @@
 	ast_mutex_destroy(&pvt->lock);
 	ast_free(pvt);
 	return NULL;
+}
+
+/*! \brief Return the bridged channel of a Local channel */
+static struct ast_channel *local_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge)
+{
+	struct local_pvt *p = bridge->tech_pvt;
+	struct ast_channel *bridged = bridge;
+
+	ast_mutex_lock(&p->lock);
+
+	if (ast_test_flag(p, LOCAL_BRIDGE)) {
+		/* Find the opposite channel */
+		bridged = (bridge == p->owner ? p->chan : p->owner);
+		
+		/* Now see if the opposite channel is bridged to anything */
+		if (bridged->_bridge)
+			bridged = bridged->_bridge;
+	}
+
+	ast_mutex_unlock(&p->lock);
+
+	return bridged;
 }
 
 static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_frame *f, struct ast_channel *us)
@@ -601,6 +626,9 @@
 					"to use the 'j' option to enable the jitterbuffer\n");
 			}
 		}
+		if (strchr(opts, 'b')) {
+			ast_set_flag(tmp, LOCAL_BRIDGE);
+		}
 	}
 
 	/* Look for a context */




More information about the asterisk-commits mailing list