Exemple #1
0
static void defer_bridge_add_dtor(void *obj)
{
    struct defer_bridge_add_obj *defer = obj;

    ao2_cleanup(defer->bridge);
    ast_channel_cleanup(defer->swap);
}
Exemple #2
0
static void control_dtor(void *obj)
{
	struct stasis_app_control *control = obj;

	ao2_cleanup(control->command_queue);

	ast_channel_cleanup(control->channel);
	ao2_cleanup(control->app);

	ast_cond_destroy(&control->wait_cond);
	AST_LIST_HEAD_DESTROY(&control->add_rules);
	AST_LIST_HEAD_DESTROY(&control->remove_rules);
}
Exemple #3
0
/*! \brief Destructor for snoop structure */
static void snoop_destroy(void *obj)
{
	struct stasis_app_snoop *snoop = obj;

	if (snoop->timer) {
		ast_timer_close(snoop->timer);
	}

	if (snoop->spy_active) {
		ast_audiohook_destroy(&snoop->spy);
	}

	if (snoop->whisper_active) {
		ast_audiohook_destroy(&snoop->whisper);
	}

	ast_free(snoop->app);

	ast_channel_cleanup(snoop->chan);
}
Exemple #4
0
static char *assign_uuid(struct ast_json *json_channel)
{
	const char *channel_name = ast_json_string_get(ast_json_object_get(json_channel, "name"));
	enum hep_uuid_type uuid_type = hepv3_get_uuid_type();
	char *uuid = NULL;

	if (!channel_name) {
		return NULL;
	}

	if (uuid_type == HEP_UUID_TYPE_CALL_ID) {
		struct ast_channel *chan = NULL;
		char buf[128];

		if (ast_begins_with(channel_name, "PJSIP")) {
			chan = ast_channel_get_by_name(channel_name);

			if (chan && !ast_func_read(chan, "CHANNEL(pjsip,call-id)", buf, sizeof(buf))) {
				uuid = ast_strdup(buf);
			}
		} else if (ast_begins_with(channel_name, "SIP")) {
			chan = ast_channel_get_by_name(channel_name);

			if (chan && !ast_func_read(chan, "SIP_HEADER(call-id)", buf, sizeof(buf))) {
				uuid = ast_strdup(buf);
			}
		}

		ast_channel_cleanup(chan);
	}

	/* If we couldn't get the call-id or didn't want it, just use the channel name */
	if (!uuid) {
		uuid = ast_strdup(channel_name);
	}

	return uuid;
}
Exemple #5
0
static struct ast_channel *prepare_bridge_media_channel(const char *type)
{
	RAII_VAR(struct ast_format_cap *, cap, NULL, ao2_cleanup);
	struct ast_channel *chan;

	cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
	if (!cap) {
		return NULL;
	}

	ast_format_cap_append(cap, ast_format_slin, 0);

	chan = ast_request(type, cap, NULL, NULL, "ARI", NULL);
	if (!chan) {
		return NULL;
	}

	if (stasis_app_channel_unreal_set_internal(chan)) {
		ast_channel_cleanup(chan);
		return NULL;
	}
	return chan;
}
Exemple #6
0
static int manager_park(struct mansession *s, const struct message *m)
{
	const char *channel = astman_get_header(m, "Channel");
	const char *timeout_channel = S_OR(astman_get_header(m, "TimeoutChannel"), astman_get_header(m, "Channel2"));
	const char *announce_channel = astman_get_header(m, "AnnounceChannel");
	const char *timeout = astman_get_header(m, "Timeout");
	const char *parkinglot = astman_get_header(m, "Parkinglot");
	char buf[BUFSIZ];
	int timeout_override = -1;

	RAII_VAR(struct ast_channel *, parker_chan, NULL, ao2_cleanup);
	RAII_VAR(struct ast_channel *, chan, NULL, ao2_cleanup);

	if (ast_strlen_zero(channel)) {
		astman_send_error(s, m, "Channel not specified");
		return 0;
	}

	if (!ast_strlen_zero(timeout)) {
		if (sscanf(timeout, "%30d", &timeout_override) != 1 || timeout < 0) {
			astman_send_error(s, m, "Invalid Timeout value.");
			return 0;
		}

		if (timeout_override > 0) {
			/* If greater than zero, convert to seconds for internal use. Must be >= 1 second. */
			timeout_override = MAX(1, timeout_override / 1000);
		}
	}

	if (!(chan = ast_channel_get_by_name(channel))) {
		snprintf(buf, sizeof(buf), "Channel does not exist: %s", channel);
		astman_send_error(s, m, buf);
		return 0;
	}

	ast_channel_lock(chan);
	if (!ast_strlen_zero(timeout_channel)) {
		ast_bridge_set_transfer_variables(chan, timeout_channel, 0);
	}
	ast_channel_unlock(chan);

	parker_chan = ast_channel_bridge_peer(chan);
	if (!parker_chan || strcmp(ast_channel_name(parker_chan), timeout_channel)) {
		if (!ast_strlen_zero(announce_channel)) {
			struct ast_channel *announce_chan = ast_channel_get_by_name(announce_channel);
			if (!announce_channel) {
				astman_send_error(s, m, "AnnounceChannel does not exist");
				return 0;
			}

			create_parked_subscription(announce_chan, ast_channel_uniqueid(chan), 0);
			ast_channel_cleanup(announce_chan);
		}

		manager_park_unbridged(s, m, chan, parkinglot, timeout_override);
		return 0;
	}

	if (!ast_strlen_zero(announce_channel) && strcmp(announce_channel, timeout_channel)) {
		/* When using an announce_channel in bridge mode, only add the announce channel if it isn't
		 * the same as the timeout channel (which will play announcements anyway) */
		struct ast_channel *announce_chan = ast_channel_get_by_name(announce_channel);
		if (!announce_channel) {
			astman_send_error(s, m, "AnnounceChannel does not exist");
			return 0;
		}

		create_parked_subscription(announce_chan, ast_channel_uniqueid(chan), 0);
		ast_channel_cleanup(announce_chan);
	}

	manager_park_bridged(s, m, chan, parker_chan, parkinglot, timeout_override);
	return 0;
}
static void channel_cleanup_wrapper(void *data)
{
	struct ast_channel *chan = data;
	ast_channel_cleanup(chan);
}