]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_confbridge: Add a regcontext option for confbridge bridge profiles. 69/2769/6
authorJaco Kroon <jaco@uls.co.za>
Wed, 4 May 2016 07:40:55 +0000 (09:40 +0200)
committerJoshua Colp <jcolp@digium.com>
Mon, 9 May 2016 13:17:59 +0000 (08:17 -0500)
This patch allows for having app_confbridge register the name of the
conference as an extension into a specific context, similar to
regcontext for chan_sip.  This variant is not quite as involved as the
one in chan_sip and doesn't allow for multiple contexts or custom
extensions, you can only specify the context and the conference name
will always be used as the extension to register.

ASTERISK-25989 #close

Change-Id: Icacf94d9f2b5dfd31ef36f6cb702392619a7902f

CHANGES
apps/app_confbridge.c
apps/confbridge/conf_config_parser.c
apps/confbridge/include/confbridge.h
configs/samples/confbridge.conf.sample

diff --git a/CHANGES b/CHANGES
index 63b814c21c2c3fcb0b323e6062f65a24dacd5224..965b1b4beac0fef55a08290a1508095ee82a2318 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -26,6 +26,14 @@ res_pjsip
    into the "reg_server" field in the ps_contacts table to facilitate
    multi-server setups.
 
+app_confbridge
+------------------
+ * Added a bridge profile option called regcontext that allows you to
+   dynamically register the conference bridge name as an extension into
+   the specified context.  This allows tracking down conferences on multi-
+   server installations via alternate means (DUNDI for example). By default
+   this feature is not used.
+
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 13.8.0 to Asterisk 13.9.0 ------------
 ------------------------------------------------------------------------------
index 55b7b12402f0defb7dfad51e712c9e457f7a5940..991b3a307a324c845215367a41ca70fb8e016dd1 100644 (file)
@@ -1253,9 +1253,17 @@ void conf_handle_second_active(struct confbridge_conference *conference)
 
 void conf_ended(struct confbridge_conference *conference)
 {
+       struct pbx_find_info q = { .stacklen = 0 };
+
        /* Called with a reference to conference */
        ao2_unlink(conference_bridges, conference);
        send_conf_end_event(conference);
+       if (!ast_strlen_zero(conference->b_profile.regcontext) &&
+                       pbx_find_extension(NULL, NULL, &q, conference->b_profile.regcontext,
+                               conference->name, 1, NULL, "", E_MATCH)) {
+               ast_context_remove_extension(conference->b_profile.regcontext,
+                               conference->name, 1, NULL);
+       }
        ao2_lock(conference);
        conf_stop_record(conference);
        ao2_unlock(conference);
@@ -1360,6 +1368,13 @@ static struct confbridge_conference *join_conference_bridge(const char *conferen
                }
 
                send_conf_start_event(conference);
+
+               if (!ast_strlen_zero(conference->b_profile.regcontext)) {
+                       if (!ast_exists_extension(NULL, conference->b_profile.regcontext, conference->name, 1, NULL)) {
+                               ast_add_extension(conference->b_profile.regcontext, 1, conference->name, 1, NULL, NULL, "Noop", NULL, NULL, "ConfBridge");
+                       }
+               }
+
                ast_debug(1, "Created conference '%s' and linked to container.\n", conference_name);
        }
 
index b8b1e2a9c9ce151dc53994452e41855d08035cac..f5bb7eb57c3099b378128abefc2b12eb35fe56e3 100644 (file)
@@ -317,6 +317,22 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                                on a conference.
                                        </para></description>
                                </configOption>
+                               <configOption name="regcontext">
+                                       <synopsis>The name of the context into which to register the name of the conference bridge as NoOP() at priority 1</synopsis>
+                                       <description><para>
+                                               When set this will cause the name of the created conference to be registered
+                                               into the named context at priority 1 with an operation of NoOP().  This can
+                                               then be used in other parts of the dialplan to test for the existence of a
+                                               specific conference bridge.
+                                               You should be aware that there are potential races between testing for the
+                                               existence of a bridge, and taking action upon that information, consider
+                                               for example two callers executing the check simultaniously, and then taking
+                                               special action as "first caller" into the bridge.  The same for exiting,
+                                               directly after the check the bridge can be destroyed before the new caller
+                                               enters (creating a new bridge), for example, and the "first member" actions
+                                               could thus be missed.
+                                       </para></description>
+                               </configOption>
                                <configOption name="video_mode">
                                        <synopsis>Sets how confbridge handles video distribution to the conference participants</synopsis>
                                        <description><para>
@@ -1563,6 +1579,8 @@ static char *handle_cli_confbridge_show_bridge_profile(struct ast_cli_entry *e,
                ast_cli(a->fd,"Max Members:          No Limit\n");
        }
 
+       ast_cli(a->fd,"Registration context: %s\n", b_profile.regcontext);
+
        switch (b_profile.flags
                & (BRIDGE_OPT_VIDEO_SRC_LAST_MARKED | BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED
                        | BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER)) {
@@ -2128,6 +2146,7 @@ int conf_load_config(void)
        aco_option_register(&cfg_info, "record_file_append", ACO_EXACT, bridge_types, "yes", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), BRIDGE_OPT_RECORD_FILE_APPEND);
        aco_option_register(&cfg_info, "max_members", ACO_EXACT, bridge_types, "0", OPT_UINT_T, 0, FLDSET(struct bridge_profile, max_members));
        aco_option_register(&cfg_info, "record_file", ACO_EXACT, bridge_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, rec_file));
+       aco_option_register(&cfg_info, "regcontext", ACO_EXACT, bridge_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, regcontext));
        aco_option_register(&cfg_info, "language", ACO_EXACT, bridge_types, "en", OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, language));
        aco_option_register_custom(&cfg_info, "^sound_", ACO_REGEX, bridge_types, NULL, sound_option_handler, 0);
        /* This option should only be used with the CONFBRIDGE dialplan function */
index 8d2dffb1cd904c9b4a0e097835b6e08e4bb9d94d..a1fa5a2b7aefbdf970cf26eea27cea1fbf4aeee5 100644 (file)
@@ -207,6 +207,7 @@ struct bridge_profile {
        unsigned int internal_sample_rate; /*!< The internal sample rate of the bridge. 0 when set to auto adjust mode. */
        unsigned int mix_interval;  /*!< The internal mixing interval used by the bridge. When set to 0 the bridgewill use a default interval. */
        struct bridge_profile_sounds *sounds;
+       char regcontext[AST_MAX_CONTEXT];
 };
 
 /*! \brief The structure that represents a conference bridge */
index d0bdd6fd9b05cdd7576b7f6fb9c8c0cefd0034c8..49208c31b8e075cd857029c4c18412e6797250b6 100644 (file)
@@ -211,6 +211,8 @@ type=bridge
 ;language=en               ; Set the language used for announcements to the conference.
                            ; Default is en (English).
 
+;regcontext=conferences    ; The name of the context into which to register conference names as extensions.
+
 ; All sounds in the conference are customizable using the bridge profile options below.
 ; Simply state the option followed by the filename or full path of the filename after
 ; the option.  Example: sound_had_joined=conf-hasjoin  This will play the conf-hasjoin