[asterisk-commits] dlee: branch dlee/ASTERISK-21969 r397810 - in /team/dlee/ASTERISK-21969: ./ a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 27 13:50:42 CDT 2013


Author: dlee
Date: Tue Aug 27 13:50:38 2013
New Revision: 397810

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397810
Log:
Merged revisions 397481-397494 from http://svn.asterisk.org/svn/asterisk/trunk

Modified:
    team/dlee/ASTERISK-21969/   (props changed)
    team/dlee/ASTERISK-21969/CHANGES
    team/dlee/ASTERISK-21969/apps/app_chanspy.c
    team/dlee/ASTERISK-21969/apps/app_directory.c
    team/dlee/ASTERISK-21969/apps/app_followme.c
    team/dlee/ASTERISK-21969/apps/app_voicemail.c
    team/dlee/ASTERISK-21969/bridges/bridge_holding.c
    team/dlee/ASTERISK-21969/include/asterisk/musiconhold.h
    team/dlee/ASTERISK-21969/include/asterisk/say.h
    team/dlee/ASTERISK-21969/main/channel.c
    team/dlee/ASTERISK-21969/main/pbx.c
    team/dlee/ASTERISK-21969/main/say.c
    team/dlee/ASTERISK-21969/res/res_agi.c
    team/dlee/ASTERISK-21969/res/res_pjsip.c
    team/dlee/ASTERISK-21969/res/res_pjsip_dtmf_info.c

Propchange: team/dlee/ASTERISK-21969/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Aug 27 13:50:38 2013
@@ -1,1 +1,1 @@
-/trunk:1-397472
+/trunk:1-397504

Modified: team/dlee/ASTERISK-21969/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/CHANGES?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/CHANGES (original)
+++ team/dlee/ASTERISK-21969/CHANGES Tue Aug 27 13:50:38 2013
@@ -338,6 +338,10 @@
  * The CONTROL STREAM FILE command now accepts an offsetms parameter. This
    will start the playback of the audio at the position specified. It will
    also return the final position of the file in 'endpos'.
+
+ * The SAY ALPHA command now accepts an additional parameter to control
+   whether it specifies the case of uppercase, lowercase, or all letters to
+   provide functionality similar to SayAlphaCase.
 
 CDR (Call Detail Records)
 ------------------

Modified: team/dlee/ASTERISK-21969/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/apps/app_chanspy.c?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/apps/app_chanspy.c (original)
+++ team/dlee/ASTERISK-21969/apps/app_chanspy.c Tue Aug 27 13:50:38 2013
@@ -1048,7 +1048,7 @@
 								break;
 							}
 						} else {
-							res = ast_say_character_str(chan, peer_name, "", ast_channel_language(chan));
+							res = ast_say_character_str(chan, peer_name, "", ast_channel_language(chan), AST_SAY_CASE_NONE);
 						}
 					}
 					if (ptr && (num = atoi(ptr))) {

Modified: team/dlee/ASTERISK-21969/apps/app_directory.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/apps/app_directory.c?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/apps/app_directory.c (original)
+++ team/dlee/ASTERISK-21969/apps/app_directory.c Tue Aug 27 13:50:38 2013
@@ -281,13 +281,13 @@
 		/* If Option 'e' was specified, also read the extension number with the name */
 		if (ast_test_flag(flags, OPT_SAYEXTENSION)) {
 			ast_stream_and_wait(chan, "vm-extension", AST_DIGIT_ANY);
-			res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan));
+			res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
 		}
 	} else {
-		res = ast_say_character_str(chan, S_OR(name, ext), AST_DIGIT_ANY, ast_channel_language(chan));
+		res = ast_say_character_str(chan, S_OR(name, ext), AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
 		if (!ast_strlen_zero(name) && ast_test_flag(flags, OPT_SAYEXTENSION)) {
 			ast_stream_and_wait(chan, "vm-extension", AST_DIGIT_ANY);
-			res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan));
+			res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
 		}
 	}
 

Modified: team/dlee/ASTERISK-21969/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/apps/app_followme.c?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/apps/app_followme.c (original)
+++ team/dlee/ASTERISK-21969/apps/app_followme.c Tue Aug 27 13:50:38 2013
@@ -1424,7 +1424,7 @@
 			if (ast_waitstream(chan, "") < 0)
 				goto outrun;
 		}
-		ast_moh_start(chan, S_OR(targs->mohclass, NULL), NULL);
+		ast_moh_start(chan, targs->mohclass, NULL);
 	}
 
 	ast_channel_lock(chan);

Modified: team/dlee/ASTERISK-21969/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/apps/app_voicemail.c?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/apps/app_voicemail.c (original)
+++ team/dlee/ASTERISK-21969/apps/app_voicemail.c Tue Aug 27 13:50:38 2013
@@ -13683,7 +13683,7 @@
 		ast_debug(3, "Greeting not found for '%s@%s', falling back to mailbox number.\n", args_copy, context);
 		res = ast_stream_and_wait(chan, "vm-extension", AST_DIGIT_ANY);
 		if (!res) {
-			res = ast_say_character_str(chan, args_copy, AST_DIGIT_ANY, ast_channel_language(chan));
+			res = ast_say_character_str(chan, args_copy, AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
 		}
 	}
 

Modified: team/dlee/ASTERISK-21969/bridges/bridge_holding.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/bridges/bridge_holding.c?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/bridges/bridge_holding.c (original)
+++ team/dlee/ASTERISK-21969/bridges/bridge_holding.c Tue Aug 27 13:50:38 2013
@@ -204,7 +204,7 @@
 	switch(hc->idle_mode) {
 	case IDLE_MODE_MOH:
 		moh_class = ast_bridge_channel_get_role_option(bridge_channel, "holding_participant", "moh_class");
-		ast_moh_start(bridge_channel->chan, ast_strlen_zero(moh_class) ? NULL : moh_class, NULL);
+		ast_moh_start(bridge_channel->chan, moh_class, NULL);
 		break;
 	case IDLE_MODE_RINGING:
 		ast_indicate(bridge_channel->chan, AST_CONTROL_RINGING);

Modified: team/dlee/ASTERISK-21969/include/asterisk/musiconhold.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/include/asterisk/musiconhold.h?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/include/asterisk/musiconhold.h (original)
+++ team/dlee/ASTERISK-21969/include/asterisk/musiconhold.h Tue Aug 27 13:50:38 2013
@@ -28,20 +28,21 @@
 #endif
 
 /*!
- * \brief Turn on music on hold on a given channel 
+ * \brief Turn on music on hold on a given channel
  *
  * \param chan The channel structure that will get music on hold
  * \param mclass The class to use if the musicclass is not currently set on
- *               the channel structure.
+ *               the channel structure.  NULL and the empty string are equivalent.
  * \param interpclass The class to use if the musicclass is not currently set on
  *                    the channel structure or in the mclass argument.
+ *                    NULL and the empty string are equivalent.
  *
  * \retval Zero on success
  * \retval non-zero on failure
  */
 int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass);
 
-/*! Turn off music on hold on a given channel */
+/*! \brief Turn off music on hold on a given channel */
 void ast_moh_stop(struct ast_channel *chan);
 
 void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, const char *, const char *),

Modified: team/dlee/ASTERISK-21969/include/asterisk/say.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/include/asterisk/say.h?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/include/asterisk/say.h (original)
+++ team/dlee/ASTERISK-21969/include/asterisk/say.h Tue Aug 27 13:50:38 2013
@@ -148,13 +148,23 @@
  */
 SAY_EXTERN int (* ast_say_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_full);
 
+/*!
+ * \brief Controls how ast_say_character_str denotes the case of characters in a string
+ */
+enum ast_say_case_sensitivity {
+	AST_SAY_CASE_NONE,  /*!< Do not distinguish case on any letters */
+	AST_SAY_CASE_LOWER, /*!< Denote case only on lower case letters, upper case is assumed otherwise */
+	AST_SAY_CASE_UPPER, /*!< Denote case only on upper case letters, lower case is assumed otherwise */
+	AST_SAY_CASE_ALL,   /*!< Denote case on all letters, upper and lower */
+};
+
 /*! \brief
  * function to pronounce character and phonetic strings
  */
 int ast_say_character_str(struct ast_channel *chan, const char *num,
-	const char *ints, const char *lang);
+	const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity);
 
-SAY_EXTERN int (* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full);
+SAY_EXTERN int (* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full);
 
 int ast_say_phonetic_str(struct ast_channel *chan, const char *num,
 	const char *ints, const char *lang);

Modified: team/dlee/ASTERISK-21969/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/main/channel.c?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/main/channel.c (original)
+++ team/dlee/ASTERISK-21969/main/channel.c Tue Aug 27 13:50:38 2013
@@ -7193,7 +7193,6 @@
 	ast_moh_cleanup_ptr = NULL;
 }
 
-/*! \brief Turn on music on hold on a given channel */
 int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
 {
 	if (ast_moh_start_ptr)
@@ -7204,7 +7203,6 @@
 	return 0;
 }
 
-/*! \brief Turn off music on hold on a given channel */
 void ast_moh_stop(struct ast_channel *chan)
 {
 	if (ast_moh_stop_ptr)
@@ -7792,9 +7790,9 @@
 }
 
 int ast_say_character_str(struct ast_channel *chan, const char *str,
-	const char *ints, const char *lang)
-{
-	return ast_say_character_str_full(chan, str, ints, lang, -1, -1);
+	const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity)
+{
+	return ast_say_character_str_full(chan, str, ints, lang, sensitivity, -1, -1);
 }
 
 int ast_say_phonetic_str(struct ast_channel *chan, const char *str,

Modified: team/dlee/ASTERISK-21969/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/main/pbx.c?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/main/pbx.c (original)
+++ team/dlee/ASTERISK-21969/main/pbx.c Tue Aug 27 13:50:38 2013
@@ -501,6 +501,46 @@
 			<ref type="function">CHANNEL</ref>
 		</see-also>
 	</application>
+	<application name="SayAlphaCase" language="en_US">
+		<synopsis>
+			Say Alpha.
+		</synopsis>
+		<syntax>
+			<parameter name="casetype" required="true" >
+				<enumlist>
+					<enum name="a">
+						<para>Case sensitive (all) pronunciation.
+						(Ex: SayAlphaCase(a,aBc); - lowercase a uppercase b lowercase c).</para>
+					</enum>
+					<enum name="l">
+						<para>Case sensitive (lower) pronunciation.
+						(Ex: SayAlphaCase(l,aBc); - lowercase a b lowercase c).</para>
+					</enum>
+					<enum name="n">
+						<para>Case insensitive pronunciation. Equivalent to SayAlpha.
+						(Ex: SayAlphaCase(n,aBc) - a b c).</para>
+					</enum>
+					<enum name="u">
+						<para>Case sensitive (upper) pronunciation.
+						(Ex: SayAlphaCase(u,aBc); - a uppercase b c).</para>
+					</enum>
+				</enumlist>
+			</parameter>
+			<parameter name="string" required="true" />
+		</syntax>
+		<description>
+			<para>This application will play the sounds that correspond to the letters of the
+			given <replaceable>string</replaceable>.  Optionally, a <replaceable>casetype</replaceable> may be
+			specified.  This will be used for case-insensitive or case-sensitive pronunciations.</para>
+		</description>
+		<see-also>
+			<ref type="application">SayDigits</ref>
+			<ref type="application">SayNumber</ref>
+			<ref type="application">SayPhonetic</ref>
+			<ref type="application">SayAlpha</ref>
+			<ref type="function">CHANNEL</ref>
+		</see-also>
+	</application>
 	<application name="SayDigits" language="en_US">
 		<synopsis>
 			Say Digits.
@@ -1122,6 +1162,7 @@
 static int pbx_builtin_saynumber(struct ast_channel *, const char *);
 static int pbx_builtin_saydigits(struct ast_channel *, const char *);
 static int pbx_builtin_saycharacters(struct ast_channel *, const char *);
+static int pbx_builtin_saycharacters_case(struct ast_channel *, const char *);
 static int pbx_builtin_sayphonetic(struct ast_channel *, const char *);
 static int matchcid(const char *cidpattern, const char *callerid);
 #ifdef NEED_DEBUG
@@ -1297,6 +1338,7 @@
 	{ "RaiseException", pbx_builtin_raise_exception },
 	{ "Ringing",        pbx_builtin_ringing },
 	{ "SayAlpha",       pbx_builtin_saycharacters },
+	{ "SayAlphaCase",   pbx_builtin_saycharacters_case },
 	{ "SayDigits",      pbx_builtin_saydigits },
 	{ "SayNumber",      pbx_builtin_saynumber },
 	{ "SayPhonetic",    pbx_builtin_sayphonetic },
@@ -11260,12 +11302,60 @@
 	return res;
 }
 
+static int pbx_builtin_saycharacters_case(struct ast_channel *chan, const char *data)
+{
+	int res = 0;
+	int sensitivity = 0;
+	char *parse;
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(options);
+		AST_APP_ARG(characters);
+	);
+
+	if (ast_strlen_zero(data)) {
+		ast_log(LOG_WARNING, "SayAlphaCase requires two arguments (options, characters)\n");
+		return 0;
+	}
+
+	parse = ast_strdupa(data);
+	AST_STANDARD_APP_ARGS(args, parse);
+
+	if (!args.options || strlen(args.options) != 1) {
+		ast_log(LOG_WARNING, "SayAlphaCase options are mutually exclusive and required\n");
+		return 0;
+	}
+
+	switch (args.options[0]) {
+	case 'a':
+		sensitivity = AST_SAY_CASE_ALL;
+		break;
+	case 'l':
+		sensitivity = AST_SAY_CASE_LOWER;
+		break;
+	case 'n':
+		sensitivity = AST_SAY_CASE_NONE;
+		break;
+	case 'u':
+		sensitivity = AST_SAY_CASE_UPPER;
+		break;
+	default:
+		ast_log(LOG_WARNING, "Invalid option: '%s'\n", args.options);
+		return 0;
+	}
+
+	res = ast_say_character_str(chan, args.characters, "", ast_channel_language(chan), sensitivity);
+
+	return res;
+}
+
 static int pbx_builtin_saycharacters(struct ast_channel *chan, const char *data)
 {
 	int res = 0;
 
-	if (data)
-		res = ast_say_character_str(chan, data, "", ast_channel_language(chan));
+	if (data) {
+		res = ast_say_character_str(chan, data, "", ast_channel_language(chan), AST_SAY_CASE_NONE);
+	}
+
 	return res;
 }
 

Modified: team/dlee/ASTERISK-21969/main/say.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/main/say.c?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/main/say.c (original)
+++ team/dlee/ASTERISK-21969/main/say.c Tue Aug 27 13:50:38 2013
@@ -61,13 +61,15 @@
 static int wait_file(struct ast_channel *chan, const char *ints, const char *file, const char *lang);
 
 
-static int say_character_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
+static int say_character_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity, int audiofd, int ctrlfd)
 {
 	const char *fn;
 	char fnbuf[10], asciibuf[20] = "letters/ascii";
 	char ltr;
 	int num = 0;
 	int res = 0;
+	int upper = 0;
+	int lower = 0;
 
 	while (str[num] && !res) {
 		fn = NULL;
@@ -121,9 +123,35 @@
 			break;
 		default:
 			ltr = str[num];
-			if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A';		/* file names are all lower-case */
-			strcpy(fnbuf, "letters/X");
-			fnbuf[8] = ltr;
+			if ('A' <= ltr && ltr <= 'Z') {
+				ltr += 'a' - 'A';		/* file names are all lower-case */
+				switch (sensitivity) {
+				case AST_SAY_CASE_UPPER:
+				case AST_SAY_CASE_ALL:
+					upper = !upper;
+				case AST_SAY_CASE_LOWER:
+				case AST_SAY_CASE_NONE:
+					break;
+				}
+			} else if ('a' <= ltr && ltr <= 'z') {
+				switch (sensitivity) {
+				case AST_SAY_CASE_LOWER:
+				case AST_SAY_CASE_ALL:
+					lower = !lower;
+				case AST_SAY_CASE_UPPER:
+				case AST_SAY_CASE_NONE:
+					break;
+				}
+			}
+
+			if (upper) {
+				strcpy(fnbuf, "uppercase");
+			} else if (lower) {
+				strcpy(fnbuf, "lowercase");
+			} else {
+				strcpy(fnbuf, "letters/X");
+				fnbuf[8] = ltr;
+			}
 			fn = fnbuf;
 		}
 		if ((fn && ast_fileexists(fn, NULL, lang) > 0) ||
@@ -136,6 +164,9 @@
 					res = ast_waitstream(chan, ints);
 			}
 			ast_stopstream(chan);
+		}
+		if (upper || lower) {
+			continue;
 		}
 		num++;
 	}

Modified: team/dlee/ASTERISK-21969/res/res_agi.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/res/res_agi.c?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/res/res_agi.c (original)
+++ team/dlee/ASTERISK-21969/res/res_agi.c Tue Aug 27 13:50:38 2013
@@ -2313,11 +2313,37 @@
 static int handle_sayalpha(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
 {
 	int res;
-
-	if (argc != 4)
-		return RESULT_SHOWUSAGE;
-
-	res = ast_say_character_str_full(chan, argv[2], argv[3], ast_channel_language(chan), agi->audio, agi->ctrl);
+	int sensitivity = AST_SAY_CASE_NONE;
+
+	if (argc < 4 || argc > 5) {
+		return RESULT_SHOWUSAGE;
+	}
+
+	if (argc > 4) {
+		switch (argv[4][0]) {
+		case 'a':
+		case 'A':
+			sensitivity = AST_SAY_CASE_ALL;
+			break;
+		case 'l':
+		case 'L':
+			sensitivity = AST_SAY_CASE_LOWER;
+			break;
+		case 'n':
+		case 'N':
+			sensitivity = AST_SAY_CASE_NONE;
+			break;
+		case 'u':
+		case 'U':
+			sensitivity = AST_SAY_CASE_UPPER;
+			break;
+		case '\0':
+			break;
+		default:
+			return RESULT_SHOWUSAGE;
+		}
+	}
+	res = ast_say_character_str_full(chan, argv[2], argv[3], ast_channel_language(chan), sensitivity, agi->audio, agi->ctrl);
 	if (res == 1) /* New command */
 		return RESULT_SUCCESS;
 	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);

Modified: team/dlee/ASTERISK-21969/res/res_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/res/res_pjsip.c?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/res/res_pjsip.c (original)
+++ team/dlee/ASTERISK-21969/res/res_pjsip.c Tue Aug 27 13:50:38 2013
@@ -685,7 +685,7 @@
 					Signifies that a domain is an alias. If the domain on a session is
 					not found to match an AoR then this object is used to see if we have
 					an alias for the AoR to which the endpoint is binding. This objects
-					name as defined in configuration should be the domain alias and a 
+					name as defined in configuration should be the domain alias and a
 					config option is provided to specify the domain to be aliased.
 				</para></description>
 				<configOption name="type">
@@ -851,7 +851,7 @@
 					This must be used in conjuction with the <literal>PJSIP_DIAL_CONTACTS</literal>.
 					</para><para>
 					Registrations: For Asterisk to match an inbound registration to an endpoint,
-					the AoR object name must match the user portion of the SIP URI in the "To:" 
+					the AoR object name must match the user portion of the SIP URI in the "To:"
 					header of the inbound SIP registration. That will usually be equivalent
 					to the "user name" set in your hard or soft phones configuration.
 				</para></description>
@@ -935,7 +935,7 @@
 				<description><para>
 					The settings in this section are global. In addition to being global, the values will
 					not be re-evaluated when a reload is performed. This is because the values must be set
-					before the SIP stack is initialized. The only way to reset these values is to either 
+					before the SIP stack is initialized. The only way to reset these values is to either
 					restart Asterisk, or unload res_pjsip.so and then load it again.
 				</para></description>
 				<configOption name="timert1" default="500">
@@ -970,6 +970,9 @@
 				<configOption name="threadpool_max_size" default="0">
 					<synopsis>Maximum number of threads in the res_pjsip threadpool.
 					A value of 0 indicates no maximum.</synopsis>
+				</configOption>
+				<configOption name="type">
+                                        <synopsis>Must be of type 'system'.</synopsis>
 				</configOption>
 			</configObject>
 			<configObject name="global">
@@ -983,6 +986,9 @@
 				</configOption>
 				<configOption name="useragent" default="Asterisk &lt;Asterisk Version&gt;">
 					<synopsis>Value used in User-Agent header for SIP requests and Server header for SIP responses.</synopsis>
+				</configOption>
+				<configOption name="type">
+                                        <synopsis>Must be of type 'global'.</synopsis>
 				</configOption>
 			</configObject>
 		</configFile>
@@ -1718,7 +1724,7 @@
 
 	pjsip_media_type_init2(&compare, type, subtype);
 
-	return pjsip_media_type_cmp(content_type, &compare, 0) ? -1 : 0;
+	return pjsip_media_type_cmp(content_type, &compare, 0) ? 0 : -1;
 }
 
 pj_caching_pool caching_pool;

Modified: team/dlee/ASTERISK-21969/res/res_pjsip_dtmf_info.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/res/res_pjsip_dtmf_info.c?view=diff&rev=397810&r1=397809&r2=397810
==============================================================================
--- team/dlee/ASTERISK-21969/res/res_pjsip_dtmf_info.c (original)
+++ team/dlee/ASTERISK-21969/res/res_pjsip_dtmf_info.c Tue Aug 27 13:50:38 2013
@@ -32,77 +32,114 @@
 #include "asterisk/res_pjsip_session.h"
 #include "asterisk/module.h"
 
+static int is_media_type(pjsip_rx_data *rdata, char *subtype)
+{
+	return !pj_strcmp2(&rdata->msg_info.ctype->media.type, "application") &&
+		!pj_strcmp2(&rdata->msg_info.ctype->media.subtype, subtype);
+}
+
+static void send_response(struct ast_sip_session *session,
+			  struct pjsip_rx_data *rdata, int code)
+{
+	pjsip_tx_data *tdata;
+	pjsip_dialog *dlg = session->inv_session->dlg;
+
+	if (pjsip_dlg_create_response(dlg, rdata, code,
+				      NULL, &tdata) == PJ_SUCCESS) {
+		struct pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
+		pjsip_dlg_send_response(dlg, tsx, tdata);
+	}
+}
+
+static char get_event(const char *c)
+{
+	unsigned int event;
+
+	if (*c == '!' || *c == '*' || *c == '#' ||
+	    ('A' <= *c && *c <= 'D') ||
+	    ('a' <= *c && *c <= 'd')) {
+		return *c;
+	}
+
+	if ((sscanf(c, "%30u", &event) != 1) || event > 16) {
+		return '\0';
+	}
+
+	if (event < 10) {
+		return *c;
+	}
+
+	switch (event) {
+	case 10: return '*';
+	case 11: return '#';
+	case 16: return '!';
+	}
+
+	return 'A' + (event - 12);
+}
+
 static int dtmf_info_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
 {
-	int res = 0;
 	pjsip_msg_body *body = rdata->msg_info.msg->body;
-
-	pjsip_tx_data *tdata;
-
 	char buf[body ? body->len : 0];
 	char *cur = buf;
 	char *line;
 
 	char event = '\0';
-	unsigned int duration = 0;
+	unsigned int duration = 100;
 
-	if (!body || !ast_sip_is_content_type(&body->content_type, "application", "dtmf-relay")) {
+	char is_dtmf = is_media_type(rdata, "dtmf");
+
+	if (!is_dtmf && !is_media_type(rdata, "dtmf-relay")) {
+		return 0;
+	}
+
+	if (!body || !body->len) {
+		/* need to return 200 OK on empty body */
+		send_response(session, rdata, 200);
 		return 0;
 	}
 
 	body->print_body(body, buf, body->len);
 
-	while ((line = strsep(&cur, "\r\n"))) {
-		char *c;
+	if (is_dtmf) {
+		/* directly use what is in the message body */
+		event = get_event(cur);
+	} else { /* content type = application/dtmf-relay */
+		while ((line = strsep(&cur, "\r\n"))) {
+			char *c;
 
-		if (!(c = strchr(line, '='))) {
-			continue;
+			if (!(c = strchr(line, '='))) {
+				continue;
+			}
+
+			*c++ = '\0';
+			c = ast_skip_blanks(c);
+
+			if (!strcasecmp(line, "signal")) {
+				if (!(event = get_event(c))) {
+					break;
+				}
+			} else if (!strcasecmp(line, "duration")) {
+				sscanf(c, "%30u", &duration);
+			}
 		}
-		*c++ = '\0';
-
-		c = ast_skip_blanks(c);
-
-		if (!strcasecmp(line, "signal")) {
-			if (c[0] == '!' || c[0] == '*' || c[0] == '#' ||
-			    ('0' <= c[0] && c[0] <= '9') ||
-			    ('A' <= c[0] && c[0] <= 'D') ||
-			    ('a' <= c[0] && c[0] <= 'd')) {
-				event = c[0];
-			} else {
-				ast_log(LOG_ERROR, "Invalid DTMF event signal in INFO message.\n");
-				res = -1;
-				break;
-			}
-		} else if (!strcasecmp(line, "duration")) {
-			sscanf(c, "%30u", &duration);
-		}
-	}
-
-	if (!duration) {
-		duration = 100;
 	}
 
 	if (event == '!') {
 		struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_FLASH, } };
-
 		ast_queue_frame(session->channel, &f);
 	} else if (event != '\0') {
 		struct ast_frame f = { AST_FRAME_DTMF, };
 		f.len = duration;
 		f.subclass.integer = event;
-
 		ast_queue_frame(session->channel, &f);
 	} else {
-		res = -1;
+		ast_log(LOG_ERROR, "Invalid DTMF event signal in INFO message.\n");
 	}
 
-	if (pjsip_dlg_create_response(session->inv_session->dlg, rdata, !res ? 200 : 500, NULL, &tdata) == PJ_SUCCESS) {
-		struct pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
-
-		pjsip_dlg_send_response(session->inv_session->dlg, tsx, tdata);
-	}
-
-	return res;
+	send_response(session, rdata, event ? 200 : 500);
+	return event ? 0 : -1;
 }
 
 static struct ast_sip_session_supplement dtmf_info_supplement = {




More information about the asterisk-commits mailing list