summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2017-07-12 14:24:36 -0400
committerCorey Farrell <git@cfware.com>2017-07-12 19:08:23 -0400
commit6b138046e7db59e975fc06ee3aea54fe0c143f5d (patch)
tree5d1297d795a8640b0b1f15b52652131688541197 /main/channel.c
parent27aeca3594ae6618ffcafc8fe764fb0c9507ec14 (diff)
core: Add digit filtering to ast_waitfordigit_full
This adds a parameter to ast_waitfordigit_full which can be used to only stop waiting when certain expected digits are received. Any unexpected DTMF digits are simply ignored. This also creates a new dialplan application WaitDigit. ASTERISK-27129 #close Change-Id: Id233935ea3d13e71c75a0861834c5936c3700ef9
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/main/channel.c b/main/channel.c
index 811826f1c..27efb2ee3 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3160,7 +3160,7 @@ int ast_waitfor(struct ast_channel *c, int ms)
int ast_waitfordigit(struct ast_channel *c, int ms)
{
- return ast_waitfordigit_full(c, ms, -1, -1);
+ return ast_waitfordigit_full(c, ms, NULL, -1, -1);
}
int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data)
@@ -3222,7 +3222,7 @@ int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int (*func)(co
return res;
}
-int ast_waitfordigit_full(struct ast_channel *c, int timeout_ms, int audiofd, int cmdfd)
+int ast_waitfordigit_full(struct ast_channel *c, int timeout_ms, const char *breakon, int audiofd, int cmdfd)
{
struct timeval start = ast_tvnow();
int ms;
@@ -3273,9 +3273,12 @@ int ast_waitfordigit_full(struct ast_channel *c, int timeout_ms, int audiofd, in
break;
case AST_FRAME_DTMF_END:
res = f->subclass.integer;
- ast_frfree(f);
- ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
- return res;
+ if (!breakon || strchr(breakon, res)) {
+ ast_frfree(f);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
+ return res;
+ }
+ break;
case AST_FRAME_CONTROL:
switch (f->subclass.integer) {
case AST_CONTROL_HANGUP:
@@ -6351,11 +6354,11 @@ int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, in
silgen = ast_channel_start_silence_generator(c);
usleep(1000);
if (!d)
- d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
+ d = ast_waitfordigit_full(c, to, NULL, audiofd, ctrlfd);
} else {
if (!silgen && ast_opt_transmit_silence)
silgen = ast_channel_start_silence_generator(c);
- d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
+ d = ast_waitfordigit_full(c, to, NULL, audiofd, ctrlfd);
}
if (d < 0) {
ast_channel_stop_silence_generator(c, silgen);