[asterisk-commits] trunk - r7969 in /trunk: app.c
include/asterisk/app.h
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Jan 10 23:23:21 CST 2006
Author: russell
Date: Tue Jan 10 23:23:19 2006
New Revision: 7969
URL: http://svn.digium.com/view/asterisk?rev=7969&view=rev
Log:
add doxygen documentation and fix various issues with ast_dtmf_stream
(discussed in issue #6087)
Modified:
trunk/app.c
trunk/include/asterisk/app.h
Modified: trunk/app.c
URL: http://svn.digium.com/view/asterisk/trunk/app.c?rev=7969&r1=7968&r2=7969&view=diff
==============================================================================
--- trunk/app.c (original)
+++ trunk/app.c Tue Jan 10 23:23:19 2006
@@ -279,53 +279,57 @@
return 0;
}
-int ast_dtmf_stream(struct ast_channel *chan,struct ast_channel *peer,char *digits,int between)
-{
- char *ptr;
+int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between)
+{
+ const char *ptr;
int res = 0;
- struct ast_frame f;
+ struct ast_frame f = {
+ .frametype = AST_FRAME_DTMF,
+ .src = "ast_dtmf_stream"
+ };
+
if (!between)
between = 100;
if (peer)
res = ast_autoservice_start(peer);
- if (!res) {
- res = ast_waitfor(chan,100);
- if (res > -1) {
- for (ptr=digits; *ptr; ptr++) {
- if (*ptr == 'w') {
- res = ast_safe_sleep(chan, 500);
- if (res)
- break;
- continue;
- }
- memset(&f, 0, sizeof(f));
- f.frametype = AST_FRAME_DTMF;
+ if (!res)
+ res = ast_waitfor(chan, 100);
+
+ /* ast_waitfor will return the number of remaining ms on success */
+ if (res < 0)
+ return res;
+
+ for (ptr = digits; *ptr; ptr++) {
+ if (*ptr == 'w') {
+ /* 'w' -- wait half a second */
+ if ((res = ast_safe_sleep(chan, 500)))
+ break;
+ } else if (strchr("0123456789*#abcdfABCDF", *ptr)) {
+ /* Character represents valid DTMF */
+ if (*ptr == 'f' || *ptr == 'F') {
+ /* ignore return values if not supported by channel */
+ ast_indicate(chan, AST_CONTROL_FLASH);
+ } else {
f.subclass = *ptr;
- f.src = "ast_dtmf_stream";
- if (strchr("0123456789*#abcdfABCDF",*ptr)==NULL) {
- ast_log(LOG_WARNING, "Illegal DTMF character '%c' in string. (0-9*#aAbBcCdDfF allowed)\n",*ptr);
- } else {
- if (*ptr == 'f' || *ptr == 'F') {
- /* ignore return values if not supported by channel */
- ast_indicate(chan, AST_CONTROL_FLASH);
- res = 0;
- } else {
- res = ast_write(chan, &f);
- }
- if (res)
- break;
- /* pause between digits */
- res = ast_safe_sleep(chan,between);
- if (res)
- break;
- }
- }
- }
- if (peer)
- res = ast_autoservice_stop(peer);
- }
+ if ((res = ast_write(chan, &f)))
+ break;
+ }
+ /* pause between digits */
+ if ((res = ast_safe_sleep(chan, between)))
+ break;
+ } else
+ ast_log(LOG_WARNING, "Illegal DTMF character '%c' in string. (0-9*#aAbBcCdD allowed)\n",*ptr);
+ }
+
+ if (peer) {
+ /* Stop autoservice on the peer channel, but don't overwrite any error condition
+ that has occurred previously while acting on the primary channel */
+ if (ast_autoservice_stop(peer) && !res)
+ res = -1;
+ }
+
return res;
}
Modified: trunk/include/asterisk/app.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/app.h?rev=7969&r1=7968&r2=7969&view=diff
==============================================================================
--- trunk/include/asterisk/app.h (original)
+++ trunk/include/asterisk/app.h Tue Jan 10 23:23:19 2006
@@ -118,8 +118,18 @@
*/
extern int ast_safe_system(const char *s);
-/*! Send DTMF to chan (optionally entertain peer) */
-int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, char *digits, int between);
+/*!
+ \brief Send DTMF to a channel
+
+ \param chan The channel that will receive the DTMF frames
+ \param peer (optional) Peer channel that will be autoserviced while the primary
+ channel is receiving DTMF
+ \param digits This is a string of characters representing the DTMF digits to be sent
+ to the channel. Valid characters are "0123456789*#abcdABCD".
+ \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.
+*/
+int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between);
/*! Stream a filename (or file descriptor) as a generator. */
int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, int allowoverride);
More information about the asterisk-commits
mailing list