|
|
|
@ -875,25 +875,37 @@ int ast_vm_test_destroy_user(const char *context, const char *mailbox)
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
|
|
|
|
|
static int external_sleep(struct ast_channel *chan, int ms)
|
|
|
|
|
{
|
|
|
|
|
usleep(ms * 1000);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int dtmf_stream(struct ast_channel *chan, const char *digits, int between, unsigned int duration, int is_external)
|
|
|
|
|
{
|
|
|
|
|
const char *ptr;
|
|
|
|
|
int res;
|
|
|
|
|
struct ast_silence_generator *silgen = NULL;
|
|
|
|
|
int (*my_sleep)(struct ast_channel *chan, int ms);
|
|
|
|
|
int (*my_senddigit)(struct ast_channel *chan, char digit, unsigned int duration);
|
|
|
|
|
|
|
|
|
|
if (!between) {
|
|
|
|
|
between = 100;
|
|
|
|
|
if (is_external) {
|
|
|
|
|
my_sleep = external_sleep;
|
|
|
|
|
my_senddigit = ast_senddigit_external;
|
|
|
|
|
} else {
|
|
|
|
|
my_sleep = ast_safe_sleep;
|
|
|
|
|
my_senddigit = ast_senddigit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (peer && ast_autoservice_start(peer)) {
|
|
|
|
|
return -1;
|
|
|
|
|
if (!between) {
|
|
|
|
|
between = 100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Need a quiet time before sending digits. */
|
|
|
|
|
if (ast_opt_transmit_silence) {
|
|
|
|
|
silgen = ast_channel_start_silence_generator(chan);
|
|
|
|
|
}
|
|
|
|
|
res = ast_safe_sleep(chan, 100);
|
|
|
|
|
res = my_sleep(chan, 100);
|
|
|
|
|
if (res) {
|
|
|
|
|
goto dtmf_stream_cleanup;
|
|
|
|
|
}
|
|
|
|
@ -901,12 +913,14 @@ int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const ch
|
|
|
|
|
for (ptr = digits; *ptr; ptr++) {
|
|
|
|
|
if (*ptr == 'w') {
|
|
|
|
|
/* 'w' -- wait half a second */
|
|
|
|
|
if ((res = ast_safe_sleep(chan, 500))) {
|
|
|
|
|
res = my_sleep(chan, 500);
|
|
|
|
|
if (res) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else if (*ptr == 'W') {
|
|
|
|
|
/* 'W' -- wait a second */
|
|
|
|
|
if ((res = ast_safe_sleep(chan, 1000))) {
|
|
|
|
|
res = my_sleep(chan, 1000);
|
|
|
|
|
if (res) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else if (strchr("0123456789*#abcdfABCDF", *ptr)) {
|
|
|
|
@ -915,10 +929,11 @@ int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const ch
|
|
|
|
|
ast_indicate(chan, AST_CONTROL_FLASH);
|
|
|
|
|
} else {
|
|
|
|
|
/* Character represents valid DTMF */
|
|
|
|
|
ast_senddigit(chan, *ptr, duration);
|
|
|
|
|
my_senddigit(chan, *ptr, duration);
|
|
|
|
|
}
|
|
|
|
|
/* pause between digits */
|
|
|
|
|
if ((res = ast_safe_sleep(chan, between))) {
|
|
|
|
|
res = my_sleep(chan, between);
|
|
|
|
|
if (res) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -930,6 +945,18 @@ dtmf_stream_cleanup:
|
|
|
|
|
if (silgen) {
|
|
|
|
|
ast_channel_stop_silence_generator(chan, silgen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
|
|
|
|
|
{
|
|
|
|
|
int res;
|
|
|
|
|
|
|
|
|
|
if (peer && ast_autoservice_start(peer)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
res = dtmf_stream(chan, digits, between, duration, 0);
|
|
|
|
|
if (peer && ast_autoservice_stop(peer)) {
|
|
|
|
|
res = -1;
|
|
|
|
|
}
|
|
|
|
@ -937,6 +964,11 @@ dtmf_stream_cleanup:
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ast_dtmf_stream_external(struct ast_channel *chan, const char *digits, int between, unsigned int duration)
|
|
|
|
|
{
|
|
|
|
|
dtmf_stream(chan, digits, between, duration, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct linear_state {
|
|
|
|
|
int fd;
|
|
|
|
|
int autoclose;
|
|
|
|
|