summaryrefslogtreecommitdiff
path: root/res/parking
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2013-07-08 15:59:47 +0000
committerJonathan Rose <jrose@digium.com>2013-07-08 15:59:47 +0000
commitb083a4cdae461b9e6e6326cb882ffd78e354347d (patch)
treed43b1dfdce507f6ce5219ff6012e85635ce83ff6 /res/parking
parent7ee5b025f44656edae72ada703832fb093dcfde1 (diff)
res_parking: Apply ringing role option on swap with a channel that rings
(closes issue ASTERISK-21877) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/2656/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393815 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/parking')
-rw-r--r--res/parking/parking_bridge.c17
-rw-r--r--res/parking/parking_controller.c21
-rw-r--r--res/parking/res_parking.h5
3 files changed, 32 insertions, 11 deletions
diff --git a/res/parking/parking_bridge.c b/res/parking/parking_bridge.c
index d0566a898..75bd62bf9 100644
--- a/res/parking/parking_bridge.c
+++ b/res/parking/parking_bridge.c
@@ -219,6 +219,7 @@ static int bridge_parking_push(struct ast_bridge_parking *self, struct ast_bridg
}
if (swap) {
+ int use_ringing = 0;
ao2_lock(swap);
pu = swap->bridge_pvt;
if (!pu) {
@@ -236,15 +237,21 @@ static int bridge_parking_push(struct ast_bridge_parking *self, struct ast_bridg
/* TODO Add a parked call swap message type to relay information about parked channel swaps */
+ if (ast_bridge_channel_has_role(swap, "holding_participant")) {
+ const char *idle_mode = ast_bridge_channel_get_role_option(swap, "holding_participant", "idle_mode");
+ if (!ast_strlen_zero(idle_mode) && !strcmp(idle_mode, "ringing")) {
+ use_ringing = 1;
+ }
+ }
+
ao2_unlock(swap);
parking_set_duration(bridge_channel->features, pu);
- /* BUGBUG Adding back local channel swapping made us not hear music on hold for the channel that got swapped
- * into the parking lot. Setting the roels back up gets around that, but we still need to deal with the ringing option
- * to the park application here somehow.
- */
- parking_channel_set_roles(bridge_channel->chan, self->lot, 0);
+ if (parking_channel_set_roles(bridge_channel->chan, self->lot, use_ringing)) {
+ ast_log(LOG_WARNING, "Failed to apply holding bridge roles to %s while joining the parking lot.\n",
+ ast_channel_name(bridge_channel->chan));
+ }
return 0;
}
diff --git a/res/parking/parking_controller.c b/res/parking/parking_controller.c
index aa2baf5cc..ec34cd483 100644
--- a/res/parking/parking_controller.c
+++ b/res/parking/parking_controller.c
@@ -54,17 +54,28 @@ struct ast_bridge *parking_lot_get_bridge(struct parking_lot *lot)
return lot_bridge;
}
-void parking_channel_set_roles(struct ast_channel *chan, struct parking_lot *lot, int force_ringing)
+int parking_channel_set_roles(struct ast_channel *chan, struct parking_lot *lot, int force_ringing)
{
- ast_channel_add_bridge_role(chan, "holding_participant");
+ if (ast_channel_add_bridge_role(chan, "holding_participant")) {
+ return -1;
+ }
+
if (force_ringing) {
- ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "ringing");
+ if (ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "ringing")) {
+ return -1;
+ }
} else {
- ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "musiconhold");
+ if (ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "musiconhold")) {
+ return -1;
+ }
if (!ast_strlen_zero(lot->cfg->mohclass)) {
- ast_channel_set_bridge_role_option(chan, "holding_participant", "moh_class", lot->cfg->mohclass);
+ if (ast_channel_set_bridge_role_option(chan, "holding_participant", "moh_class", lot->cfg->mohclass)) {
+ return -1;
+ }
}
}
+
+ return 0;
}
struct parking_limits_pvt {
diff --git a/res/parking/res_parking.h b/res/parking/res_parking.h
index b128ee335..78ad9117d 100644
--- a/res/parking/res_parking.h
+++ b/res/parking/res_parking.h
@@ -214,8 +214,11 @@ void parked_call_retrieve_enable_features(struct ast_channel *chan, struct parki
* \param chan Entering channel
* \param lot The parking lot the channel will be entering
* \param force_ringing Use ringing instead of music on hold
+ *
+ * \retval 0 on success
+ * \retval non-zero on failure
*/
-void parking_channel_set_roles(struct ast_channel *chan, struct parking_lot *lot, int force_ringing);
+int parking_channel_set_roles(struct ast_channel *chan, struct parking_lot *lot, int force_ringing);
/*!
* \since 12.0.0