Build console_video support by linking in, as opposed to including,
[asterisk/asterisk.git] / apps / app_senddtmf.c
index 66e31c8..67bd4fe 100644 (file)
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "asterisk/lock.h"
-#include "asterisk/file.h"
-#include "asterisk/logger.h"
-#include "asterisk/channel.h"
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
-#include "asterisk/translate.h"
-#include "asterisk/options.h"
-#include "asterisk/utils.h"
 #include "asterisk/app.h"
 #include "asterisk/manager.h"
+#include "asterisk/channel.h"
 
 static char *app = "SendDTMF";
 
@@ -60,13 +50,14 @@ static int senddtmf_exec(struct ast_channel *chan, void *vdata)
 {
        int res = 0;
        char *data;
-       int timeout;
+       int timeout = 0, duration = 0;
        AST_DECLARE_APP_ARGS(args,
                AST_APP_ARG(digits);
                AST_APP_ARG(timeout);
+               AST_APP_ARG(duration);
        );
 
-       if (ast_strlen_zero(data)) {
+       if (ast_strlen_zero(vdata)) {
                ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
                return 0;
        }
@@ -74,8 +65,11 @@ static int senddtmf_exec(struct ast_channel *chan, void *vdata)
        data = ast_strdupa(vdata);
        AST_STANDARD_APP_ARGS(args, data);
 
-       timeout = atoi(args.timeout);
-       res = ast_dtmf_stream(chan, NULL, args.digits, timeout <= 0 ? 250 : timeout);
+       if (!ast_strlen_zero(args.timeout))
+               timeout = atoi(args.timeout);
+       if (!ast_strlen_zero(args.duration))
+               duration = atoi(args.duration);
+       res = ast_dtmf_stream(chan, NULL, args.digits, timeout <= 0 ? 250 : timeout, duration);
 
        return res;
 }
@@ -98,13 +92,13 @@ static int manager_play_dtmf(struct mansession *s, const struct message *m)
        }
        if (!digit) {
                astman_send_error(s, m, "No digit specified");
-               ast_mutex_unlock(&chan->lock);
+               ast_channel_unlock(chan);
                return 0;
        }
 
-       ast_senddigit(chan, *digit);
+       ast_senddigit(chan, *digit, 0);
 
-       ast_mutex_unlock(&chan->lock);
+       ast_channel_unlock(chan);
        astman_send_ack(s, m, "DTMF successfully queued");
        
        return 0;