<p>Michael Bradeen has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19904">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_senddtmf: Add option to answer target channel.<br><br>Adds a new option to SendDTMF() which will answer the specified<br>channel if it is not already up. If no channel is specified, the<br>current channel will be answered instead.<br><br>ASTERISK-30422<br><br>Change-Id: Iddcbd501fcdf9fef0f453b7a8115a90b11f1d085<br>---<br>M apps/app_senddtmf.c<br>A doc/CHANGES-staging/app_senddtmf_answer.txt<br>2 files changed, 51 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/04/19904/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c</span><br><span>index ea75a9e..c119d8c 100644</span><br><span>--- a/apps/app_senddtmf.c</span><br><span>+++ b/apps/app_senddtmf.c</span><br><span>@@ -57,6 +57,15 @@</span><br><span>                        <parameter name="channel" required="false"></span><br><span>                                <para>Channel where digits will be played</para></span><br><span>                         </parameter></span><br><span style="color: hsl(120, 100%, 40%);">+                    <parameter name="options"></span><br><span style="color: hsl(120, 100%, 40%);">+                            <optionlist></span><br><span style="color: hsl(120, 100%, 40%);">+                                    <option name="a"></span><br><span style="color: hsl(120, 100%, 40%);">+                                             <para>Answer the channel specified by the <literal>channel</literal></span><br><span style="color: hsl(120, 100%, 40%);">+                                                parameter if it is not already up. If no <literal>channel</literal></span><br><span style="color: hsl(120, 100%, 40%);">+                                               parameter is provided, the current channel will be answered.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                     </option></span><br><span style="color: hsl(120, 100%, 40%);">+                               </optionlist></span><br><span style="color: hsl(120, 100%, 40%);">+                   </parameter></span><br><span>           </syntax></span><br><span>              <description></span><br><span>                  <para>It will send all digits or terminate if it encounters an error.</para></span><br><span>@@ -90,6 +99,19 @@</span><br><span>        </manager></span><br><span>  ***/</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+enum read_option_flags {</span><br><span style="color: hsl(120, 100%, 40%);">+       OPT_ANSWER = (1 << 0),</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+AST_APP_OPTIONS(senddtmf_app_options, {</span><br><span style="color: hsl(120, 100%, 40%);">+   AST_APP_OPTION('a', OPT_ANSWER),</span><br><span style="color: hsl(120, 100%, 40%);">+});</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+enum {</span><br><span style="color: hsl(120, 100%, 40%);">+       /* note: this entry _MUST_ be the last one in the enum */</span><br><span style="color: hsl(120, 100%, 40%);">+     OPT_ARG_ARRAY_SIZE,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static const char senddtmf_name[] = "SendDTMF";</span><br><span> </span><br><span> static int senddtmf_exec(struct ast_channel *chan, const char *vdata)</span><br><span>@@ -100,11 +122,14 @@</span><br><span>  struct ast_channel *chan_found = NULL;</span><br><span>       struct ast_channel *chan_dest = chan;</span><br><span>        struct ast_channel *chan_autoservice = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+  char *opt_args[OPT_ARG_ARRAY_SIZE];</span><br><span style="color: hsl(120, 100%, 40%);">+   struct ast_flags flags = {0};</span><br><span>        AST_DECLARE_APP_ARGS(args,</span><br><span>           AST_APP_ARG(digits);</span><br><span>                 AST_APP_ARG(dinterval);</span><br><span>              AST_APP_ARG(duration);</span><br><span>               AST_APP_ARG(channel);</span><br><span style="color: hsl(120, 100%, 40%);">+         AST_APP_ARG(options);</span><br><span>        );</span><br><span> </span><br><span>       if (ast_strlen_zero(vdata)) {</span><br><span>@@ -136,6 +161,12 @@</span><br><span>                         chan_autoservice = chan;</span><br><span>             }</span><br><span>    }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!ast_strlen_zero(args.options)) {</span><br><span style="color: hsl(120, 100%, 40%);">+         ast_app_parse_options(senddtmf_app_options, &flags, opt_args, args.options);</span><br><span style="color: hsl(120, 100%, 40%);">+      }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (ast_test_flag(&flags, OPT_ANSWER)) {</span><br><span style="color: hsl(120, 100%, 40%);">+          ast_auto_answer(chan_dest);</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span>    res = ast_dtmf_stream(chan_dest, chan_autoservice, args.digits,</span><br><span>              dinterval <= 0 ? 250 : dinterval, duration);</span><br><span>      if (chan_found) {</span><br><span>diff --git a/doc/CHANGES-staging/app_senddtmf_answer.txt b/doc/CHANGES-staging/app_senddtmf_answer.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..76811e3</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/app_senddtmf_answer.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_senddtmf</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+A new option has been added to SendDTMF() which will answer the</span><br><span style="color: hsl(120, 100%, 40%);">+specified channel if it is not already up. If no channel is specified,</span><br><span style="color: hsl(120, 100%, 40%);">+the current channel will be answered instead.</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19904">change 19904</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19904"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Iddcbd501fcdf9fef0f453b7a8115a90b11f1d085 </div>
<div style="display:none"> Gerrit-Change-Number: 19904 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>