aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-06 21:52:30 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-06 21:52:30 +0000
commite8820a04915e9c541e5330eef7435d68c6215327 (patch)
treeb89adfb31308894d6ab44ad8b7232a763dfee84f
parent6f3cf2396f0d88b7a9dcba22aa39b969b107da2c (diff)
Extend the ast_senddigit and ast_dtmf_stream API calls to allow the duration of the DTMF digit(s) to be specified and make the SendDTMF application have the capability to use it.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@78278 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_dial.c6
-rw-r--r--apps/app_senddtmf.c8
-rw-r--r--apps/app_test.c20
-rw-r--r--include/asterisk/app.h3
-rw-r--r--include/asterisk/channel.h3
-rw-r--r--main/app.c4
-rw-r--r--main/channel.c6
-rw-r--r--res/res_features.c6
8 files changed, 30 insertions, 26 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index c7928116a..758426f6d 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1527,7 +1527,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
/* Ok, done. stop autoservice */
res = ast_autoservice_stop(chan);
if (digit > 0 && !res)
- res = ast_senddigit(chan, digit);
+ res = ast_senddigit(chan, digit, 0);
else
res = digit;
@@ -1696,12 +1696,12 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
if (!ast_strlen_zero(dtmfcalled)) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Sending DTMF '%s' to the called party.\n", dtmfcalled);
- res = ast_dtmf_stream(peer,chan,dtmfcalled,250);
+ res = ast_dtmf_stream(peer,chan,dtmfcalled,250,0);
}
if (!ast_strlen_zero(dtmfcalling)) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Sending DTMF '%s' to the calling party.\n", dtmfcalling);
- res = ast_dtmf_stream(chan,peer,dtmfcalling,250);
+ res = ast_dtmf_stream(chan,peer,dtmfcalling,250,0);
}
}
diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c
index 81651ec6b..fab83360e 100644
--- a/apps/app_senddtmf.c
+++ b/apps/app_senddtmf.c
@@ -60,10 +60,11 @@ static int senddtmf_exec(struct ast_channel *chan, void *vdata)
{
int res = 0;
char *data;
- int timeout;
+ int timeout, duration;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(digits);
AST_APP_ARG(timeout);
+ AST_APP_ARG(duration);
);
if (ast_strlen_zero(vdata)) {
@@ -75,7 +76,8 @@ static int senddtmf_exec(struct ast_channel *chan, void *vdata)
AST_STANDARD_APP_ARGS(args, data);
timeout = atoi(args.timeout);
- res = ast_dtmf_stream(chan, NULL, args.digits, timeout <= 0 ? 250 : timeout);
+ duration = atoi(args.duration);
+ res = ast_dtmf_stream(chan, NULL, args.digits, timeout <= 0 ? 250 : timeout, duration);
return res;
}
@@ -102,7 +104,7 @@ static int manager_play_dtmf(struct mansession *s, const struct message *m)
return 0;
}
- ast_senddigit(chan, *digit);
+ ast_senddigit(chan, *digit, 0);
ast_mutex_unlock(&chan->lock);
astman_send_ack(s, m, "DTMF successfully queued");
diff --git a/apps/app_test.c b/apps/app_test.c
index df221f326..c4a10ba25 100644
--- a/apps/app_test.c
+++ b/apps/app_test.c
@@ -148,7 +148,7 @@ static int testclient_exec(struct ast_channel *chan, void *data)
res = ast_safe_sleep(chan, 3000);
/* Transmit client version */
if (!res)
- res = ast_dtmf_stream(chan, NULL, "8378*1#", 0);
+ res = ast_dtmf_stream(chan, NULL, "8378*1#", 0, 0);
ast_debug(1, "Transmit client version\n");
/* Read server version */
@@ -166,9 +166,9 @@ static int testclient_exec(struct ast_channel *chan, void *data)
res = ast_safe_sleep(chan, 1000);
/* Send test id */
if (!res)
- res = ast_dtmf_stream(chan, NULL, testid, 0);
+ res = ast_dtmf_stream(chan, NULL, testid, 0, 0);
if (!res)
- res = ast_dtmf_stream(chan, NULL, "#", 0);
+ res = ast_dtmf_stream(chan, NULL, "#", 0, 0);
ast_debug(1, "send test identifier: %s\n", testid);
if ((res >=0) && (!ast_strlen_zero(testid))) {
@@ -198,7 +198,7 @@ static int testclient_exec(struct ast_channel *chan, void *data)
if (!res) {
/* Step 2: Send "2" */
ast_debug(1, "TestClient: 2. Send DTMF 2\n");
- res = ast_dtmf_stream(chan, NULL, "2", 0);
+ res = ast_dtmf_stream(chan, NULL, "2", 0, 0);
fprintf(f, "SEND DTMF 2: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
res = 0;
@@ -265,7 +265,7 @@ static int testclient_exec(struct ast_channel *chan, void *data)
if (!res) {
/* Step 10: Send "7" */
ast_debug(1, "TestClient: 7. Send DTMF 7\n");
- res = ast_dtmf_stream(chan, NULL, "7", 0);
+ res = ast_dtmf_stream(chan, NULL, "7", 0, 0);
fprintf(f, "SEND DTMF 7: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
res =0;
@@ -318,7 +318,7 @@ static int testserver_exec(struct ast_channel *chan, void *data)
res = ast_safe_sleep(chan, 1000);
if (!res)
- res = ast_dtmf_stream(chan, NULL, "8378*1#", 0);
+ res = ast_dtmf_stream(chan, NULL, "8378*1#", 0, 0);
if (res > 0)
res = 0;
@@ -344,7 +344,7 @@ static int testserver_exec(struct ast_channel *chan, void *data)
if (!res) {
/* Step 1: Send "1" */
ast_debug(1, "TestServer: 1. Send DTMF 1\n");
- res = ast_dtmf_stream(chan, NULL, "1", 0);
+ res = ast_dtmf_stream(chan, NULL, "1", 0,0 );
fprintf(f, "SEND DTMF 1: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
res = 0;
@@ -370,7 +370,7 @@ static int testserver_exec(struct ast_channel *chan, void *data)
if (!res) {
/* Step 4: Send "4" */
ast_debug(1, "TestServer: 4. Send DTMF 4\n");
- res = ast_dtmf_stream(chan, NULL, "4", 0);
+ res = ast_dtmf_stream(chan, NULL, "4", 0, 0);
fprintf(f, "SEND DTMF 4: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
res = 0;
@@ -397,7 +397,7 @@ static int testserver_exec(struct ast_channel *chan, void *data)
if (!res) {
/* Step 7: Send "5" */
ast_debug(1, "TestServer: 7. Send DTMF 5\n");
- res = ast_dtmf_stream(chan, NULL, "5", 0);
+ res = ast_dtmf_stream(chan, NULL, "5", 0, 0);
fprintf(f, "SEND DTMF 5: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
res = 0;
@@ -426,7 +426,7 @@ static int testserver_exec(struct ast_channel *chan, void *data)
if (!res) {
/* Step 10: Send "8" */
ast_debug(1, "TestServer: 10. Send DTMF 8\n");
- res = ast_dtmf_stream(chan, NULL, "8", 0);
+ res = ast_dtmf_stream(chan, NULL, "8", 0, 0);
fprintf(f, "SEND DTMF 8: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
res = 0;
diff --git a/include/asterisk/app.h b/include/asterisk/app.h
index 1d3fcdfb5..4bee632b9 100644
--- a/include/asterisk/app.h
+++ b/include/asterisk/app.h
@@ -157,8 +157,9 @@ void ast_unreplace_sigchld(void);
\param between This is the number of milliseconds to wait in between each
DTMF digit. If zero milliseconds is specified, then the
default value of 100 will be used.
+ \param duration This is the duration that each DTMF digit should have.
*/
-int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between);
+int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration);
/*! Stream a filename (or file descriptor) as a generator. */
int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, int allowoverride);
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 9bfc3dd4d..3e63259aa 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -950,9 +950,10 @@ int ast_recvchar(struct ast_channel *chan, int timeout);
* Send a DTMF digit to a channel.
* \param chan channel to act upon
* \param digit the DTMF digit to send, encoded in ASCII
+ * \param duration the duration of the digit ending in ms
* \return Returns 0 on success, -1 on failure
*/
-int ast_senddigit(struct ast_channel *chan, char digit);
+int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
/*! \brief Send a DTMF digit to a channel
* Send a DTMF digit to a channel.
diff --git a/main/app.c b/main/app.c
index 41bbe1c50..d3304b9fd 100644
--- a/main/app.c
+++ b/main/app.c
@@ -245,7 +245,7 @@ int ast_app_messagecount(const char *context, const char *mailbox, const char *f
return 0;
}
-int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between)
+int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
{
const char *ptr;
int res = 0;
@@ -274,7 +274,7 @@ int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const ch
/* ignore return values if not supported by channel */
ast_indicate(chan, AST_CONTROL_FLASH);
} else
- ast_senddigit(chan, *ptr);
+ ast_senddigit(chan, *ptr, duration);
/* pause between digits */
if ((res = ast_safe_sleep(chan, between)))
break;
diff --git a/main/channel.c b/main/channel.c
index 4c1dc4b84..5c8de5694 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -2657,14 +2657,14 @@ int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duratio
return 0;
}
-int ast_senddigit(struct ast_channel *chan, char digit)
+int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
{
if (chan->tech->send_digit_begin) {
ast_senddigit_begin(chan, digit);
- ast_safe_sleep(chan, AST_DEFAULT_EMULATE_DTMF_DURATION);
+ ast_safe_sleep(chan, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));
}
- return ast_senddigit_end(chan, digit, AST_DEFAULT_EMULATE_DTMF_DURATION);
+ return ast_senddigit_end(chan, digit, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));
}
int ast_prod(struct ast_channel *chan)
diff --git a/res/res_features.c b/res/res_features.c
index c90a5c523..df08bb971 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -1678,11 +1678,11 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
digits to come in for features. */
ast_debug(1, "Timed out for feature!\n");
if (!ast_strlen_zero(peer_featurecode)) {
- ast_dtmf_stream(chan, peer, peer_featurecode, 0);
+ ast_dtmf_stream(chan, peer, peer_featurecode, 0, 0);
memset(peer_featurecode, 0, sizeof(peer_featurecode));
}
if (!ast_strlen_zero(chan_featurecode)) {
- ast_dtmf_stream(peer, chan, chan_featurecode, 0);
+ ast_dtmf_stream(peer, chan, chan_featurecode, 0, 0);
memset(chan_featurecode, 0, sizeof(chan_featurecode));
}
if (f)
@@ -1774,7 +1774,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
res = ast_feature_interpret(chan, peer, config, featurecode, sense);
switch(res) {
case FEATURE_RETURN_PASSDIGITS:
- ast_dtmf_stream(other, who, featurecode, 0);
+ ast_dtmf_stream(other, who, featurecode, 0, 0);
/* Fall through */
case FEATURE_RETURN_SUCCESS:
memset(featurecode, 0, sizeof(chan_featurecode));