]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Add Duration header for PlayDTMF AMI Action
authorMatthew Jordan <mjordan@digium.com>
Fri, 28 Sep 2012 03:06:53 +0000 (03:06 +0000)
committerMatthew Jordan <mjordan@digium.com>
Fri, 28 Sep 2012 03:06:53 +0000 (03:06 +0000)
This patch adds an optional header to the PlayDTMF AMI action, Duration.
It allows the duration of the DTMF digit to be played on the channel to be
specified in milliseconds.

(closes issue ASTERISK-18172)
Reported by: Renato dos Santos

patches:
  send-dtmf.patch uploaded by Renato dos Santos (license #6267)

Modified slightly for this commit for Asterisk 12.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373979 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
apps/app_senddtmf.c

diff --git a/CHANGES b/CHANGES
index 83728500eab6af2424b5b489ca3b82bac7403fd3..344f28f2309beea3f41410c374fee653faf02ef3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -17,6 +17,9 @@ AMI (Asterisk Manager Interface)
    that the request is against a known peer. It also issues a new event,
    'SIPqualifypeerdone', once the qualify action has been completed.
 
+ * The PlayDTMF action now supports an optional 'Duration' parameter.  This
+   specifies the duration of the digit to be played, in milliseconds.
+
  * Added VoicemailRefresh action to allow an external entity to trigger mailbox
    updates when changes occur instead of requiring the use of pollmailboxes.
 
index e1e8ee92f0435a17e8da2bea1911dc8e351a8b3b..7db9a3f4b7e62feb76b8cb1851b72af7a1e143a6 100644 (file)
@@ -79,6 +79,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                        <parameter name="Digit" required="true">
                                <para>The DTMF digit to play.</para>
                        </parameter>
+                       <parameter name="Duration" required="false">
+                               <para>The duration, in milliseconds, of the digit to be played.</para>
+                       </parameter>
                </syntax>
                <description>
                        <para>Plays a dtmf digit on the specified channel.</para>
@@ -145,7 +148,9 @@ static int manager_play_dtmf(struct mansession *s, const struct message *m)
 {
        const char *channel = astman_get_header(m, "Channel");
        const char *digit = astman_get_header(m, "Digit");
+       const char *duration = astman_get_header(m, "Duration");
        struct ast_channel *chan;
+       unsigned int duration_ms = 0;
 
        if (!(chan = ast_channel_get_by_name(channel))) {
                astman_send_error(s, m, "Channel not found");
@@ -157,8 +162,14 @@ static int manager_play_dtmf(struct mansession *s, const struct message *m)
                chan = ast_channel_unref(chan);
                return 0;
        }
+       
+       if (!ast_strlen_zero(duration) && (sscanf(duration, "%30u", &duration_ms) != 1)) {
+               astman_send_error(s, m, "Could not convert Duration parameter");
+               chan = ast_channel_unref(chan);
+               return 0;
+       }
 
-       ast_senddigit(chan, *digit, 0);
+       ast_senddigit(chan, *digit, duration_ms);
 
        chan = ast_channel_unref(chan);