[asterisk-commits] rmudgett: branch rmudgett/display_text r305249 - in /team/rmudgett/display_te...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 31 16:53:17 CST 2011


Author: rmudgett
Date: Mon Jan 31 16:53:11 2011
New Revision: 305249

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=305249
Log:
Initial display text implementation.

Modified:
    team/rmudgett/display_text/apps/app_sendtext.c
    team/rmudgett/display_text/channels/chan_dahdi.c
    team/rmudgett/display_text/channels/sig_pri.c
    team/rmudgett/display_text/channels/sig_pri.h
    team/rmudgett/display_text/configs/chan_dahdi.conf.sample
    team/rmudgett/display_text/configure.ac
    team/rmudgett/display_text/main/channel.c

Modified: team/rmudgett/display_text/apps/app_sendtext.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/display_text/apps/app_sendtext.c?view=diff&rev=305249&r1=305248&r2=305249
==============================================================================
--- team/rmudgett/display_text/apps/app_sendtext.c (original)
+++ team/rmudgett/display_text/apps/app_sendtext.c Mon Jan 31 16:53:11 2011
@@ -98,10 +98,10 @@
 		return 0;
 	}
 	status = "FAILURE";
-	ast_channel_unlock(chan);
 	if (!ast_sendtext(chan, ast_str_buffer(str))) {
 		status = "SUCCESS";
 	}
+	ast_channel_unlock(chan);
 	pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
 	return 0;
 }

Modified: team/rmudgett/display_text/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/display_text/channels/chan_dahdi.c?view=diff&rev=305249&r1=305248&r2=305249
==============================================================================
--- team/rmudgett/display_text/channels/chan_dahdi.c (original)
+++ team/rmudgett/display_text/channels/chan_dahdi.c Mon Jan 31 16:53:11 2011
@@ -12324,6 +12324,10 @@
 						ast_copy_string(pris[span].pri.unknownprefix, conf->pri.pri.unknownprefix, sizeof(pris[span].pri.unknownprefix));
 						pris[span].pri.moh_signaling = conf->pri.pri.moh_signaling;
 						pris[span].pri.resetinterval = conf->pri.pri.resetinterval;
+#if defined(HAVE_PRI_DISPLAY_TEXT)
+						pris[span].pri.display_flags_send = conf->pri.pri.display_flags_send;
+						pris[span].pri.display_flags_receive = conf->pri.pri.display_flags_receive;
+#endif	/* defined(HAVE_PRI_DISPLAY_TEXT) */
 
 						for (x = 0; x < PRI_MAX_TIMERS; x++) {
 							pris[span].pri.pritimers[x] = conf->pri.pri.pritimers[x];
@@ -16450,6 +16454,53 @@
 		confp->chan.echocancel.head.param_count++;
 	}
 }
+
+#if defined(HAVE_PRI)
+#if defined(HAVE_PRI_DISPLAY_TEXT)
+/*!
+ * \internal
+ * \brief Determine the configured display text options.
+ * \since 1.10
+ *
+ * \param value Configuration value string.
+ *
+ * \return Configured display text option flags.
+ */
+static unsigned long dahdi_display_text_option(const char *value)
+{
+	char *val_str;
+	char *opt_str;
+	unsigned long options;
+
+	options = 0;
+	val_str = ast_strdupa(value);
+
+	for (;;) {
+		opt_str = strsep(&val_str, ",");
+		if (!opt_str) {
+			break;
+		}
+		opt_str = ast_strip(opt_str);
+		if (!*opt_str) {
+			continue;
+		}
+
+		if (!strcasecmp(opt_str, "block")) {
+			options |= PRI_DISPLAY_OPTION_BLOCK;
+		} else if (!strcasecmp(opt_str, "name_initial")) {
+			options |= PRI_DISPLAY_OPTION_NAME_INITIAL;
+		} else if (!strcasecmp(opt_str, "name_update")) {
+			options |= PRI_DISPLAY_OPTION_NAME_UPDATE;
+		} else if (!strcasecmp(opt_str, "name")) {
+			options |= (PRI_DISPLAY_OPTION_NAME_INITIAL | PRI_DISPLAY_OPTION_NAME_UPDATE);
+		} else if (!strcasecmp(opt_str, "text")) {
+			options |= PRI_DISPLAY_OPTION_TEXT;
+		}
+	}
+	return options;
+}
+#endif	/* defined(HAVE_PRI_DISPLAY_TEXT) */
+#endif	/* defined(HAVE_PRI) */
 
 /*! process_dahdi() - ignore keyword 'channel' and similar */
 #define PROC_DAHDI_OPT_NOCHAN  (1 << 0)
@@ -17223,6 +17274,12 @@
 #endif	/* defined(HAVE_PRI_MWI) */
 			} else if (!strcasecmp(v->name, "append_msn_to_cid_tag")) {
 				confp->pri.pri.append_msn_to_user_tag = ast_true(v->value);
+#if defined(HAVE_PRI_DISPLAY_TEXT)
+			} else if (!strcasecmp(v->name, "display_send")) {
+				confp->pri.pri.display_flags_send = dahdi_display_text_option(v->value);
+			} else if (!strcasecmp(v->name, "display_receive")) {
+				confp->pri.pri.display_flags_receive = dahdi_display_text_option(v->value);
+#endif	/* defined(HAVE_PRI_DISPLAY_TEXT) */
 #endif /* HAVE_PRI */
 #if defined(HAVE_SS7)
 			} else if (!strcasecmp(v->name, "ss7type")) {
@@ -18131,13 +18188,26 @@
 	float scont = 0.0;
 	int idx;
 
+	if (!text[0]) {
+		return(0); /* if nothing to send, don't */
+	}
 	idx = dahdi_get_index(c, p, 0);
 	if (idx < 0) {
 		ast_log(LOG_WARNING, "Huh?  I don't exist?\n");
 		return -1;
 	}
-	if (!text[0]) return(0); /* if nothing to send, don't */
-	if ((!p->tdd) && (!p->mate)) return(0);  /* if not in TDD mode, just return */
+	if ((!p->tdd) && (!p->mate)) {
+#if defined(HAVE_PRI)
+#if defined(HAVE_PRI_DISPLAY_TEXT)
+		ast_mutex_lock(&p->lock);
+		if (dahdi_sig_pri_lib_handles(p->sig)) {
+			sig_pri_sendtext(p->sig_pvt, text);
+		}
+		ast_mutex_unlock(&p->lock);
+#endif	/* defined(HAVE_PRI_DISPLAY_TEXT) */
+#endif	/* defined(HAVE_PRI) */
+		return(0);  /* if not in TDD mode, just return */
+	}
 	if (p->mate)
 		buf = ast_malloc(((strlen(text) + 1) * ASCII_BYTES_PER_CHAR) + END_SILENCE_LEN + HEADER_LEN);
 	else

Modified: team/rmudgett/display_text/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/display_text/channels/sig_pri.c?view=diff&rev=305249&r1=305248&r2=305249
==============================================================================
--- team/rmudgett/display_text/channels/sig_pri.c (original)
+++ team/rmudgett/display_text/channels/sig_pri.c Mon Jan 31 16:53:11 2011
@@ -4084,6 +4084,31 @@
 			/* Ignore for now. */
 			break;
 #endif	/* defined(HAVE_PRI_MCID) */
+#if defined(HAVE_PRI_DISPLAY_TEXT)
+		case PRI_SUBCMD_DISPLAY_TEXT:
+			if (event_id != PRI_EVENT_RING) {
+				/*
+				 * This display text was not from a SETUP message.  We can do
+				 * something with this display text string.
+				 */
+				sig_pri_lock_owner(pri, chanpos);
+				owner = pri->pvts[chanpos]->owner;
+				if (owner) {
+					struct ast_frame f;
+
+					/* Pass the display text to the peer channel. */
+					memset(&f, 0, sizeof(f));
+					f.frametype = AST_FRAME_TEXT;
+					f.subclass.integer = 0;
+					f.offset = 0;
+					f.data.ptr = &subcmd->u.display.text;
+					f.datalen = subcmd->u.display.length;
+					ast_queue_frame(owner, &f);
+					ast_channel_unlock(owner);
+				}
+			}
+			break;
+#endif	/* defined(HAVE_PRI_DISPLAY_TEXT) */
 		default:
 			ast_debug(2,
 				"Unknown call subcommand(%d) in %s event on channel %d/%d on span %d.\n",
@@ -8171,6 +8196,10 @@
 #if defined(HAVE_PRI_MCID)
 	pri_mcid_enable(pri->pri, 1);
 #endif	/* defined(HAVE_PRI_MCID) */
+#if defined(HAVE_PRI_DISPLAY_TEXT)
+	pri_display_options_send(pri->pri, pri->display_flags_send);
+	pri_display_options_receive(pri->pri, pri->display_flags_receive);
+#endif	/* defined(HAVE_PRI_DISPLAY_TEXT) */
 
 	pri->resetpos = -1;
 	if (ast_pthread_create_background(&pri->master, NULL, pri_dchannel, pri)) {
@@ -8381,6 +8410,31 @@
 	}
 }
 
+#if defined(HAVE_PRI_DISPLAY_TEXT)
+/*!
+ * \brief Send display text.
+ * \since 1.10
+ *
+ * \param p Channel to send text over
+ * \param text Text to send.
+ *
+ * \return Nothing
+ */
+void sig_pri_sendtext(struct sig_pri_chan *p, const char *text)
+{
+	struct pri_subcmd_display_txt display;
+
+	if (p->pri && p->pri->pri) {
+		ast_copy_string(display.text, text, sizeof(display.text));
+		display.length = strlen(display.text);
+		display.char_set = 0;/* unknown(0) */
+		pri_grab(p, p->pri);
+		pri_display_text(p->pri->pri, p->call, &display);
+		pri_rel(p->pri);
+	}
+}
+#endif	/* defined(HAVE_PRI_DISPLAY_TEXT) */
+
 #if defined(HAVE_PRI_CCSS)
 /*!
  * \brief PRI CC agent initialization.

Modified: team/rmudgett/display_text/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/display_text/channels/sig_pri.h?view=diff&rev=305249&r1=305248&r2=305249
==============================================================================
--- team/rmudgett/display_text/channels/sig_pri.h (original)
+++ team/rmudgett/display_text/channels/sig_pri.h Mon Jan 31 16:53:11 2011
@@ -31,6 +31,10 @@
 #include "asterisk/ccss.h"
 #include <libpri.h>
 #include <dahdi/user.h>
+
+#if defined(PRI_SUBCMD_DISPLAY_TEXT)
+#define	HAVE_PRI_DISPLAY_TEXT	1	/* BUGBUG delete this when merge branch. */
+#endif
 
 #if defined(HAVE_PRI_CCSS)
 /*! PRI debug message flags when normal PRI debugging is turned on at the command line. */
@@ -412,6 +416,10 @@
 	char unknownprefix[20];					/*!< for unknown dialplans */
 	enum sig_pri_moh_signaling moh_signaling;
 	long resetinterval;						/*!< Interval (in seconds) for resetting unused channels */
+#if defined(HAVE_PRI_DISPLAY_TEXT)
+	unsigned long display_flags_send;		/*!< PRI_DISPLAY_OPTION_xxx flags for display text sending */
+	unsigned long display_flags_receive;	/*!< PRI_DISPLAY_OPTION_xxx flags for display text receiving */
+#endif	/* defined(HAVE_PRI_DISPLAY_TEXT) */
 #if defined(HAVE_PRI_MWI)
 	/*! \brief Active MWI mailboxes */
 	struct sig_pri_mbox mbox[SIG_PRI_MAX_MWI_MAILBOXES];
@@ -576,6 +584,9 @@
 #endif	/* defined(HAVE_PRI_SERVICE_MESSAGES) */
 
 void sig_pri_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_pri_chan *pchan);
+#if defined(HAVE_PRI_DISPLAY_TEXT)
+void sig_pri_sendtext(struct sig_pri_chan *pchan, const char *text);
+#endif	/* defined(HAVE_PRI_DISPLAY_TEXT) */
 
 int sig_pri_cc_agent_init(struct ast_cc_agent *agent, struct sig_pri_chan *pvt_chan);
 int sig_pri_cc_agent_start_offer_timer(struct ast_cc_agent *agent);

Modified: team/rmudgett/display_text/configs/chan_dahdi.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/display_text/configs/chan_dahdi.conf.sample?view=diff&rev=305249&r1=305248&r2=305249
==============================================================================
--- team/rmudgett/display_text/configs/chan_dahdi.conf.sample (original)
+++ team/rmudgett/display_text/configs/chan_dahdi.conf.sample Mon Jan 31 16:53:11 2011
@@ -205,7 +205,32 @@
 ; yes or both: both directions
 ;
 ;overlapdial=yes
-;
+
+; Send/receive ISDN display IE options.  The display options are a comma separated
+; list of the following options:
+;
+; block:        Do not pass display text data.
+;               Q.SIG: Default for send/receive.
+;               ETSI CPE: Default for send.
+; name_initial: Use display text in SETUP/CONNECT messages as the party name.
+;               Default for all other modes.
+; name_update:  Use display text in other messages (NOTIFY/FACILITY) for COLP name
+;               update.
+; name:         Combined name_initial and name_update options.
+; text:         Pass any unused display text data as an arbitrary display message
+;               during a call.  Sent text goes out in an INFORMATION message.
+;
+; * Default is an empty string for legacy behavior.
+; * The name options are not recommended for Q.SIG since Q.SIG already
+;   supports names.
+; * The send block is the only recommended setting for CPE mode since Q.931 uses
+;   the display IE only in the network to user direction.
+;
+; display_send and display_receive cannot be changed on reload.
+;
+;display_send=
+;display_receive=
+
 ; Allow inband audio (progress) when a call is DISCONNECTed by the far end of a PRI
 ;
 ;inbanddisconnect=yes

Modified: team/rmudgett/display_text/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/display_text/configure.ac?view=diff&rev=305249&r1=305248&r2=305249
==============================================================================
--- team/rmudgett/display_text/configure.ac (original)
+++ team/rmudgett/display_text/configure.ac Mon Jan 31 16:53:11 2011
@@ -415,6 +415,7 @@
 AST_EXT_LIB_SETUP([PORTAUDIO], [PortAudio], [portaudio])
 AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
 AST_EXT_LIB_SETUP_DEPENDENT([PRI_MWI], [ISDN PRI Message Waiting Indication], [PRI], [pri])
+AST_EXT_LIB_SETUP_DEPENDENT([PRI_DISPLAY_TEXT], [ISDN PRI user display text IE contents during call], [PRI], [pri])
 AST_EXT_LIB_SETUP_DEPENDENT([PRI_MCID], [ISDN PRI Malicious Call ID], [PRI], [pri])
 AST_EXT_LIB_SETUP_DEPENDENT([PRI_CALL_WAITING], [ISDN PRI call waiting supplementary service], [PRI], [pri])
 AST_EXT_LIB_SETUP_DEPENDENT([PRI_AOC_EVENTS], [ISDN PRI advice of charge supplementary service events], [PRI], [pri])
@@ -1811,6 +1812,7 @@
 AST_EXT_LIB_CHECK([PORTAUDIO], [portaudio], [Pa_GetDeviceCount], [portaudio.h])
 
 AST_EXT_LIB_CHECK([PRI], [pri], [pri_connected_line_update], [libpri.h])
+AST_EXT_LIB_CHECK([PRI_DISPLAY_TEXT], [pri], [pri_display_text], [libpri.h])
 AST_EXT_LIB_CHECK([PRI_MWI], [pri], [pri_mwi_indicate], [libpri.h])
 AST_EXT_LIB_CHECK([PRI_MCID], [pri], [pri_mcid_enable], [libpri.h])
 AST_EXT_LIB_CHECK([PRI_CALL_WAITING], [pri], [pri_connect_ack_enable], [libpri.h])

Modified: team/rmudgett/display_text/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/display_text/main/channel.c?view=diff&rev=305249&r1=305248&r2=305249
==============================================================================
--- team/rmudgett/display_text/main/channel.c (original)
+++ team/rmudgett/display_text/main/channel.c Mon Jan 31 16:53:11 2011
@@ -4466,13 +4466,18 @@
 int ast_sendtext(struct ast_channel *chan, const char *text)
 {
 	int res = 0;
+
+	ast_channel_lock(chan);
 	/* Stop if we're a zombie or need a soft hangup */
-	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan))
+	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
+		ast_channel_unlock(chan);
 		return -1;
+	}
 	CHECK_BLOCKING(chan);
 	if (chan->tech->send_text)
 		res = chan->tech->send_text(chan, text);
 	ast_clear_flag(chan, AST_FLAG_BLOCKING);
+	ast_channel_unlock(chan);
 	return res;
 }
 




More information about the asterisk-commits mailing list