<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15941">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_dial: Expanded A option to add caller announcement<br><br>Hitherto, the A option has made it possible to play<br>audio upon answer to the called party only. This option<br>is expanded to allow for playback of an audio file to<br>the caller instead of or in addition to the audio<br>played to the answerer.<br><br>ASTERISK-29442<br><br>Change-Id: If6eed3ff5c341dc8c588c8210987f2571e891e5e<br>---<br>M apps/app_dial.c<br>A doc/CHANGES-staging/app_dial_announcement.txt<br>2 files changed, 68 insertions(+), 17 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_dial.c b/apps/app_dial.c</span><br><span>index d611083..51f5f45 100644</span><br><span>--- a/apps/app_dial.c</span><br><span>+++ b/apps/app_dial.c</span><br><span>@@ -93,11 +93,17 @@</span><br><span>                     </parameter></span><br><span>                   <parameter name="options" required="false"></span><br><span>                                <optionlist></span><br><span style="color: hsl(0, 100%, 40%);">-                              <option name="A"></span><br><span style="color: hsl(0, 100%, 40%);">-                                       <argument name="x" required="true"></span><br><span style="color: hsl(120, 100%, 40%);">+                         <option name="A" argsep=":"></span><br><span style="color: hsl(120, 100%, 40%);">+                                        <argument name="x"></span><br><span>                                          <para>The file to play to the called party</para></span><br><span>                                        </argument></span><br><span style="color: hsl(0, 100%, 40%);">-                                       <para>Play an announcement to the called party, where <replaceable>x</replaceable> is the prompt to be played</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                  <argument name="y"></span><br><span style="color: hsl(120, 100%, 40%);">+                                           <para>The file to play to the calling party</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                        </argument></span><br><span style="color: hsl(120, 100%, 40%);">+                                     <para>Play an announcement to the called and/or calling parties, where <replaceable>x</replaceable></span><br><span style="color: hsl(120, 100%, 40%);">+                                 is the prompt to be played to the called party and <replaceable>y</replaceable> is the prompt</span><br><span style="color: hsl(120, 100%, 40%);">+                                     to be played to the caller. The files may be different and will be played to each party</span><br><span style="color: hsl(120, 100%, 40%);">+                                       simultaneously.</para></span><br><span>                                 </option></span><br><span>                              <option name="a"></span><br><span>                                    <para>Immediately answer the calling channel when the called channel answers in</span><br><span>@@ -2941,33 +2947,71 @@</span><br><span>                      int digit = 0;</span><br><span>                       struct ast_channel *chans[2];</span><br><span>                        struct ast_channel *active_chan;</span><br><span style="color: hsl(120, 100%, 40%);">+                      char *calledfile = NULL, *callerfile = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+                  int calledstream = 0, callerstream = 0;</span><br><span> </span><br><span>                  chans[0] = chan;</span><br><span>                     chans[1] = peer;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                    /* we need to stream the announcement to the called party when the OPT_ARG_ANNOUNCE (-A) is setted */</span><br><span style="color: hsl(120, 100%, 40%);">+                 /* we need to stream the announcement(s) when the OPT_ARG_ANNOUNCE (-A) is set */</span><br><span style="color: hsl(120, 100%, 40%);">+                     callerfile = opt_args[OPT_ARG_ANNOUNCE];</span><br><span style="color: hsl(120, 100%, 40%);">+                      calledfile = strsep(&callerfile, ":");</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                        /* stream the file */</span><br><span style="color: hsl(0, 100%, 40%);">-                   res = ast_streamfile(peer, opt_args[OPT_ARG_ANNOUNCE], ast_channel_language(peer));</span><br><span style="color: hsl(0, 100%, 40%);">-                     if (res) {</span><br><span style="color: hsl(0, 100%, 40%);">-                              res = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-                                ast_log(LOG_ERROR, "error streaming file '%s' to callee\n", opt_args[OPT_ARG_ANNOUNCE]);</span><br><span style="color: hsl(120, 100%, 40%);">+                    /* stream the file(s) */</span><br><span style="color: hsl(120, 100%, 40%);">+                      if (!ast_strlen_zero(calledfile)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                           res = ast_streamfile(peer, calledfile, ast_channel_language(peer));</span><br><span style="color: hsl(120, 100%, 40%);">+                           if (res) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                    res = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+                                      ast_log(LOG_ERROR, "error streaming file '%s' to callee\n", calledfile);</span><br><span style="color: hsl(120, 100%, 40%);">+                            } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                                      calledstream = 1;</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%);">+                     if (!ast_strlen_zero(callerfile)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                           res = ast_streamfile(chan, callerfile, ast_channel_language(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+                           if (res) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                    res = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+                                      ast_log(LOG_ERROR, "error streaming file '%s' to caller\n", callerfile);</span><br><span style="color: hsl(120, 100%, 40%);">+                            } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                                      callerstream = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+                             }</span><br><span>                    }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+                 /* can't use ast_waitstream, because we're streaming two files at once, and can't block</span><br><span style="color: hsl(120, 100%, 40%);">+                           We'll need to handle both channels at once. */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                         ast_channel_set_flag(peer, AST_FLAG_END_DTMF_ONLY);</span><br><span style="color: hsl(0, 100%, 40%);">-                     while (ast_channel_stream(peer)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                              int ms;</span><br><span style="color: hsl(120, 100%, 40%);">+                       while (ast_channel_stream(peer) || ast_channel_stream(chan)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                int mspeer, mschan;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                         ms = ast_sched_wait(ast_channel_sched(peer));</span><br><span style="color: hsl(120, 100%, 40%);">+                         mspeer = ast_sched_wait(ast_channel_sched(peer));</span><br><span style="color: hsl(120, 100%, 40%);">+                             mschan = ast_sched_wait(ast_channel_sched(chan));</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                           if (ms < 0 && !ast_channel_timingfunc(peer)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                                       ast_stopstream(peer);</span><br><span style="color: hsl(120, 100%, 40%);">+                         if (calledstream) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                   if (mspeer < 0 && !ast_channel_timingfunc(peer)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                         ast_stopstream(peer);</span><br><span style="color: hsl(120, 100%, 40%);">+                                         calledstream = 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%);">+                             if (callerstream) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                   if (mschan < 0 && !ast_channel_timingfunc(chan)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                         ast_stopstream(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+                                         callerstream = 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%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                           if (!calledstream && !callerstream) {</span><br><span>                                        break;</span><br><span>                               }</span><br><span style="color: hsl(0, 100%, 40%);">-                               if (ms < 0)</span><br><span style="color: hsl(0, 100%, 40%);">-                                  ms = 1000;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                          active_chan = ast_waitfor_n(chans, 2, &ms);</span><br><span style="color: hsl(120, 100%, 40%);">+                               if (mspeer < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                                    mspeer = 1000;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                              if (mschan < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                                    mschan = 1000;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                              /* wait for the lowest maximum of the two */</span><br><span style="color: hsl(120, 100%, 40%);">+                          active_chan = ast_waitfor_n(chans, 2, (mspeer > mschan ? &mschan : &mspeer));</span><br><span>                             if (active_chan) {</span><br><span>                                   struct ast_channel *other_chan;</span><br><span>                                      struct ast_frame *fr = ast_read(active_chan);</span><br><span>@@ -3017,6 +3061,7 @@</span><br><span>                                        ast_frfree(fr);</span><br><span>                              }</span><br><span>                            ast_sched_runq(ast_channel_sched(peer));</span><br><span style="color: hsl(120, 100%, 40%);">+                              ast_sched_runq(ast_channel_sched(chan));</span><br><span>                     }</span><br><span>                    ast_channel_clear_flag(peer, AST_FLAG_END_DTMF_ONLY);</span><br><span>                }</span><br><span>diff --git a/doc/CHANGES-staging/app_dial_announcement.txt b/doc/CHANGES-staging/app_dial_announcement.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..3947b0e</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/app_dial_announcement.txt</span><br><span>@@ -0,0 +1,6 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_dial announcement option</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The A option for Dial now supports</span><br><span style="color: hsl(120, 100%, 40%);">+playing audio to the caller as well</span><br><span style="color: hsl(120, 100%, 40%);">+as the called party.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15941">change 15941</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/+/15941"/><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: If6eed3ff5c341dc8c588c8210987f2571e891e5e </div>
<div style="display:none"> Gerrit-Change-Number: 15941 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Mark Murawski <markm@intellasoft.net> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>