Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Functions | Variables
app_confbridge.c File Reference

Conference Bridge application. More...

#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include "asterisk/cli.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/bridge.h"
#include "asterisk/musiconhold.h"
#include "asterisk/say.h"
#include "asterisk/audiohook.h"
#include "asterisk/astobj2.h"
#include "confbridge/include/confbridge.h"
#include "asterisk/paths.h"
#include "asterisk/manager.h"
#include "asterisk/test.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_bridges.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/json.h"
#include "asterisk/format_cache.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/stream.h"
#include "asterisk/message.h"

Go to the source code of this file.

Data Structures

struct  async_datastore_data
 
struct  async_delete_name_rec_task_data
 
struct  async_playback_task_data
 
struct  confbridge_hook_data
 
struct  hangup_data
 
struct  playback_task_data
 

Macros

#define CONFERENCE_BRIDGE_BUCKETS   53
 
#define RECORD_FILENAME_INITIAL_SPACE   128
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int action_confbridgekick (struct mansession *s, const struct message *m)
 
static int action_confbridgelist (struct mansession *s, const struct message *m)
 
static int action_confbridgelist_item (struct mansession *s, const char *id_text, struct confbridge_conference *conference, struct confbridge_user *user, int waiting)
 
static int action_confbridgelistrooms (struct mansession *s, const struct message *m)
 
static int action_confbridgelock (struct mansession *s, const struct message *m)
 
static int action_confbridgemute (struct mansession *s, const struct message *m)
 
static int action_confbridgesetsinglevideosrc (struct mansession *s, const struct message *m)
 
static int action_confbridgestartrecord (struct mansession *s, const struct message *m)
 
static int action_confbridgestoprecord (struct mansession *s, const struct message *m)
 
static int action_confbridgeunlock (struct mansession *s, const struct message *m)
 
static int action_confbridgeunmute (struct mansession *s, const struct message *m)
 
static int action_dialplan_exec (struct ast_bridge_channel *bridge_channel, struct conf_menu_action *menu_action)
 
static int action_kick_last (struct confbridge_conference *conference, struct ast_bridge_channel *bridge_channel, struct confbridge_user *user)
 
static int action_lock_unlock_helper (struct mansession *s, const struct message *m, int lock)
 
static int action_mute_unmute_helper (struct mansession *s, const struct message *m, int mute)
 
static int action_playback (struct ast_bridge_channel *bridge_channel, const char *playback_file)
 
static int action_playback_and_continue (struct confbridge_conference *conference, struct confbridge_user *user, struct ast_bridge_channel *bridge_channel, struct conf_menu *menu, const char *playback_file, const char *cur_dtmf, int *stop_prompts)
 
static int action_toggle_binaural (struct confbridge_conference *conference, struct confbridge_user *user, struct ast_bridge_channel *bridge_channel)
 
static int action_toggle_mute (struct confbridge_conference *conference, struct confbridge_user *user, struct ast_bridge_channel *bridge_channel)
 
static int action_toggle_mute_participants (struct confbridge_conference *conference, struct confbridge_user *user)
 
static int alloc_playback_chan (struct confbridge_conference *conference)
 
static int announce_user_count (struct confbridge_conference *conference, struct confbridge_user *user, struct ast_bridge_channel *bridge_channel)
 Announce number of users in the conference bridge to the caller. More...
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static struct async_datastore_dataasync_datastore_data_alloc (void)
 
static void async_datastore_data_destroy (void *data)
 
static int async_delete_name_rec (struct confbridge_conference *conference, const char *filename)
 
static int async_delete_name_rec_task (void *data)
 Delete user's name file asynchronously. More...
 
static struct async_delete_name_rec_task_dataasync_delete_name_rec_task_data_alloc (struct confbridge_conference *conference, const char *filename)
 
static void async_delete_name_rec_task_data_destroy (struct async_delete_name_rec_task_data *atd)
 
int async_play_sound_file (struct confbridge_conference *conference, const char *filename, struct ast_channel *initiator)
 Play sound file into conference bridge asynchronously. More...
 
static int async_play_sound_helper (struct confbridge_conference *conference, const char *filename, int say_number, struct ast_channel *initiator)
 
void async_play_sound_ready (struct ast_channel *chan)
 Indicate the initiator of an async sound file is ready for it to play. More...
 
static int async_playback_task (void *data)
 Play an announcement into a confbridge asynchronously. More...
 
static struct async_playback_task_dataasync_playback_task_data_alloc (struct confbridge_conference *conference, const char *filename, int say_number, struct ast_channel *initiator)
 
static void async_playback_task_data_destroy (struct async_playback_task_data *aptd)
 
static int cli_mute_unmute_helper (int mute, struct ast_cli_args *a)
 
static char * complete_confbridge_name (const char *line, const char *word, int pos, int state)
 
static char * complete_confbridge_participant (const char *conference_name, const char *line, const char *word, int pos, int state)
 
int conf_add_post_join_action (struct confbridge_user *user, int(*func)(struct confbridge_user *user))
 Queue a function to run with the given conference bridge user as an argument once the state transition is complete. More...
 
void conf_add_user_active (struct confbridge_conference *conference, struct confbridge_user *user)
 Add a conference bridge user as an unmarked active user of the conference. More...
 
void conf_add_user_marked (struct confbridge_conference *conference, struct confbridge_user *user)
 Add a conference bridge user as a marked active user of the conference. More...
 
void conf_add_user_waiting (struct confbridge_conference *conference, struct confbridge_user *user)
 Add a conference bridge user as an waiting user of the conference. More...
 
void conf_ended (struct confbridge_conference *conference)
 Callback to be called when the conference has become empty. More...
 
struct confbridge_conferenceconf_find_bridge (const char *conference_name)
 Find a confbridge by name. More...
 
static int conf_get_pin (struct ast_channel *chan, struct confbridge_user *user)
 
const char * conf_get_sound (enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds)
 Looks to see if sound file is stored in bridge profile sounds, if not default sound is provided.
 
int conf_handle_dtmf (struct ast_bridge_channel *bridge_channel, struct confbridge_user *user, struct conf_menu_entry *menu_entry, struct conf_menu *menu)
 Once a DTMF sequence matches a sequence in the user's DTMF menu, this function will get called to perform the menu action. More...
 
void conf_handle_first_join (struct confbridge_conference *conference)
 Callback to execute any time we transition from zero to one active users. More...
 
int conf_handle_inactive_waitmarked (struct confbridge_user *user)
 Handle actions every time a waitmarked user joins w/o a marked user present. More...
 
int conf_handle_only_person (struct confbridge_user *user)
 Handle actions whenever an user joins an empty conference. More...
 
void conf_handle_second_active (struct confbridge_conference *conference)
 Handle when a conference moves to having more than one active participant. More...
 
static int conf_handle_talker_cb (struct ast_bridge_channel *bridge_channel, void *hook_pvt, int talking)
 
static int conf_is_recording (struct confbridge_conference *conference)
 
void conf_moh_start (struct confbridge_user *user)
 Start MOH for the conference user. More...
 
void conf_moh_stop (struct confbridge_user *user)
 Stop MOH for the conference user. More...
 
static void conf_moh_suspend (struct confbridge_user *user)
 
static void conf_moh_unsuspend (struct confbridge_user *user)
 
void conf_mute_only_active (struct confbridge_conference *conference)
 Attempt to mute/play MOH to the only user in the conference if they require it. More...
 
static int conf_rec_name (struct confbridge_user *user, const char *conf_name)
 
void conf_remove_user_active (struct confbridge_conference *conference, struct confbridge_user *user)
 Remove a conference bridge user from the unmarked active conference users in the conference. More...
 
void conf_remove_user_marked (struct confbridge_conference *conference, struct confbridge_user *user)
 Remove a conference bridge user from the marked active conference users in the conference. More...
 
void conf_remove_user_waiting (struct confbridge_conference *conference, struct confbridge_user *user)
 Remove a conference bridge user from the waiting conference users in the conference. More...
 
static int conf_start_record (struct confbridge_conference *conference)
 
static int conf_stop_record (struct confbridge_conference *conference)
 
void conf_update_user_mute (struct confbridge_user *user)
 Update the actual mute status of the user and set it on the bridge. More...
 
static int confbridge_exec (struct ast_channel *chan, const char *data)
 The ConfBridge application.
 
void confbridge_handle_atxfer (struct ast_attended_transfer_message *msg)
 Create join/leave events for attended transfers. More...
 
static void confbridge_unlock_and_unref (void *obj)
 
static int conference_bridge_cmp_cb (void *obj, void *arg, int flags)
 Comparison function used for conference bridges container.
 
static int conference_bridge_hash_cb (const void *obj, const int flags)
 Hashing function used for conference bridges container.
 
static int confkick_exec (struct ast_channel *chan, const char *data)
 
static void destroy_conference_bridge (void *obj)
 Destroy a conference bridge. More...
 
static int execute_menu_entry (struct confbridge_conference *conference, struct confbridge_user *user, struct ast_bridge_channel *bridge_channel, struct conf_menu_entry *menu_entry, struct conf_menu *menu)
 
static int func_confbridge_channels (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int func_confbridge_info (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int generic_lock_unlock_helper (int lock, const char *conference_name)
 
static int generic_mute_unmute_helper (int mute, const char *conference_name, const char *chan_name)
 
static void generic_mute_unmute_user (struct confbridge_conference *conference, struct confbridge_user *user, int mute)
 
static char * handle_cli_confbridge_kick (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_confbridge_list (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static void handle_cli_confbridge_list_item (struct ast_cli_args *a, struct confbridge_user *user, int waiting)
 
static char * handle_cli_confbridge_lock (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_confbridge_mute (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_confbridge_start_record (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_confbridge_stop_record (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_confbridge_unlock (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_confbridge_unmute (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static int handle_conf_user_join (struct confbridge_user *user)
 Call the proper join event handler for the user for the conference bridge's current state.
 
static int handle_conf_user_leave (struct confbridge_user *user)
 Call the proper leave event handler for the user for the conference bridge's current state.
 
static void handle_video_on_exit (struct confbridge_conference *conference, struct ast_channel *chan)
 
static void handle_video_on_join (struct confbridge_conference *conference, struct ast_channel *chan, int marked)
 
static void hangup_data_destroy (struct hangup_data *hangup)
 
static void hangup_data_init (struct hangup_data *hangup, struct confbridge_conference *conference)
 
static int hangup_playback (void *data)
 Hang up the announcer channel. More...
 
static int is_new_rec_file (const char *rec_file, struct ast_str **orig_rec_file)
 
static int join_callback (struct ast_bridge_channel *bridge_channel, void *ignore)
 
static struct confbridge_conferencejoin_conference_bridge (const char *conference_name, struct confbridge_user *user)
 Join a conference bridge. More...
 
static int kick_conference_participant (struct confbridge_conference *conference, const char *channel)
 
static void leave_conference (struct confbridge_user *user)
 Leave a conference. More...
 
static int load_module (void)
 Load the module. More...
 
static int play_file (struct ast_bridge_channel *bridge_channel, struct ast_channel *channel, const char *filename)
 Playback the given filename and monitor for any dtmf interrupts. More...
 
static int play_prompt_to_user (struct confbridge_user *user, const char *filename)
 Play back an audio file to a channel. More...
 
int play_sound_file (struct confbridge_conference *conference, const char *filename)
 Play sound file into conference bridge. More...
 
static int play_sound_helper (struct confbridge_conference *conference, const char *filename, int say_number)
 
static int play_sound_number (struct confbridge_conference *conference, int say_number)
 Play number into the conference bridge. More...
 
static void playback_common (struct confbridge_conference *conference, const char *filename, int say_number)
 
static int playback_task (void *data)
 Play an announcement into a confbridge. More...
 
static void playback_task_data_destroy (struct playback_task_data *ptd)
 
static void playback_task_data_init (struct playback_task_data *ptd, struct confbridge_conference *conference, const char *filename, int say_number)
 
static int push_announcer (struct confbridge_conference *conference)
 Push the announcer channel into the bridge. More...
 
static int register_channel_tech (struct ast_channel_tech *tech)
 
static int reload (void)
 
static void send_conf_end_event (struct confbridge_conference *conference)
 
static void send_conf_start_event (struct confbridge_conference *conference)
 
static void send_conf_stasis (struct confbridge_conference *conference, struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *extras, int channel_topic)
 
static void send_conf_stasis_snapshots (struct confbridge_conference *conference, struct ast_channel_snapshot *chan_snapshot, struct stasis_message_type *type, struct ast_json *extras)
 
static int send_event_hook_callback (struct ast_bridge_channel *bridge_channel, void *data)
 
static void send_join_event (struct confbridge_user *user, struct confbridge_conference *conference)
 
static void send_leave_event (struct confbridge_user *user, struct confbridge_conference *conference)
 
static void send_mute_event (struct confbridge_user *user, struct confbridge_conference *conference)
 
static void send_start_record_event (struct confbridge_conference *conference)
 
static void send_stop_record_event (struct confbridge_conference *conference)
 
static void send_unmute_event (struct confbridge_user *user, struct confbridge_conference *conference)
 
static void set_rec_filename (struct confbridge_conference *conference, struct ast_str **filename, int is_new)
 
static int setup_async_playback_datastore (struct ast_channel *initiator)
 Prepare the async playback datastore. More...
 
static int sound_file_exists (const char *filename)
 
static int unload_module (void)
 Called when module is being unloaded.
 
static void unregister_channel_tech (struct ast_channel_tech *tech)
 
static int user_timeout (struct ast_bridge_channel *bridge_channel, void *ignore)
 
static void wait_for_initiator (struct ast_channel *initiator)
 Wait for the initiator of an async playback to be ready. More...
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Conference Bridge Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "da6642af068ee5e6490c5b1d2cc1d238" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_DEVSTATE_PROVIDER, .optional_modules = "codec_speex,func_jitterbuffer", }
 
static const char app [] = "ConfBridge"
 
static const char app2 [] = "ConfKick"
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_datastore_info async_datastore_info
 Datastore used for timing of async announcement playback. More...
 
static struct ast_cli_entry cli_confbridge []
 
static struct ast_custom_function confbridge_channels_function
 
static struct ast_custom_function confbridge_function
 
static struct ast_custom_function confbridge_info_function
 
struct ao2_containerconference_bridges
 Container to hold all conference bridges in progress.
 

Detailed Description

Conference Bridge application.

Author
Joshua Colp <jcolp@digium.com> 
David Vossel <dvossel@digium.com> 

This is a conference bridge application utilizing the bridging core.

Definition in file app_confbridge.c.

Macro Definition Documentation

#define CONFERENCE_BRIDGE_BUCKETS   53

Number of buckets our conference bridges container can have

Definition at line 551 of file app_confbridge.c.

Referenced by load_module().

#define RECORD_FILENAME_INITIAL_SPACE   128

Initial recording filename space.

Definition at line 554 of file app_confbridge.c.

Referenced by join_conference_bridge().

Function Documentation

static int announce_user_count ( struct confbridge_conference conference,
struct confbridge_user user,
struct ast_bridge_channel bridge_channel 
)
static

Announce number of users in the conference bridge to the caller.

Parameters
conferenceConference bridge to peek at
userOptional Caller
bridge_channelThe bridged channel involved
Note
if caller is NULL, the announcment will be sent to all participants in the conference.
Return values
0on success.
-1if the user hung up.

Definition at line 1076 of file app_confbridge.c.

References confbridge_conference::activeusers, ast_say_number(), ast_stream_and_wait(), confbridge_conference::b_profile, confbridge_user::chan, conf_get_sound(), play_file(), play_sound_file(), and play_sound_number().

Referenced by join_conference_bridge().

1078 {
1079  const char *other_in_party = conf_get_sound(CONF_SOUND_OTHER_IN_PARTY, conference->b_profile.sounds);
1080  const char *only_one = conf_get_sound(CONF_SOUND_ONLY_ONE, conference->b_profile.sounds);
1081  const char *there_are = conf_get_sound(CONF_SOUND_THERE_ARE, conference->b_profile.sounds);
1082 
1083  if (conference->activeusers <= 1) {
1084  /* Awww we are the only person in the conference bridge OR we only have waitmarked users */
1085  return 0;
1086  } else if (conference->activeusers == 2) {
1087  if (user) {
1088  /* Eep, there is one other person */
1089  if (play_file(bridge_channel, user->chan, only_one) < 0) {
1090  return -1;
1091  }
1092  } else {
1093  play_sound_file(conference, only_one);
1094  }
1095  } else {
1096  /* Alas multiple others in here */
1097  if (user) {
1098  if (ast_stream_and_wait(user->chan,
1099  there_are,
1100  "")) {
1101  return -1;
1102  }
1103  if (ast_say_number(user->chan, conference->activeusers - 1, "", ast_channel_language(user->chan), NULL)) {
1104  return -1;
1105  }
1106  if (play_file(bridge_channel, user->chan, other_in_party) < 0) {
1107  return -1;
1108  }
1109  } else if (sound_file_exists(there_are) && sound_file_exists(other_in_party)) {
1110  play_sound_file(conference, there_are);
1111  play_sound_number(conference, conference->activeusers - 1);
1112  play_sound_file(conference, other_in_party);
1113  }
1114  }
1115  return 0;
1116 }
struct ast_channel * chan
Definition: confbridge.h:279
const char * conf_get_sound(enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds)
Looks to see if sound file is stored in bridge profile sounds, if not default sound is provided...
static int play_sound_number(struct confbridge_conference *conference, int say_number)
Play number into the conference bridge.
struct bridge_profile b_profile
Definition: confbridge.h:250
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
stream file until digit If the file name is non-empty, try to play it.
Definition: file.c:1878
unsigned int activeusers
Definition: confbridge.h:251
int ast_say_number(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options)
says a number
Definition: channel.c:8235
static int play_file(struct ast_bridge_channel *bridge_channel, struct ast_channel *channel, const char *filename)
Playback the given filename and monitor for any dtmf interrupts.
int play_sound_file(struct confbridge_conference *conference, const char *filename)
Play sound file into conference bridge.
static int async_delete_name_rec_task ( void *  data)
static

Delete user's name file asynchronously.

This runs in the playback queue taskprocessor. This ensures that sound file is removed after playback is finished and not before.

Parameters
dataAn async_delete_name_rec_task_data
Returns
0

Definition at line 2569 of file app_confbridge.c.

References ast_filedelete(), and confbridge_conference::name.

2570 {
2571  struct async_delete_name_rec_task_data *atd = data;
2572 
2573  ast_filedelete(atd->filename, NULL);
2574  ast_log(LOG_DEBUG, "Conference '%s' removed user name file '%s'\n",
2575  atd->conference->name, atd->filename);
2576 
2577  async_delete_name_rec_task_data_destroy(atd);
2578  return 0;
2579 }
int ast_filedelete(const char *filename, const char *fmt)
Deletes a file.
Definition: file.c:1141
char name[MAX_CONF_NAME]
Definition: confbridge.h:247
int async_play_sound_file ( struct confbridge_conference conference,
const char *  filename,
struct ast_channel initiator 
)

Play sound file into conference bridge asynchronously.

If the initiator parameter is non-NULL, then the playback will wait for that initiator channel to get back in the bridge before playing the sound file. This way, the initiator has no danger of hearing a "clipped" file.

Parameters
conferenceThe conference bridge to play sound file into
filenameSound file to play
initiatorChannel that initiated playback.
Return values
0success
-1failure

Definition at line 2371 of file app_confbridge.c.

Referenced by confbridge_exec().

2373 {
2374  return async_play_sound_helper(conference, filename, -1, initiator);
2375 }
void async_play_sound_ready ( struct ast_channel chan)

Indicate the initiator of an async sound file is ready for it to play.

When playing an async sound file, the initiator is typically either out of the bridge or not in a position to hear the queued announcement. This function lets the announcement thread know that the initiator is now ready for the sound to play.

If an async announcement was queued and no initiator channel was provided, then this is a no-op

Parameters
chanThe channel that initiated the async announcement

Definition at line 2377 of file app_confbridge.c.

References ast_channel_datastore_find(), and ast_datastore::data.

Referenced by conf_handle_dtmf(), and confbridge_exec().

2378 {
2379  struct ast_datastore *async_datastore;
2380  struct async_datastore_data *add;
2381 
2382  ast_channel_lock(chan);
2383  async_datastore = ast_channel_datastore_find(chan, &async_datastore_info, NULL);
2384  ast_channel_unlock(chan);
2385  if (!async_datastore) {
2386  return;
2387  }
2388 
2389  add = async_datastore->data;
2390 
2391  ast_mutex_lock(&add->lock);
2392  add->wait = 0;
2393  ast_cond_signal(&add->cond);
2394  ast_mutex_unlock(&add->lock);
2395 }
Structure for a data store object.
Definition: datastore.h:64
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition: channel.c:2399
static struct ast_datastore_info async_datastore_info
Datastore used for timing of async announcement playback.
void * data
Definition: datastore.h:66
static int async_playback_task ( void *  data)
static

Play an announcement into a confbridge asynchronously.

This runs in the playback queue taskprocessor. This ensures that all playbacks are handled in sequence and do not play over top one another.

Parameters
dataAn async_playback_task_data
Returns
0

Definition at line 2322 of file app_confbridge.c.

References wait_for_initiator().

2323 {
2324  struct async_playback_task_data *aptd = data;
2325 
2326  /* Wait for the initiator to get back in the bridge or be hung up */
2327  if (aptd->initiator) {
2328  wait_for_initiator(aptd->initiator);
2329  }
2330 
2331  playback_common(aptd->conference, aptd->filename, aptd->say_number);
2332 
2333  async_playback_task_data_destroy(aptd);
2334  return 0;
2335 }
static void wait_for_initiator(struct ast_channel *initiator)
Wait for the initiator of an async playback to be ready.
int conf_add_post_join_action ( struct confbridge_user user,
int(*)(struct confbridge_user *user func 
)

Queue a function to run with the given conference bridge user as an argument once the state transition is complete.

Parameters
userThe conference bridge user to pass to the function
funcThe function to queue
Return values
0success
non-zerofailure

Definition at line 1532 of file app_confbridge.c.

References ast_calloc, AST_LIST_INSERT_TAIL, and confbridge_user::post_join_list.

Referenced by conf_default_join_waitmarked().

1533 {
1534  struct post_join_action *action;
1535  if (!(action = ast_calloc(1, sizeof(*action)))) {
1536  return -1;
1537  }
1538  action->func = func;
1539  AST_LIST_INSERT_TAIL(&user->post_join_list, action, list);
1540  return 0;
1541 }
struct confbridge_user::@93 post_join_list
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
void conf_add_user_active ( struct confbridge_conference conference,
struct confbridge_user user 
)

Add a conference bridge user as an unmarked active user of the conference.

Parameters
conferenceThe conference bridge to add the user to
userThe conference bridge user to add to the conference

Definition at line 4485 of file app_confbridge.c.

References confbridge_conference::active_list, confbridge_conference::activeusers, and AST_LIST_INSERT_TAIL.

4486 {
4487  AST_LIST_INSERT_TAIL(&conference->active_list, user, list);
4488  conference->activeusers++;
4489 }
struct confbridge_conference::@90 active_list
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
unsigned int activeusers
Definition: confbridge.h:251
void conf_add_user_marked ( struct confbridge_conference conference,
struct confbridge_user user 
)

Add a conference bridge user as a marked active user of the conference.

Parameters
conferenceThe conference bridge to add the user to
userThe conference bridge user to add to the conference

Definition at line 4491 of file app_confbridge.c.

References confbridge_conference::active_list, confbridge_conference::activeusers, AST_LIST_INSERT_TAIL, and confbridge_conference::markedusers.

4492 {
4493  AST_LIST_INSERT_TAIL(&conference->active_list, user, list);
4494  conference->activeusers++;
4495  conference->markedusers++;
4496 }
unsigned int markedusers
Definition: confbridge.h:252
struct confbridge_conference::@90 active_list
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
unsigned int activeusers
Definition: confbridge.h:251
void conf_add_user_waiting ( struct confbridge_conference conference,
struct confbridge_user user 
)

Add a conference bridge user as an waiting user of the conference.

Parameters
conferenceThe conference bridge to add the user to
userThe conference bridge user to add to the conference

Definition at line 4498 of file app_confbridge.c.

References AST_LIST_INSERT_TAIL, confbridge_conference::waiting_list, and confbridge_conference::waitingusers.

Referenced by conf_default_join_waitmarked().

4499 {
4500  AST_LIST_INSERT_TAIL(&conference->waiting_list, user, list);
4501  conference->waitingusers++;
4502 }
unsigned int waitingusers
Definition: confbridge.h:253
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
struct confbridge_conference::@91 waiting_list
void conf_ended ( struct confbridge_conference conference)

Callback to be called when the conference has become empty.

Parameters
conferenceThe conference bridge

Definition at line 1560 of file app_confbridge.c.

References ao2_unlink, ast_context_remove_extension(), confbridge_conference::b_profile, and confbridge_conference::name.

1561 {
1562  struct pbx_find_info q = { .stacklen = 0 };
1563 
1564  /* Called with a reference to conference */
1565  ao2_unlink(conference_bridges, conference);
1566  send_conf_end_event(conference);
1567  if (!ast_strlen_zero(conference->b_profile.regcontext) &&
1568  pbx_find_extension(NULL, NULL, &q, conference->b_profile.regcontext,
1569  conference->name, 1, NULL, "", E_MATCH)) {
1570  ast_context_remove_extension(conference->b_profile.regcontext,
1571  conference->name, 1, NULL);
1572  }
1573  ao2_lock(conference);
1574  conf_stop_record(conference);
1575  ao2_unlock(conference);
1576 }
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
Definition: pbx.c:4948
struct bridge_profile b_profile
Definition: confbridge.h:250
struct ao2_container * conference_bridges
Container to hold all conference bridges in progress.
#define ao2_unlink(container, obj)
Remove an object from a container.
Definition: astobj2.h:1578
char name[MAX_CONF_NAME]
Definition: confbridge.h:247
struct confbridge_conference* conf_find_bridge ( const char *  conference_name)

Find a confbridge by name.

Since
13.22.0
15.5.0
Parameters
conference_nameThe name to search for
Returns
ConfBridge (which must be unreffed) or NULL.

Definition at line 875 of file app_confbridge.c.

References OBJ_KEY.

876 {
877  return ao2_find(conference_bridges, conference_name, OBJ_KEY);
878 }
#define OBJ_KEY
Definition: astobj2.h:1151
struct ao2_container * conference_bridges
Container to hold all conference bridges in progress.
int conf_handle_dtmf ( struct ast_bridge_channel bridge_channel,
struct confbridge_user user,
struct conf_menu_entry menu_entry,
struct conf_menu menu 
)

Once a DTMF sequence matches a sequence in the user's DTMF menu, this function will get called to perform the menu action.

Parameters
bridge_channelBridged channel this is involving
userthe conference user to perform the action on.
menu_entrythe menu entry that invoked this callback to occur.
menuan AO2 referenced pointer to the entire menu structure the menu_entry derived from.
Note
The menu_entry is a deep copy of the entry found in the menu structure. This allows for the menu_entry to be accessed without requiring the menu lock. If the menu must be accessed, the menu lock must be held. Reference counting of the menu structure is handled outside of the scope of this function.
Return values
0success
-1failure

Definition at line 3310 of file app_confbridge.c.

References async_play_sound_ready(), ast_bridge_channel::chan, and confbridge_user::conference.

3314 {
3315  /* See if music on hold is playing */
3316  conf_moh_suspend(user);
3317 
3318  /* execute the list of actions associated with this menu entry */
3319  execute_menu_entry(user->conference, user, bridge_channel, menu_entry, menu);
3320 
3321  /* See if music on hold needs to be started back up again */
3322  conf_moh_unsuspend(user);
3323 
3324  async_play_sound_ready(bridge_channel->chan);
3325 
3326  return 0;
3327 }
struct confbridge_conference * conference
Definition: confbridge.h:274
void async_play_sound_ready(struct ast_channel *chan)
Indicate the initiator of an async sound file is ready for it to play.
struct ast_channel * chan
void conf_handle_first_join ( struct confbridge_conference conference)

Callback to execute any time we transition from zero to one active users.

Parameters
conferenceThe conference bridge with a single active user joined

Definition at line 1544 of file app_confbridge.c.

References AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, ast_devstate_changed(), and confbridge_conference::name.

1545 {
1546  ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "confbridge:%s", conference->name);
1547 }
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
Definition: devicestate.c:510
char name[MAX_CONF_NAME]
Definition: confbridge.h:247
int conf_handle_inactive_waitmarked ( struct confbridge_user user)

Handle actions every time a waitmarked user joins w/o a marked user present.

Parameters
userThe waitmarked user
Return values
0success
-1failure

Definition at line 1508 of file app_confbridge.c.

References confbridge_conference::b_profile, conf_get_sound(), confbridge_user::conference, play_prompt_to_user(), and confbridge_user::u_profile.

Referenced by conf_default_join_waitmarked().

1509 {
1510  /* If we have not been quieted play back that they are waiting for the leader */
1511  if (!ast_test_flag(&user->u_profile, USER_OPT_QUIET) && play_prompt_to_user(user,
1512  conf_get_sound(CONF_SOUND_WAIT_FOR_LEADER, user->conference->b_profile.sounds))) {
1513  /* user hungup while the sound was playing */
1514  return -1;
1515  }
1516  return 0;
1517 }
struct confbridge_conference * conference
Definition: confbridge.h:274
const char * conf_get_sound(enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds)
Looks to see if sound file is stored in bridge profile sounds, if not default sound is provided...
struct bridge_profile b_profile
Definition: confbridge.h:250
struct user_profile u_profile
Definition: confbridge.h:276
static int play_prompt_to_user(struct confbridge_user *user, const char *filename)
Play back an audio file to a channel.
int conf_handle_only_person ( struct confbridge_user user)

Handle actions whenever an user joins an empty conference.

Parameters
userThe user

Definition at line 1519 of file app_confbridge.c.

References confbridge_conference::b_profile, conf_get_sound(), confbridge_user::conference, play_prompt_to_user(), and confbridge_user::u_profile.

1520 {
1521  /* If audio prompts have not been quieted or this prompt quieted play it on out */
1522  if (!ast_test_flag(&user->u_profile, USER_OPT_QUIET | USER_OPT_NOONLYPERSON)) {
1523  if (play_prompt_to_user(user,
1524  conf_get_sound(CONF_SOUND_ONLY_PERSON, user->conference->b_profile.sounds))) {
1525  /* user hungup while the sound was playing */
1526  return -1;
1527  }
1528  }
1529  return 0;
1530 }
struct confbridge_conference * conference
Definition: confbridge.h:274
const char * conf_get_sound(enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds)
Looks to see if sound file is stored in bridge profile sounds, if not default sound is provided...
struct bridge_profile b_profile
Definition: confbridge.h:250
struct user_profile u_profile
Definition: confbridge.h:276
static int play_prompt_to_user(struct confbridge_user *user, const char *filename)
Play back an audio file to a channel.
void conf_handle_second_active ( struct confbridge_conference conference)

Handle when a conference moves to having more than one active participant.

Parameters
conferenceThe conference bridge with more than one active participant

Definition at line 1549 of file app_confbridge.c.

References confbridge_conference::active_list, AST_LIST_FIRST, conf_moh_stop(), conf_update_user_mute(), and confbridge_user::u_profile.

1550 {
1551  /* If we are the second participant we may need to stop music on hold on the first */
1552  struct confbridge_user *first_user = AST_LIST_FIRST(&conference->active_list);
1553 
1554  if (ast_test_flag(&first_user->u_profile, USER_OPT_MUSICONHOLD)) {
1555  conf_moh_stop(first_user);
1556  }
1557  conf_update_user_mute(first_user);
1558 }
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:421
void conf_update_user_mute(struct confbridge_user *user)
Update the actual mute status of the user and set it on the bridge.
struct confbridge_conference::@90 active_list
void conf_moh_stop(struct confbridge_user *user)
Stop MOH for the conference user.
The structure that represents a conference bridge user.
Definition: confbridge.h:273
struct user_profile u_profile
Definition: confbridge.h:276
void conf_moh_start ( struct confbridge_user user)

Start MOH for the conference user.

Parameters
userConference user to start MOH on.

Definition at line 1451 of file app_confbridge.c.

References ast_bridge_lock, ast_bridge_suspend(), ast_bridge_unlock, ast_bridge_unsuspend(), ast_moh_start(), confbridge_conference::bridge, confbridge_user::chan, confbridge_user::conference, confbridge_user::playing_moh, confbridge_user::suspended_moh, and confbridge_user::u_profile.

Referenced by conf_mute_only_active().

1452 {
1453  user->playing_moh = 1;
1454  if (!user->suspended_moh) {
1455  int in_bridge;
1456 
1457  /*
1458  * Locking the ast_bridge here is the only way to hold off the
1459  * call to ast_bridge_join() in confbridge_exec() from
1460  * interfering with the bridge and MOH operations here.
1461  */
1463 
1464  /*
1465  * Temporarily suspend the user from the bridge so we have
1466  * control to start MOH if needed.
1467  */
1468  in_bridge = !ast_bridge_suspend(user->conference->bridge, user->chan);
1469  ast_moh_start(user->chan, user->u_profile.moh_class, NULL);
1470  if (in_bridge) {
1471  ast_bridge_unsuspend(user->conference->bridge, user->chan);
1472  }
1473 
1475  }
1476 }
struct ast_channel * chan
Definition: confbridge.h:279
unsigned int playing_moh
Definition: confbridge.h:285
struct confbridge_conference * conference
Definition: confbridge.h:274
int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan)
Unsuspend a channel from a bridge.
Definition: bridge.c:3028
unsigned int suspended_moh
Definition: confbridge.h:282
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition: channel.c:7766
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
int ast_bridge_suspend(struct ast_bridge *bridge, struct ast_channel *chan)
Suspend a channel temporarily from a bridge.
Definition: bridge.c:3007
struct user_profile u_profile
Definition: confbridge.h:276
struct ast_bridge * bridge
Definition: confbridge.h:249
void conf_moh_stop ( struct confbridge_user user)

Stop MOH for the conference user.

Parameters
userConference user to stop MOH on.

Definition at line 1424 of file app_confbridge.c.

References ast_bridge_lock, ast_bridge_suspend(), ast_bridge_unlock, ast_bridge_unsuspend(), ast_moh_stop(), confbridge_conference::bridge, confbridge_user::chan, confbridge_user::conference, confbridge_user::playing_moh, and confbridge_user::suspended_moh.

Referenced by conf_default_leave_waitmarked(), and conf_handle_second_active().

1425 {
1426  user->playing_moh = 0;
1427  if (!user->suspended_moh) {
1428  int in_bridge;
1429 
1430  /*
1431  * Locking the ast_bridge here is the only way to hold off the
1432  * call to ast_bridge_join() in confbridge_exec() from
1433  * interfering with the bridge and MOH operations here.
1434  */
1436 
1437  /*
1438  * Temporarily suspend the user from the bridge so we have
1439  * control to stop MOH if needed.
1440  */
1441  in_bridge = !ast_bridge_suspend(user->conference->bridge, user->chan);
1442  ast_moh_stop(user->chan);
1443  if (in_bridge) {
1444  ast_bridge_unsuspend(user->conference->bridge, user->chan);
1445  }
1446 
1448  }
1449 }
struct ast_channel * chan
Definition: confbridge.h:279
unsigned int playing_moh
Definition: confbridge.h:285
struct confbridge_conference * conference
Definition: confbridge.h:274
int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan)
Unsuspend a channel from a bridge.
Definition: bridge.c:3028
unsigned int suspended_moh
Definition: confbridge.h:282
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:7776
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
int ast_bridge_suspend(struct ast_bridge *bridge, struct ast_channel *chan)
Suspend a channel temporarily from a bridge.
Definition: bridge.c:3007
struct ast_bridge * bridge
Definition: confbridge.h:249
void conf_mute_only_active ( struct confbridge_conference conference)

Attempt to mute/play MOH to the only user in the conference if they require it.

Parameters
conferenceA conference bridge containing a single user

Definition at line 4517 of file app_confbridge.c.

References confbridge_conference::active_list, AST_LIST_FIRST, conf_moh_start(), conf_update_user_mute(), and confbridge_user::u_profile.

4518 {
4519  struct confbridge_user *only_user = AST_LIST_FIRST(&conference->active_list);
4520 
4521  /* Turn on MOH if the single participant is set up for it */
4522  if (ast_test_flag(&only_user->u_profile, USER_OPT_MUSICONHOLD)) {
4523  conf_moh_start(only_user);
4524  }
4525  conf_update_user_mute(only_user);
4526 }
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:421
void conf_update_user_mute(struct confbridge_user *user)
Update the actual mute status of the user and set it on the bridge.
struct confbridge_conference::@90 active_list
void conf_moh_start(struct confbridge_user *user)
Start MOH for the conference user.
The structure that represents a conference bridge user.
Definition: confbridge.h:273
struct user_profile u_profile
Definition: confbridge.h:276
void conf_remove_user_active ( struct confbridge_conference conference,
struct confbridge_user user 
)

Remove a conference bridge user from the unmarked active conference users in the conference.

Parameters
conferenceThe conference bridge to remove the user from
userThe conference bridge user to remove from the conference

Definition at line 4504 of file app_confbridge.c.

References confbridge_conference::active_list, confbridge_conference::activeusers, and AST_LIST_REMOVE.

4505 {
4506  AST_LIST_REMOVE(&conference->active_list, user, list);
4507  conference->activeusers--;
4508 }
struct confbridge_user::@94 list
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:856
struct confbridge_conference::@90 active_list
unsigned int activeusers
Definition: confbridge.h:251
void conf_remove_user_marked ( struct confbridge_conference conference,
struct confbridge_user user 
)

Remove a conference bridge user from the marked active conference users in the conference.

Parameters
conferenceThe conference bridge to remove the user from
userThe conference bridge user to remove from the conference

Definition at line 4510 of file app_confbridge.c.

References confbridge_conference::active_list, confbridge_conference::activeusers, AST_LIST_REMOVE, and confbridge_conference::markedusers.

4511 {
4512  AST_LIST_REMOVE(&conference->active_list, user, list);
4513  conference->activeusers--;
4514  conference->markedusers--;
4515 }
struct confbridge_user::@94 list
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:856
unsigned int markedusers
Definition: confbridge.h:252
struct confbridge_conference::@90 active_list
unsigned int activeusers
Definition: confbridge.h:251
void conf_remove_user_waiting ( struct confbridge_conference conference,
struct confbridge_user user 
)

Remove a conference bridge user from the waiting conference users in the conference.

Parameters
conferenceThe conference bridge to remove the user from
userThe conference bridge user to remove from the conference

Definition at line 4528 of file app_confbridge.c.

References AST_LIST_REMOVE, confbridge_user::list, confbridge_conference::waiting_list, and confbridge_conference::waitingusers.

Referenced by conf_default_leave_waitmarked().

4529 {
4530  AST_LIST_REMOVE(&conference->waiting_list, user, list);
4531  conference->waitingusers--;
4532 }
struct confbridge_user::@94 list
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:856
unsigned int waitingusers
Definition: confbridge.h:253
struct confbridge_conference::@91 waiting_list
void conf_update_user_mute ( struct confbridge_user user)

Update the actual mute status of the user and set it on the bridge.

Parameters
userUser to update the mute status.

Definition at line 1366 of file app_confbridge.c.

References ast_debug, ast_test_suite_event_notify, confbridge_conference::b_profile, confbridge_user::chan, confbridge_user::conference, confbridge_user::features, confbridge_conference::markedusers, ast_bridge_features::mute, confbridge_user::muted, confbridge_user::playing_moh, and confbridge_user::u_profile.

Referenced by conf_handle_second_active(), and conf_mute_only_active().

1367 {
1368  int mute_user;
1369  int mute_system;
1370  int mute_effective;
1371 
1372  /* User level mute request. */
1373  mute_user = user->muted;
1374 
1375  /* System level mute request. */
1376  mute_system = user->playing_moh
1377  /*
1378  * Do not allow waitmarked users to talk to anyone unless there
1379  * is a marked user present.
1380  */
1381  || (!user->conference->markedusers
1382  && ast_test_flag(&user->u_profile, USER_OPT_WAITMARKED));
1383 
1384  mute_effective = mute_user || mute_system;
1385 
1386  ast_debug(1, "User %s is %s: user:%d system:%d.\n",
1387  ast_channel_name(user->chan), mute_effective ? "muted" : "unmuted",
1388  mute_user, mute_system);
1389  user->features.mute = mute_effective;
1390  ast_test_suite_event_notify("CONF_MUTE_UPDATE",
1391  "Mode: %s\r\n"
1392  "Conference: %s\r\n"
1393  "Channel: %s",
1394  mute_effective ? "muted" : "unmuted",
1395  user->conference->b_profile.name,
1396  ast_channel_name(user->chan));
1397 }
struct ast_channel * chan
Definition: confbridge.h:279
unsigned int playing_moh
Definition: confbridge.h:285
struct confbridge_conference * conference
Definition: confbridge.h:274
unsigned int markedusers
Definition: confbridge.h:252
struct bridge_profile b_profile
Definition: confbridge.h:250
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:189
unsigned int muted
Definition: confbridge.h:283
struct ast_bridge_features features
Definition: confbridge.h:280
struct user_profile u_profile
Definition: confbridge.h:276
void confbridge_handle_atxfer ( struct ast_attended_transfer_message msg)

Create join/leave events for attended transfers.

Since
13.28
16.5
Parameters
msgThe attended transfer stasis message

Definition at line 1649 of file app_confbridge.c.

References confbridge_conference::active_list, ast_channel_snapshot_dialplan::appl, ast_debug, ast_json_pack(), ast_json_unref(), AST_LIST_TRAVERSE, ast_strdupa, ast_channel_snapshot::base, confbridge_user::chan, ast_channel_snapshot_dialplan::data, ast_channel_snapshot::dialplan, confbridge_user::muted, ast_channel_snapshot_base::name, OBJ_SEARCH_KEY, RAII_VAR, ast_attended_transfer_message::target, ast_attended_transfer_message::to_transfer_target, ast_attended_transfer_message::to_transferee, ast_attended_transfer_message::transferee, confbridge_user::u_profile, confbridge_conference::waiting_list, and confbridge_conference::waitingusers.

1650 {
1651  struct ast_channel_snapshot *old_snapshot;
1652  struct ast_channel_snapshot *new_snapshot;
1653  char *confbr_name = NULL;
1654  char *comma;
1655  RAII_VAR(struct confbridge_conference *, conference, NULL, confbridge_unlock_and_unref);
1656  struct confbridge_user *user = NULL;
1657  int found_user = 0;
1658  struct ast_json *json_object;
1659 
1660  if (msg->to_transferee.channel_snapshot
1661  && strcmp(msg->to_transferee.channel_snapshot->dialplan->appl, "ConfBridge") == 0
1662  && msg->target) {
1663  /* We're transferring a bridge to an extension */
1664  old_snapshot = msg->to_transferee.channel_snapshot;
1665  new_snapshot = msg->target;
1666  } else if (msg->to_transfer_target.channel_snapshot
1667  && strcmp(msg->to_transfer_target.channel_snapshot->dialplan->appl, "ConfBridge") == 0
1668  && msg->transferee) {
1669  /* We're transferring a call to a bridge */
1670  old_snapshot = msg->to_transfer_target.channel_snapshot;
1671  new_snapshot = msg->transferee;
1672  } else {
1673  ast_log(LOG_ERROR, "Could not determine proper channels\n");
1674  return;
1675  }
1676 
1677  /*
1678  * old_snapshot->data should have the original parameters passed to
1679  * the ConfBridge app:
1680  * conference[,bridge_profile[,user_profile[,menu]]]
1681  * We'll use "conference" to look up the bridge.
1682  *
1683  * We _could_ use old_snapshot->bridgeid to get the bridge but
1684  * that would involve locking the conference_bridges container
1685  * and iterating over it looking for a matching bridge.
1686  */
1687  if (ast_strlen_zero(old_snapshot->dialplan->data)) {
1688  ast_log(LOG_ERROR, "Channel '%s' didn't have app data set\n", old_snapshot->base->name);
1689  return;
1690  }
1691  confbr_name = ast_strdupa(old_snapshot->dialplan->data);
1692  comma = strchr(confbr_name, ',');
1693  if (comma) {
1694  *comma = '\0';
1695  }
1696 
1697  ast_debug(1, "Confbr: %s Leaving: %s Joining: %s\n", confbr_name, old_snapshot->base->name, new_snapshot->base->name);
1698 
1699  conference = ao2_find(conference_bridges, confbr_name, OBJ_SEARCH_KEY);
1700  if (!conference) {
1701  ast_log(LOG_ERROR, "Conference bridge '%s' not found\n", confbr_name);
1702  return;
1703  }
1704  ao2_lock(conference);
1705 
1706  /*
1707  * We need to grab the user profile for the departing user in order to
1708  * properly format the join/leave messages.
1709  */
1710  AST_LIST_TRAVERSE(&conference->active_list, user, list) {
1711  if (strcasecmp(ast_channel_name(user->chan), old_snapshot->base->name) == 0) {
1712  found_user = 1;
1713  break;
1714  }
1715  }
1716 
1717  /*
1718  * If we didn't find the user in the active list, try the waiting list.
1719  */
1720  if (!found_user && conference->waitingusers) {
1721  AST_LIST_TRAVERSE(&conference->waiting_list, user, list) {
1722  if (strcasecmp(ast_channel_name(user->chan), old_snapshot->base->name) == 0) {
1723  found_user = 1;
1724  break;
1725  }
1726  }
1727  }
1728 
1729  if (!found_user) {
1730  ast_log(LOG_ERROR, "Unable to find user profile for channel '%s' in bridge '%s'\n",
1731  old_snapshot->base->name, confbr_name);
1732  return;
1733  }
1734 
1735  /*
1736  * We're going to use the existing user profile to create the messages.
1737  */
1738  json_object = ast_json_pack("{s: b}",
1739  "admin", ast_test_flag(&user->u_profile, USER_OPT_ADMIN)
1740  );
1741  if (!json_object) {
1742  return;
1743  }
1744 
1745  send_conf_stasis_snapshots(conference, old_snapshot, confbridge_leave_type(), json_object);
1746  ast_json_unref(json_object);
1747 
1748  json_object = ast_json_pack("{s: b, s: b}",
1749  "admin", ast_test_flag(&user->u_profile, USER_OPT_ADMIN),
1750  "muted", user->muted);
1751  if (!json_object) {
1752  return;
1753  }
1754  send_conf_stasis_snapshots(conference, new_snapshot, confbridge_join_type(), json_object);
1755  ast_json_unref(json_object);
1756 }
const ast_string_field data
struct ast_channel_snapshot_base * base
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
struct ast_channel * chan
Definition: confbridge.h:279
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
Structure representing a snapshot of channel state.
struct ast_channel_snapshot * target
struct ast_channel_snapshot_dialplan * dialplan
struct ast_bridge_channel_snapshot_pair to_transferee
struct ast_bridge_channel_snapshot_pair to_transfer_target
const ast_string_field appl
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
struct ast_channel_snapshot * transferee
#define ast_debug(level,...)
Log a DEBUG message.
struct ao2_container * conference_bridges
Container to hold all conference bridges in progress.
unsigned int muted
Definition: confbridge.h:283
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
The structure that represents a conference bridge.
Definition: confbridge.h:246
structure to hold users read from users.conf
Abstract JSON element (object, array, string, int, ...).
The structure that represents a conference bridge user.
Definition: confbridge.h:273
struct user_profile u_profile
Definition: confbridge.h:276
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941
const ast_string_field name
static void destroy_conference_bridge ( void *  obj)
static

Destroy a conference bridge.

Parameters
objThe conference bridge object

Definition at line 1264 of file app_confbridge.c.

References ast_bridge_destroy(), ast_channel_cleanup, ast_debug, ast_hangup(), ast_taskprocessor_push(), ast_taskprocessor_unreference(), confbridge_conference::b_profile, confbridge_conference::bridge, conf_bridge_profile_destroy(), hangup_playback(), confbridge_conference::name, confbridge_conference::orig_rec_file, confbridge_conference::playback_chan, confbridge_conference::playback_queue, confbridge_conference::record_chan, and confbridge_conference::record_filename.

Referenced by join_conference_bridge().

1265 {
1266  struct confbridge_conference *conference = obj;
1267 
1268  ast_debug(1, "Destroying conference bridge '%s'\n", conference->name);
1269 
1270  if (conference->playback_chan) {
1271  if (conference->playback_queue) {
1272  struct hangup_data hangup;
1273  hangup_data_init(&hangup, conference);
1274 
1275  if (!ast_taskprocessor_push(conference->playback_queue, hangup_playback, &hangup)) {
1276  ast_mutex_lock(&hangup.lock);
1277  while (!hangup.hungup) {
1278  ast_cond_wait(&hangup.cond, &hangup.lock);
1279  }
1280  ast_mutex_unlock(&hangup.lock);
1281  }
1282 
1283  hangup_data_destroy(&hangup);
1284  } else {
1285  /* Playback queue is not yet allocated. Just hang up the channel straight */
1286  ast_hangup(conference->playback_chan);
1287  conference->playback_chan = NULL;
1288  }
1289  }
1290 
1291  /* Destroying a conference bridge is simple, all we have to do is destroy the bridging object */
1292  if (conference->bridge) {
1293  ast_bridge_destroy(conference->bridge, 0);
1294  conference->bridge = NULL;
1295  }
1296 
1297  ast_channel_cleanup(conference->record_chan);
1298  ast_free(conference->orig_rec_file);
1299  ast_free(conference->record_filename);
1300 
1301  conf_bridge_profile_destroy(&conference->b_profile);
1303 }
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
Definition: bridge.c:944
struct ast_channel * record_chan
Definition: confbridge.h:257
struct ast_str * orig_rec_file
Definition: confbridge.h:259
static int hangup_playback(void *data)
Hang up the announcer channel.
struct ast_taskprocessor * playback_queue
Definition: confbridge.h:262
struct bridge_profile b_profile
Definition: confbridge.h:250
void conf_bridge_profile_destroy(struct bridge_profile *b_profile)
Destroy a bridge profile found by 'conf_find_bridge_profile'.
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition: channel.h:2969
#define ast_debug(level,...)
Log a DEBUG message.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2541
The structure that represents a conference bridge.
Definition: confbridge.h:246
int ast_taskprocessor_push(struct ast_taskprocessor *tps, int(*task_exe)(void *datap), void *datap) attribute_warn_unused_result
Push a task into the specified taskprocessor queue and signal the taskprocessor thread.
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
struct ast_channel * playback_chan
Definition: confbridge.h:256
struct ast_str * record_filename
Definition: confbridge.h:258
char name[MAX_CONF_NAME]
Definition: confbridge.h:247
struct ast_bridge * bridge
Definition: confbridge.h:249
static int hangup_playback ( void *  data)
static

Hang up the announcer channel.

This hangs up the announcer channel in the conference. This runs in the playback queue taskprocessor since we do not want to hang up the channel while it's trying to play an announcement.

This task is performed synchronously, so there is no need to perform any cleanup on the passed-in data.

Parameters
dataA hangup_data structure
Returns
0

Definition at line 1227 of file app_confbridge.c.

References ast_autoservice_stop(), ast_hangup(), and confbridge_conference::playback_chan.

Referenced by destroy_conference_bridge().

1228 {
1229  struct hangup_data *hangup = data;
1230 
1231  ast_autoservice_stop(hangup->conference->playback_chan);
1232 
1233  ast_hangup(hangup->conference->playback_chan);
1234  hangup->conference->playback_chan = NULL;
1235 
1236  ast_mutex_lock(&hangup->lock);
1237  hangup->hungup = 1;
1238  ast_cond_signal(&hangup->cond);
1239  ast_mutex_unlock(&hangup->lock);
1240 
1241  return 0;
1242 }
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2541
struct ast_channel * playback_chan
Definition: confbridge.h:256
static struct confbridge_conference* join_conference_bridge ( const char *  conference_name,
struct confbridge_user user 
)
static

Join a conference bridge.

Parameters
conference_nameThe conference name
userConference bridge user structure
Returns
A pointer to the conference bridge struct, or NULL if the conference room wasn't found.

Definition at line 1766 of file app_confbridge.c.

References confbridge_conference::activeusers, announce_user_count(), ao2_link, ao2_ref, ao2_unlink, app, ast_add_extension(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_base_new(), AST_BRIDGE_CAPABILITY_MULTIMIX, AST_BRIDGE_FLAG_MASQUERADE_ONLY, AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY, ast_bridge_set_binaural_active(), ast_bridge_set_internal_sample_rate(), ast_bridge_set_maximum_sample_rate(), ast_bridge_set_mixing_interval(), ast_bridge_set_remb_estimated_bitrate(), ast_bridge_set_remb_send_interval(), ast_bridge_set_send_sdp_label(), ast_bridge_set_sfu_video_mode(), ast_bridge_set_talker_src_video_mode(), ast_bridge_set_video_update_discard(), AST_BRIDGE_VIDEO_SFU_REMB_AVERAGE, AST_BRIDGE_VIDEO_SFU_REMB_AVERAGE_ALL, AST_BRIDGE_VIDEO_SFU_REMB_FORCE, AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST, AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST_ALL, AST_BRIDGE_VIDEO_SFU_REMB_LOWEST, AST_BRIDGE_VIDEO_SFU_REMB_LOWEST_ALL, ast_brige_set_remb_behavior(), ast_check_hangup(), ast_copy_string(), ast_debug, ast_exists_extension(), AST_LIST_REMOVE_HEAD, ast_str_create, ast_stream_and_wait(), confbridge_conference::b_profile, confbridge_user::b_profile, confbridge_conference::bridge, confbridge_user::chan, conf_bridge_profile_copy(), conf_get_sound(), CONF_STATE_EMPTY, confbridge_user::conference, destroy_conference_bridge(), handle_conf_user_join(), bridge_profile::internal_sample_rate, leave_conference(), confbridge_conference::locked, bridge_profile::max_members, bridge_profile::maximum_sample_rate, bridge_profile::mix_interval, confbridge_conference::muted, confbridge_user::muted, confbridge_conference::name, OBJ_KEY, play_prompt_to_user(), confbridge_user::post_join_list, push_announcer(), confbridge_conference::record_filename, RECORD_FILENAME_INITIAL_SPACE, bridge_profile::remb_estimated_bitrate, bridge_profile::remb_send_interval, confbridge_conference::state, confbridge_user::suspended_moh, confbridge_user::u_profile, and bridge_profile::video_update_discard.

Referenced by confbridge_exec().

1767 {
1768  struct confbridge_conference *conference;
1769  struct post_join_action *action;
1770  int max_members_reached = 0;
1771 
1772  /* We explicitly lock the conference bridges container ourselves so that other callers can not create duplicate conferences at the same time */
1773  ao2_lock(conference_bridges);
1774 
1775  ast_debug(1, "Trying to find conference bridge '%s'\n", conference_name);
1776 
1777  /* Attempt to find an existing conference bridge */
1778  conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
1779  if (conference && conference->b_profile.max_members) {
1780  max_members_reached = conference->b_profile.max_members > conference->activeusers ? 0 : 1;
1781  }
1782 
1783  /* When finding a conference bridge that already exists make sure that it is not locked, and if so that we are not an admin */
1784  if (conference && (max_members_reached || conference->locked) && !ast_test_flag(&user->u_profile, USER_OPT_ADMIN)) {
1785  ao2_unlock(conference_bridges);
1786  ast_debug(1, "Conference '%s' is locked and caller is not an admin\n", conference_name);
1787  ast_stream_and_wait(user->chan,
1788  conf_get_sound(CONF_SOUND_LOCKED, conference->b_profile.sounds),
1789  "");
1790  ao2_ref(conference, -1);
1791  return NULL;
1792  }
1793 
1794  /* If no conference bridge was found see if we can create one */
1795  if (!conference) {
1796  /* Try to allocate memory for a new conference bridge, if we fail... this won't end well. */
1797  if (!(conference = ao2_alloc(sizeof(*conference), destroy_conference_bridge))) {
1798  ao2_unlock(conference_bridges);
1799  ast_log(LOG_ERROR, "Conference '%s' could not be created.\n", conference_name);
1800  return NULL;
1801  }
1802 
1803  /* Setup for the record channel */
1805  if (!conference->record_filename) {
1806  ao2_ref(conference, -1);
1807  ao2_unlock(conference_bridges);
1808  return NULL;
1809  }
1810 
1811  /* Setup conference bridge parameters */
1812  ast_copy_string(conference->name, conference_name, sizeof(conference->name));
1813  conf_bridge_profile_copy(&conference->b_profile, &user->b_profile);
1814 
1815  /* Create an actual bridge that will do the audio mixing */
1818  app, conference_name, NULL);
1819  if (!conference->bridge) {
1820  ao2_ref(conference, -1);
1821  ao2_unlock(conference_bridges);
1822  ast_log(LOG_ERROR, "Conference '%s' mixing bridge could not be created.\n", conference_name);
1823  return NULL;
1824  }
1825 
1826  /* Set the internal sample rate on the bridge from the bridge profile */
1828  /* Set the maximum sample rate on the bridge from the bridge profile */
1830  /* Set the internal mixing interval on the bridge from the bridge profile */
1831  ast_bridge_set_mixing_interval(conference->bridge, conference->b_profile.mix_interval);
1832  ast_bridge_set_binaural_active(conference->bridge, ast_test_flag(&conference->b_profile, BRIDGE_OPT_BINAURAL_ACTIVE));
1833 
1834  if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER)) {
1836  } else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_VIDEO_SRC_SFU)) {
1839  if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE)) {
1841  } else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_REMB_BEHAVIOR_LOWEST)) {
1843  } else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST)) {
1845  } else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE_ALL)) {
1847  } else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_REMB_BEHAVIOR_LOWEST_ALL)) {
1849  } else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST_ALL)) {
1851  } else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_REMB_BEHAVIOR_FORCE)) {
1854  }
1855  }
1856 
1857  /* Always set the minimum interval between video updates, to avoid infinite video updates. */
1859 
1860  if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_ENABLE_EVENTS)) {
1861  ast_bridge_set_send_sdp_label(conference->bridge, 1);
1862  }
1863 
1864  /* Link it into the conference bridges container */
1865  if (!ao2_link(conference_bridges, conference)) {
1866  ao2_ref(conference, -1);
1867  ao2_unlock(conference_bridges);
1868  ast_log(LOG_ERROR,
1869  "Conference '%s' could not be added to the conferences list.\n", conference_name);
1870  return NULL;
1871  }
1872 
1873  /* Set the initial state to EMPTY */
1874  conference->state = CONF_STATE_EMPTY;
1875 
1876  if (alloc_playback_chan(conference)) {
1877  ao2_unlink(conference_bridges, conference);
1878  ao2_ref(conference, -1);
1879  ao2_unlock(conference_bridges);
1880  ast_log(LOG_ERROR, "Could not allocate announcer channel for conference '%s'\n", conference_name);
1881  return NULL;
1882  }
1883 
1884  if (push_announcer(conference)) {
1885  ao2_unlink(conference_bridges, conference);
1886  ao2_ref(conference, -1);
1887  ao2_unlock(conference_bridges);
1888  ast_log(LOG_ERROR, "Could not add announcer channel for conference '%s' bridge\n", conference_name);
1889  return NULL;
1890  }
1891 
1892  if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_RECORD_CONFERENCE)) {
1893  ao2_lock(conference);
1894  conf_start_record(conference);
1895  ao2_unlock(conference);
1896  }
1897 
1898  send_conf_start_event(conference);
1899 
1900  if (!ast_strlen_zero(conference->b_profile.regcontext)) {
1901  if (!ast_exists_extension(NULL, conference->b_profile.regcontext, conference->name, 1, NULL)) {
1902  ast_add_extension(conference->b_profile.regcontext, 1, conference->name, 1, NULL, NULL, "Noop", NULL, NULL, "ConfBridge");
1903  }
1904  }
1905 
1906  ast_debug(1, "Created conference '%s' and linked to container.\n", conference_name);
1907  }
1908 
1909  ao2_unlock(conference_bridges);
1910 
1911  /* Setup conference bridge user parameters */
1912  user->conference = conference;
1913 
1914  ao2_lock(conference);
1915 
1916  /* Determine if the new user should join the conference muted. */
1917  if (ast_test_flag(&user->u_profile, USER_OPT_STARTMUTED)
1918  || (!ast_test_flag(&user->u_profile, USER_OPT_ADMIN) && conference->muted)) {
1919  /* Set user level mute request. */
1920  user->muted = 1;
1921  }
1922 
1923  /*
1924  * Suspend any MOH until the user actually joins the bridge of
1925  * the conference. This way any pre-join file playback does not
1926  * need to worry about MOH.
1927  */
1928  user->suspended_moh = 1;
1929 
1930  if (handle_conf_user_join(user)) {
1931  /* Invalid event, nothing was done, so we don't want to process a leave. */
1932  ao2_unlock(conference);
1933  ao2_ref(conference, -1);
1934  user->conference = NULL;
1935  return NULL;
1936  }
1937 
1938  if (ast_check_hangup(user->chan)) {
1939  ao2_unlock(conference);
1940  leave_conference(user);
1941  return NULL;
1942  }
1943 
1944  ao2_unlock(conference);
1945 
1946  /* If an announcement is to be played play it */
1947  if (!ast_strlen_zero(user->u_profile.announcement)) {
1948  if (play_prompt_to_user(user,
1949  user->u_profile.announcement)) {
1950  leave_conference(user);
1951  return NULL;
1952  }
1953  }
1954 
1955  /* Announce number of users if need be */
1956  if (ast_test_flag(&user->u_profile, USER_OPT_ANNOUNCEUSERCOUNT)) {
1957  if (announce_user_count(conference, user, NULL)) {
1958  leave_conference(user);
1959  return NULL;
1960  }
1961  }
1962 
1963  if (ast_test_flag(&user->u_profile, USER_OPT_ANNOUNCEUSERCOUNTALL) &&
1964  (conference->activeusers > user->u_profile.announce_user_count_all_after)) {
1965  int user_count_res;
1966 
1967  /*
1968  * We have to autoservice the new user because he has not quite
1969  * joined the conference yet.
1970  */
1971  ast_autoservice_start(user->chan);
1972  user_count_res = announce_user_count(conference, NULL, NULL);
1973  ast_autoservice_stop(user->chan);
1974  if (user_count_res) {
1975  leave_conference(user);
1976  return NULL;
1977  }
1978  }
1979 
1980  /* Handle post-join actions */
1981  while ((action = AST_LIST_REMOVE_HEAD(&user->post_join_list, list))) {
1982  action->func(user);
1983  ast_free(action);
1984  }
1985 
1986  return conference;
1987 }
void ast_bridge_set_sfu_video_mode(struct ast_bridge *bridge)
Set the bridge to be a selective forwarding unit.
Definition: bridge.c:3774
static int announce_user_count(struct confbridge_conference *conference, struct confbridge_user *user, struct ast_bridge_channel *bridge_channel)
Announce number of users in the conference bridge to the caller.
void ast_bridge_set_mixing_interval(struct ast_bridge *bridge, unsigned int mixing_interval)
Adjust the internal mixing interval of a bridge used during multimix mode.
Definition: bridge.c:3698
void ast_bridge_set_binaural_active(struct ast_bridge *bridge, unsigned int binaural_active)
Activates the use of binaural signals in a conference bridge.
Definition: bridge.c:3705
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:200
struct ast_channel * chan
Definition: confbridge.h:279
void ast_bridge_set_maximum_sample_rate(struct ast_bridge *bridge, unsigned int sample_rate)
Adjust the maximum mixing sample rate of a bridge used during multimix mode.
Definition: bridge.c:3719
struct confbridge_conference * conference
Definition: confbridge.h:274
const char * conf_get_sound(enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds)
Looks to see if sound file is stored in bridge profile sounds, if not default sound is provided...
#define OBJ_KEY
Definition: astobj2.h:1151
struct confbridge_user::@93 post_join_list
unsigned int suspended_moh
Definition: confbridge.h:282
struct confbridge_state * CONF_STATE_EMPTY
Conference state with no active or waiting users.
static const char app[]
void ast_bridge_set_remb_estimated_bitrate(struct ast_bridge *bridge, float estimated_bitrate)
Force the REMB report estimated bitrate to a specific max value.
Definition: bridge.c:3807
struct bridge_profile b_profile
Definition: confbridge.h:250
unsigned int locked
Definition: confbridge.h:254
static void destroy_conference_bridge(void *obj)
Destroy a conference bridge.
void conf_bridge_profile_copy(struct bridge_profile *dst, struct bridge_profile *src)
copies a bridge profile
void ast_bridge_set_send_sdp_label(struct ast_bridge *bridge, unsigned int send_sdp_label)
Controls whether to send a "label" attribute in each stream in an SDP.
Definition: bridge.c:3966
void ast_brige_set_remb_behavior(struct ast_bridge *bridge, enum ast_bridge_video_sfu_remb_behavior behavior)
Set the REMB report generation behavior on a bridge.
Definition: bridge.c:3798
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define ast_debug(level,...)
Log a DEBUG message.
struct ao2_container * conference_bridges
Container to hold all conference bridges in progress.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
struct ast_bridge * ast_bridge_base_new(uint32_t capabilities, unsigned int flags, const char *creator, const char *name, const char *id)
Create a new base class bridge.
Definition: bridge.c:934
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4175
unsigned int maximum_sample_rate
Definition: confbridge.h:236
unsigned int internal_sample_rate
Definition: confbridge.h:235
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:445
void ast_bridge_set_video_update_discard(struct ast_bridge *bridge, unsigned int video_update_discard)
Set the amount of time to discard subsequent video updates after a video update has been sent...
Definition: bridge.c:3782
struct confbridge_state * state
Definition: confbridge.h:248
unsigned int video_update_discard
Definition: confbridge.h:240
#define RECORD_FILENAME_INITIAL_SPACE
#define ao2_unlink(container, obj)
Remove an object from a container.
Definition: astobj2.h:1578
unsigned int muted
Definition: confbridge.h:283
void ast_bridge_set_remb_send_interval(struct ast_bridge *bridge, unsigned int remb_send_interval)
Set the interval at which a combined REMB frame will be sent to video sources.
Definition: bridge.c:3789
unsigned int max_members
Definition: confbridge.h:234
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
stream file until digit If the file name is non-empty, try to play it.
Definition: file.c:1878
void ast_bridge_set_talker_src_video_mode(struct ast_bridge *bridge)
Set the bridge to pick the strongest talker supporting video as the single source video feed...
Definition: bridge.c:3766
struct bridge_profile b_profile
Definition: confbridge.h:275
static int push_announcer(struct confbridge_conference *conference)
Push the announcer channel into the bridge.
The structure that represents a conference bridge.
Definition: confbridge.h:246
unsigned int activeusers
Definition: confbridge.h:251
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
Definition: pbx.c:6928
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
unsigned int remb_estimated_bitrate
Definition: confbridge.h:242
unsigned int muted
Definition: confbridge.h:255
struct ast_str * record_filename
Definition: confbridge.h:258
struct user_profile u_profile
Definition: confbridge.h:276
static int play_prompt_to_user(struct confbridge_user *user, const char *filename)
Play back an audio file to a channel.
static int handle_conf_user_join(struct confbridge_user *user)
Call the proper join event handler for the user for the conference bridge's current state...
unsigned int remb_send_interval
Definition: confbridge.h:241
char name[MAX_CONF_NAME]
Definition: confbridge.h:247
unsigned int mix_interval
Definition: confbridge.h:237
void ast_bridge_set_internal_sample_rate(struct ast_bridge *bridge, unsigned int sample_rate)
Adjust the internal mixing sample rate of a bridge used during multimix mode.
Definition: bridge.c:3712
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
static void leave_conference(struct confbridge_user *user)
Leave a conference.
struct ast_bridge * bridge
Definition: confbridge.h:249
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
static void leave_conference ( struct confbridge_user user)
static

Leave a conference.

Parameters
userThe conference user

Definition at line 1994 of file app_confbridge.c.

References ao2_ref, AST_LIST_REMOVE_HEAD, confbridge_user::conference, handle_conf_user_leave(), and confbridge_user::post_join_list.

Referenced by confbridge_exec(), and join_conference_bridge().

1995 {
1996  struct post_join_action *action;
1997 
1998  ao2_lock(user->conference);
1999  handle_conf_user_leave(user);
2000  ao2_unlock(user->conference);
2001 
2002  /* Discard any post-join actions */
2003  while ((action = AST_LIST_REMOVE_HEAD(&user->post_join_list, list))) {
2004  ast_free(action);
2005  }
2006 
2007  /* Done mucking with the conference, huzzah */
2008  ao2_ref(user->conference, -1);
2009  user->conference = NULL;
2010 }
struct confbridge_conference * conference
Definition: confbridge.h:274
struct confbridge_user::@93 post_join_list
static int handle_conf_user_leave(struct confbridge_user *user)
Call the proper leave event handler for the user for the conference bridge's current state...
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
static int load_module ( void  )
static

Load the module.

Module loading including tests for configuration or dependencies. This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails tests return AST_MODULE_LOAD_FAILURE. If the module can not load the configuration file or other non-critical problem return AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.

Definition at line 4620 of file app_confbridge.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, app, ast_cli_register_multiple, ast_custom_function_register, ast_custom_function_register_escalating, ast_manager_register_xml, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, conf_announce_get_tech(), conf_load_config(), conf_record_get_tech(), confbridge_exec(), CONFERENCE_BRIDGE_BUCKETS, conference_bridge_cmp_cb(), conference_bridge_hash_cb(), manager_confbridge_init(), and unload_module().

4621 {
4622  int res = 0;
4623 
4624  if (conf_load_config()) {
4625  ast_log(LOG_ERROR, "Unable to load config. Not loading module.\n");
4626  return AST_MODULE_LOAD_DECLINE;
4627  }
4628 
4629  if (register_channel_tech(conf_record_get_tech())
4630  || register_channel_tech(conf_announce_get_tech())) {
4631  unload_module();
4632  return AST_MODULE_LOAD_DECLINE;
4633  }
4634 
4635  /* Create a container to hold the conference bridges */
4639  if (!conference_bridges) {
4640  unload_module();
4641  return AST_MODULE_LOAD_DECLINE;
4642  }
4643 
4644  /* Setup manager stasis subscriptions */
4645  res |= manager_confbridge_init();
4646 
4648  res |= ast_register_application_xml(app2, confkick_exec);
4649 
4650  res |= ast_custom_function_register_escalating(&confbridge_function, AST_CFE_WRITE);
4651  res |= ast_custom_function_register(&confbridge_info_function);
4652  res |= ast_custom_function_register(&confbridge_channels_function);
4653 
4654  res |= ast_cli_register_multiple(cli_confbridge, ARRAY_LEN(cli_confbridge));
4655 
4656  res |= ast_manager_register_xml("ConfbridgeList", EVENT_FLAG_REPORTING, action_confbridgelist);
4657  res |= ast_manager_register_xml("ConfbridgeListRooms", EVENT_FLAG_REPORTING, action_confbridgelistrooms);
4658  res |= ast_manager_register_xml("ConfbridgeMute", EVENT_FLAG_CALL, action_confbridgemute);
4659  res |= ast_manager_register_xml("ConfbridgeUnmute", EVENT_FLAG_CALL, action_confbridgeunmute);
4660  res |= ast_manager_register_xml("ConfbridgeKick", EVENT_FLAG_CALL, action_confbridgekick);
4661  res |= ast_manager_register_xml("ConfbridgeUnlock", EVENT_FLAG_CALL, action_confbridgeunlock);
4662  res |= ast_manager_register_xml("ConfbridgeLock", EVENT_FLAG_CALL, action_confbridgelock);
4663  res |= ast_manager_register_xml("ConfbridgeStartRecord", EVENT_FLAG_SYSTEM, action_confbridgestartrecord);
4664  res |= ast_manager_register_xml("ConfbridgeStopRecord", EVENT_FLAG_SYSTEM, action_confbridgestoprecord);
4665  res |= ast_manager_register_xml("ConfbridgeSetSingleVideoSrc", EVENT_FLAG_CALL, action_confbridgesetsinglevideosrc);
4666  if (res) {
4667  unload_module();
4668  return AST_MODULE_LOAD_DECLINE;
4669  }
4670 
4671  return AST_MODULE_LOAD_SUCCESS;
4672 }
int manager_confbridge_init(void)
register stasis message routers to handle manager events for confbridge messages
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static const char app[]
#define CONFERENCE_BRIDGE_BUCKETS
struct ast_channel_tech * conf_record_get_tech(void)
Get ConfBridge record channel technology struct.
#define ast_custom_function_register_escalating(acf, escalation)
Register a custom function which requires escalated privileges.
Definition: pbx.h:1567
struct ast_channel_tech * conf_announce_get_tech(void)
Get ConfBridge announce channel technology struct.
struct ao2_container * conference_bridges
Container to hold all conference bridges in progress.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
static int unload_module(void)
Called when module is being unloaded.
static int conference_bridge_hash_cb(const void *obj, const int flags)
Hashing function used for conference bridges container.
static int conference_bridge_cmp_cb(void *obj, void *arg, int flags)
Comparison function used for conference bridges container.
int conf_load_config(void)
load confbridge.conf file
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:191
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640
static int confbridge_exec(struct ast_channel *chan, const char *data)
The ConfBridge application.
static int play_file ( struct ast_bridge_channel bridge_channel,
struct ast_channel channel,
const char *  filename 
)
static

Playback the given filename and monitor for any dtmf interrupts.

This function is used to playback sound files on a given channel and optionally allow dtmf interrupts to occur.

If the optional bridge_channel parameter is given then sound file playback is played on that channel and dtmf interruptions are allowed. However, if bridge_channel is not set then the channel parameter is expected to be set instead and non interruptible playback is played on that channel.

Parameters
bridge_channelBridge channel to play file on
channelOptional channel to play file on if bridge_channel not given
filenameThe file name to playback
Return values
-1failure during playback.
0on file was fully played.
1on dtmf interrupt.

Definition at line 1018 of file app_confbridge.c.

References ast_bridge_channel_feature_digit_add(), AST_DIGIT_NONE, ast_stopstream(), ast_stream_and_wait(), and ast_bridge_channel::chan.

Referenced by announce_user_count(), and say_periodic_announcement().

1020 {
1021  struct ast_channel *chan;
1022  const char *stop_digits;
1023  int digit;
1024 
1025  if (bridge_channel) {
1026  chan = bridge_channel->chan;
1027  stop_digits = AST_DIGIT_ANY;
1028  } else {
1029  chan = channel;
1030  stop_digits = AST_DIGIT_NONE;
1031  }
1032 
1033  digit = ast_stream_and_wait(chan, filename, stop_digits);
1034  if (digit < 0) {
1035  ast_log(LOG_WARNING, "Failed to playback file '%s' to channel\n", filename);
1036  return -1;
1037  }
1038 
1039  if (digit > 0) {
1040  ast_stopstream(bridge_channel->chan);
1041  ast_bridge_channel_feature_digit_add(bridge_channel, digit);
1042  return 1;
1043  }
1044 
1045  return 0;
1046 }
Main Channel structure associated with a channel.
void ast_bridge_channel_feature_digit_add(struct ast_bridge_channel *bridge_channel, int digit)
Add a DTMF digit to the collected digits.
#define AST_DIGIT_NONE
Definition: file.h:47
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
stream file until digit If the file name is non-empty, try to play it.
Definition: file.c:1878
struct ast_channel * chan
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition: file.c:222
static int play_prompt_to_user ( struct confbridge_user user,
const char *  filename 
)
static

Play back an audio file to a channel.

Parameters
userUser to play audio prompt to
filenamePrompt to play
Return values
0on success.
-1if the user hung up.
Note
Generally this should be called when the conference is unlocked to avoid blocking the entire conference while the sound is played. But don't unlock the conference bridge in the middle of a state transition.

Definition at line 1131 of file app_confbridge.c.

References ast_stream_and_wait(), and confbridge_user::chan.

Referenced by conf_handle_inactive_waitmarked(), conf_handle_only_person(), and join_conference_bridge().

1132 {
1133  return ast_stream_and_wait(user->chan, filename, "");
1134 }
struct ast_channel * chan
Definition: confbridge.h:279
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
stream file until digit If the file name is non-empty, try to play it.
Definition: file.c:1878
int play_sound_file ( struct confbridge_conference conference,
const char *  filename 
)

Play sound file into conference bridge.

Parameters
conferenceThe conference bridge to play sound file into
filenameSound file to play
Return values
0success
-1failure

Definition at line 2124 of file app_confbridge.c.

Referenced by announce_user_count(), and confbridge_exec().

2125 {
2126  return play_sound_helper(conference, filename, -1);
2127 }
static int play_sound_number ( struct confbridge_conference conference,
int  say_number 
)
static

Play number into the conference bridge.

Parameters
conferenceThe conference bridge to say the number into
say_numbernumber to say
Return values
0success
-1failure

Definition at line 2406 of file app_confbridge.c.

Referenced by announce_user_count().

2407 {
2408  return play_sound_helper(conference, NULL, say_number);
2409 }
static int playback_task ( void *  data)
static

Play an announcement into a confbridge.

This runs in the playback queue taskprocessor. This ensures that all playbacks are handled in sequence and do not play over top one another.

This task runs synchronously so there is no need for performing any sort of cleanup on the input parameter.

Parameters
dataA playback_task_data
Returns
0

Definition at line 2054 of file app_confbridge.c.

2055 {
2056  struct playback_task_data *ptd = data;
2057 
2058  playback_common(ptd->conference, ptd->filename, ptd->say_number);
2059 
2060  ast_mutex_lock(&ptd->lock);
2061  ptd->playback_finished = 1;
2062  ast_cond_signal(&ptd->cond);
2063  ast_mutex_unlock(&ptd->lock);
2064 
2065  return 0;
2066 }
static int push_announcer ( struct confbridge_conference conference)
static

Push the announcer channel into the bridge.

Parameters
conferenceConference bridge to push the announcer to
Return values
0Success
-1Failed to push the channel to the bridge

Definition at line 1626 of file app_confbridge.c.

References ast_autoservice_start(), ast_hangup(), conf_announce_channel_push(), and confbridge_conference::playback_chan.

Referenced by join_conference_bridge().

1627 {
1628  if (conf_announce_channel_push(conference->playback_chan)) {
1629  ast_hangup(conference->playback_chan);
1630  conference->playback_chan = NULL;
1631  return -1;
1632  }
1633 
1634  ast_autoservice_start(conference->playback_chan);
1635  return 0;
1636 }
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:200
int conf_announce_channel_push(struct ast_channel *ast)
Push the announcer channel into the conference.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2541
struct ast_channel * playback_chan
Definition: confbridge.h:256
static int setup_async_playback_datastore ( struct ast_channel initiator)
static

Prepare the async playback datastore.

This is done prior to queuing an async announcement. If the datastore has not yet been created, it is allocated and initialized. If it already exists, we set it to be in "waiting" mode.

Parameters
initiatorThe channel that is queuing the async playback
Return values
0Success
-1Failure :(

Definition at line 2201 of file app_confbridge.c.

References ast_channel_datastore_add(), ast_channel_datastore_find(), ast_datastore_free(), and ast_datastore::data.

2202 {
2203  struct ast_datastore *async_datastore;
2204 
2205  async_datastore = ast_channel_datastore_find(initiator, &async_datastore_info, NULL);
2206  if (async_datastore) {
2207  struct async_datastore_data *add;
2208 
2209  add = async_datastore->data;
2210  add->wait = 1;
2211 
2212  return 0;
2213  }
2214 
2215  async_datastore = ast_datastore_alloc(&async_datastore_info, NULL);
2216  if (!async_datastore) {
2217  return -1;
2218  }
2219 
2220  async_datastore->data = async_datastore_data_alloc();
2221  if (!async_datastore->data) {
2222  ast_datastore_free(async_datastore);
2223  return -1;
2224  }
2225 
2226  ast_channel_datastore_add(initiator, async_datastore);
2227  return 0;
2228 }
Structure for a data store object.
Definition: datastore.h:64
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition: channel.c:2399
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:68
static struct ast_datastore_info async_datastore_info
Datastore used for timing of async announcement playback.
void * data
Definition: datastore.h:66
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2385
static void wait_for_initiator ( struct ast_channel initiator)
static

Wait for the initiator of an async playback to be ready.

See the description on the async_datastore_info structure for more information about what this is about.

Parameters
initiatorThe channel that queued the async announcement

Definition at line 2290 of file app_confbridge.c.

References ast_channel_datastore_find(), and ast_datastore::data.

Referenced by async_playback_task().

2291 {
2292  struct ast_datastore *async_datastore;
2293  struct async_datastore_data *add;
2294 
2295  ast_channel_lock(initiator);
2296  async_datastore = ast_channel_datastore_find(initiator, &async_datastore_info, NULL);
2297  ast_channel_unlock(initiator);
2298 
2299  if (!async_datastore) {
2300  return;
2301  }
2302 
2303  add = async_datastore->data;
2304 
2305  ast_mutex_lock(&add->lock);
2306  while (add->wait) {
2307  ast_cond_wait(&add->cond, &add->lock);
2308  }
2309  ast_mutex_unlock(&add->lock);
2310 }
Structure for a data store object.
Definition: datastore.h:64
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition: channel.c:2399
static struct ast_datastore_info async_datastore_info
Datastore used for timing of async announcement playback.
void * data
Definition: datastore.h:66

Variable Documentation

const char app[] = "ConfBridge"
static
Playing back a file to a channel in a conference
You might notice in this application that while playing a sound file to a channel the actual conference bridge lock is not held. This is done so that other channels are not blocked from interacting with the conference bridge. Unfortunately because of this it is possible for things to change after the sound file is done being played. Data must therefore be checked after reacquiring the conference bridge lock if it is important.

Definition at line 547 of file app_confbridge.c.

Referenced by confbridge_exec(), join_conference_bridge(), load_module(), and unload_module().

struct ast_datastore_info async_datastore_info
static
Initial value:
= {
.type = "Confbridge async playback",
.destroy = async_datastore_data_destroy,
}

Datastore used for timing of async announcement playback.

Announcements that are played to the entire conference can be played asynchronously (i.e. The channel that queues the playback does not wait for the playback to complete before continuing)

The thing about async announcements is that the channel that queues the announcement is either not in the bridge or is in some other way "occupied" at the time the announcement is queued. Because of that, the initiator of the announcement may enter after the announcement has already started, resulting in the sound being "clipped".

This datastore makes it so that the channel that queues the async announcement can say "I'm ready now". This way the announcement does not start until the initiator of the announcement is ready to hear the sound.

Definition at line 2169 of file app_confbridge.c.

struct ast_custom_function confbridge_channels_function
static
Initial value:
= {
.name = "CONFBRIDGE_CHANNELS",
.read = func_confbridge_channels,
}

Definition at line 3996 of file app_confbridge.c.

struct ast_custom_function confbridge_function
static
Initial value:
= {
.name = "CONFBRIDGE",
.write = func_confbridge_helper,
}

Definition at line 3906 of file app_confbridge.c.

struct ast_custom_function confbridge_info_function
static
Initial value:
= {
.name = "CONFBRIDGE_INFO",
.read = func_confbridge_info,
}

Definition at line 3912 of file app_confbridge.c.