Esempio n. 1
0
struct stasis_cp_single *stasis_cp_single_create(struct stasis_cp_all *all,
	const char *name)
{
	RAII_VAR(struct stasis_cp_single *, one, NULL, ao2_cleanup);

	one = ao2_alloc(sizeof(*one), one_dtor);
	if (!one) {
		return NULL;
	}

	one->topic = stasis_topic_create(name);
	if (!one->topic) {
		return NULL;
	}
	one->topic_cached = stasis_caching_topic_create(one->topic, all->cache);
	if (!one->topic_cached) {
		return NULL;
	}

	one->forward_topic_to_all = stasis_forward_all(one->topic, all->topic);
	if (!one->forward_topic_to_all) {
		return NULL;
	}
	one->forward_cached_to_all = stasis_forward_all(
		stasis_caching_get_topic(one->topic_cached), all->topic_cached);
	if (!one->forward_cached_to_all) {
		return NULL;
	}

	ao2_ref(one, +1);
	return one;
}
Esempio n. 2
0
struct stasis_cp_single *stasis_cp_sink_create(struct stasis_cp_all *all,
	const char *name)
{
	struct stasis_cp_single *one;

	one = ao2_t_alloc(sizeof(*one), one_dtor, name);
	if (!one) {
		return NULL;
	}

	one->topic = stasis_topic_create(name);
	if (!one->topic) {
		ao2_ref(one, -1);

		return NULL;
	}

	one->topic_cached = stasis_caching_topic_create(one->topic, all->cache);
	if (!one->topic_cached) {
		ao2_ref(one, -1);

		return NULL;
	}

	return one;
}
Esempio n. 3
0
int ast_stasis_channels_init(void)
{
	int res = 0;

	ast_register_cleanup(stasis_channels_cleanup);

	channel_cache_all = stasis_cp_all_create("ast_channel_topic_all",
		channel_snapshot_get_id);
	if (!channel_cache_all) {
		return -1;
	}
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_agent_login_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_agent_logoff_type);

	channel_cache_by_name = stasis_cache_create(channel_snapshot_get_name);
	if (!channel_cache_by_name) {
		return -1;
	}

	/* This should be initialized before the caching topic */
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_snapshot_type);

	channel_by_name_topic = stasis_caching_topic_create(
		stasis_cp_all_topic(channel_cache_all),
		channel_cache_by_name);
	if (!channel_by_name_topic) {
		return -1;
	}

	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dial_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_varset_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_user_event_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_hangup_request_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_begin_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_end_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_hold_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_unhold_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_chanspy_start_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_chanspy_stop_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_fax_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_hangup_handler_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_moh_start_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_moh_stop_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_monitor_start_type);
	res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_monitor_stop_type);

	return res;
}