<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18515">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  George Joseph: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_confbridge: Add function to retrieve channels.<br><br>Adds the CONFBRIDGE_CHANNELS function which can be used<br>to retrieve a comma-separated list of channels, filtered<br>by a particular type of participant category. This output<br>can then be used with functions like UNSHIFT, SHIFT, POP,<br>etc.<br><br>ASTERISK-30036 #close<br><br>Change-Id: I1950aff932437476dc1abab6f47fb4ac90520b83<br>---<br>M apps/app_confbridge.c<br>A doc/CHANGES-staging/app_confbridge_channels.txt<br>2 files changed, 139 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c</span><br><span>index d365075..ae17bca 100644</span><br><span>--- a/apps/app_confbridge.c</span><br><span>+++ b/apps/app_confbridge.c</span><br><span>@@ -128,6 +128,7 @@</span><br><span>                    <ref type="application">ConfKick</ref></span><br><span>                         <ref type="function">CONFBRIDGE</ref></span><br><span>                  <ref type="function">CONFBRIDGE_INFO</ref></span><br><span style="color: hsl(120, 100%, 40%);">+                      <ref type="function">CONFBRIDGE_CHANNELS</ref></span><br><span>                 </see-also></span><br><span>    </application></span><br><span>         <application name="ConfKick" language="en_US"></span><br><span>@@ -164,6 +165,7 @@</span><br><span>                       <ref type="application">ConfBridge</ref></span><br><span>                       <ref type="function">CONFBRIDGE</ref></span><br><span>                  <ref type="function">CONFBRIDGE_INFO</ref></span><br><span style="color: hsl(120, 100%, 40%);">+                      <ref type="function">CONFBRIDGE_CHANNELS</ref></span><br><span>                 </see-also></span><br><span>    </application></span><br><span>         <function name="CONFBRIDGE" language="en_US"></span><br><span>@@ -248,6 +250,50 @@</span><br><span>                       <para>This function returns a non-negative integer for valid conference</span><br><span>                        names and an empty string for invalid conference names.</para></span><br><span>                 </description></span><br><span style="color: hsl(120, 100%, 40%);">+          <see-also></span><br><span style="color: hsl(120, 100%, 40%);">+                      <ref type="function">CONFBRIDGE_CHANNELS</ref></span><br><span style="color: hsl(120, 100%, 40%);">+          </see-also></span><br><span style="color: hsl(120, 100%, 40%);">+     </function></span><br><span style="color: hsl(120, 100%, 40%);">+     <function name="CONFBRIDGE_CHANNELS" language="en_US"></span><br><span style="color: hsl(120, 100%, 40%);">+              <since></span><br><span style="color: hsl(120, 100%, 40%);">+                 <version>16.26.0</version></span><br><span style="color: hsl(120, 100%, 40%);">+                        <version>18.12.0</version></span><br><span style="color: hsl(120, 100%, 40%);">+                        <version>19.4.0</version></span><br><span style="color: hsl(120, 100%, 40%);">+         </since></span><br><span style="color: hsl(120, 100%, 40%);">+                <synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+                      Get a list of channels in a ConfBridge conference.</span><br><span style="color: hsl(120, 100%, 40%);">+            </synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+             <syntax></span><br><span style="color: hsl(120, 100%, 40%);">+                        <parameter name="type" required="true"></span><br><span style="color: hsl(120, 100%, 40%);">+                             <para>What conference information is requested.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                            <enumlist></span><br><span style="color: hsl(120, 100%, 40%);">+                                      <enum name="admins"></span><br><span style="color: hsl(120, 100%, 40%);">+                                          <para>Get the number of admin users in the conference.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                     </enum></span><br><span style="color: hsl(120, 100%, 40%);">+                                 <enum name="marked"></span><br><span style="color: hsl(120, 100%, 40%);">+                                          <para>Get the number of marked users in the conference.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                    </enum></span><br><span style="color: hsl(120, 100%, 40%);">+                                 <enum name="parties"></span><br><span style="color: hsl(120, 100%, 40%);">+                                         <para>Get the number of total users in the conference.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                     </enum></span><br><span style="color: hsl(120, 100%, 40%);">+                                 <enum name="active"></span><br><span style="color: hsl(120, 100%, 40%);">+                                          <para>Get the number of active users in the conference.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                    </enum></span><br><span style="color: hsl(120, 100%, 40%);">+                                 <enum name="waiting"></span><br><span style="color: hsl(120, 100%, 40%);">+                                         <para>Get the number of waiting users in the conference.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                   </enum></span><br><span style="color: hsl(120, 100%, 40%);">+                         </enumlist></span><br><span style="color: hsl(120, 100%, 40%);">+                     </parameter></span><br><span style="color: hsl(120, 100%, 40%);">+                    <parameter name="conf" required="true"></span><br><span style="color: hsl(120, 100%, 40%);">+                             <para>The name of the conference being referenced.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                 </parameter></span><br><span style="color: hsl(120, 100%, 40%);">+            </syntax></span><br><span style="color: hsl(120, 100%, 40%);">+               <description></span><br><span style="color: hsl(120, 100%, 40%);">+                   <para>This function returns a comma-separated list of channels in a ConfBridge conference, optionally filtered by a type of participant.</para></span><br><span style="color: hsl(120, 100%, 40%);">+           </description></span><br><span style="color: hsl(120, 100%, 40%);">+          <see-also></span><br><span style="color: hsl(120, 100%, 40%);">+                      <ref type="function">CONFBRIDGE_INFO</ref></span><br><span style="color: hsl(120, 100%, 40%);">+              </see-also></span><br><span>    </function></span><br><span>    <manager name="ConfbridgeList" language="en_US"></span><br><span>           <synopsis></span><br><span>@@ -3829,6 +3875,90 @@</span><br><span>    .read = func_confbridge_info,</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static int func_confbridge_channels(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ char *parse, *outbuf;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct confbridge_conference *conference;</span><br><span style="color: hsl(120, 100%, 40%);">+     struct confbridge_user *user;</span><br><span style="color: hsl(120, 100%, 40%);">+ int bytes, count = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t outlen;</span><br><span style="color: hsl(120, 100%, 40%);">+        AST_DECLARE_APP_ARGS(args,</span><br><span style="color: hsl(120, 100%, 40%);">+            AST_APP_ARG(type);</span><br><span style="color: hsl(120, 100%, 40%);">+            AST_APP_ARG(confno);</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%);">+  /* parse all the required arguments and make sure they exist. */</span><br><span style="color: hsl(120, 100%, 40%);">+      if (ast_strlen_zero(data)) {</span><br><span style="color: hsl(120, 100%, 40%);">+          return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     parse = ast_strdupa(data);</span><br><span style="color: hsl(120, 100%, 40%);">+    AST_STANDARD_APP_ARGS(args, parse);</span><br><span style="color: hsl(120, 100%, 40%);">+   if (ast_strlen_zero(args.confno) || ast_strlen_zero(args.type)) {</span><br><span style="color: hsl(120, 100%, 40%);">+             ast_log(LOG_WARNING, "Usage: %s(category,confno)", cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+            return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     conference = ao2_find(conference_bridges, args.confno, OBJ_KEY);</span><br><span style="color: hsl(120, 100%, 40%);">+      if (!conference) {</span><br><span style="color: hsl(120, 100%, 40%);">+            ast_debug(1, "No such conference: %s\n", args.confno);</span><br><span style="color: hsl(120, 100%, 40%);">+              return -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%);">+   outbuf = buf;</span><br><span style="color: hsl(120, 100%, 40%);">+ outlen = len;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       ao2_lock(conference);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!strcasecmp(args.type, "parties")) {</span><br><span style="color: hsl(120, 100%, 40%);">+            AST_LIST_TRAVERSE(&conference->active_list, user, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      bytes = snprintf(outbuf, outlen, "%s%s", count++ ? "," : "", ast_channel_name(user->chan));</span><br><span style="color: hsl(120, 100%, 40%);">+                  outbuf += bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+                      outlen -= bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+              }</span><br><span style="color: hsl(120, 100%, 40%);">+             AST_LIST_TRAVERSE(&conference->waiting_list, user, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     bytes = snprintf(outbuf, outlen, "%s%s", count++ ? "," : "", ast_channel_name(user->chan));</span><br><span style="color: hsl(120, 100%, 40%);">+                  outbuf += bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+                      outlen -= bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+              }</span><br><span style="color: hsl(120, 100%, 40%);">+     } else if (!strcasecmp(args.type, "active")) {</span><br><span style="color: hsl(120, 100%, 40%);">+              AST_LIST_TRAVERSE(&conference->active_list, user, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      bytes = snprintf(outbuf, outlen, "%s%s", count++ ? "," : "", ast_channel_name(user->chan));</span><br><span style="color: hsl(120, 100%, 40%);">+                  outbuf += bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+                      outlen -= bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+              }</span><br><span style="color: hsl(120, 100%, 40%);">+     } else if (!strcasecmp(args.type, "waiting")) {</span><br><span style="color: hsl(120, 100%, 40%);">+             AST_LIST_TRAVERSE(&conference->waiting_list, user, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     bytes = snprintf(outbuf, outlen, "%s%s", count++ ? "," : "", ast_channel_name(user->chan));</span><br><span style="color: hsl(120, 100%, 40%);">+                  outbuf += bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+                      outlen -= bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+              }</span><br><span style="color: hsl(120, 100%, 40%);">+     } else if (!strcasecmp(args.type, "admins")) {</span><br><span style="color: hsl(120, 100%, 40%);">+              AST_LIST_TRAVERSE(&conference->active_list, user, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      if (ast_test_flag(&user->u_profile, USER_OPT_ADMIN)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                         bytes = snprintf(outbuf, outlen, "%s%s", count++ ? "," : "", ast_channel_name(user->chan));</span><br><span style="color: hsl(120, 100%, 40%);">+                          outbuf += bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+                              outlen -= bytes;</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%);">+     } else if (!strcasecmp(args.type, "marked")) {</span><br><span style="color: hsl(120, 100%, 40%);">+              AST_LIST_TRAVERSE(&conference->active_list, user, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      if (ast_test_flag(&user->u_profile, USER_OPT_MARKEDUSER)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                            bytes = snprintf(outbuf, outlen, "%s%s", count++ ? "," : "", ast_channel_name(user->chan));</span><br><span style="color: hsl(120, 100%, 40%);">+                          outbuf += bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+                              outlen -= bytes;</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%);">+     } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              ast_log(LOG_ERROR, "Invalid keyword '%s' passed to %s.\n", args.type, cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     ao2_unlock(conference);</span><br><span style="color: hsl(120, 100%, 40%);">+       ao2_ref(conference, -1);</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%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static struct ast_custom_function confbridge_channels_function = {</span><br><span style="color: hsl(120, 100%, 40%);">+    .name = "CONFBRIDGE_CHANNELS",</span><br><span style="color: hsl(120, 100%, 40%);">+      .read = func_confbridge_channels,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static int action_confbridgelist_item(struct mansession *s, const char *id_text, struct confbridge_conference *conference, struct confbridge_user *user, int waiting)</span><br><span> {</span><br><span>        struct ast_channel_snapshot *snapshot;</span><br><span>@@ -4406,6 +4536,7 @@</span><br><span> </span><br><span>   ast_custom_function_unregister(&confbridge_function);</span><br><span>    ast_custom_function_unregister(&confbridge_info_function);</span><br><span style="color: hsl(120, 100%, 40%);">+        ast_custom_function_unregister(&confbridge_channels_function);</span><br><span> </span><br><span>       ast_cli_unregister_multiple(cli_confbridge, ARRAY_LEN(cli_confbridge));</span><br><span> </span><br><span>@@ -4477,6 +4608,7 @@</span><br><span> </span><br><span>      res |= ast_custom_function_register_escalating(&confbridge_function, AST_CFE_WRITE);</span><br><span>     res |= ast_custom_function_register(&confbridge_info_function);</span><br><span style="color: hsl(120, 100%, 40%);">+   res |= ast_custom_function_register(&confbridge_channels_function);</span><br><span> </span><br><span>  res |= ast_cli_register_multiple(cli_confbridge, ARRAY_LEN(cli_confbridge));</span><br><span> </span><br><span>diff --git a/doc/CHANGES-staging/app_confbridge_channels.txt b/doc/CHANGES-staging/app_confbridge_channels.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..485f664</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/app_confbridge_channels.txt</span><br><span>@@ -0,0 +1,7 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_confbridge</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Adds the CONFBRIDGE_CHANNELS function which can</span><br><span style="color: hsl(120, 100%, 40%);">+be used to retrieve a list of channels in a ConfBridge,</span><br><span style="color: hsl(120, 100%, 40%);">+optionally filtered by a particular category. This</span><br><span style="color: hsl(120, 100%, 40%);">+list can then be used with functions like SHIFT, POP,</span><br><span style="color: hsl(120, 100%, 40%);">+UNSHIFT, etc.</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/+/18515">change 18515</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/+/18515"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: I1950aff932437476dc1abab6f47fb4ac90520b83 </div>
<div style="display:none"> Gerrit-Change-Number: 18515 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.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-MessageType: merged </div>