2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2011, Digium, Inc.
6 * David Vossel <dvossel@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief ConfBridge config parser
23 * \author David Vossel <dvossel@digium.com>
27 <support_level>core</support_level>
32 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
33 #include "asterisk/logger.h"
34 #include "asterisk/config.h"
35 #include "asterisk/config_options.h"
36 #include "include/confbridge.h"
37 #include "asterisk/astobj2.h"
38 #include "asterisk/cli.h"
39 #include "asterisk/bridging_features.h"
40 #include "asterisk/stringfields.h"
41 #include "asterisk/pbx.h"
43 struct confbridge_cfg {
44 struct ao2_container *bridge_profiles;
45 struct ao2_container *user_profiles;
46 struct ao2_container *menus;
49 static void *bridge_profile_alloc(const char *category);
50 static void *bridge_profile_find(struct ao2_container *container, const char *category);
51 static struct bridge_profile_sounds *bridge_profile_sounds_alloc(void);
53 static void bridge_profile_destructor(void *obj)
55 struct bridge_profile *b_profile = obj;
56 ao2_cleanup(b_profile->sounds);
59 static void *bridge_profile_alloc(const char *category)
61 struct bridge_profile *b_profile;
63 if (!(b_profile = ao2_alloc(sizeof(*b_profile), bridge_profile_destructor))) {
67 if (!(b_profile->sounds = bridge_profile_sounds_alloc())) {
68 ao2_ref(b_profile, -1);
72 ast_copy_string(b_profile->name, category, sizeof(b_profile->name));
77 static void *bridge_profile_find(struct ao2_container *container, const char *category)
79 return ao2_find(container, category, OBJ_KEY);
82 static struct aco_type bridge_type = {
84 .category_match = ACO_BLACKLIST,
85 .category = "^general$",
87 .matchvalue = "bridge",
88 .item_alloc = bridge_profile_alloc,
89 .item_find = bridge_profile_find,
90 .item_offset = offsetof(struct confbridge_cfg, bridge_profiles),
93 static void *user_profile_alloc(const char *category);
94 static void *user_profile_find(struct ao2_container *container, const char *category);
95 static void user_profile_destructor(void *obj)
100 static void *user_profile_alloc(const char *category)
102 struct user_profile *u_profile;
104 if (!(u_profile = ao2_alloc(sizeof(*u_profile), user_profile_destructor))) {
108 ast_copy_string(u_profile->name, category, sizeof(u_profile->name));
113 static void *user_profile_find(struct ao2_container *container, const char *category)
115 return ao2_find(container, category, OBJ_KEY);
118 static struct aco_type user_type = {
120 .category_match = ACO_BLACKLIST,
121 .category = "^general$",
122 .matchfield = "type",
123 .matchvalue = "user",
124 .item_alloc = user_profile_alloc,
125 .item_find = user_profile_find,
126 .item_offset = offsetof(struct confbridge_cfg, user_profiles),
129 static void *menu_alloc(const char *category);
130 static void *menu_find(struct ao2_container *container, const char *category);
131 static void menu_destructor(void *obj);
133 static void *menu_alloc(const char *category)
135 struct conf_menu *menu;
136 if (!(menu = ao2_alloc(sizeof(*menu), menu_destructor))) {
139 ast_copy_string(menu->name, category, sizeof(menu->name));
143 static void *menu_find(struct ao2_container *container, const char *category)
145 return ao2_find(container, category, OBJ_KEY);
148 static struct aco_type menu_type = {
150 .category_match = ACO_BLACKLIST,
151 .category = "^general$",
152 .matchfield = "type",
153 .matchvalue = "menu",
154 .item_alloc = menu_alloc,
155 .item_find = menu_find,
156 .item_offset = offsetof(struct confbridge_cfg, menus),
159 /* Used to pass to aco_option_register */
160 static struct aco_type *bridge_types[] = ACO_TYPES(&bridge_type);
161 static struct aco_type *menu_types[] = ACO_TYPES(&menu_type);
162 static struct aco_type *user_types[] = ACO_TYPES(&user_type);
164 /* The general category is reserved, but unused */
165 static struct aco_type general_type = {
167 .category_match = ACO_WHITELIST,
168 .category = "^general$",
171 static struct aco_file confbridge_conf = {
172 .filename = "confbridge.conf",
173 .types = ACO_TYPES(&bridge_type, &user_type, &menu_type, &general_type),
176 static AO2_GLOBAL_OBJ_STATIC(cfg_handle);
178 static void *confbridge_cfg_alloc(void);
180 CONFIG_INFO_STANDARD(cfg_info, cfg_handle, confbridge_cfg_alloc,
181 .files = ACO_FILES(&confbridge_conf),
184 /*! bridge profile container functions */
185 static int bridge_cmp_cb(void *obj, void *arg, int flags)
187 const struct bridge_profile *entry1 = obj, *entry2 = arg;
188 const char *name = arg;
189 return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ?
190 CMP_MATCH | CMP_STOP : 0;
192 static int bridge_hash_cb(const void *obj, const int flags)
194 const struct bridge_profile *b_profile = obj;
195 const char *name = obj;
196 return ast_str_case_hash(flags & OBJ_KEY ? name : b_profile->name);
199 /*! menu container functions */
200 static int menu_cmp_cb(void *obj, void *arg, int flags)
202 const struct conf_menu *entry1 = obj, *entry2 = arg;
203 const char *name = arg;
204 return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ?
205 CMP_MATCH | CMP_STOP : 0;
207 static int menu_hash_cb(const void *obj, const int flags)
209 const struct conf_menu *menu = obj;
210 const char *name = obj;
211 return ast_str_case_hash(flags & OBJ_KEY ? name : menu->name);
213 static void menu_destructor(void *obj)
215 struct conf_menu *menu = obj;
216 struct conf_menu_entry *entry = NULL;
218 while ((entry = AST_LIST_REMOVE_HEAD(&menu->entries, entry))) {
219 conf_menu_entry_destroy(entry);
224 /*! User profile container functions */
225 static int user_cmp_cb(void *obj, void *arg, int flags)
227 const struct user_profile *entry1 = obj, *entry2 = arg;
228 const char *name = arg;
229 return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ?
230 CMP_MATCH | CMP_STOP : 0;
232 static int user_hash_cb(const void *obj, const int flags)
234 const struct user_profile *u_profile = obj;
235 const char *name = obj;
236 return ast_str_case_hash(flags & OBJ_KEY ? name : u_profile->name);
239 /*! Bridge Profile Sounds functions */
240 static void bridge_profile_sounds_destroy_cb(void *obj)
242 struct bridge_profile_sounds *sounds = obj;
243 ast_string_field_free_memory(sounds);
246 static struct bridge_profile_sounds *bridge_profile_sounds_alloc(void)
248 struct bridge_profile_sounds *sounds = ao2_alloc(sizeof(*sounds), bridge_profile_sounds_destroy_cb);
253 if (ast_string_field_init(sounds, 512)) {
261 static int set_sound(const char *sound_name, const char *sound_file, struct bridge_profile *b_profile)
263 struct bridge_profile_sounds *sounds = b_profile->sounds;
264 if (ast_strlen_zero(sound_file)) {
268 if (!strcasecmp(sound_name, "sound_only_person")) {
269 ast_string_field_set(sounds, onlyperson, sound_file);
270 } else if (!strcasecmp(sound_name, "sound_only_one")) {
271 ast_string_field_set(sounds, onlyone, sound_file);
272 } else if (!strcasecmp(sound_name, "sound_has_joined")) {
273 ast_string_field_set(sounds, hasjoin, sound_file);
274 } else if (!strcasecmp(sound_name, "sound_has_left")) {
275 ast_string_field_set(sounds, hasleft, sound_file);
276 } else if (!strcasecmp(sound_name, "sound_kicked")) {
277 ast_string_field_set(sounds, kicked, sound_file);
278 } else if (!strcasecmp(sound_name, "sound_muted")) {
279 ast_string_field_set(sounds, muted, sound_file);
280 } else if (!strcasecmp(sound_name, "sound_unmuted")) {
281 ast_string_field_set(sounds, unmuted, sound_file);
282 } else if (!strcasecmp(sound_name, "sound_there_are")) {
283 ast_string_field_set(sounds, thereare, sound_file);
284 } else if (!strcasecmp(sound_name, "sound_other_in_party")) {
285 ast_string_field_set(sounds, otherinparty, sound_file);
286 } else if (!strcasecmp(sound_name, "sound_place_into_conference")) {
287 ast_string_field_set(sounds, placeintoconf, sound_file);
288 } else if (!strcasecmp(sound_name, "sound_wait_for_leader")) {
289 ast_string_field_set(sounds, waitforleader, sound_file);
290 } else if (!strcasecmp(sound_name, "sound_leader_has_left")) {
291 ast_string_field_set(sounds, leaderhasleft, sound_file);
292 } else if (!strcasecmp(sound_name, "sound_get_pin")) {
293 ast_string_field_set(sounds, getpin, sound_file);
294 } else if (!strcasecmp(sound_name, "sound_invalid_pin")) {
295 ast_string_field_set(sounds, invalidpin, sound_file);
296 } else if (!strcasecmp(sound_name, "sound_locked")) {
297 ast_string_field_set(sounds, locked, sound_file);
298 } else if (!strcasecmp(sound_name, "sound_unlocked_now")) {
299 ast_string_field_set(sounds, unlockednow, sound_file);
300 } else if (!strcasecmp(sound_name, "sound_locked_now")) {
301 ast_string_field_set(sounds, lockednow, sound_file);
302 } else if (!strcasecmp(sound_name, "sound_error_menu")) {
303 ast_string_field_set(sounds, errormenu, sound_file);
304 } else if (!strcasecmp(sound_name, "sound_join")) {
305 ast_string_field_set(sounds, join, sound_file);
306 } else if (!strcasecmp(sound_name, "sound_leave")) {
307 ast_string_field_set(sounds, leave, sound_file);
308 } else if (!strcasecmp(sound_name, "sound_participants_muted")) {
309 ast_string_field_set(sounds, participantsmuted, sound_file);
310 } else if (!strcasecmp(sound_name, "sound_participants_unmuted")) {
311 ast_string_field_set(sounds, participantsunmuted, sound_file);
319 /*! CONFBRIDGE dialplan function functions and channel datastore. */
320 struct func_confbridge_data {
321 struct bridge_profile b_profile;
322 struct user_profile u_profile;
323 unsigned int b_usable:1; /*!< Tells if bridge profile is usable or not */
324 unsigned int u_usable:1; /*!< Tells if user profile is usable or not */
326 static void func_confbridge_destroy_cb(void *data)
328 struct func_confbridge_data *b_data = data;
329 conf_bridge_profile_destroy(&b_data->b_profile);
332 static const struct ast_datastore_info confbridge_datastore = {
333 .type = "confbridge",
334 .destroy = func_confbridge_destroy_cb
336 int func_confbridge_helper(struct ast_channel *chan, const char *cmd, char *data, const char *value)
338 struct ast_datastore *datastore = NULL;
339 struct func_confbridge_data *b_data = NULL;
342 struct ast_variable tmpvar = { 0, };
343 AST_DECLARE_APP_ARGS(args,
348 /* parse all the required arguments and make sure they exist. */
349 if (ast_strlen_zero(data) || ast_strlen_zero(value)) {
352 parse = ast_strdupa(data);
353 AST_STANDARD_APP_ARGS(args, parse);
354 if (ast_strlen_zero(args.type) || ast_strlen_zero(args.option)) {
358 ast_channel_lock(chan);
359 if (!(datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL))) {
360 ast_channel_unlock(chan);
362 if (!(datastore = ast_datastore_alloc(&confbridge_datastore, NULL))) {
365 if (!(b_data = ast_calloc(1, sizeof(*b_data)))) {
366 ast_datastore_free(datastore);
369 if (!(b_data->b_profile.sounds = bridge_profile_sounds_alloc())) {
370 ast_datastore_free(datastore);
374 datastore->data = b_data;
377 ast_channel_unlock(chan);
378 b_data = datastore->data;
381 tmpvar.name = args.option;
382 tmpvar.value = value;
383 tmpvar.file = "CONFBRIDGE";
384 /* SET(CONFBRIDGE(type,option)=value) */
385 if (!strcasecmp(args.type, "bridge") && !aco_process_var(&bridge_type, "dialplan", &tmpvar, &b_data->b_profile)) {
386 b_data->b_usable = 1;
387 } else if (!strcasecmp(args.type, "user") && !aco_process_var(&user_type, "dialplan", &tmpvar, &b_data->u_profile)) {
388 b_data->u_usable = 1;
390 ast_log(LOG_WARNING, "Profile type \"%s\" can not be set in CONFBRIDGE function with option \"%s\" and value \"%s\"\n",
391 args.type, args.option, value);
395 ast_channel_lock(chan);
396 ast_channel_datastore_add(chan, datastore);
397 ast_channel_unlock(chan);
402 ast_log(LOG_ERROR, "Invalid argument provided to the %s function\n", cmd);
404 ast_datastore_free(datastore);
409 static int add_action_to_menu_entry(struct conf_menu_entry *menu_entry, enum conf_menu_action_id id, char *databuf)
411 struct conf_menu_action *menu_action = ast_calloc(1, sizeof(*menu_action));
416 menu_action->id = id;
419 case MENU_ACTION_NOOP:
420 case MENU_ACTION_TOGGLE_MUTE:
421 case MENU_ACTION_INCREASE_LISTENING:
422 case MENU_ACTION_DECREASE_LISTENING:
423 case MENU_ACTION_INCREASE_TALKING:
424 case MENU_ACTION_DECREASE_TALKING:
425 case MENU_ACTION_RESET_LISTENING:
426 case MENU_ACTION_RESET_TALKING:
427 case MENU_ACTION_ADMIN_TOGGLE_LOCK:
428 case MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS:
429 case MENU_ACTION_PARTICIPANT_COUNT:
430 case MENU_ACTION_ADMIN_KICK_LAST:
431 case MENU_ACTION_LEAVE:
432 case MENU_ACTION_SET_SINGLE_VIDEO_SRC:
433 case MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC:
435 case MENU_ACTION_PLAYBACK:
436 case MENU_ACTION_PLAYBACK_AND_CONTINUE:
437 if (!(ast_strlen_zero(databuf))) {
438 ast_copy_string(menu_action->data.playback_file, databuf, sizeof(menu_action->data.playback_file));
440 ast_free(menu_action);
444 case MENU_ACTION_DIALPLAN_EXEC:
445 if (!(ast_strlen_zero(databuf))) {
446 AST_DECLARE_APP_ARGS(args,
447 AST_APP_ARG(context);
449 AST_APP_ARG(priority);
451 AST_STANDARD_APP_ARGS(args, databuf);
452 if (!ast_strlen_zero(args.context)) {
453 ast_copy_string(menu_action->data.dialplan_args.context,
455 sizeof(menu_action->data.dialplan_args.context));
457 if (!ast_strlen_zero(args.exten)) {
458 ast_copy_string(menu_action->data.dialplan_args.exten,
460 sizeof(menu_action->data.dialplan_args.exten));
462 menu_action->data.dialplan_args.priority = 1; /* 1 by default */
463 if (!ast_strlen_zero(args.priority) &&
464 (sscanf(args.priority, "%30u", &menu_action->data.dialplan_args.priority) != 1)) {
465 /* invalid priority */
466 ast_free(menu_action);
470 ast_free(menu_action);
475 AST_LIST_INSERT_TAIL(&menu_entry->actions, menu_action, action);
480 static int add_menu_entry(struct conf_menu *menu, const char *dtmf, const char *action_names)
482 struct conf_menu_entry *menu_entry = NULL, *cur = NULL;
484 char *tmp_action_names = ast_strdupa(action_names);
489 char *delimiter = ",";
491 if (!(menu_entry = ast_calloc(1, sizeof(*menu_entry)))) {
499 unsigned int action_len;
501 if (ast_strlen_zero(tmp_action_names)) {
504 startbrace = strchr(tmp_action_names, '(');
505 endbrace = strchr(tmp_action_names, ')');
506 comma = strchr(tmp_action_names, ',');
508 /* If the next action has brackets with comma delimited arguments in it,
509 * make the delimeter ')' instead of a comma to preserve the argments */
510 if (startbrace && endbrace && comma && (comma > startbrace && comma < endbrace)) {
516 if (!(action = strsep(&tmp_action_names, delimiter))) {
520 action = ast_strip(action);
521 if (ast_strlen_zero(action)) {
525 action_len = strlen(action);
526 ast_copy_string(menu_entry->dtmf, dtmf, sizeof(menu_entry->dtmf));
527 if (!strcasecmp(action, "toggle_mute")) {
528 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_TOGGLE_MUTE, NULL);
529 } else if (!strcasecmp(action, "no_op")) {
530 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_NOOP, NULL);
531 } else if (!strcasecmp(action, "increase_listening_volume")) {
532 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_LISTENING, NULL);
533 } else if (!strcasecmp(action, "decrease_listening_volume")) {
534 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_LISTENING, NULL);
535 } else if (!strcasecmp(action, "increase_talking_volume")) {
536 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_TALKING, NULL);
537 } else if (!strcasecmp(action, "reset_listening_volume")) {
538 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_LISTENING, NULL);
539 } else if (!strcasecmp(action, "reset_talking_volume")) {
540 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_TALKING, NULL);
541 } else if (!strcasecmp(action, "decrease_talking_volume")) {
542 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_TALKING, NULL);
543 } else if (!strcasecmp(action, "admin_toggle_conference_lock")) {
544 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_TOGGLE_LOCK, NULL);
545 } else if (!strcasecmp(action, "admin_toggle_mute_participants")) {
546 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS, NULL);
547 } else if (!strcasecmp(action, "participant_count")) {
548 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PARTICIPANT_COUNT, NULL);
549 } else if (!strcasecmp(action, "admin_kick_last")) {
550 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_KICK_LAST, NULL);
551 } else if (!strcasecmp(action, "leave_conference")) {
552 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_LEAVE, NULL);
553 } else if (!strcasecmp(action, "set_as_single_video_src")) {
554 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_SET_SINGLE_VIDEO_SRC, NULL);
555 } else if (!strcasecmp(action, "release_as_single_video_src")) {
556 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC, NULL);
557 } else if (!strncasecmp(action, "dialplan_exec(", 14)) {
558 ast_copy_string(buf, action, sizeof(buf));
560 if ((action_args = strchr(action, '('))) {
563 /* it is possible that this argument may or may not
564 * have a closing brace at this point, it all depends on if
565 * comma delimited arguments were provided */
566 if ((tmp = strchr(action, ')'))) {
569 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DIALPLAN_EXEC, action_args);
570 } else if (action_len >= 21 && !strncasecmp(action, "playback_and_continue(", 22)) {
571 ast_copy_string(buf, action, sizeof(buf));
573 if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
577 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK_AND_CONTINUE, action_args);
578 } else if (action_len >= 8 && !strncasecmp(action, "playback(", 9)) {
579 ast_copy_string(buf, action, sizeof(buf));
581 if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
585 res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK, action_args);
589 /* if adding any of the actions failed, bail */
591 struct conf_menu_action *menu_action;
592 while ((menu_action = AST_LIST_REMOVE_HEAD(&menu_entry->actions, action))) {
593 ast_free(menu_action);
595 ast_free(menu_entry);
599 /* remove any list entry with an identical DTMF sequence for overrides */
600 AST_LIST_TRAVERSE_SAFE_BEGIN(&menu->entries, cur, entry) {
601 if (!strcasecmp(cur->dtmf, menu_entry->dtmf)) {
602 AST_LIST_REMOVE_CURRENT(entry);
607 AST_LIST_TRAVERSE_SAFE_END;
609 AST_LIST_INSERT_TAIL(&menu->entries, menu_entry, entry);
614 static char *complete_user_profile_name(const char *line, const char *word, int pos, int state)
618 int wordlen = strlen(word);
619 struct ao2_iterator i;
620 struct user_profile *u_profile = NULL;
621 RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
627 i = ao2_iterator_init(cfg->user_profiles, 0);
628 while ((u_profile = ao2_iterator_next(&i))) {
629 if (!strncasecmp(u_profile->name, word, wordlen) && ++which > state) {
630 res = ast_strdup(u_profile->name);
631 ao2_ref(u_profile, -1);
634 ao2_ref(u_profile, -1);
636 ao2_iterator_destroy(&i);
641 static char *handle_cli_confbridge_show_user_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
643 struct ao2_iterator it;
644 struct user_profile *u_profile;
645 RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup);
649 e->command = "confbridge show profile users";
651 "Usage confbridge show profile users\n";
657 if (!(cfg = ao2_global_obj_ref(cfg_handle))) {
661 ast_cli(a->fd,"--------- User Profiles -----------\n");
662 ao2_lock(cfg->user_profiles);
663 it = ao2_iterator_init(cfg->user_profiles, 0);
664 while ((u_profile = ao2_iterator_next(&it))) {
665 ast_cli(a->fd,"%s\n", u_profile->name);
666 ao2_ref(u_profile, -1);
668 ao2_iterator_destroy(&it);
669 ao2_unlock(cfg->user_profiles);
673 static char *handle_cli_confbridge_show_user_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
675 struct user_profile u_profile;
679 e->command = "confbridge show profile user";
681 "Usage confbridge show profile user [<profile name>]\n";
685 return complete_user_profile_name(a->line, a->word, a->pos, a->n);
691 return CLI_SHOWUSAGE;
694 if (!(conf_find_user_profile(NULL, a->argv[4], &u_profile))) {
695 ast_cli(a->fd, "No conference user profile named '%s' found!\n", a->argv[4]);
699 ast_cli(a->fd,"--------------------------------------------\n");
700 ast_cli(a->fd,"Name: %s\n",
702 ast_cli(a->fd,"Admin: %s\n",
703 u_profile.flags & USER_OPT_ADMIN ?
705 ast_cli(a->fd,"Marked User: %s\n",
706 u_profile.flags & USER_OPT_MARKEDUSER ?
708 ast_cli(a->fd,"Start Muted: %s\n",
709 u_profile.flags & USER_OPT_STARTMUTED?
711 ast_cli(a->fd,"MOH When Empty: %s\n",
712 u_profile.flags & USER_OPT_MUSICONHOLD ?
713 "enabled" : "disabled");
714 ast_cli(a->fd,"MOH Class: %s\n",
715 ast_strlen_zero(u_profile.moh_class) ?
716 "default" : u_profile.moh_class);
717 ast_cli(a->fd,"Announcement: %s\n",
718 u_profile.announcement);
719 ast_cli(a->fd,"Quiet: %s\n",
720 u_profile.flags & USER_OPT_QUIET ?
721 "enabled" : "disabled");
722 ast_cli(a->fd,"Wait Marked: %s\n",
723 u_profile.flags & USER_OPT_WAITMARKED ?
724 "enabled" : "disabled");
725 ast_cli(a->fd,"END Marked: %s\n",
726 u_profile.flags & USER_OPT_ENDMARKED ?
727 "enabled" : "disabled");
728 ast_cli(a->fd,"Drop_silence: %s\n",
729 u_profile.flags & USER_OPT_DROP_SILENCE ?
730 "enabled" : "disabled");
731 ast_cli(a->fd,"Silence Threshold: %dms\n",
732 u_profile.silence_threshold);
733 ast_cli(a->fd,"Talking Threshold: %dms\n",
734 u_profile.talking_threshold);
735 ast_cli(a->fd,"Denoise: %s\n",
736 u_profile.flags & USER_OPT_DENOISE ?
737 "enabled" : "disabled");
738 ast_cli(a->fd,"Jitterbuffer: %s\n",
739 u_profile.flags & USER_OPT_JITTERBUFFER ?
740 "enabled" : "disabled");
741 ast_cli(a->fd,"Talk Detect Events: %s\n",
742 u_profile.flags & USER_OPT_TALKER_DETECT ?
743 "enabled" : "disabled");
744 ast_cli(a->fd,"DTMF Pass Through: %s\n",
745 u_profile.flags & USER_OPT_DTMF_PASS ?
746 "enabled" : "disabled");
747 ast_cli(a->fd,"PIN: %s\n",
748 ast_strlen_zero(u_profile.pin) ?
749 "None" : u_profile.pin);
750 ast_cli(a->fd,"Announce User Count: %s\n",
751 u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNT ?
752 "enabled" : "disabled");
753 ast_cli(a->fd,"Announce join/leave: %s\n",
754 u_profile.flags & USER_OPT_ANNOUNCE_JOIN_LEAVE ?
755 "enabled" : "disabled");
756 ast_cli(a->fd,"Announce User Count all: %s\n",
757 u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNTALL ?
758 "enabled" : "disabled");
764 static char *complete_bridge_profile_name(const char *line, const char *word, int pos, int state)
768 int wordlen = strlen(word);
769 struct ao2_iterator i;
770 struct bridge_profile *b_profile = NULL;
771 RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
777 i = ao2_iterator_init(cfg->bridge_profiles, 0);
778 while ((b_profile = ao2_iterator_next(&i))) {
779 if (!strncasecmp(b_profile->name, word, wordlen) && ++which > state) {
780 res = ast_strdup(b_profile->name);
781 ao2_ref(b_profile, -1);
784 ao2_ref(b_profile, -1);
786 ao2_iterator_destroy(&i);
791 static char *handle_cli_confbridge_show_bridge_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
793 struct ao2_iterator it;
794 struct bridge_profile *b_profile;
795 RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup);
799 e->command = "confbridge show profile bridges";
801 "Usage confbridge show profile bridges\n";
807 if (!(cfg = ao2_global_obj_ref(cfg_handle))) {
811 ast_cli(a->fd,"--------- Bridge Profiles -----------\n");
812 ao2_lock(cfg->bridge_profiles);
813 it = ao2_iterator_init(cfg->bridge_profiles, 0);
814 while ((b_profile = ao2_iterator_next(&it))) {
815 ast_cli(a->fd,"%s\n", b_profile->name);
816 ao2_ref(b_profile, -1);
818 ao2_iterator_destroy(&it);
819 ao2_unlock(cfg->bridge_profiles);
824 static char *handle_cli_confbridge_show_bridge_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
826 struct bridge_profile b_profile;
831 e->command = "confbridge show profile bridge";
833 "Usage confbridge show profile bridge <profile name>\n";
837 return complete_bridge_profile_name(a->line, a->word, a->pos, a->n);
843 return CLI_SHOWUSAGE;
846 if (!(conf_find_bridge_profile(NULL, a->argv[4], &b_profile))) {
847 ast_cli(a->fd, "No conference bridge profile named '%s' found!\n", a->argv[4]);
851 ast_cli(a->fd,"--------------------------------------------\n");
852 ast_cli(a->fd,"Name: %s\n", b_profile.name);
854 if (b_profile.internal_sample_rate) {
855 snprintf(tmp, sizeof(tmp), "%d", b_profile.internal_sample_rate);
857 ast_copy_string(tmp, "auto", sizeof(tmp));
859 ast_cli(a->fd,"Internal Sample Rate: %s\n", tmp);
861 if (b_profile.mix_interval) {
862 ast_cli(a->fd,"Mixing Interval: %d\n", b_profile.mix_interval);
864 ast_cli(a->fd,"Mixing Interval: Default 20ms\n");
867 ast_cli(a->fd,"Record Conference: %s\n",
868 b_profile.flags & BRIDGE_OPT_RECORD_CONFERENCE ?
871 ast_cli(a->fd,"Record File: %s\n",
872 ast_strlen_zero(b_profile.rec_file) ? "Auto Generated" :
875 if (b_profile.max_members) {
876 ast_cli(a->fd,"Max Members: %d\n", b_profile.max_members);
878 ast_cli(a->fd,"Max Members: No Limit\n");
881 if (b_profile.flags & BRIDGE_OPT_VIDEO_SRC_LAST_MARKED) {
882 ast_cli(a->fd, "Video Mode: last_marked\n");
883 } else if (b_profile.flags & BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED) {
884 ast_cli(a->fd, "Video Mode: first_marked\n");
885 } else if (b_profile.flags & BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER) {
886 ast_cli(a->fd, "Video Mode: follow_talker\n");
888 ast_cli(a->fd, "Video Mode: no video\n");
891 ast_cli(a->fd,"sound_join: %s\n", conf_get_sound(CONF_SOUND_JOIN, b_profile.sounds));
892 ast_cli(a->fd,"sound_leave: %s\n", conf_get_sound(CONF_SOUND_LEAVE, b_profile.sounds));
893 ast_cli(a->fd,"sound_only_person: %s\n", conf_get_sound(CONF_SOUND_ONLY_PERSON, b_profile.sounds));
894 ast_cli(a->fd,"sound_has_joined: %s\n", conf_get_sound(CONF_SOUND_HAS_JOINED, b_profile.sounds));
895 ast_cli(a->fd,"sound_has_left: %s\n", conf_get_sound(CONF_SOUND_HAS_LEFT, b_profile.sounds));
896 ast_cli(a->fd,"sound_kicked: %s\n", conf_get_sound(CONF_SOUND_KICKED, b_profile.sounds));
897 ast_cli(a->fd,"sound_muted: %s\n", conf_get_sound(CONF_SOUND_MUTED, b_profile.sounds));
898 ast_cli(a->fd,"sound_unmuted: %s\n", conf_get_sound(CONF_SOUND_UNMUTED, b_profile.sounds));
899 ast_cli(a->fd,"sound_there_are: %s\n", conf_get_sound(CONF_SOUND_THERE_ARE, b_profile.sounds));
900 ast_cli(a->fd,"sound_other_in_party: %s\n", conf_get_sound(CONF_SOUND_OTHER_IN_PARTY, b_profile.sounds));
901 ast_cli(a->fd,"sound_place_into_conference: %s\n", conf_get_sound(CONF_SOUND_PLACE_IN_CONF, b_profile.sounds));
902 ast_cli(a->fd,"sound_wait_for_leader: %s\n", conf_get_sound(CONF_SOUND_WAIT_FOR_LEADER, b_profile.sounds));
903 ast_cli(a->fd,"sound_leader_has_left: %s\n", conf_get_sound(CONF_SOUND_LEADER_HAS_LEFT, b_profile.sounds));
904 ast_cli(a->fd,"sound_get_pin: %s\n", conf_get_sound(CONF_SOUND_GET_PIN, b_profile.sounds));
905 ast_cli(a->fd,"sound_invalid_pin: %s\n", conf_get_sound(CONF_SOUND_INVALID_PIN, b_profile.sounds));
906 ast_cli(a->fd,"sound_locked: %s\n", conf_get_sound(CONF_SOUND_LOCKED, b_profile.sounds));
907 ast_cli(a->fd,"sound_unlocked_now: %s\n", conf_get_sound(CONF_SOUND_UNLOCKED_NOW, b_profile.sounds));
908 ast_cli(a->fd,"sound_lockednow: %s\n", conf_get_sound(CONF_SOUND_LOCKED_NOW, b_profile.sounds));
909 ast_cli(a->fd,"sound_error_menu: %s\n", conf_get_sound(CONF_SOUND_ERROR_MENU, b_profile.sounds));
910 ast_cli(a->fd,"sound_participants_muted: %s\n", conf_get_sound(CONF_SOUND_PARTICIPANTS_MUTED, b_profile.sounds));
911 ast_cli(a->fd,"sound_participants_unmuted: %s\n", conf_get_sound(CONF_SOUND_PARTICIPANTS_UNMUTED, b_profile.sounds));
914 conf_bridge_profile_destroy(&b_profile);
918 static char *complete_menu_name(const char *line, const char *word, int pos, int state)
922 int wordlen = strlen(word);
923 struct ao2_iterator i;
924 struct conf_menu *menu = NULL;
925 RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
931 i = ao2_iterator_init(cfg->menus, 0);
932 while ((menu = ao2_iterator_next(&i))) {
933 if (!strncasecmp(menu->name, word, wordlen) && ++which > state) {
934 res = ast_strdup(menu->name);
940 ao2_iterator_destroy(&i);
945 static char *handle_cli_confbridge_show_menus(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
947 struct ao2_iterator it;
948 struct conf_menu *menu;
949 RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup);
953 e->command = "confbridge show menus";
955 "Usage confbridge show profile menus\n";
961 if (!(cfg = ao2_global_obj_ref(cfg_handle))) {
965 ast_cli(a->fd,"--------- Menus -----------\n");
966 ao2_lock(cfg->menus);
967 it = ao2_iterator_init(cfg->menus, 0);
968 while ((menu = ao2_iterator_next(&it))) {
969 ast_cli(a->fd,"%s\n", menu->name);
972 ao2_iterator_destroy(&it);
973 ao2_unlock(cfg->menus);
978 static char *handle_cli_confbridge_show_menu(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
980 RAII_VAR(struct conf_menu *, menu, NULL, ao2_cleanup);
981 RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup);
982 struct conf_menu_entry *menu_entry = NULL;
983 struct conf_menu_action *menu_action = NULL;
987 e->command = "confbridge show menu";
989 "Usage confbridge show menu [<menu name>]\n";
993 return complete_menu_name(a->line, a->word, a->pos, a->n);
999 return CLI_SHOWUSAGE;
1002 if (!(cfg = ao2_global_obj_ref(cfg_handle))) {
1006 if (!(menu = menu_find(cfg->menus, a->argv[3]))) {
1007 ast_cli(a->fd, "No conference menu named '%s' found!\n", a->argv[3]);
1012 ast_cli(a->fd,"Name: %s\n", menu->name);
1013 AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) {
1015 ast_cli(a->fd, "%s=", menu_entry->dtmf);
1016 AST_LIST_TRAVERSE(&menu_entry->actions, menu_action, action) {
1018 ast_cli(a->fd, ", ");
1020 switch (menu_action->id) {
1021 case MENU_ACTION_TOGGLE_MUTE:
1022 ast_cli(a->fd, "toggle_mute");
1024 case MENU_ACTION_NOOP:
1025 ast_cli(a->fd, "no_op");
1027 case MENU_ACTION_INCREASE_LISTENING:
1028 ast_cli(a->fd, "increase_listening_volume");
1030 case MENU_ACTION_DECREASE_LISTENING:
1031 ast_cli(a->fd, "decrease_listening_volume");
1033 case MENU_ACTION_RESET_LISTENING:
1034 ast_cli(a->fd, "reset_listening_volume");
1036 case MENU_ACTION_RESET_TALKING:
1037 ast_cli(a->fd, "reset_talking_volume");
1039 case MENU_ACTION_INCREASE_TALKING:
1040 ast_cli(a->fd, "increase_talking_volume");
1042 case MENU_ACTION_DECREASE_TALKING:
1043 ast_cli(a->fd, "decrease_talking_volume");
1045 case MENU_ACTION_PLAYBACK:
1046 ast_cli(a->fd, "playback(%s)", menu_action->data.playback_file);
1048 case MENU_ACTION_PLAYBACK_AND_CONTINUE:
1049 ast_cli(a->fd, "playback_and_continue(%s)", menu_action->data.playback_file);
1051 case MENU_ACTION_DIALPLAN_EXEC:
1052 ast_cli(a->fd, "dialplan_exec(%s,%s,%d)",
1053 menu_action->data.dialplan_args.context,
1054 menu_action->data.dialplan_args.exten,
1055 menu_action->data.dialplan_args.priority);
1057 case MENU_ACTION_ADMIN_TOGGLE_LOCK:
1058 ast_cli(a->fd, "admin_toggle_conference_lock");
1060 case MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS:
1061 ast_cli(a->fd, "admin_toggle_mute_participants");
1063 case MENU_ACTION_PARTICIPANT_COUNT:
1064 ast_cli(a->fd, "participant_count");
1066 case MENU_ACTION_ADMIN_KICK_LAST:
1067 ast_cli(a->fd, "admin_kick_last");
1069 case MENU_ACTION_LEAVE:
1070 ast_cli(a->fd, "leave_conference");
1072 case MENU_ACTION_SET_SINGLE_VIDEO_SRC:
1073 ast_cli(a->fd, "set_as_single_video_src");
1075 case MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC:
1076 ast_cli(a->fd, "release_as_single_video_src");
1081 ast_cli(a->fd,"\n");
1089 static struct ast_cli_entry cli_confbridge_parser[] = {
1090 AST_CLI_DEFINE(handle_cli_confbridge_show_user_profile, "Show a conference user profile."),
1091 AST_CLI_DEFINE(handle_cli_confbridge_show_bridge_profile, "Show a conference bridge profile."),
1092 AST_CLI_DEFINE(handle_cli_confbridge_show_menu, "Show a conference menu"),
1093 AST_CLI_DEFINE(handle_cli_confbridge_show_user_profiles, "Show a list of conference user profiles."),
1094 AST_CLI_DEFINE(handle_cli_confbridge_show_bridge_profiles, "Show a list of conference bridge profiles."),
1095 AST_CLI_DEFINE(handle_cli_confbridge_show_menus, "Show a list of conference menus"),
1099 static void confbridge_cfg_destructor(void *obj)
1101 struct confbridge_cfg *cfg = obj;
1102 ao2_cleanup(cfg->user_profiles);
1103 ao2_cleanup(cfg->bridge_profiles);
1104 ao2_cleanup(cfg->menus);
1107 void *confbridge_cfg_alloc(void)
1109 struct confbridge_cfg *cfg;
1111 if (!(cfg = ao2_alloc(sizeof(*cfg), confbridge_cfg_destructor))) {
1115 if (!(cfg->user_profiles = ao2_container_alloc(283, user_hash_cb, user_cmp_cb))) {
1119 if (!(cfg->bridge_profiles = ao2_container_alloc(283, bridge_hash_cb, bridge_cmp_cb))) {
1123 if (!(cfg->menus = ao2_container_alloc(283, menu_hash_cb, menu_cmp_cb))) {
1133 static int announce_user_count_all_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
1135 struct user_profile *u_profile = obj;
1137 if (strcasecmp(var->name, "announce_user_count_all")) {
1140 if (ast_true(var->value)) {
1141 u_profile->flags = u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNTALL;
1142 } else if (ast_false(var->value)) {
1143 u_profile->flags = u_profile->flags & ~USER_OPT_ANNOUNCEUSERCOUNTALL;
1144 } else if (sscanf(var->value, "%30u", &u_profile->announce_user_count_all_after) == 1) {
1145 u_profile->flags = u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNTALL;
1152 static int mix_interval_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
1154 struct bridge_profile *b_profile = obj;
1156 if (strcasecmp(var->name, "mixing_interval")) {
1159 if (sscanf(var->value, "%30u", &b_profile->mix_interval) != 1) {
1162 switch (b_profile->mix_interval) {
1173 static int video_mode_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
1175 struct bridge_profile *b_profile = obj;
1177 if (strcasecmp(var->name, "video_mode")) {
1180 if (!strcasecmp(var->value, "first_marked")) {
1181 ast_set_flag(b_profile, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED);
1182 } else if (!strcasecmp(var->value, "last_marked")) {
1183 ast_set_flag(b_profile, BRIDGE_OPT_VIDEO_SRC_LAST_MARKED);
1184 } else if (!strcasecmp(var->value, "follow_talker")) {
1185 ast_set_flag(b_profile, BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER);
1186 } else if (!strcasecmp(var->value, "none")) {
1194 static int user_template_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
1196 struct user_profile *u_profile = obj;
1198 return conf_find_user_profile(NULL, var->value, u_profile) ? 0 : -1;
1201 static int bridge_template_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
1203 struct bridge_profile *b_profile = obj;
1204 struct bridge_profile_sounds *sounds = bridge_profile_sounds_alloc();
1205 struct bridge_profile_sounds *oldsounds = b_profile->sounds;
1210 if (!(conf_find_bridge_profile(NULL, var->value, b_profile))) {
1211 ao2_ref(sounds, -1);
1214 /* Using a bridge profile as a template is a little complicated due to the sounds. Since the sounds
1215 * structure of a dynamic profile will need to be altered, a completely new sounds structure must be
1216 * created instead of simply holding a reference to the one built by the config file. */
1217 ast_string_field_set(sounds, onlyperson, b_profile->sounds->onlyperson);
1218 ast_string_field_set(sounds, hasjoin, b_profile->sounds->hasjoin);
1219 ast_string_field_set(sounds, hasleft, b_profile->sounds->hasleft);
1220 ast_string_field_set(sounds, kicked, b_profile->sounds->kicked);
1221 ast_string_field_set(sounds, muted, b_profile->sounds->muted);
1222 ast_string_field_set(sounds, unmuted, b_profile->sounds->unmuted);
1223 ast_string_field_set(sounds, thereare, b_profile->sounds->thereare);
1224 ast_string_field_set(sounds, otherinparty, b_profile->sounds->otherinparty);
1225 ast_string_field_set(sounds, placeintoconf, b_profile->sounds->placeintoconf);
1226 ast_string_field_set(sounds, waitforleader, b_profile->sounds->waitforleader);
1227 ast_string_field_set(sounds, leaderhasleft, b_profile->sounds->leaderhasleft);
1228 ast_string_field_set(sounds, getpin, b_profile->sounds->getpin);
1229 ast_string_field_set(sounds, invalidpin, b_profile->sounds->invalidpin);
1230 ast_string_field_set(sounds, locked, b_profile->sounds->locked);
1231 ast_string_field_set(sounds, unlockednow, b_profile->sounds->unlockednow);
1232 ast_string_field_set(sounds, lockednow, b_profile->sounds->lockednow);
1233 ast_string_field_set(sounds, errormenu, b_profile->sounds->errormenu);
1234 ast_string_field_set(sounds, participantsmuted, b_profile->sounds->participantsmuted);
1235 ast_string_field_set(sounds, participantsunmuted, b_profile->sounds->participantsunmuted);
1237 ao2_ref(b_profile->sounds, -1); /* sounds struct copied over to it from the template by reference only. */
1238 ao2_ref(oldsounds,-1); /* original sounds struct we don't need anymore */
1239 b_profile->sounds = sounds; /* the new sounds struct that is a deep copy of the one from the template. */
1244 static int sound_option_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
1246 set_sound(var->name, var->value, obj);
1250 static int menu_option_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
1252 add_menu_entry(obj, var->name, var->value);
1256 int conf_load_config(int reload)
1259 if (aco_info_init(&cfg_info)) {
1265 aco_option_register(&cfg_info, "type", ACO_EXACT, user_types, NULL, OPT_NOOP_T, 0, 0);
1266 aco_option_register(&cfg_info, "type", ACO_EXACT, bridge_types, NULL, OPT_NOOP_T, 0, 0);
1267 aco_option_register(&cfg_info, "type", ACO_EXACT, menu_types, NULL, OPT_NOOP_T, 0, 0);
1268 aco_option_register(&cfg_info, "admin", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ADMIN);
1269 aco_option_register(&cfg_info, "marked", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_MARKEDUSER);
1270 aco_option_register(&cfg_info, "startmuted", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_STARTMUTED);
1271 aco_option_register(&cfg_info, "music_on_hold_when_empty", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_MUSICONHOLD);
1272 aco_option_register(&cfg_info, "quiet", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_QUIET);
1273 aco_option_register_custom(&cfg_info, "announce_user_count_all", ACO_EXACT, user_types, "no", announce_user_count_all_handler, 0);
1274 aco_option_register(&cfg_info, "announce_user_count", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ANNOUNCEUSERCOUNT);
1275 /* Negative logic. Defaults to "yes" and evaluates with ast_false(). If !ast_false(), USER_OPT_NOONLYPERSON is cleared */
1276 aco_option_register(&cfg_info, "announce_only_user", ACO_EXACT, user_types, "yes", OPT_BOOLFLAG_T, 0, FLDSET(struct user_profile, flags), USER_OPT_NOONLYPERSON);
1277 aco_option_register(&cfg_info, "wait_marked", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_WAITMARKED);
1278 aco_option_register(&cfg_info, "end_marked", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ENDMARKED);
1279 aco_option_register(&cfg_info, "talk_detection_events", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_TALKER_DETECT);
1280 aco_option_register(&cfg_info, "dtmf_passthrough", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_DTMF_PASS);
1281 aco_option_register(&cfg_info, "announce_join_leave", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ANNOUNCE_JOIN_LEAVE);
1282 aco_option_register(&cfg_info, "pin", ACO_EXACT, user_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct user_profile, pin));
1283 aco_option_register(&cfg_info, "music_on_hold_class", ACO_EXACT, user_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct user_profile, moh_class));
1284 aco_option_register(&cfg_info, "announcement", ACO_EXACT, user_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct user_profile, announcement));
1285 aco_option_register(&cfg_info, "denoise", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_DENOISE);
1286 aco_option_register(&cfg_info, "dsp_drop_silence", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_DROP_SILENCE);
1287 aco_option_register(&cfg_info, "dsp_silence_threshold", ACO_EXACT, user_types, __stringify(DEFAULT_SILENCE_THRESHOLD), OPT_UINT_T, 0, FLDSET(struct user_profile, silence_threshold));
1288 aco_option_register(&cfg_info, "dsp_talking_threshold", ACO_EXACT, user_types, __stringify(DEFAULT_TALKING_THRESHOLD), OPT_UINT_T, 0, FLDSET(struct user_profile, silence_threshold));
1289 aco_option_register(&cfg_info, "jitterbuffer", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_JITTERBUFFER);
1290 /* This option should only be used with the CONFBRIDGE dialplan function */
1291 aco_option_register_custom(&cfg_info, "template", ACO_EXACT, user_types, NULL, user_template_handler, 0);
1293 /* Bridge options */
1294 aco_option_register(&cfg_info, "jitterbuffer", ACO_EXACT, bridge_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), USER_OPT_JITTERBUFFER);
1295 /* "auto" will fail to parse as a uint, but we use PARSE_DEFAULT to set the value to 0 in that case, which is the value that auto resolves to */
1296 aco_option_register(&cfg_info, "internal_sample_rate", ACO_EXACT, bridge_types, "0", OPT_UINT_T, PARSE_DEFAULT, FLDSET(struct bridge_profile, internal_sample_rate), 0);
1297 aco_option_register_custom(&cfg_info, "mixing_interval", ACO_EXACT, bridge_types, "20", mix_interval_handler, 0);
1298 aco_option_register(&cfg_info, "record_conference", ACO_EXACT, bridge_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), BRIDGE_OPT_RECORD_CONFERENCE);
1299 aco_option_register_custom(&cfg_info, "video_mode", ACO_EXACT, bridge_types, NULL, video_mode_handler, 0);
1300 aco_option_register(&cfg_info, "max_members", ACO_EXACT, bridge_types, "0", OPT_UINT_T, 0, FLDSET(struct bridge_profile, max_members));
1301 aco_option_register(&cfg_info, "record_file", ACO_EXACT, bridge_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, rec_file));
1302 aco_option_register_custom(&cfg_info, "^sound_", ACO_REGEX, bridge_types, NULL, sound_option_handler, 0);
1303 /* This option should only be used with the CONFBRIDGE dialplan function */
1304 aco_option_register_custom(&cfg_info, "template", ACO_EXACT, bridge_types, NULL, bridge_template_handler, 0);
1307 aco_option_register_custom(&cfg_info, "^[0-9A-D*#]+$", ACO_REGEX, menu_types, NULL, menu_option_handler, 0);
1309 if (aco_process_config(&cfg_info, reload) == ACO_PROCESS_ERROR) {
1313 if (!reload && ast_cli_register_multiple(cli_confbridge_parser, ARRAY_LEN(cli_confbridge_parser))) {
1319 /* On a reload, just keep the config we already have in place. */
1321 conf_destroy_config();
1326 static void conf_user_profile_copy(struct user_profile *dst, struct user_profile *src)
1328 memcpy(dst, src, sizeof(*dst));
1331 const struct user_profile *conf_find_user_profile(struct ast_channel *chan, const char *user_profile_name, struct user_profile *result)
1333 struct user_profile *tmp2;
1334 struct ast_datastore *datastore = NULL;
1335 struct func_confbridge_data *b_data = NULL;
1336 RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
1343 ast_channel_lock(chan);
1344 if ((datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL))) {
1345 ast_channel_unlock(chan);
1346 b_data = datastore->data;
1347 if (b_data->u_usable) {
1348 conf_user_profile_copy(result, &b_data->u_profile);
1352 ast_channel_unlock(chan);
1356 if (ast_strlen_zero(user_profile_name)) {
1357 user_profile_name = DEFAULT_USER_PROFILE;
1359 if (!(tmp2 = ao2_find(cfg->user_profiles, user_profile_name, OBJ_KEY))) {
1363 conf_user_profile_copy(result, tmp2);
1370 void conf_bridge_profile_copy(struct bridge_profile *dst, struct bridge_profile *src)
1372 memcpy(dst, src, sizeof(*dst));
1374 ao2_ref(src->sounds, +1);
1378 void conf_bridge_profile_destroy(struct bridge_profile *b_profile)
1380 if (b_profile->sounds) {
1381 ao2_ref(b_profile->sounds, -1);
1382 b_profile->sounds = NULL;
1386 const struct bridge_profile *conf_find_bridge_profile(struct ast_channel *chan, const char *bridge_profile_name, struct bridge_profile *result)
1388 struct bridge_profile *tmp2;
1389 struct ast_datastore *datastore = NULL;
1390 struct func_confbridge_data *b_data = NULL;
1391 RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
1398 ast_channel_lock(chan);
1399 if ((datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL))) {
1400 ast_channel_unlock(chan);
1401 b_data = datastore->data;
1402 if (b_data->b_usable) {
1403 conf_bridge_profile_copy(result, &b_data->b_profile);
1407 ast_channel_unlock(chan);
1410 if (ast_strlen_zero(bridge_profile_name)) {
1411 bridge_profile_name = DEFAULT_BRIDGE_PROFILE;
1413 if (!(tmp2 = ao2_find(cfg->bridge_profiles, bridge_profile_name, OBJ_KEY))) {
1417 conf_bridge_profile_copy(result, tmp2);
1424 struct dtmf_menu_hook_pvt {
1425 struct conference_bridge_user *conference_bridge_user;
1426 struct conf_menu_entry menu_entry;
1427 struct conf_menu *menu;
1430 static void menu_hook_destroy(void *hook_pvt)
1432 struct dtmf_menu_hook_pvt *pvt = hook_pvt;
1433 struct conf_menu_action *action = NULL;
1435 ao2_ref(pvt->menu, -1);
1437 while ((action = AST_LIST_REMOVE_HEAD(&pvt->menu_entry.actions, action))) {
1443 static int menu_hook_callback(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
1445 struct dtmf_menu_hook_pvt *pvt = hook_pvt;
1446 return conf_handle_dtmf(bridge_channel, pvt->conference_bridge_user, &pvt->menu_entry, pvt->menu);
1449 static int copy_menu_entry(struct conf_menu_entry *dst, struct conf_menu_entry *src)
1451 struct conf_menu_action *menu_action = NULL;
1452 struct conf_menu_action *new_menu_action = NULL;
1454 memcpy(dst, src, sizeof(*dst));
1455 AST_LIST_HEAD_INIT_NOLOCK(&dst->actions);
1457 AST_LIST_TRAVERSE(&src->actions, menu_action, action) {
1458 if (!(new_menu_action = ast_calloc(1, sizeof(*new_menu_action)))) {
1461 memcpy(new_menu_action, menu_action, sizeof(*new_menu_action));
1462 AST_LIST_INSERT_HEAD(&dst->actions, new_menu_action, action);
1467 void conf_menu_entry_destroy(struct conf_menu_entry *menu_entry)
1469 struct conf_menu_action *menu_action = NULL;
1470 while ((menu_action = AST_LIST_REMOVE_HEAD(&menu_entry->actions, action))) {
1471 ast_free(menu_action);
1475 int conf_find_menu_entry_by_sequence(const char *dtmf_sequence, struct conf_menu *menu, struct conf_menu_entry *result)
1477 struct conf_menu_entry *menu_entry = NULL;
1480 AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) {
1481 if (!strcasecmp(menu_entry->dtmf, dtmf_sequence)) {
1482 copy_menu_entry(result, menu_entry);
1492 int conf_set_menu_to_user(const char *menu_name, struct conference_bridge_user *conference_bridge_user)
1494 struct conf_menu *menu;
1495 struct conf_menu_entry *menu_entry = NULL;
1496 RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
1502 if (!(menu = menu_find(cfg->menus, menu_name))) {
1506 AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) {
1507 struct dtmf_menu_hook_pvt *pvt;
1508 if (!(pvt = ast_calloc(1, sizeof(*pvt)))) {
1513 if (copy_menu_entry(&pvt->menu_entry, menu_entry)) {
1519 pvt->conference_bridge_user = conference_bridge_user;
1523 ast_bridge_features_hook(&conference_bridge_user->features, pvt->menu_entry.dtmf, menu_hook_callback, pvt, menu_hook_destroy);
1532 void conf_destroy_config(void)
1534 ast_cli_unregister_multiple(cli_confbridge_parser, ARRAY_LEN(cli_confbridge_parser));
1535 aco_info_destroy(&cfg_info);
1536 ao2_global_obj_release(cfg_handle);