当前位置: 首页>>代码示例>>C++>>正文


C++ stasis_message_data函数代码示例

本文整理汇总了C++中stasis_message_data函数的典型用法代码示例。如果您正苦于以下问题:C++ stasis_message_data函数的具体用法?C++ stasis_message_data怎么用?C++ stasis_message_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了stasis_message_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: consumer_exec

static void consumer_exec(void *data, struct stasis_subscription *sub, struct stasis_message *message)
{
    struct consumer *consumer = data;
    struct stasis_cache_update *cache_update = stasis_message_data(message);
    struct ast_device_state_message *device_state;

    if (!cache_update->new_snapshot) {
        return;
    }

    device_state = stasis_message_data(cache_update->new_snapshot);

    if (strcmp(device_state->device, UNIT_TEST_DEVICE_IDENTIFIER)) {
        /* not a device state we're interested in */
        return;
    }

    {
        SCOPED_AO2LOCK(lock, consumer);

        ++consumer->event_count;
        if (device_state->eid) {
            consumer->state = device_state->state;
            if (consumer->sig_on_non_aggregate_state) {
                consumer->sig_on_non_aggregate_state = 0;
                consumer->already_out = 1;
                ast_cond_signal(&consumer->out);
            }
        } else {
            consumer->aggregate_state = device_state->state;
            consumer->already_out = 1;
            ast_cond_signal(&consumer->out);
        }
    }
}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:35,代码来源:test_devicestate.c

示例2: sub_endpoint_update_handler

static void sub_endpoint_update_handler(void *data,
	struct stasis_subscription *sub,
	struct stasis_message *message)
{
	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
	struct stasis_app *app = data;
	struct stasis_cache_update *update;
	struct ast_endpoint_snapshot *new_snapshot;
	struct ast_endpoint_snapshot *old_snapshot;
	const struct timeval *tv;

	ast_assert(stasis_message_type(message) == stasis_cache_update_type());

	update = stasis_message_data(message);

	ast_assert(update->type == ast_endpoint_snapshot_type());

	new_snapshot = stasis_message_data(update->new_snapshot);
	old_snapshot = stasis_message_data(update->old_snapshot);

	if (new_snapshot) {
		tv = stasis_message_timestamp(update->new_snapshot);

		json = simple_endpoint_event("EndpointStateChange", new_snapshot, tv);
		if (!json) {
			return;
		}

		app_send(app, json);
	}

	if (!new_snapshot && old_snapshot) {
		unsubscribe(app, "endpoint", old_snapshot->id, 1);
	}
}
开发者ID:lyx2014,项目名称:Asterisk,代码行数:35,代码来源:app.c

示例3: confbridge_publish_manager_event

static void confbridge_publish_manager_event(
	struct stasis_message *message,
	const char *event,
	struct ast_str *extra_text)
{
	struct ast_bridge_blob *blob = stasis_message_data(message);
	const char *conference_name;
	RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);
	RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);

	ast_assert(blob != NULL);
	ast_assert(event != NULL);

	bridge_text = ast_manager_build_bridge_state_string(blob->bridge);
	if (!bridge_text) {
		return;
	}

	conference_name = ast_json_string_get(ast_json_object_get(blob->blob, "conference"));
	ast_assert(conference_name != NULL);

	if (blob->channel) {
		channel_text = ast_manager_build_channel_state_string(blob->channel);
	}

	manager_event(EVENT_FLAG_CALL, event,
		"Conference: %s\r\n"
		"%s"
		"%s"
		"%s",
		conference_name,
		ast_str_buffer(bridge_text),
		S_COR(channel_text, ast_str_buffer(channel_text), ""),
		S_COR(extra_text, ast_str_buffer(extra_text), ""));
}
开发者ID:huangjingpei,项目名称:asterisk,代码行数:35,代码来源:confbridge_manager.c

示例4: stasis_message_data

static struct ast_manager_event_blob *system_registry_to_ami(struct stasis_message *message)
{
    struct ast_json_payload *payload = stasis_message_data(message);
    const char *channeltype;
    const char *username;
    const char *domain;
    const char *status;
    const char *cause;
    RAII_VAR(struct ast_str *, cause_string, ast_str_create(32), ast_free);

    if (!cause_string) {
        return NULL;
    }

    channeltype = ast_json_string_get(ast_json_object_get(payload->json, "channeltype"));
    username = ast_json_string_get(ast_json_object_get(payload->json, "username"));
    domain = ast_json_string_get(ast_json_object_get(payload->json, "domain"));
    status = ast_json_string_get(ast_json_object_get(payload->json, "status"));
    cause = ast_json_string_get(ast_json_object_get(payload->json, "cause"));

    if (!ast_strlen_zero(cause)) {
        ast_str_set(&cause_string, 0, "Cause: %s\r\n", cause);
    }

    return ast_manager_event_blob_create(EVENT_FLAG_SYSTEM, "Registry",
                                         "ChannelType: %s\r\n"
                                         "Username: %s\r\n"
                                         "Domain: %s\r\n"
                                         "Status: %s\r\n"
                                         "%s",
                                         channeltype, username, domain, status, ast_str_buffer(cause_string));
}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:32,代码来源:stasis_system.c

示例5: cache_update_cb

static void cache_update_cb(void *data, struct stasis_subscription *sub,
	struct stasis_message *message)
{
	struct stasis_cache_update *update = stasis_message_data(message);
	struct ast_endpoint_snapshot *old_snapshot;
	struct ast_endpoint_snapshot *new_snapshot;

	if (ast_endpoint_snapshot_type() != update->type) {
		return;
	}

	old_snapshot = stasis_message_data(update->old_snapshot);
	new_snapshot = stasis_message_data(update->new_snapshot);

	handle_endpoint_update(old_snapshot, new_snapshot);
}
开发者ID:MattheusNiels,项目名称:BackupCerberus,代码行数:16,代码来源:res_endpoint_stats.c

示例6: parking_event_cb

static void parking_event_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
{
	if (stasis_message_type(message) == ast_parked_call_type()) {
		struct ast_parked_call_payload *parked_call_message = stasis_message_data(message);
		parked_call_message_response(parked_call_message);
	}
}
开发者ID:lyx2014,项目名称:Asterisk,代码行数:7,代码来源:parking_manager.c

示例7: stasis_message_data

static struct ast_json *dtmf_end_to_json(
	struct stasis_message *message,
	const struct stasis_message_sanitizer *sanitize)
{
	struct ast_channel_blob *channel_blob = stasis_message_data(message);
	struct ast_json *blob = channel_blob->blob;
	struct ast_channel_snapshot *snapshot = channel_blob->snapshot;
	const char *direction =
		ast_json_string_get(ast_json_object_get(blob, "direction"));
	const struct timeval *tv = stasis_message_timestamp(message);
	struct ast_json *json_channel = ast_channel_snapshot_to_json(snapshot, sanitize);

	/* Only present received DTMF end events as JSON */
	if (strcasecmp("Received", direction) != 0) {
		return NULL;
	}

	if (!json_channel) {
		return NULL;
	}

	return ast_json_pack("{s: s, s: o, s: O, s: O, s: o}",
		"type", "ChannelDtmfReceived",
		"timestamp", ast_json_timeval(*tv, NULL),
		"digit", ast_json_object_get(blob, "digit"),
		"duration_ms", ast_json_object_get(blob, "duration_ms"),
		"channel", json_channel);
}
开发者ID:jcollie,项目名称:asterisk,代码行数:28,代码来源:stasis_channels.c

示例8: channel_enter_cb

static void channel_enter_cb(void *data, struct stasis_subscription *sub,
				    struct stasis_message *message)
{
	static const char *swap_name = "SwapUniqueid: ";
	struct ast_bridge_blob *blob = stasis_message_data(message);
	RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);
	RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);
	const char *swap_id;

	bridge_text = ast_manager_build_bridge_state_string(blob->bridge);
	channel_text = ast_manager_build_channel_state_string(blob->channel);
	if (!bridge_text || !channel_text) {
		return;
	}

	swap_id = ast_json_string_get(ast_json_object_get(blob->blob, "swap"));

	manager_event(EVENT_FLAG_CALL, "BridgeEnter",
		"%s"
		"%s"
		"%s%s%s",
		ast_str_buffer(bridge_text),
		ast_str_buffer(channel_text),
		swap_id ? swap_name : "",
		S_OR(swap_id, ""),
		swap_id ? "\r\n" : "");
}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:27,代码来源:manager_bridges.c

示例9: stasis_message_data

static struct ast_manager_event_blob *call_pickup_to_ami(struct stasis_message *message)
{
	struct ast_multi_channel_blob *contents = stasis_message_data(message);
	struct ast_channel_snapshot *chan;
	struct ast_channel_snapshot *target;
	struct ast_manager_event_blob *res;

	RAII_VAR(struct ast_str *, channel_str, NULL, ast_free);
	RAII_VAR(struct ast_str *, target_str, NULL, ast_free);

	chan = ast_multi_channel_blob_get_channel(contents, "channel");
	target = ast_multi_channel_blob_get_channel(contents, "target");

	ast_assert(chan != NULL && target != NULL);

	if (!(channel_str = ast_manager_build_channel_state_string(chan))) {
		return NULL;
	}

	if (!(target_str = ast_manager_build_channel_state_string_prefix(target, "Target"))) {
		return NULL;
	}

	res = ast_manager_event_blob_create(EVENT_FLAG_CALL, "Pickup",
		"%s"
		"%s",
		ast_str_buffer(channel_str),
		ast_str_buffer(target_str));

	return res;
}
开发者ID:huangjingpei,项目名称:asterisk,代码行数:31,代码来源:pickup.c

示例10: ast_ari_channels_get

void ast_ari_channels_get(struct ast_variable *headers,
	struct ast_ari_channels_get_args *args,
	struct ast_ari_response *response)
{
	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
	struct stasis_cache *cache;
	struct ast_channel_snapshot *snapshot;

	cache = ast_channel_cache();
	if (!cache) {
		ast_ari_response_error(
			response, 500, "Internal Server Error",
			"Message bus not initialized");
		return;
	}

	msg = stasis_cache_get(cache, ast_channel_snapshot_type(),
				   args->channel_id);
	if (!msg) {
		ast_ari_response_error(
			response, 404, "Not Found",
			"Channel not found");
		return;
	}

	snapshot = stasis_message_data(msg);
	ast_assert(snapshot != NULL);

	ast_ari_response_ok(response,
				ast_channel_snapshot_to_json(snapshot, NULL));
}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:31,代码来源:resource_channels.c

示例11: find_route

static int find_route(
	struct stasis_message_router *router,
	struct stasis_message *message,
	struct stasis_message_route *route_out)
{
	struct stasis_message_route *route = NULL;
	struct stasis_message_type *type = stasis_message_type(message);
	SCOPED_AO2LOCK(lock, router);

	ast_assert(route_out != NULL);

	if (type == stasis_cache_update_type()) {
		/* Find a cache route */
		struct stasis_cache_update *update =
			stasis_message_data(message);
		route = route_table_find(&router->cache_routes, update->type);
	}

	if (route == NULL) {
		/* Find a regular route */
		route = route_table_find(&router->routes, type);
	}

	if (route == NULL && router->default_route.callback) {
		/* Maybe the default route, then? */
		route = &router->default_route;
	}

	if (!route) {
		return -1;
	}

	*route_out = *route;
	return 0;
}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:35,代码来源:stasis_message_router.c

示例12: stasis_topic_wait

int stasis_topic_wait(struct stasis_topic *topic)
{
	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
	RAII_VAR(struct stasis_subscription *, sub, NULL, stasis_unsubscribe);
	struct caching_guarantee *guarantee;

	msg = caching_guarantee_create();
	if (!msg) {
		return -1;
	}

	sub = stasis_subscribe(topic, guarantee_handler, msg);
	if (!sub) {
		return -1;
	}

	guarantee = stasis_message_data(msg);

	ast_mutex_lock(&guarantee->lock);
	stasis_publish(topic, msg);
	while (!guarantee->done) {
		ast_cond_wait(&guarantee->cond, &guarantee->lock);
	}
	ast_mutex_unlock(&guarantee->lock);
	return 0;
}
开发者ID:hardikk,项目名称:asterisk,代码行数:26,代码来源:stasis_wait.c

示例13: mwi_update_cb

static void mwi_update_cb(void *data, struct stasis_subscription *sub,
				    struct stasis_message *message)
{
	struct ast_mwi_state *mwi_state;
	RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);

	if (ast_mwi_state_type() != stasis_message_type(message)) {
		return;
	}

	mwi_state = stasis_message_data(message);
	if (!mwi_state) {
		return;
	}

	if (mwi_state->snapshot) {
		channel_event_string = ast_manager_build_channel_state_string(mwi_state->snapshot);
	}

	/*** DOCUMENTATION
		<managerEventInstance>
			<synopsis>Raised when the state of messages in a voicemail mailbox
			has changed or when a channel has finished interacting with a
			mailbox.</synopsis>
			<syntax>
				<channel_snapshot/>
				<parameter name="Mailbox">
					<para>The mailbox with the new message, specified as <literal>mailbox</literal>@<literal>context</literal></para>
				</parameter>
				<parameter name="Waiting">
					<para>Whether or not the mailbox has messages waiting for it.</para>
				</parameter>
				<parameter name="New">
					<para>The number of new messages.</para>
				</parameter>
				<parameter name="Old">
					<para>The number of old messages.</para>
				</parameter>
			</syntax>
			<description>
				<note><para>The Channel related parameters are only present if a
				channel was involved in the manipulation of a mailbox. If no
				channel is involved, the parameters are not included with the
				event.</para>
				</note>
			</description>
		</managerEventInstance>
	***/
	manager_event(EVENT_FLAG_CALL, "MessageWaiting",
			"%s"
			"Mailbox: %s\r\n"
			"Waiting: %d\r\n"
			"New: %d\r\n"
			"Old: %d\r\n",
			AS_OR(channel_event_string, ""),
			mwi_state->uniqueid,
			ast_app_has_voicemail(mwi_state->uniqueid, NULL),
			mwi_state->new_msgs,
			mwi_state->old_msgs);
}
开发者ID:asterisk,项目名称:asterisk,代码行数:60,代码来源:manager_mwi.c

示例14: RAII_VAR

static struct ast_manager_event_blob *varset_to_ami(struct stasis_message *msg)
{
	RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
	struct ast_channel_blob *obj = stasis_message_data(msg);
	const char *variable =
		ast_json_string_get(ast_json_object_get(obj->blob, "variable"));
	const char *value =
		ast_json_string_get(ast_json_object_get(obj->blob, "value"));

	if (obj->snapshot) {
		channel_event_string =
			ast_manager_build_channel_state_string(obj->snapshot);
	} else {
		channel_event_string = ast_str_create(35);
		ast_str_set(&channel_event_string, 0,
			    "Channel: none\r\n"
			    "Uniqueid: none\r\n");
	}

	if (!channel_event_string) {
		return NULL;
	}

	return ast_manager_event_blob_create(EVENT_FLAG_DIALPLAN, "VarSet",
		"%s"
		"Variable: %s\r\n"
		"Value: %s\r\n",
		ast_str_buffer(channel_event_string), variable, value);
}
开发者ID:jcollie,项目名称:asterisk,代码行数:29,代码来源:stasis_channels.c

示例15: RAII_VAR

struct ast_endpoint_snapshot *ast_endpoint_latest_snapshot(const char *tech,
	const char *name)
{
	RAII_VAR(char *, id, NULL, ast_free);
	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
	struct ast_endpoint_snapshot *snapshot;

	if (ast_strlen_zero(name)) {
		ast_asprintf(&id, "%s", tech);
	} else {
		ast_asprintf(&id, "%s/%s", tech, name);
	}
	if (!id) {
		return NULL;
	}
	ast_tech_to_upper(id);

	msg = stasis_cache_get(ast_endpoint_cache(),
		ast_endpoint_snapshot_type(), id);
	if (!msg) {
		return NULL;
	}

	snapshot = stasis_message_data(msg);
	ast_assert(snapshot != NULL);

	ao2_ref(snapshot, +1);
	return snapshot;
}
开发者ID:alyosha1879,项目名称:asterisk,代码行数:29,代码来源:stasis_endpoints.c


注:本文中的stasis_message_data函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。