Asterisk - The Open Source Telephony Project GIT-master-f36a736
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 <twilson@digium.com> 

Definition in file conf_state_multi_marked.c.

Function Documentation

◆ join_active()

static void join_active ( struct confbridge_user user)
static

Definition at line 58 of file conf_state_multi_marked.c.

59{
60 conf_add_user_active(user->conference, user);
62}
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.
void conf_update_user_mute(struct confbridge_user *user)
Update the actual mute status of the user and set it on the bridge.
structure to hold users read from users.conf

References conf_add_user_active(), and conf_update_user_mute().

◆ join_marked()

static void join_marked ( struct confbridge_user user)
static

Definition at line 64 of file conf_state_multi_marked.c.

65{
66 conf_add_user_marked(user->conference, user);
68}
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.

References conf_add_user_marked(), and conf_update_user_mute().

◆ leave_active()

static void leave_active ( struct confbridge_user user)
static

Definition at line 70 of file conf_state_multi_marked.c.

71{
72 conf_remove_user_active(user->conference, user);
73 if (user->conference->activeusers == 1) {
75 }
76}
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.
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:77
struct confbridge_state * CONF_STATE_SINGLE_MARKED
Conference state with only a single marked active user.

References conf_change_state(), conf_remove_user_active(), and CONF_STATE_SINGLE_MARKED.

◆ leave_marked()

static void leave_marked ( struct confbridge_user user)
static

Definition at line 78 of file conf_state_multi_marked.c.

79{
80 struct confbridge_user *user_iter;
81 int need_prompt = 0;
82
83 conf_remove_user_marked(user->conference, user);
84
85 /* If all marked users have left, or we're set to kick if any marked user leaves, then boot everyone */
86 AST_LIST_TRAVERSE_SAFE_BEGIN(&user->conference->active_list, user_iter, list) {
87 if (user->conference->markedusers > 0 && !ast_test_flag(&user_iter->u_profile, USER_OPT_ENDMARKEDANY)) {
88 continue;
89 }
90 /* Kick ENDMARKED cbu_iters */
91 if ((ast_test_flag(&user_iter->u_profile, USER_OPT_ENDMARKED) || ast_test_flag(&user_iter->u_profile, USER_OPT_ENDMARKEDANY)) && !user_iter->kicked) {
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 nor end_marked_any; however, they
112 * should still hear the prompt.
113 */
114 need_prompt = 1;
115 }
116 }
118
119 switch (user->conference->activeusers) {
120 case 0:
121 /* Implies markedusers == 0 */
122 switch (user->conference->waitingusers) {
123 case 0:
125 break;
126 default:
128 break;
129 }
130 break;
131 case 1:
132 switch (user->conference->markedusers) {
133 case 0:
135 break;
136 case 1:
137 /* XXX I seem to remember doing this for a reason, but right now it escapes me
138 * how we could possibly ever have a waiting user while we have a marked user */
139 switch (user->conference->waitingusers) {
140 case 0:
142 break;
143 case 1:
144 break; /* Stay in marked */
145 }
146 break;
147 }
148 break;
149 default:
150 switch (user->conference->markedusers) {
151 case 0:
153 break;
154 default:
155 break; /* Stay in marked */
156 }
157 }
158
159 if (need_prompt) {
160 /* Play back the audio prompt saying the leader has left the conference */
161 if (!ast_test_flag(&user->u_profile, USER_OPT_QUIET)) {
162 async_play_sound_file(user->conference,
163 conf_get_sound(CONF_SOUND_LEADER_HAS_LEFT, user->conference->b_profile.sounds),
164 NULL);
165 }
166
167 AST_LIST_TRAVERSE(&user->conference->waiting_list, user_iter, list) {
168 if (user_iter->kicked) {
169 continue;
170 }
171
172 if (ast_test_flag(&user_iter->u_profile, USER_OPT_MUSICONHOLD)) {
173 conf_moh_start(user_iter);
174 }
175
176 conf_update_user_mute(user_iter);
177 }
178 }
179}
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 async_play_sound_file(struct confbridge_conference *conference, const char *filename, struct ast_channel *initiator)
Play sound file into conference bridge asynchronously.
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.
void conf_moh_start(struct confbridge_user *user)
Start MOH for the conference user.
int ast_bridge_remove(struct ast_bridge *bridge, struct ast_channel *chan)
Remove a channel from a bridge.
Definition: bridge.c:1951
struct confbridge_state * CONF_STATE_EMPTY
Conference state with no active or waiting users.
struct confbridge_state * CONF_STATE_INACTIVE
Conference state with only waiting users.
struct confbridge_state * CONF_STATE_MULTI
Conference state with multiple active users, but no marked users.
struct confbridge_state * CONF_STATE_SINGLE
Conference state with only a single unmarked active user.
@ USER_OPT_ENDMARKED
Definition: confbridge.h:60
@ USER_OPT_WAITMARKED
Definition: confbridge.h:59
@ USER_OPT_QUIET
Definition: confbridge.h:57
@ USER_OPT_MARKEDUSER
Definition: confbridge.h:54
@ USER_OPT_MUSICONHOLD
Definition: confbridge.h:56
@ USER_OPT_ENDMARKEDANY
Definition: confbridge.h:74
@ CONF_SOUND_LEADER_HAS_LEFT
Definition: confbridge.h:180
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:615
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:529
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:557
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.
#define NULL
Definition: resample.c:96
struct ast_bridge * bridge
Definition: confbridge.h:249
unsigned int activeusers
Definition: confbridge.h:251
unsigned int waitingusers
Definition: confbridge.h:253
struct confbridge_conference::@95 waiting_list
The structure that represents a conference bridge user.
Definition: confbridge.h:273
unsigned int kicked
Definition: confbridge.h:284
struct confbridge_conference * conference
Definition: confbridge.h:274
struct confbridge_user::@98 list
struct ast_channel * chan
Definition: confbridge.h:279
struct user_profile u_profile
Definition: confbridge.h:276
#define ast_test_flag(p, flag)
Definition: utils.h:63

References 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::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, NULL, pbx_builtin_setvar_helper(), confbridge_user::u_profile, USER_OPT_ENDMARKED, USER_OPT_ENDMARKEDANY, USER_OPT_MARKEDUSER, USER_OPT_MUSICONHOLD, USER_OPT_QUIET, USER_OPT_WAITMARKED, confbridge_conference::waiting_list, and confbridge_conference::waitingusers.

◆ post_join_play_begin()

static int post_join_play_begin ( struct confbridge_user user)
static

Definition at line 181 of file conf_state_multi_marked.c.

182{
183 int res;
184
186 res = play_sound_file(user->conference,
187 conf_get_sound(CONF_SOUND_BEGIN, user->conference->b_profile.sounds));
189 return res;
190}
int play_sound_file(struct confbridge_conference *conference, const char *filename)
Play sound file into conference bridge.
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:200
@ CONF_SOUND_BEGIN
Definition: confbridge.h:192

References ast_autoservice_start(), ast_autoservice_stop(), conf_get_sound(), CONF_SOUND_BEGIN, and play_sound_file().

Referenced by transition_to_marked().

◆ transition_to_marked()

static void transition_to_marked ( struct confbridge_user user)
static

Definition at line 192 of file conf_state_multi_marked.c.

193{
194 struct confbridge_user *user_iter;
195 int waitmarked_moved = 0;
196
197 /* Move all waiting users to active, stopping MOH and unmuting if necessary */
198 AST_LIST_TRAVERSE_SAFE_BEGIN(&user->conference->waiting_list, user_iter, list) {
200 user->conference->waitingusers--;
201 AST_LIST_INSERT_TAIL(&user->conference->active_list, user_iter, list);
202 user->conference->activeusers++;
203 if (user_iter->playing_moh) {
204 conf_moh_stop(user_iter);
205 }
206 conf_update_user_mute(user_iter);
207 waitmarked_moved++;
208 }
210
211 /* Play the audio file stating that the conference is beginning */
212 if (user->conference->markedusers == 1
213 && ast_test_flag(&user->u_profile, USER_OPT_MARKEDUSER)
214 && !ast_test_flag(&user->u_profile, USER_OPT_QUIET)
215 && waitmarked_moved) {
217 }
218}
void conf_moh_stop(struct confbridge_user *user)
Stop MOH for the conference user.
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...
static int post_join_play_begin(struct confbridge_user *user)
unsigned int playing_moh
Definition: confbridge.h:285

References 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::list, confbridge_user::playing_moh, post_join_play_begin(), USER_OPT_MARKEDUSER, and USER_OPT_QUIET.

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 56 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 46 of file conf_state_multi_marked.c.