[asterisk-commits] rmudgett: branch 11 r375966 - in /branches/11: ./ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 6 12:59:38 CST 2012


Author: rmudgett
Date: Tue Nov  6 12:59:33 2012
New Revision: 375966

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=375966
Log:
Fix stuck DTMF when bridge is broken.

When a bridge is broken by an AMI Redirect action or the ChannelRedirect
application, an in progress DTMF digit could be stuck sending forever.

* Made simulate a DTMF end event when a bridge is broken and a DTMF digit
was in progress.

(closes issue ASTERISK-20492)
Reported by: Jeremiah Gowdy
Patches:
      bridge_end_dtmf-v3.patch.txt (license #6358) patch uploaded by Jeremiah Gowdy
      Modified to jira_asterisk_20492_v1.8.patch
      jira_asterisk_20492_v1.8.patch (license #5621) patch uploaded by rmudgett
Tested by: rmudgett

Review: https://reviewboard.asterisk.org/r/2169/
........

Merged revisions 375964 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 375965 from http://svn.asterisk.org/svn/asterisk/branches/10

Modified:
    branches/11/   (props changed)
    branches/11/include/asterisk/channel.h
    branches/11/include/asterisk/features.h
    branches/11/main/channel.c
    branches/11/main/channel_internal_api.c
    branches/11/main/features.c

Propchange: branches/11/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Modified: branches/11/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/branches/11/include/asterisk/channel.h?view=diff&rev=375966&r1=375965&r2=375966
==============================================================================
--- branches/11/include/asterisk/channel.h (original)
+++ branches/11/include/asterisk/channel.h Tue Nov  6 12:59:33 2012
@@ -3758,6 +3758,10 @@
 
 char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan);
 void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value);
+char ast_channel_sending_dtmf_digit(const struct ast_channel *chan);
+void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value);
+struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan);
+void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value);
 int ast_channel_amaflags(const struct ast_channel *chan);
 void ast_channel_amaflags_set(struct ast_channel *chan, int value);
 int ast_channel_epfd(const struct ast_channel *chan);

Modified: branches/11/include/asterisk/features.h
URL: http://svnview.digium.com/svn/asterisk/branches/11/include/asterisk/features.h?view=diff&rev=375966&r1=375965&r2=375966
==============================================================================
--- branches/11/include/asterisk/features.h (original)
+++ branches/11/include/asterisk/features.h Tue Nov  6 12:59:33 2012
@@ -169,6 +169,18 @@
 /*! \brief Determine system call pickup extension */
 const char *ast_pickup_ext(void);
 
+/*!
+ * \brief Simulate a DTMF end on a broken bridge channel.
+ *
+ * \param chan Channel sending DTMF that has not ended.
+ * \param digit DTMF digit to stop.
+ * \param start DTMF digit start time.
+ * \param why Reason bridge broken.
+ *
+ * \return Nothing
+ */
+void ast_bridge_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why);
+
 /*! \brief Bridge a call, optionally allowing redirection */
 int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer,struct ast_bridge_config *config);
 

Modified: branches/11/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/channel.c?view=diff&rev=375966&r1=375965&r2=375966
==============================================================================
--- branches/11/main/channel.c (original)
+++ branches/11/main/channel.c Tue Nov  6 12:59:33 2012
@@ -72,6 +72,7 @@
 #include "asterisk/global_datastores.h"
 #include "asterisk/data.h"
 #include "asterisk/channel_internal.h"
+#include "asterisk/features.h"
 
 /*** DOCUMENTATION
  ***/
@@ -4730,6 +4731,11 @@
 	if (!ast_channel_tech(chan)->send_digit_begin)
 		return 0;
 
+	ast_channel_lock(chan);
+	ast_channel_sending_dtmf_digit_set(chan, digit);
+	ast_channel_sending_dtmf_tv_set(chan, ast_tvnow());
+	ast_channel_unlock(chan);
+
 	if (!ast_channel_tech(chan)->send_digit_begin(chan, digit))
 		return 0;
 
@@ -4755,6 +4761,12 @@
 
 	if (ast_channel_tech(chan)->send_digit_end)
 		res = ast_channel_tech(chan)->send_digit_end(chan, digit, duration);
+
+	ast_channel_lock(chan);
+	if (ast_channel_sending_dtmf_digit(chan) == digit) {
+		ast_channel_sending_dtmf_digit_set(chan, 0);
+	}
+	ast_channel_unlock(chan);
 
 	if (res && ast_channel_generator(chan))
 		ast_playtones_stop(chan);
@@ -6787,6 +6799,8 @@
 	char orig[AST_CHANNEL_NAME];
 	char masqn[AST_CHANNEL_NAME];
 	char zombn[AST_CHANNEL_NAME];
+	char clone_sending_dtmf_digit;
+	struct timeval clone_sending_dtmf_tv;
 
 	/* XXX This operation is a bit odd.  We're essentially putting the guts of
 	 * the clone channel into the original channel.  Start by killing off the
@@ -6915,6 +6929,10 @@
 	free_translation(clonechan);
 	free_translation(original);
 
+	/* Save the current DTMF digit being sent if any. */
+	clone_sending_dtmf_digit = ast_channel_sending_dtmf_digit(clonechan);
+	clone_sending_dtmf_tv = ast_channel_sending_dtmf_tv(clonechan);
+
 	/* Save the original name */
 	ast_copy_string(orig, ast_channel_name(original), sizeof(orig));
 	/* Save the new name */
@@ -7158,6 +7176,15 @@
 	 */
 	ast_channel_unlock(original);
 	ast_channel_unlock(clonechan);
+
+	if (clone_sending_dtmf_digit) {
+		/*
+		 * The clonechan was sending a DTMF digit that was not completed
+		 * before the masquerade.
+		 */
+		ast_bridge_end_dtmf(original, clone_sending_dtmf_digit, clone_sending_dtmf_tv,
+			"masquerade");
+	}
 
 	/*
 	 * If an indication is currently playing, maintain it on the

Modified: branches/11/main/channel_internal_api.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/channel_internal_api.c?view=diff&rev=375966&r1=375965&r2=375966
==============================================================================
--- branches/11/main/channel_internal_api.c (original)
+++ branches/11/main/channel_internal_api.c Tue Nov  6 12:59:33 2012
@@ -193,6 +193,8 @@
 	char macrocontext[AST_MAX_CONTEXT];		/*!< Macro: Current non-macro context. See app_macro.c */
 	char macroexten[AST_MAX_EXTENSION];		/*!< Macro: Current non-macro extension. See app_macro.c */
 	char dtmf_digit_to_emulate;			/*!< Digit being emulated */
+	char sending_dtmf_digit;			/*!< Digit this channel is currently sending out. (zero if not sending) */
+	struct timeval sending_dtmf_tv;		/*!< The time this channel started sending the current digit. (Invalid if sending_dtmf_digit is zero.) */
 };
 
 /* AST_DATA definitions, which will probably have to be re-thought since the channel will be opaque */
@@ -523,6 +525,25 @@
 {
 	chan->dtmf_digit_to_emulate = value;
 }
+
+char ast_channel_sending_dtmf_digit(const struct ast_channel *chan)
+{
+	return chan->sending_dtmf_digit;
+}
+void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value)
+{
+	chan->sending_dtmf_digit = value;
+}
+
+struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan)
+{
+	return chan->sending_dtmf_tv;
+}
+void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value)
+{
+	chan->sending_dtmf_tv = value;
+}
+
 int ast_channel_amaflags(const struct ast_channel *chan)
 {
 	return chan->amaflags;

Modified: branches/11/main/features.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/features.c?view=diff&rev=375966&r1=375965&r2=375966
==============================================================================
--- branches/11/main/features.c (original)
+++ branches/11/main/features.c Tue Nov  6 12:59:33 2012
@@ -4240,6 +4240,24 @@
 	ast_channel_unlock(chan);
 }
 
+void ast_bridge_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why)
+{
+	int dead;
+	long duration;
+
+	ast_channel_lock(chan);
+	dead = ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) || ast_check_hangup(chan);
+	ast_channel_unlock(chan);
+	if (dead) {
+		return;
+	}
+
+	duration = ast_tvdiff_ms(ast_tvnow(), start);
+	ast_senddigit_end(chan, digit, duration);
+	ast_log(LOG_DTMF, "DTMF end '%c' simulated on %s due to %s, duration %ld ms\n",
+		digit, ast_channel_name(chan), why, duration);
+}
+
 /*!
  * \brief bridge the call and set CDR
  *
@@ -4689,6 +4707,15 @@
 	ast_cel_report_event(chan, AST_CEL_BRIDGE_END, NULL, NULL, peer);
 
 before_you_go:
+	if (ast_channel_sending_dtmf_digit(chan)) {
+		ast_bridge_end_dtmf(chan, ast_channel_sending_dtmf_digit(chan),
+			ast_channel_sending_dtmf_tv(chan), "bridge end");
+	}
+	if (ast_channel_sending_dtmf_digit(peer)) {
+		ast_bridge_end_dtmf(peer, ast_channel_sending_dtmf_digit(peer),
+			ast_channel_sending_dtmf_tv(peer), "bridge end");
+	}
+
 	/* Just in case something weird happened and we didn't clean up the silence generator... */
 	if (silgen) {
 		ast_channel_stop_silence_generator(who == chan ? peer : chan, silgen);




More information about the asterisk-commits mailing list