[asterisk-commits] trunk r26417 - in /trunk: ./ channels/ include/asterisk/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed May 10 05:24:11 MST 2006


Author: kpfleming
Date: Wed May 10 07:24:11 2006
New Revision: 26417

URL: http://svn.digium.com/view/asterisk?rev=26417&view=rev
Log:
ensure that control frames with payload can be sent to channel drivers via ->indicate()
update iax2_indicate to pass control frame payload to the connected channel
add an API call for sending an indication with payload, and use it for control frames with payload

Modified:
    trunk/channel.c
    trunk/channels/chan_agent.c
    trunk/channels/chan_alsa.c
    trunk/channels/chan_features.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_local.c
    trunk/channels/chan_mgcp.c
    trunk/channels/chan_nbs.c
    trunk/channels/chan_oss.c
    trunk/channels/chan_phone.c
    trunk/channels/chan_sip.c
    trunk/channels/chan_skinny.c
    trunk/channels/chan_vpb.c
    trunk/channels/chan_zap.c
    trunk/include/asterisk/channel.h

Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Wed May 10 07:24:11 2006
@@ -2098,6 +2098,11 @@
 
 int ast_indicate(struct ast_channel *chan, int condition)
 {
+	return ast_indicate_data(chan, condition, NULL, 0);
+}
+
+int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
+{
 	int res = -1;
 
 	ast_channel_lock(chan);
@@ -2107,7 +2112,7 @@
 		return -1;
 	}
 	if (chan->tech->indicate)
-		res = chan->tech->indicate(chan, condition);
+		res = chan->tech->indicate(chan, condition, data, datalen);
 	ast_channel_unlock(chan);
 	if (!chan->tech->indicate || res) {
 		/*
@@ -3334,16 +3339,21 @@
 		other = (who == c0) ? c1 : c0; /* the 'other' channel */
 
 		if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) {
-			if ((f->subclass == AST_CONTROL_HOLD) || (f->subclass == AST_CONTROL_UNHOLD) ||
-			    (f->subclass == AST_CONTROL_VIDUPDATE)) {
-				ast_indicate(other, f->subclass);
-			} else {
+			switch (f->subclass) {
+			case AST_CONTROL_HOLD:
+			case AST_CONTROL_UNHOLD:
+			case AST_CONTROL_VIDUPDATE:
+				ast_indicate_data(other, f->subclass, f->data, f->datalen);
+				break;
+			default:
 				*fo = f;
 				*rc = who;
 				res =  AST_BRIDGE_COMPLETE;
 				ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
 				break;
 			}
+			if (res == AST_BRIDGE_COMPLETE)
+				break;
 		}
 		if ((f->frametype == AST_FRAME_VOICE) ||
 		    (f->frametype == AST_FRAME_DTMF) ||

Modified: trunk/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_agent.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Wed May 10 07:24:11 2006
@@ -248,7 +248,7 @@
 static int agent_write(struct ast_channel *ast, struct ast_frame *f);
 static int agent_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
 static int agent_sendtext(struct ast_channel *ast, const char *text);
-static int agent_indicate(struct ast_channel *ast, int condition);
+static int agent_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
 static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge);
 static void set_agentbycallerid(const char *callerid, const char *agent);
@@ -586,7 +586,7 @@
 	return 0;
 }
 
-static int agent_indicate(struct ast_channel *ast, int condition)
+static int agent_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
 	struct agent_pvt *p = ast->tech_pvt;
 	int res = -1;

Modified: trunk/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_alsa.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_alsa.c (original)
+++ trunk/channels/chan_alsa.c Wed May 10 07:24:11 2006
@@ -183,7 +183,7 @@
 static struct ast_frame *alsa_read(struct ast_channel *chan);
 static int alsa_call(struct ast_channel *c, char *dest, int timeout);
 static int alsa_write(struct ast_channel *chan, struct ast_frame *f);
-static int alsa_indicate(struct ast_channel *chan, int cond);
+static int alsa_indicate(struct ast_channel *chan, int cond, const void *data, size_t datalen);
 static int alsa_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 
 static const struct ast_channel_tech alsa_tech = {
@@ -750,7 +750,7 @@
 	return 0;
 }
 
-static int alsa_indicate(struct ast_channel *chan, int cond)
+static int alsa_indicate(struct ast_channel *chan, int cond, const void *data, size_t datalen)
 {
 	int res = 0;
 	ast_mutex_lock(&alsalock);

Modified: trunk/channels/chan_features.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_features.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_features.c (original)
+++ trunk/channels/chan_features.c Wed May 10 07:24:11 2006
@@ -101,7 +101,7 @@
 static int features_answer(struct ast_channel *ast);
 static struct ast_frame *features_read(struct ast_channel *ast);
 static int features_write(struct ast_channel *ast, struct ast_frame *f);
-static int features_indicate(struct ast_channel *ast, int condition);
+static int features_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
 static int features_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 
 static const struct ast_channel_tech features_tech = {
@@ -285,7 +285,7 @@
 	return 0;
 }
 
-static int features_indicate(struct ast_channel *ast, int condition)
+static int features_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
 	struct feature_pvt *p = ast->tech_pvt;
 	int res = -1;

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Wed May 10 07:24:11 2006
@@ -791,7 +791,7 @@
 static int iax2_do_register(struct iax2_registry *reg);
 static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newchan);
 static int iax2_hangup(struct ast_channel *c);
-static int iax2_indicate(struct ast_channel *c, int condition);
+static int iax2_indicate(struct ast_channel *c, int condition, const void *data, size_t datalen);
 static int iax2_poke_peer(struct iax2_peer *peer, int heldcall);
 static int iax2_provision(struct sockaddr_in *end, int sockfd, char *dest, const char *template, int force);
 static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned int ts, int seqno, int now, int transfer, int final);
@@ -3493,12 +3493,12 @@
 	return send_command_locked(callno, AST_FRAME_CONTROL, AST_CONTROL_ANSWER, 0, NULL, 0, -1);
 }
 
-static int iax2_indicate(struct ast_channel *c, int condition)
+static int iax2_indicate(struct ast_channel *c, int condition, const void *data, size_t datalen)
 {
 	unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
 	if (option_debug && iaxdebug)
 		ast_log(LOG_DEBUG, "Indicating condition %d\n", condition);
-	return send_command_locked(callno, AST_FRAME_CONTROL, condition, 0, NULL, 0, -1);
+	return send_command_locked(callno, AST_FRAME_CONTROL, condition, 0, data, datalen, -1);
 }
 	
 static int iax2_transfer(struct ast_channel *c, const char *dest)

Modified: trunk/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_local.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_local.c (original)
+++ trunk/channels/chan_local.c Wed May 10 07:24:11 2006
@@ -72,7 +72,7 @@
 static int local_answer(struct ast_channel *ast);
 static struct ast_frame *local_read(struct ast_channel *ast);
 static int local_write(struct ast_channel *ast, struct ast_frame *f);
-static int local_indicate(struct ast_channel *ast, int condition);
+static int local_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
 static int local_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 static int local_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
 
@@ -261,7 +261,7 @@
 	return 0;
 }
 
-static int local_indicate(struct ast_channel *ast, int condition)
+static int local_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
 	struct local_pvt *p = ast->tech_pvt;
 	int res = -1;

Modified: trunk/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_mgcp.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Wed May 10 07:24:11 2006
@@ -494,7 +494,7 @@
 static int mgcp_answer(struct ast_channel *ast);
 static struct ast_frame *mgcp_read(struct ast_channel *ast);
 static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame);
-static int mgcp_indicate(struct ast_channel *ast, int ind);
+static int mgcp_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen);
 static int mgcp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 static int mgcp_senddigit(struct ast_channel *ast, char digit);
 static int mgcp_devicestate(void *data);
@@ -1401,7 +1401,7 @@
 	return "UNKNOWN";
 }
 
-static int mgcp_indicate(struct ast_channel *ast, int ind)
+static int mgcp_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen)
 {
 	struct mgcp_subchannel *sub = ast->tech_pvt;
 	int res = 0;

Modified: trunk/channels/chan_nbs.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_nbs.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_nbs.c (original)
+++ trunk/channels/chan_nbs.c Wed May 10 07:24:11 2006
@@ -296,12 +296,12 @@
 	return 0;
 }
 
-int unload_module(void)
+static int unload_module(void)
 {
 	return __unload_module();
 }
 
-int load_module(void)
+static int load_module(void)
 {
 	/* Make sure we can register our channel type */
 	if (ast_channel_register(&nbs_tech)) {

Modified: trunk/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_oss.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_oss.c (original)
+++ trunk/channels/chan_oss.c Wed May 10 07:24:11 2006
@@ -373,7 +373,7 @@
 static struct ast_frame *oss_read(struct ast_channel *chan);
 static int oss_call(struct ast_channel *c, char *dest, int timeout);
 static int oss_write(struct ast_channel *chan, struct ast_frame *f);
-static int oss_indicate(struct ast_channel *chan, int cond);
+static int oss_indicate(struct ast_channel *chan, int cond, const void *data, size_t datalen);
 static int oss_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 static char tdesc[] = "OSS Console Channel Driver";
 
@@ -901,7 +901,7 @@
 	return 0;
 }
 
-static int oss_indicate(struct ast_channel *c, int cond)
+static int oss_indicate(struct ast_channel *c, int cond, const void *data, size_t datalen)
 {
 	struct chan_oss_pvt *o = c->tech_pvt;
 	int res;

Modified: trunk/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_phone.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_phone.c (original)
+++ trunk/channels/chan_phone.c Wed May 10 07:24:11 2006
@@ -169,7 +169,7 @@
 static struct ast_frame *phone_exception(struct ast_channel *ast);
 static int phone_send_text(struct ast_channel *ast, const char *text);
 static int phone_fixup(struct ast_channel *old, struct ast_channel *new);
-static int phone_indicate(struct ast_channel *chan, int condition);
+static int phone_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen);
 
 static const struct ast_channel_tech phone_tech = {
 	.type = "Phone",
@@ -206,7 +206,7 @@
 
 static struct ast_channel_tech *cur_tech;
 
-static int phone_indicate(struct ast_channel *chan, int condition)
+static int phone_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen)
 {
 	struct phone_pvt *p = chan->tech_pvt;
 	int res=-1;

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed May 10 07:24:11 2006
@@ -1060,7 +1060,7 @@
 static int sip_answer(struct ast_channel *ast);
 static struct ast_frame *sip_read(struct ast_channel *ast);
 static int sip_write(struct ast_channel *ast, struct ast_frame *frame);
-static int sip_indicate(struct ast_channel *ast, int condition);
+static int sip_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
 static int sip_transfer(struct ast_channel *ast, const char *dest);
 static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 static int sip_senddigit(struct ast_channel *ast, char digit);
@@ -2927,7 +2927,7 @@
    the indication - busy signal, congestion etc 
    \return -1 to force ast_indicate to send indication in audio, 0 if SIP can handle the indication by sending a message
 */
-static int sip_indicate(struct ast_channel *ast, int condition)
+static int sip_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
 	struct sip_pvt *p = ast->tech_pvt;
 	int res = 0;

Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Wed May 10 07:24:11 2006
@@ -901,7 +901,7 @@
 static int skinny_answer(struct ast_channel *ast);
 static struct ast_frame *skinny_read(struct ast_channel *ast);
 static int skinny_write(struct ast_channel *ast, struct ast_frame *frame);
-static int skinny_indicate(struct ast_channel *ast, int ind);
+static int skinny_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen);
 static int skinny_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 static int skinny_senddigit(struct ast_channel *ast, char digit);
 
@@ -2172,7 +2172,7 @@
 }
 
 
-static int skinny_indicate(struct ast_channel *ast, int ind)
+static int skinny_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen)
 {
 	struct skinny_subchannel *sub = ast->tech_pvt;
 	struct skinny_line *l = sub->parent;

Modified: trunk/channels/chan_vpb.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_vpb.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_vpb.c (original)
+++ trunk/channels/chan_vpb.c Wed May 10 07:24:11 2006
@@ -349,7 +349,7 @@
 static struct ast_frame *vpb_read(struct ast_channel *ast);
 static int vpb_write(struct ast_channel *ast, struct ast_frame *frame);
 static enum ast_bridge_result ast_vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
-static int vpb_indicate(struct ast_channel *ast, int condition);
+static int vpb_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
 static int vpb_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 
 static struct ast_channel_tech vpb_tech = {
@@ -1720,7 +1720,7 @@
 	return tmp;
 }
 
-static int vpb_indicate(struct ast_channel *ast, int condition)
+static int vpb_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
 	struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
 	int res = 0;
@@ -1818,7 +1818,7 @@
 		else {
 			if (option_verbose > 3)
 				ast_verbose(VERBOSE_PREFIX_4 "%s: vpb_fixup Calling vpb_indicate\n", p->dev);
-			vpb_indicate(newchan, AST_CONTROL_RINGING);
+			vpb_indicate(newchan, AST_CONTROL_RINGING, NULL, 0);
 		}
 	}
 

Modified: trunk/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_zap.c?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/channels/chan_zap.c (original)
+++ trunk/channels/chan_zap.c Wed May 10 07:24:11 2006
@@ -695,7 +695,7 @@
 struct ast_frame *zt_read(struct ast_channel *ast);
 static int zt_write(struct ast_channel *ast, struct ast_frame *frame);
 struct ast_frame *zt_exception(struct ast_channel *ast);
-static int zt_indicate(struct ast_channel *chan, int condition);
+static int zt_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen);
 static int zt_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 static int zt_setoption(struct ast_channel *chan, int option, void *data, int datalen);
 static int zt_func_read(struct ast_channel *chan, char *function, char *data, char *buf, size_t len); 
@@ -3341,7 +3341,7 @@
 			p->subs[x].owner = newchan;
 		}
 	if (newchan->_state == AST_STATE_RINGING) 
-		zt_indicate(newchan, AST_CONTROL_RINGING);
+		zt_indicate(newchan, AST_CONTROL_RINGING, NULL, 0);
 	update_conf(p);
 	ast_mutex_unlock(&p->lock);
 	return 0;
@@ -4843,7 +4843,7 @@
 	return 0;
 }
 
-static int zt_indicate(struct ast_channel *chan, int condition)
+static int zt_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen)
 {
 	struct zt_pvt *p = chan->tech_pvt;
 	int res=-1;

Modified: trunk/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/channel.h?rev=26417&r1=26416&r2=26417&view=diff
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Wed May 10 07:24:11 2006
@@ -250,7 +250,7 @@
 						struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
 
 	/*! Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */
-	int (* const indicate)(struct ast_channel *c, int condition);
+	int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen);
 
 	/*! Fix up a channel:  If a channel is consumed, this is called.  Basically update any ->owner links */
 	int (* const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan);
@@ -764,6 +764,16 @@
  */
 int ast_indicate(struct ast_channel *chan, int condition);
 
+/*! \brief Indicates condition of channel, with payload
+ * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
+ * \param chan channel to change the indication
+ * \param condition which condition to indicate on the channel
+ * \param data pointer to payload data
+ * \param datalen size of payload data
+ * \return Returns 0 on success, -1 on failure
+ */
+int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen);
+
 /* Misc stuff ------------------------------------------------ */
 
 /*! \brief Wait for input on a channel 



More information about the asterisk-commits mailing list