Exemplo n.º 1
0
/*!
 * \internal
 * \brief Push this channel into the Stasis bridge.
 * \since 12.5.0
 *
 * \param self Bridge to operate upon.
 * \param bridge_channel Bridge channel to push.
 * \param swap Bridge channel to swap places with if not NULL.
 *
 * \note On entry, self is already locked.
 *
 * \retval 0 on success.
 * \retval -1 on failure.  The channel did not get pushed.
 */
static int bridge_stasis_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
{
    struct stasis_app_control *control = stasis_app_control_find_by_channel(bridge_channel->chan);

    if (!control && !stasis_app_channel_is_internal(bridge_channel->chan)) {
        /* channel not in Stasis(), get it there */
        ast_debug(1, "Bridge %s: pushing non-stasis %p(%s) setup to come back in under stasis\n",
                  self->uniqueid, bridge_channel, ast_channel_name(bridge_channel->chan));

        /* Attach after-bridge callback and pass ownership of swap_app to it */
        if (ast_bridge_set_after_callback(bridge_channel->chan,
                                          bridge_stasis_run_cb, NULL, NULL)) {
            ast_log(LOG_ERROR,
                    "Failed to set after bridge callback for bridge %s non-stasis push of %s\n",
                    self->uniqueid, ast_channel_name(bridge_channel->chan));
            return -1;
        }

        bridge_stasis_queue_join_action(self, bridge_channel, swap);

        /* Return -1 so the push fails and the after-bridge callback gets called
         * This keeps the bridging framework from putting the channel into the bridge
         * until the Stasis thread gets started, and then the channel is put into the bridge.
         */
        return -1;
    }

    /*
     * If going into a holding bridge, default the role to participant, if
     * it has no compatible role currently
     */
    if ((self->technology->capabilities & AST_BRIDGE_CAPABILITY_HOLDING)
            && !ast_channel_has_role(bridge_channel->chan, "announcer")
            && !ast_channel_has_role(bridge_channel->chan, "holding_participant")) {
        if (ast_channel_add_bridge_role(bridge_channel->chan, "holding_participant")) {
            ast_log(LOG_ERROR, "Failed to set holding participant on %s\n", ast_channel_name(bridge_channel->chan));
            return -1;
        }

        if (ast_channel_set_bridge_role_option(bridge_channel->chan, "holding_participant", "idle_mode", "none")) {
            ast_log(LOG_ERROR, "Failed to set holding participant mode on %s\n", ast_channel_name(bridge_channel->chan));
            return -1;
        }
    }

    ao2_cleanup(control);
    if (self->allowed_capabilities & STASIS_BRIDGE_MIXING_CAPABILITIES) {
        ast_bridge_channel_update_linkedids(bridge_channel, swap);
        if (ast_test_flag(&self->feature_flags, AST_BRIDGE_FLAG_SMART)) {
            ast_bridge_channel_update_accountcodes(bridge_channel, swap);
        }
    }

    return ast_bridge_base_v_table.push(self, bridge_channel, swap);
}
Exemplo n.º 2
0
static int apply_option_entertainment(struct ast_channel *chan, const char *entertainment_arg)
{
    char entertainment = entertainment_arg[0];

    switch (entertainment) {
    case 'm':
        return ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "musiconhold");
    case 'r':
        return ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "ringing");
    case 's':
        return ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "silence");
    case 'h':
        return ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "hold");
    case 'n':
        return ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "none");
    default:
        ast_log(LOG_ERROR, "Invalid argument for BridgeWait entertainment '%s'\n", entertainment_arg);
        return -1;
    }
}
Exemplo n.º 3
0
int parking_channel_set_roles(struct ast_channel *chan, struct parking_lot *lot, int force_ringing)
{
	if (ast_channel_add_bridge_role(chan, "holding_participant")) {
		return -1;
	}

	if (force_ringing) {
		if (ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "ringing")) {
			return -1;
		}
	} else {
		if (ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "musiconhold")) {
			return -1;
		}
		if (!ast_strlen_zero(lot->cfg->mohclass)) {
			if (ast_channel_set_bridge_role_option(chan, "holding_participant", "moh_class", lot->cfg->mohclass)) {
				return -1;
			}
		}
	}

	return 0;
}
Exemplo n.º 4
0
static int apply_option_moh(struct ast_channel *chan, const char *class_arg)
{
    return ast_channel_set_bridge_role_option(chan, "holding_participant", "moh_class", class_arg);
}