summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-11-06 19:05:11 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-11-06 19:05:11 +0000
commit6ad0126425993bd9c9c73b0c05a52984cbcadc5d (patch)
treef070df191a27b220f3097e18ea17a9870ea666b6 /main/channel.c
parent82dc21e0e1813b3f24099ad0c90918d95b39ff9d (diff)
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 ........ Merged revisions 375966 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@375967 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/main/channel.c b/main/channel.c
index b0622fa9c..126e44cf6 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -72,6 +72,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/global_datastores.h"
#include "asterisk/data.h"
#include "asterisk/channel_internal.h"
+#include "asterisk/features.h"
/*** DOCUMENTATION
***/
@@ -4778,6 +4779,11 @@ int ast_senddigit_begin(struct ast_channel *chan, char digit)
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;
@@ -4804,6 +4810,12 @@ int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duratio
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);
@@ -6835,6 +6847,8 @@ int ast_do_masquerade(struct ast_channel *original)
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
@@ -6963,6 +6977,10 @@ int ast_do_masquerade(struct ast_channel *original)
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 */
@@ -7207,6 +7225,15 @@ int ast_do_masquerade(struct ast_channel *original)
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
* channel that is taking the place of original.