<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13517">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Sean Bright: Looks good to me, but someone else must approve
Joshua Colp: 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_bridgeaddchan.c: Make BridgeAdd be more like Bridge<br><br>* Made BridgeAdd not hangup the call if there is a problem.<br>* Reduced message level from warning to verbose for normal exception<br>cases.<br>* Added a loop safety check to BridgeAdd.<br>* Made BridgeAdd set BRIDGERESULT with the status when dialplan is<br>resumed.<br><br>Change-Id: I374d39b8a3edcc794eeb5c6b9f31a01424cdc426<br>---<br>M apps/app_bridgeaddchan.c<br>A doc/CHANGES-staging/app_bridgeaddchan_add_bridgeresult_var.txt<br>A doc/UPGRADE-staging/app_bridgeaddchan_add_bridgeresult_var.txt<br>3 files changed, 56 insertions(+), 20 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_bridgeaddchan.c b/apps/app_bridgeaddchan.c</span><br><span>index 34642a6..6080868 100644</span><br><span>--- a/apps/app_bridgeaddchan.c</span><br><span>+++ b/apps/app_bridgeaddchan.c</span><br><span>@@ -43,17 +43,28 @@</span><br><span> Join a bridge that contains the specified channel.</span><br><span> </synopsis></span><br><span> <syntax></span><br><span style="color: hsl(0, 100%, 40%);">- <parameter name="name"></span><br><span style="color: hsl(0, 100%, 40%);">- <para>Name of the channel in an existing bridge</span><br><span style="color: hsl(0, 100%, 40%);">- </para></span><br><span style="color: hsl(120, 100%, 40%);">+ <parameter name="channel" required="true"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>The current channel joins the bridge containing the channel</span><br><span style="color: hsl(120, 100%, 40%);">+ identified by the channel name, channel name prefix, or channel</span><br><span style="color: hsl(120, 100%, 40%);">+ uniqueid.</para></span><br><span> </parameter></span><br><span> </syntax></span><br><span> <description></span><br><span> <para>This application places the incoming channel into</span><br><span> the bridge containing the specified channel. The specified</span><br><span> channel only needs to be the prefix of a full channel name</span><br><span style="color: hsl(0, 100%, 40%);">- IE. 'SIP/cisco0001'.</span><br><span style="color: hsl(120, 100%, 40%);">+ IE. 'PJSIP/cisco0001'.</span><br><span> </para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>This application sets the following channel variable upon completion:</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <variablelist></span><br><span style="color: hsl(120, 100%, 40%);">+ <variable name="BRIDGERESULT"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>The result of the bridge attempt as a text string.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <value name="SUCCESS" /></span><br><span style="color: hsl(120, 100%, 40%);">+ <value name="FAILURE" /></span><br><span style="color: hsl(120, 100%, 40%);">+ <value name="LOOP" /></span><br><span style="color: hsl(120, 100%, 40%);">+ <value name="NONEXISTENT" /></span><br><span style="color: hsl(120, 100%, 40%);">+ </variable></span><br><span style="color: hsl(120, 100%, 40%);">+ </variablelist></span><br><span> </description></span><br><span> </application></span><br><span> ***/</span><br><span>@@ -66,15 +77,28 @@</span><br><span> struct ast_bridge_features chan_features;</span><br><span> struct ast_bridge *bridge;</span><br><span> char *c_name;</span><br><span style="color: hsl(120, 100%, 40%);">+ int failed;</span><br><span> </span><br><span> /* Answer the channel if needed */</span><br><span> if (ast_channel_state(chan) != AST_STATE_UP) {</span><br><span> ast_answer(chan);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!(c_ref = ast_channel_get_by_name_prefix(data, strlen(data)))) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Channel %s not found\n", data);</span><br><span style="color: hsl(0, 100%, 40%);">- return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_strlen_zero(data)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ data = "";</span><br><span style="color: hsl(120, 100%, 40%);">+ c_ref = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ c_ref = ast_channel_get_by_name_prefix(data, strlen(data));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!c_ref) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_verb(4, "Channel '%s' not found\n", data);</span><br><span style="color: hsl(120, 100%, 40%);">+ pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "NONEXISTENT");</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (chan == c_ref) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_unref(c_ref);</span><br><span style="color: hsl(120, 100%, 40%);">+ pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "LOOP");</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span> }</span><br><span> </span><br><span> c_name = ast_strdupa(ast_channel_name(c_ref));</span><br><span>@@ -86,26 +110,24 @@</span><br><span> ast_channel_unref(c_ref);</span><br><span> </span><br><span> if (!bridge) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Channel %s is not in a bridge\n", c_name);</span><br><span style="color: hsl(0, 100%, 40%);">- return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_verb(4, "Channel '%s' is not in a bridge\n", c_name);</span><br><span style="color: hsl(120, 100%, 40%);">+ pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "FAILURE");</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_verb(3, "%s is joining %s in bridge %s\n", ast_channel_name(chan),</span><br><span style="color: hsl(0, 100%, 40%);">- c_name, bridge->uniqueid);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_verb(4, "%s is joining %s in bridge %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_name(chan), c_name, bridge->uniqueid);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_bridge_features_init(&chan_features)</span><br><span style="color: hsl(0, 100%, 40%);">- || ast_bridge_join(bridge, chan, NULL, &chan_features, NULL, 0)) {</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "%s failed to join %s in bridge %s\n", ast_channel_name(chan),</span><br><span style="color: hsl(0, 100%, 40%);">- c_name, bridge->uniqueid);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ast_bridge_features_cleanup(&chan_features);</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_cleanup(bridge);</span><br><span style="color: hsl(0, 100%, 40%);">- return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ failed = ast_bridge_features_init(&chan_features)</span><br><span style="color: hsl(120, 100%, 40%);">+ || ast_bridge_join(bridge, chan, NULL, &chan_features, NULL, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (failed) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_verb(4, "%s failed to join %s in bridge %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_name(chan), c_name, bridge->uniqueid);</span><br><span> }</span><br><span> </span><br><span> ast_bridge_features_cleanup(&chan_features);</span><br><span> ao2_cleanup(bridge);</span><br><span style="color: hsl(120, 100%, 40%);">+ pbx_builtin_setvar_helper(chan, "BRIDGERESULT", failed ? "FAILURE" : "SUCCESS");</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span>diff --git a/doc/CHANGES-staging/app_bridgeaddchan_add_bridgeresult_var.txt b/doc/CHANGES-staging/app_bridgeaddchan_add_bridgeresult_var.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..784e502</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/app_bridgeaddchan_add_bridgeresult_var.txt</span><br><span>@@ -0,0 +1,7 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_bridgeaddchan</span><br><span style="color: hsl(120, 100%, 40%);">+Master-Only: true</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The BridgeAdd application now behaves more like the Bridge application.</span><br><span style="color: hsl(120, 100%, 40%);">+The application now sets the BRIDGERESULT channel variable to indicate</span><br><span style="color: hsl(120, 100%, 40%);">+what happened when the channel resumes in dialplan. This is instead of</span><br><span style="color: hsl(120, 100%, 40%);">+hanging up the channel on failure conditions.</span><br><span>diff --git a/doc/UPGRADE-staging/app_bridgeaddchan_add_bridgeresult_var.txt b/doc/UPGRADE-staging/app_bridgeaddchan_add_bridgeresult_var.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..784e502</span><br><span>--- /dev/null</span><br><span>+++ b/doc/UPGRADE-staging/app_bridgeaddchan_add_bridgeresult_var.txt</span><br><span>@@ -0,0 +1,7 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_bridgeaddchan</span><br><span style="color: hsl(120, 100%, 40%);">+Master-Only: true</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The BridgeAdd application now behaves more like the Bridge application.</span><br><span style="color: hsl(120, 100%, 40%);">+The application now sets the BRIDGERESULT channel variable to indicate</span><br><span style="color: hsl(120, 100%, 40%);">+what happened when the channel resumes in dialplan. This is instead of</span><br><span style="color: hsl(120, 100%, 40%);">+hanging up the channel on failure conditions.</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13517">change 13517</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/+/13517"/><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: I374d39b8a3edcc794eeb5c6b9f31a01424cdc426 </div>
<div style="display:none"> Gerrit-Change-Number: 13517 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@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: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>