Asterisk - The Open Source Telephony Project  18.5.0
Functions | Variables
conf_state_multi_marked.c File Reference

Confbridge state handling for the MULTI_MARKED state. More...

#include "asterisk.h"
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
#include "include/confbridge.h"
#include "asterisk/musiconhold.h"
#include "include/conf_state.h"
#include "asterisk/pbx.h"
Include dependency graph for conf_state_multi_marked.c:

Go to the source code of this file.

Functions

static void join_active (struct confbridge_user *user)
 
static void join_marked (struct confbridge_user *user)
 
static void leave_active (struct confbridge_user *user)
 
static void leave_marked (struct confbridge_user *user)
 
static int post_join_play_begin (struct confbridge_user *user)
 
static void transition_to_marked (struct confbridge_user *user)
 

Variables

struct confbridge_stateCONF_STATE_MULTI_MARKED = &STATE_MULTI_MARKED
 Conference state with multiple active users and at least one marked user. More...
 
static struct confbridge_state STATE_MULTI_MARKED
 

Detailed Description

Confbridge state handling for the MULTI_MARKED state.

Author
Terry Wilson <[email protected]> 

Definition in file conf_state_multi_marked.c.

Function Documentation

◆ join_active()

static void join_active ( struct confbridge_user user)
static

Definition at line 61 of file conf_state_multi_marked.c.

References conf_add_user_active(), conf_update_user_mute(), and confbridge_user::conference.

62 {
63  conf_add_user_active(user->conference, user);
65 }
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.
struct confbridge_conference * conference
Definition: confbridge.h:272
void conf_update_user_mute(struct confbridge_user *user)
Update the actual mute status of the user and set it on the bridge.

◆ join_marked()

static void join_marked ( struct confbridge_user user)
static

Definition at line 67 of file conf_state_multi_marked.c.

References conf_add_user_marked(), conf_update_user_mute(), and confbridge_user::conference.

68 {
69  conf_add_user_marked(user->conference, user);
71 }
struct confbridge_conference * conference
Definition: confbridge.h:272
void conf_update_user_mute(struct confbridge_user *user)
Update the actual mute status of the user and set it on the bridge.
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.

◆ leave_active()

static void leave_active ( struct confbridge_user user)
static

Definition at line 73 of file conf_state_multi_marked.c.

References confbridge_conference::activeusers, conf_change_state(), conf_remove_user_active(), CONF_STATE_SINGLE_MARKED, and confbridge_user::conference.

74 {
76  if (user->conference->activeusers == 1) {
78  }
79 }
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.
struct confbridge_conference * conference
Definition: confbridge.h:272
struct confbridge_state * CONF_STATE_SINGLE_MARKED
Conference state with only a single marked active user.
unsigned int activeusers
Definition: confbridge.h:249
void conf_change_state(struct confbridge_user *user, struct confbridge_state *newstate)
Execute conference state transition because of a user action.
Definition: conf_state.c:82

◆ leave_marked()

static void leave_marked ( struct confbridge_user user)
static

Definition at line 81 of file conf_state_multi_marked.c.

References confbridge_conference::active_list, confbridge_conference::activeusers, ast_bridge_remove(), AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_test_flag, async_play_sound_file(), confbridge_conference::b_profile, confbridge_conference::bridge, confbridge_user::chan, conf_change_state(), conf_get_sound(), conf_moh_start(), conf_remove_user_marked(), CONF_SOUND_LEADER_HAS_LEFT, CONF_STATE_EMPTY, CONF_STATE_INACTIVE, CONF_STATE_MULTI, CONF_STATE_SINGLE, CONF_STATE_SINGLE_MARKED, conf_update_user_mute(), confbridge_user::conference, confbridge_user::kicked, confbridge_user::list, confbridge_conference::markedusers, NULL, pbx_builtin_setvar_helper(), bridge_profile::sounds, confbridge_user::u_profile, USER_OPT_ENDMARKED, USER_OPT_MARKEDUSER, USER_OPT_MUSICONHOLD, USER_OPT_QUIET, USER_OPT_WAITMARKED, confbridge_conference::waiting_list, and confbridge_conference::waitingusers.

82 {
83  struct confbridge_user *user_iter;
84  int need_prompt = 0;
85 
87 
88  if (user->conference->markedusers == 0) {
90  /* Kick ENDMARKED cbu_iters */
91  if (ast_test_flag(&user_iter->u_profile, USER_OPT_ENDMARKED) && !user_iter->kicked) {
93  && !ast_test_flag(&user_iter->u_profile, USER_OPT_MARKEDUSER)) {
95  user_iter->conference->activeusers--;
96  AST_LIST_INSERT_TAIL(&user_iter->conference->waiting_list, user_iter, list);
97  user_iter->conference->waitingusers++;
98  }
99  user_iter->kicked = 1;
100  pbx_builtin_setvar_helper(user_iter->chan, "CONFBRIDGE_RESULT", "ENDMARKED");
101  ast_bridge_remove(user_iter->conference->bridge, user_iter->chan);
102  } else if (ast_test_flag(&user_iter->u_profile, USER_OPT_WAITMARKED)
103  && !ast_test_flag(&user_iter->u_profile, USER_OPT_MARKEDUSER)) {
104  need_prompt = 1;
105 
107  user_iter->conference->activeusers--;
108  AST_LIST_INSERT_TAIL(&user_iter->conference->waiting_list, user_iter, list);
109  user_iter->conference->waitingusers++;
110  } else {
111  /* User is neither wait_marked nor end_marked; however, they
112  * should still hear the prompt.
113  */
114  need_prompt = 1;
115  }
116  }
118  }
119 
120  switch (user->conference->activeusers) {
121  case 0:
122  /* Implies markedusers == 0 */
123  switch (user->conference->waitingusers) {
124  case 0:
126  break;
127  default:
129  break;
130  }
131  break;
132  case 1:
133  switch (user->conference->markedusers) {
134  case 0:
136  break;
137  case 1:
138  /* XXX I seem to remember doing this for a reason, but right now it escapes me
139  * how we could possibly ever have a waiting user while we have a marked user */
140  switch (user->conference->waitingusers) {
141  case 0:
143  break;
144  case 1:
145  break; /* Stay in marked */
146  }
147  break;
148  }
149  break;
150  default:
151  switch (user->conference->markedusers) {
152  case 0:
154  break;
155  default:
156  break; /* Stay in marked */
157  }
158  }
159 
160  if (need_prompt) {
161  /* Play back the audio prompt saying the leader has left the conference */
162  if (!ast_test_flag(&user->u_profile, USER_OPT_QUIET)) {
165  NULL);
166  }
167 
168  AST_LIST_TRAVERSE(&user->conference->waiting_list, user_iter, list) {
169  if (user_iter->kicked) {
170  continue;
171  }
172 
173  if (ast_test_flag(&user_iter->u_profile, USER_OPT_MUSICONHOLD)) {
174  conf_moh_start(user_iter);
175  }
176 
177  conf_update_user_mute(user_iter);
178  }
179  }
180 }
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.
int ast_bridge_remove(struct ast_bridge *bridge, struct ast_channel *chan)
Remove a channel from a bridge.
Definition: bridge.c:1997
struct confbridge_state * CONF_STATE_MULTI
Conference state with multiple active users, but no marked users.
struct ast_channel * chan
Definition: confbridge.h:277
struct confbridge_conference * conference
Definition: confbridge.h:272
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 ast_test_flag(p, flag)
Definition: utils.h:63
struct bridge_profile_sounds * sounds
Definition: confbridge.h:236
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_state * CONF_STATE_EMPTY
Conference state with no active or waiting users.
struct confbridge_user::@94 list
#define NULL
Definition: resample.c:96
unsigned int markedusers
Definition: confbridge.h:250
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
struct confbridge_conference::@90 active_list
struct bridge_profile b_profile
Definition: confbridge.h:248
struct confbridge_state * CONF_STATE_SINGLE_MARKED
Conference state with only a single marked active user.
unsigned int waitingusers
Definition: confbridge.h:251
int async_play_sound_file(struct confbridge_conference *conference, const char *filename, struct ast_channel *initiator)
Play sound file into conference bridge asynchronously.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:556
void conf_moh_start(struct confbridge_user *user)
Start MOH for the conference user.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:730
struct confbridge_state * CONF_STATE_SINGLE
Conference state with only a single unmarked active user.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
unsigned int activeusers
Definition: confbridge.h:249
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
struct confbridge_state * CONF_STATE_INACTIVE
Conference state with only waiting users.
The structure that represents a conference bridge user.
Definition: confbridge.h:271
struct confbridge_conference::@91 waiting_list
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
struct user_profile u_profile
Definition: confbridge.h:274
unsigned int kicked
Definition: confbridge.h:282
void conf_change_state(struct confbridge_user *user, struct confbridge_state *newstate)
Execute conference state transition because of a user action.
Definition: conf_state.c:82
struct ast_bridge * bridge
Definition: confbridge.h:247

◆ post_join_play_begin()

static int post_join_play_begin ( struct confbridge_user user)
static

Definition at line 182 of file conf_state_multi_marked.c.

References ast_autoservice_start(), ast_autoservice_stop(), confbridge_conference::b_profile, confbridge_user::chan, conf_get_sound(), CONF_SOUND_BEGIN, confbridge_user::conference, play_sound_file(), and bridge_profile::sounds.

Referenced by transition_to_marked().

183 {
184  int res;
185 
187  res = play_sound_file(user->conference,
189  ast_autoservice_stop(user->chan);
190  return res;
191 }
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:277
struct confbridge_conference * conference
Definition: confbridge.h:272
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_sounds * sounds
Definition: confbridge.h:236
struct bridge_profile b_profile
Definition: confbridge.h:248
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
int play_sound_file(struct confbridge_conference *conference, const char *filename)
Play sound file into conference bridge.

◆ transition_to_marked()

static void transition_to_marked ( struct confbridge_user user)
static

Definition at line 193 of file conf_state_multi_marked.c.

References confbridge_conference::active_list, confbridge_conference::activeusers, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_test_flag, conf_add_post_join_action(), conf_moh_stop(), conf_update_user_mute(), confbridge_user::conference, confbridge_user::list, confbridge_conference::markedusers, confbridge_user::playing_moh, post_join_play_begin(), confbridge_user::u_profile, USER_OPT_MARKEDUSER, USER_OPT_QUIET, confbridge_conference::waiting_list, and confbridge_conference::waitingusers.

194 {
195  struct confbridge_user *user_iter;
196  int waitmarked_moved = 0;
197 
198  /* Move all waiting users to active, stopping MOH and unmuting if necessary */
201  user->conference->waitingusers--;
202  AST_LIST_INSERT_TAIL(&user->conference->active_list, user_iter, list);
203  user->conference->activeusers++;
204  if (user_iter->playing_moh) {
205  conf_moh_stop(user_iter);
206  }
207  conf_update_user_mute(user_iter);
208  waitmarked_moved++;
209  }
211 
212  /* Play the audio file stating that the conference is beginning */
213  if (user->conference->markedusers == 1
216  && waitmarked_moved) {
218  }
219 }
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 transitio...
unsigned int playing_moh
Definition: confbridge.h:283
struct confbridge_conference * conference
Definition: confbridge.h:272
#define ast_test_flag(p, flag)
Definition: utils.h:63
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_user::@94 list
unsigned int markedusers
Definition: confbridge.h:250
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
struct confbridge_conference::@90 active_list
unsigned int waitingusers
Definition: confbridge.h:251
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:556
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:730
void conf_moh_stop(struct confbridge_user *user)
Stop MOH for the conference user.
unsigned int activeusers
Definition: confbridge.h:249
static int post_join_play_begin(struct confbridge_user *user)
The structure that represents a conference bridge user.
Definition: confbridge.h:271
struct confbridge_conference::@91 waiting_list
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
struct user_profile u_profile
Definition: confbridge.h:274

Variable Documentation

◆ CONF_STATE_MULTI_MARKED

struct confbridge_state* CONF_STATE_MULTI_MARKED = &STATE_MULTI_MARKED

Conference state with multiple active users and at least one marked user.

Definition at line 59 of file conf_state_multi_marked.c.

Referenced by join_active(), and join_marked().

◆ STATE_MULTI_MARKED

struct confbridge_state STATE_MULTI_MARKED
static

Definition at line 49 of file conf_state_multi_marked.c.