Resolve issues in ConfBridge regarding marked, waitmarked, and unmarked users
Thank's to Neil Tallim (flan)'s tireless testing, issue reporting, and patches
it became clear that app_confbridge had some complex logic in how it handled
interactions between marked, waitmarked, and unmarked users. In particular,
there were some areas in which the interactions between the users resulted
in inconsistent behavior, and app_confbridge was missing logic in how to handle
some corner cases. Some areas included:
* Poor handling of mixing unmarked and waitmarked users
* Inconsistencies in how MOH and muting was applied to various users
* Handling of various announcements for different user profile options
flan's patches seem to fix the various issues, but highlighted how hard the
code could be to maintain. In an attempt to make things easier to maintain and
to more fully enumerate the various cases that exist, this patch breaks up the
logic into a state machine-like setup.
Please note that the various state transitioned are documented on the Asterisk
wiki:
https://wiki.asterisk.org/wiki/display/AST/Confbridge+state+changes
Review: //https://reviewboard.asterisk.org/r/2072/
Note that for the following issues, mjordan uploaded the patch, although it
was written by twilson. Any contributor license discrepency is due to that.
(closes issue ASTERISK-19562)
Reported by: flan
Tested by: flan, mjordan, jrose
patches:
bugASTERISK-19562_ASTERISK-19726_ASTERISK-20181.patch uploaded by twilson (license 6283)
(closes issue ASTERISK-19726)
Reported by: flan
Tested by: flan
patches:
bugASTERISK-19562_ASTERISK-19726_ASTERISK-20181.patch uploaded by twilson (license 6283)
(closes issue ASTERISK-20181)
Reported by: Jonathan White
Tested by: Jonathan White
patches:
bugASTERISK-19562_ASTERISK-19726_ASTERISK-20181.patch uploaded by twilson (license 6283)
........
Merged revisions 374652 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 374657 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374658 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-10-08 18:48:34 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012, Terry Wilson
|
|
|
|
*
|
|
|
|
* Terry Wilson <twilson@digium.com>
|
|
|
|
*
|
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*
|
|
|
|
* Please follow coding guidelines
|
|
|
|
* http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*! \file
|
|
|
|
*
|
|
|
|
* \brief Confbridge state handling for the MULTI_MARKED state
|
|
|
|
*
|
|
|
|
* \author\verbatim Terry Wilson <twilson@digium.com> \endverbatim
|
|
|
|
*
|
|
|
|
* \ingroup applications
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
|
|
|
|
|
|
|
#include "asterisk.h"
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
#include "asterisk/linkedlists.h"
|
|
|
|
#include "include/confbridge.h"
|
|
|
|
#include "asterisk/musiconhold.h"
|
|
|
|
#include "include/conf_state.h"
|
|
|
|
|
|
|
|
static void join_active(struct conference_bridge_user *cbu);
|
|
|
|
static void join_marked(struct conference_bridge_user *cbu);
|
|
|
|
static void leave_active(struct conference_bridge_user *cbu);
|
|
|
|
static void leave_marked(struct conference_bridge_user *cbu);
|
|
|
|
static void transition_to_marked(struct conference_bridge_user *cbu);
|
|
|
|
|
|
|
|
static struct conference_state STATE_MULTI_MARKED = {
|
|
|
|
.name = "MULTI_MARKED",
|
|
|
|
.join_unmarked = join_active,
|
|
|
|
.join_waitmarked = join_active,
|
|
|
|
.join_marked = join_marked,
|
|
|
|
.leave_unmarked = leave_active,
|
|
|
|
.leave_waitmarked = leave_active,
|
|
|
|
.leave_marked = leave_marked,
|
|
|
|
.entry = transition_to_marked,
|
|
|
|
};
|
|
|
|
struct conference_state *CONF_STATE_MULTI_MARKED = &STATE_MULTI_MARKED;
|
|
|
|
|
|
|
|
static void join_active(struct conference_bridge_user *cbu)
|
|
|
|
{
|
|
|
|
conf_add_user_active(cbu->conference_bridge, cbu);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void join_marked(struct conference_bridge_user *cbu)
|
|
|
|
{
|
|
|
|
conf_add_user_marked(cbu->conference_bridge, cbu);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void leave_active(struct conference_bridge_user *cbu)
|
|
|
|
{
|
|
|
|
conf_remove_user_active(cbu->conference_bridge, cbu);
|
|
|
|
if (cbu->conference_bridge->activeusers == 1) {
|
|
|
|
conf_change_state(cbu, CONF_STATE_SINGLE_MARKED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void leave_marked(struct conference_bridge_user *cbu)
|
|
|
|
{
|
|
|
|
struct conference_bridge_user *cbu_iter;
|
|
|
|
|
|
|
|
conf_remove_user_marked(cbu->conference_bridge, cbu);
|
|
|
|
|
|
|
|
if (cbu->conference_bridge->markedusers == 0) {
|
|
|
|
/* Play back the audio prompt saying the leader has left the conference */
|
|
|
|
if (!ast_test_flag(&cbu->u_profile, USER_OPT_QUIET)) {
|
|
|
|
ao2_unlock(cbu->conference_bridge);
|
|
|
|
ast_autoservice_start(cbu->chan);
|
|
|
|
play_sound_file(cbu->conference_bridge,
|
|
|
|
conf_get_sound(CONF_SOUND_LEADER_HAS_LEFT, cbu->b_profile.sounds));
|
|
|
|
ast_autoservice_stop(cbu->chan);
|
|
|
|
ao2_lock(cbu->conference_bridge);
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_LIST_TRAVERSE_SAFE_BEGIN(&cbu->conference_bridge->active_list, cbu_iter, list) {
|
|
|
|
/* Kick ENDMARKED cbu_iters */
|
|
|
|
if (ast_test_flag(&cbu_iter->u_profile, USER_OPT_ENDMARKED)) {
|
|
|
|
AST_LIST_REMOVE_CURRENT(list);
|
|
|
|
cbu_iter->conference_bridge->activeusers--;
|
|
|
|
cbu_iter->kicked = 1;
|
|
|
|
ast_bridge_remove(cbu_iter->conference_bridge->bridge, cbu_iter->chan);
|
|
|
|
} else if (ast_test_flag(&cbu_iter->u_profile, USER_OPT_WAITMARKED) &&
|
|
|
|
!ast_test_flag(&cbu_iter->u_profile, USER_OPT_MARKEDUSER)) {
|
|
|
|
AST_LIST_REMOVE_CURRENT(list);
|
|
|
|
cbu_iter->conference_bridge->activeusers--;
|
|
|
|
AST_LIST_INSERT_TAIL(&cbu_iter->conference_bridge->waiting_list, cbu_iter, list);
|
|
|
|
cbu_iter->conference_bridge->waitingusers++;
|
|
|
|
/* Handle muting/moh of cbu_iter if necessary */
|
|
|
|
if (ast_test_flag(&cbu_iter->u_profile, USER_OPT_MUSICONHOLD)) {
|
2012-12-13 21:28:15 +00:00
|
|
|
cbu_iter->features.mute = 1;
|
|
|
|
conf_moh_start(cbu_iter);
|
Resolve issues in ConfBridge regarding marked, waitmarked, and unmarked users
Thank's to Neil Tallim (flan)'s tireless testing, issue reporting, and patches
it became clear that app_confbridge had some complex logic in how it handled
interactions between marked, waitmarked, and unmarked users. In particular,
there were some areas in which the interactions between the users resulted
in inconsistent behavior, and app_confbridge was missing logic in how to handle
some corner cases. Some areas included:
* Poor handling of mixing unmarked and waitmarked users
* Inconsistencies in how MOH and muting was applied to various users
* Handling of various announcements for different user profile options
flan's patches seem to fix the various issues, but highlighted how hard the
code could be to maintain. In an attempt to make things easier to maintain and
to more fully enumerate the various cases that exist, this patch breaks up the
logic into a state machine-like setup.
Please note that the various state transitioned are documented on the Asterisk
wiki:
https://wiki.asterisk.org/wiki/display/AST/Confbridge+state+changes
Review: //https://reviewboard.asterisk.org/r/2072/
Note that for the following issues, mjordan uploaded the patch, although it
was written by twilson. Any contributor license discrepency is due to that.
(closes issue ASTERISK-19562)
Reported by: flan
Tested by: flan, mjordan, jrose
patches:
bugASTERISK-19562_ASTERISK-19726_ASTERISK-20181.patch uploaded by twilson (license 6283)
(closes issue ASTERISK-19726)
Reported by: flan
Tested by: flan
patches:
bugASTERISK-19562_ASTERISK-19726_ASTERISK-20181.patch uploaded by twilson (license 6283)
(closes issue ASTERISK-20181)
Reported by: Jonathan White
Tested by: Jonathan White
patches:
bugASTERISK-19562_ASTERISK-19726_ASTERISK-20181.patch uploaded by twilson (license 6283)
........
Merged revisions 374652 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 374657 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374658 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-10-08 18:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AST_LIST_TRAVERSE_SAFE_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (cbu->conference_bridge->activeusers) {
|
|
|
|
case 0:
|
|
|
|
/* Implies markedusers == 0 */
|
|
|
|
switch (cbu->conference_bridge->waitingusers) {
|
|
|
|
case 0:
|
|
|
|
conf_change_state(cbu, CONF_STATE_EMPTY);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
conf_change_state(cbu, CONF_STATE_INACTIVE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
switch (cbu->conference_bridge->markedusers) {
|
|
|
|
case 0:
|
|
|
|
conf_change_state(cbu, CONF_STATE_SINGLE);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
/* XXX I seem to remember doing this for a reason, but right now it escapes me
|
|
|
|
* how we could possibly ever have a waiting user while we have a marked user */
|
|
|
|
switch (cbu->conference_bridge->waitingusers) {
|
|
|
|
case 0:
|
|
|
|
conf_change_state(cbu, CONF_STATE_SINGLE_MARKED);
|
|
|
|
break;
|
|
|
|
case 1: break; /* Stay in marked */
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
switch (cbu->conference_bridge->markedusers) {
|
|
|
|
case 0:
|
|
|
|
conf_change_state(cbu, CONF_STATE_MULTI);
|
|
|
|
break;
|
|
|
|
default: break; /* Stay in marked */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void transition_to_marked(struct conference_bridge_user *cbu)
|
|
|
|
{
|
|
|
|
struct conference_bridge_user *cbu_iter;
|
|
|
|
|
|
|
|
/* Play the audio file stating they are going to be placed into the conference */
|
|
|
|
if (cbu->conference_bridge->markedusers == 1 && ast_test_flag(&cbu->u_profile, USER_OPT_MARKEDUSER)) {
|
|
|
|
conf_handle_first_marked_common(cbu);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Move all waiting users to active, stopping MOH and umuting if necessary */
|
|
|
|
AST_LIST_TRAVERSE_SAFE_BEGIN(&cbu->conference_bridge->waiting_list, cbu_iter, list) {
|
|
|
|
AST_LIST_REMOVE_CURRENT(list);
|
|
|
|
cbu->conference_bridge->waitingusers--;
|
|
|
|
AST_LIST_INSERT_TAIL(&cbu->conference_bridge->active_list, cbu_iter, list);
|
|
|
|
cbu->conference_bridge->activeusers++;
|
2012-12-13 21:28:15 +00:00
|
|
|
if (cbu_iter->playing_moh) {
|
|
|
|
conf_moh_stop(cbu_iter);
|
Resolve issues in ConfBridge regarding marked, waitmarked, and unmarked users
Thank's to Neil Tallim (flan)'s tireless testing, issue reporting, and patches
it became clear that app_confbridge had some complex logic in how it handled
interactions between marked, waitmarked, and unmarked users. In particular,
there were some areas in which the interactions between the users resulted
in inconsistent behavior, and app_confbridge was missing logic in how to handle
some corner cases. Some areas included:
* Poor handling of mixing unmarked and waitmarked users
* Inconsistencies in how MOH and muting was applied to various users
* Handling of various announcements for different user profile options
flan's patches seem to fix the various issues, but highlighted how hard the
code could be to maintain. In an attempt to make things easier to maintain and
to more fully enumerate the various cases that exist, this patch breaks up the
logic into a state machine-like setup.
Please note that the various state transitioned are documented on the Asterisk
wiki:
https://wiki.asterisk.org/wiki/display/AST/Confbridge+state+changes
Review: //https://reviewboard.asterisk.org/r/2072/
Note that for the following issues, mjordan uploaded the patch, although it
was written by twilson. Any contributor license discrepency is due to that.
(closes issue ASTERISK-19562)
Reported by: flan
Tested by: flan, mjordan, jrose
patches:
bugASTERISK-19562_ASTERISK-19726_ASTERISK-20181.patch uploaded by twilson (license 6283)
(closes issue ASTERISK-19726)
Reported by: flan
Tested by: flan
patches:
bugASTERISK-19562_ASTERISK-19726_ASTERISK-20181.patch uploaded by twilson (license 6283)
(closes issue ASTERISK-20181)
Reported by: Jonathan White
Tested by: Jonathan White
patches:
bugASTERISK-19562_ASTERISK-19726_ASTERISK-20181.patch uploaded by twilson (license 6283)
........
Merged revisions 374652 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 374657 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374658 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-10-08 18:48:34 +00:00
|
|
|
}
|
|
|
|
/* only unmute them if they are not supposed to start muted */
|
|
|
|
if (!ast_test_flag(&cbu_iter->u_profile, USER_OPT_STARTMUTED)) {
|
|
|
|
cbu_iter->features.mute = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AST_LIST_TRAVERSE_SAFE_END;
|
|
|
|
}
|