您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ switch_event_destroy函数代码示例

51自学网 2021-06-03 08:35:28
  C++
这篇教程C++ switch_event_destroy函数代码示例写得很实用,希望能帮到您。

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

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

示例1: oreka_destroy

static void oreka_destroy(oreka_session_t *oreka){	oreka->usecnt--;	if (!oreka->usecnt) {		if (oreka->invite_extra_headers) {			switch_event_destroy(&oreka->invite_extra_headers);		}		if (oreka->bye_extra_headers) {			switch_event_destroy(&oreka->bye_extra_headers);		}		/* Actual memory for the oreka session was taken from the switch core session pool, the core will take care of it */	}}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:13,


示例2: free_profile_menu_event

void free_profile_menu_event(vmivr_menu_profile_t *menu) {	if (menu->event_keys_dtmf) {		switch_event_destroy(&menu->event_keys_dtmf);	}	if (menu->event_keys_action) {		switch_event_destroy(&menu->event_keys_action);	}	if (menu->event_keys_varname) {		switch_event_destroy(&menu->event_keys_varname);	}	if (menu->event_phrases) {		switch_event_destroy(&menu->event_phrases);	}}
开发者ID:kgrofelnik,项目名称:mod_portaudio-endpoints,代码行数:15,


示例3: subscriber_execute

/** * Execute function for each subscriber */static void subscriber_execute(const char *uuid, const char *signal_type, subscriber_execute_fn callback, void *user_data){    switch_event_t *subscriber_list = NULL;    switch_event_header_t *subscriber = NULL;    /* fetch list of subscribers */    char *key = switch_mprintf("%s:%s", uuid, signal_type);    switch_event_create_subclass(&subscriber_list, SWITCH_EVENT_CLONE, NULL);    switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Subscriber execute %s/n", signal_type);    switch_mutex_lock(globals.subscribers_mutex);    {        switch_hash_index_t *hi = NULL;        switch_hash_t *signal_subscribers = switch_core_hash_find(globals.subscribers, key);        if (signal_subscribers) {            for (hi = switch_core_hash_first(signal_subscribers); hi; hi = switch_core_hash_next(hi)) {                const void *jid;                void *dont_care;                switch_core_hash_this(hi, &jid, NULL, &dont_care);                switch_event_add_header_string(subscriber_list, SWITCH_STACK_BOTTOM, "execute", (const char *)jid);            }        } else {            switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "No subscribers for %s/n", signal_type);        }    }    switch_mutex_unlock(globals.subscribers_mutex);    switch_safe_free(key);    /* execute function for each subscriber */    for (subscriber = subscriber_list->headers; subscriber; subscriber = subscriber->next) {        callback(subscriber->value, user_data);    }    switch_event_destroy(&subscriber_list);}
开发者ID:bodji,项目名称:freeswitch,代码行数:37,


示例4: conference_event_chat_message_broadcast

/* send a message to every member of the conference */void conference_event_chat_message_broadcast(conference_obj_t *conference, switch_event_t *event){	conference_member_t *member = NULL;	switch_event_t *processed;	switch_assert(conference != NULL);	switch_event_create(&processed, SWITCH_EVENT_CHANNEL_DATA);	switch_mutex_lock(conference->member_mutex);	for (member = conference->members; member; member = member->next) {		if (member->session && !conference_utils_member_test_flag(member, MFLAG_NOCHANNEL)) {			const char *presence_id = switch_channel_get_variable(member->channel, "presence_id");			const char *chat_proto = switch_channel_get_variable(member->channel, "chat_proto");			switch_event_t *reply = NULL;			if (presence_id && chat_proto) {				if (switch_event_get_header(processed, presence_id)) {					continue;				}				switch_event_dup(&reply, event);				switch_event_add_header_string(reply, SWITCH_STACK_BOTTOM, "to", presence_id);				switch_event_add_header_string(reply, SWITCH_STACK_BOTTOM, "conference_name", conference->name);				switch_event_add_header_string(reply, SWITCH_STACK_BOTTOM, "conference_domain", conference->domain);				switch_event_set_body(reply, switch_event_get_body(event));				switch_core_chat_deliver(chat_proto, &reply);				switch_event_add_header_string(processed, SWITCH_STACK_BOTTOM, presence_id, "true");			}		}	}	switch_event_destroy(&processed);	switch_mutex_unlock(conference->member_mutex);}
开发者ID:prashantchoudhary,项目名称:FreeswitchModified,代码行数:35,


示例5: conference_event_adv_la

void conference_event_adv_la(conference_obj_t *conference, conference_member_t *member, switch_bool_t join){	//if (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {	switch_channel_set_flag(member->channel, CF_VIDEO_REFRESH_REQ);	switch_core_media_gen_key_frame(member->session);	//}	if (conference && conference->la && member->session &&		!switch_channel_test_flag(member->channel, CF_VIDEO_ONLY)) {		cJSON *msg, *data;		const char *uuid = switch_core_session_get_uuid(member->session);		const char *cookie = switch_channel_get_variable(member->channel, "event_channel_cookie");		const char *event_channel = cookie ? cookie : uuid;		switch_event_t *variables;		switch_event_header_t *hp;		msg = cJSON_CreateObject();		data = json_add_child_obj(msg, "pvtData", NULL);		cJSON_AddItemToObject(msg, "eventChannel", cJSON_CreateString(event_channel));		cJSON_AddItemToObject(msg, "eventType", cJSON_CreateString("channelPvtData"));		cJSON_AddItemToObject(data, "action", cJSON_CreateString(join ? "conference-liveArray-join" : "conference-liveArray-part"));		cJSON_AddItemToObject(data, "laChannel", cJSON_CreateString(conference->la_event_channel));		cJSON_AddItemToObject(data, "laName", cJSON_CreateString(conference->la_name));		cJSON_AddItemToObject(data, "role", cJSON_CreateString(conference_utils_member_test_flag(member, MFLAG_MOD) ? "moderator" : "participant"));		cJSON_AddItemToObject(data, "chatID", cJSON_CreateString(conference->chat_id));		cJSON_AddItemToObject(data, "canvasCount", cJSON_CreateNumber(conference->canvas_count));		if (conference_utils_member_test_flag(member, MFLAG_SECOND_SCREEN)) {			cJSON_AddItemToObject(data, "secondScreen", cJSON_CreateTrue());		}		if (conference_utils_member_test_flag(member, MFLAG_MOD)) {			cJSON_AddItemToObject(data, "modChannel", cJSON_CreateString(conference->mod_event_channel));		}		cJSON_AddItemToObject(data, "chatChannel", cJSON_CreateString(conference->chat_event_channel));		switch_core_get_variables(&variables);		for (hp = variables->headers; hp; hp = hp->next) {			if (!strncasecmp(hp->name, "conference_verto_", 17)) {				char *var = hp->name + 17;				if (var) {					cJSON_AddItemToObject(data, var, cJSON_CreateString(hp->value));				}			}		}		switch_event_destroy(&variables);		switch_event_channel_broadcast(event_channel, &msg, "mod_conference", conference_globals.event_channel_id);		if (cookie) {			switch_event_channel_permission_modify(cookie, conference->la_event_channel, join);			switch_event_channel_permission_modify(cookie, conference->mod_event_channel, join);			switch_event_channel_permission_modify(cookie, conference->chat_event_channel, join);		}	}}
开发者ID:prashantchoudhary,项目名称:FreeswitchModified,代码行数:60,


示例6: menu_instance_free

void menu_instance_free(vmivr_menu_t *menu) {	if (menu->phrase_params) {		switch_event_destroy(&menu->phrase_params);		menu->phrase_params = NULL;	}	memset(&menu->ivre_d, 0, sizeof(menu->ivre_d));}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:7,


示例7: SWITCH_DECLARE

SWITCH_DECLARE(bool) Event::fire(void){	this_check(false);	if (!mine) {		switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Not My event!/n");		return false;	}	if (event) {		switch_event_t *new_event;		if (switch_event_dup(&new_event, event) == SWITCH_STATUS_SUCCESS) {			if (switch_event_fire(&new_event) != SWITCH_STATUS_SUCCESS) {				switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Failed to fire the event!/n");				switch_event_destroy(&new_event);				return false;			}			return true;		} else {			switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Failed to dup the event!/n");		}	} else {		switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to fire an event that does not exist!/n");	}	return false;}
开发者ID:gujun,项目名称:sscore,代码行数:27,


示例8: my_on_reporting

static switch_status_t my_on_reporting(switch_core_session_t *session){	switch_channel_t *channel = switch_core_session_get_channel(session);	switch_status_t status = SWITCH_STATUS_SUCCESS;	const char *template_str = NULL;	char *expanded_vars = NULL, *sql = NULL;	if (globals.shutdown) {		return SWITCH_STATUS_SUCCESS;	}	if (!((globals.legs & CDR_LEG_A) && (globals.legs & CDR_LEG_B))) {		if ((globals.legs & CDR_LEG_A)) {			if (switch_channel_get_originator_caller_profile(channel)) {				return SWITCH_STATUS_SUCCESS;			}		} else {			if (switch_channel_get_originatee_caller_profile(channel)) {				return SWITCH_STATUS_SUCCESS;			}		}	}	if (globals.debug) {		switch_event_t *event;		if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {			char *buf;			switch_channel_event_set_data(channel, event);			switch_event_serialize(event, &buf, SWITCH_FALSE);			switch_assert(buf);			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "CHANNEL_DATA:/n%s/n", buf);			switch_event_destroy(&event);			switch_safe_free(buf);		}	}	template_str = (const char *) switch_core_hash_find(globals.template_hash, globals.default_template);	if (!template_str) {		template_str = default_template;	}	expanded_vars = switch_channel_expand_variables(channel, template_str);	if (!expanded_vars) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error expanding CDR variables./n");		return SWITCH_STATUS_FALSE;	}	sql = switch_mprintf("INSERT INTO %s VALUES (%s)", globals.db_table, expanded_vars);	assert(sql);	write_cdr(sql);	switch_safe_free(sql);	if (expanded_vars != template_str) {		switch_safe_free(expanded_vars);	}	return status;}
开发者ID:DrumTechnologiesLtd,项目名称:FreeSWITCH,代码行数:60,


示例9: SWITCH_DECLARE

SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi(switch_hash_t *hash, switch_hash_delete_callback_t callback, void *pData) {	switch_hash_index_t *hi = NULL;	switch_event_t *event = NULL;	switch_event_header_t *header = NULL;	switch_status_t status = SWITCH_STATUS_GENERR;		switch_event_create_subclass(&event, SWITCH_EVENT_CLONE, NULL);	switch_assert(event);		/* iterate through the hash, call callback, if callback returns NULL or true, put the key on the list (event)	   When done, iterate through the list deleting hash entries	 */		for (hi = switch_hash_first(NULL, hash); hi; hi = switch_hash_next(hi)) {		const void *key;		void *val;		switch_hash_this(hi, &key, NULL, &val);		if (!callback || callback(key, val, pData)) {			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "delete", (const char *) key);		}	}		/* now delete them */	for (header = event->headers; header; header = header->next) {		if (switch_core_hash_delete(hash, header->value) == SWITCH_STATUS_SUCCESS) {			status = SWITCH_STATUS_SUCCESS;		}	}	switch_event_destroy(&event);		return status;}
开发者ID:moises-silva,项目名称:freeswitch,代码行数:34,


示例10: SWITCH_DECLARE

SWITCH_DECLARE(void) EventConsumer::cleanup(){	uint32_t i;	void *pop;	if (!ready) {		return;	}		ready = 0;	for (i = 0; i < node_index; i++) {		switch_event_unbind(&enodes[i]);	}	node_index = 0;	if (events) {		switch_queue_interrupt_all(events);	}	while(switch_queue_trypop(events, &pop) == SWITCH_STATUS_SUCCESS) {		switch_event_t *event = (switch_event_t *) pop;		switch_event_destroy(&event);	}	switch_core_destroy_memory_pool(&pool);}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:31,


示例11: event_handler

static void event_handler(switch_event_t *event){	if (process_event(event) != SWITCH_STATUS_SUCCESS) {		const char *peer_uuid = switch_event_get_header(event, "variable_signal_bond");		switch_core_session_t *peer_session = NULL;		switch_channel_t *peer_channel = NULL;		switch_event_t *peer_event = NULL;				if (!peer_uuid) {			return;		}		if (!(peer_session = switch_core_session_locate(peer_uuid))) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cant locate peer session for uuid %s/n", peer_uuid);			return;		}		peer_channel = switch_core_session_get_channel(peer_session);				if (switch_event_create(&peer_event, SWITCH_EVENT_CHANNEL_BRIDGE) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cant create bridge event for peer channel %s/n", peer_uuid);			goto end;		}		switch_channel_event_set_data(peer_channel, peer_event);	end:		switch_core_session_rwunlock(peer_session);		if (peer_event) {			process_event(peer_event);			switch_event_destroy(&peer_event);		}	}}
开发者ID:Deepwalker,项目名称:FreeSWITCH,代码行数:35,


示例12: menu_free

void menu_free(vmivr_menu_t *menu) {	if (menu->event_keys_dtmf) {		switch_event_destroy(&menu->event_keys_dtmf);	}	if (menu->event_keys_action) {		switch_event_destroy(&menu->event_keys_action);	}	if (menu->event_keys_varname) {		switch_event_destroy(&menu->event_keys_varname);	}	if (menu->event_phrases) {		switch_event_destroy(&menu->event_phrases);	}	if (menu->event_settings) {		switch_event_destroy(&menu->event_settings);	}}
开发者ID:konradwyr,项目名称:FreeSwitch,代码行数:19,


示例13: mtvm_menu_preference

void mtvm_menu_preference(switch_core_session_t *session, vmivr_profile_t *profile) {	switch_channel_t *channel = switch_core_session_get_channel(session);	int retry;	vmivr_menu_profile_t menu = { "std_preference" };	/* Initialize Menu Configs */	populate_profile_menu_event(profile, &menu);	if (!menu.event_keys_dtmf || !menu.event_phrases) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Menu Phrases and Keys/n");		return;	}	for (retry = MAX_ATTEMPT; switch_channel_ready(channel) && retry > 0; retry--) {		dtmf_ss_t loc;		char *dtmfa[16] = { 0 };		switch_event_t *phrase_params = NULL;		switch_event_create(&phrase_params, SWITCH_EVENT_REQUEST_PARAMS);		append_event_profile(phrase_params, profile, menu);		populate_dtmfa_from_event(phrase_params, profile, menu, dtmfa);		captureMenuInitialize(&loc, dtmfa);		captureMenu(session, &loc, switch_event_get_header(menu.event_phrases, "menu_options"), NULL, phrase_params, NULL, DEFAULT_IVR_TIMEOUT);		if (loc.result == RES_TIMEOUT) {			/* TODO Ask for the prompt Again IF retry != 0 */		} else if (loc.result == RES_INVALID) {			/* TODO Say invalid option, and ask for the prompt again IF retry != 0 */		} else if (loc.result == RES_FOUND) {  /* Matching DTMF Key Pressed */			const char *action = switch_event_get_header(menu.event_keys_dtmf, loc.dtmf_stored);			/* Reset the try count */			retry = MAX_ATTEMPT;			if (action) {				if (!strcasecmp(action, "return")) { /* Return to the previous menu */					retry = -1;				} else if (!strncasecmp(action, "menu:", 5)) { /* Sub Menu */					void (*fPtr)(switch_core_session_t *session, vmivr_profile_t *profile) = mtvm_get_menu_function(action+5);					if (fPtr) {						fPtr(session, profile);					}				}			}		}		switch_event_destroy(&phrase_params);	}	free_profile_menu_event(&menu);}
开发者ID:kgrofelnik,项目名称:mod_portaudio-endpoints,代码行数:55,


示例14: free

SWITCH_DECLARE_CONSTRUCTOR Event::~Event(){	if (serialized_string) {		free(serialized_string);	}	if (event && mine) {		switch_event_destroy(&event);	}}
开发者ID:gujun,项目名称:sscore,代码行数:11,


示例15: switch_log_printf

bool WSClientParser::Login() {	switch_log_printf(			SWITCH_CHANNEL_UUID_LOG(this->uuid),			SWITCH_LOG_INFO,			"WSClientParser::Login( "			"this : %p, "			"user : '%s', "			"domain : '%s', "			"site : '%s', "			"custom : '%s' "			") /n",			this,			mpUser,			mpDomain,			mpSite,			mpCustom			);	bool bFlag = true;	// 暂时不做PHP验证	switch_event_t *locate_params;	switch_xml_t xml = NULL;	switch_event_create(&locate_params, SWITCH_EVENT_GENERAL);	switch_assert(locate_params);	switch_event_add_header_string(locate_params, SWITCH_STACK_BOTTOM, "source", "mod_ws");	switch_event_add_header_string(locate_params, SWITCH_STACK_BOTTOM, "site", mpSite);	switch_event_add_header_string(locate_params, SWITCH_STACK_BOTTOM, "custom", mpCustom);	/* Locate user */	if (switch_xml_locate_user_merged("id", mpUser, mpDomain, NULL, &xml, locate_params) != SWITCH_STATUS_SUCCESS) {		switch_log_printf(				SWITCH_CHANNEL_UUID_LOG(this->uuid),				SWITCH_LOG_ERROR,				"WSClientParser::Login( "				"[Fail], "				"this : %p, "				"user : '%s', "				"domain : '%s' ",				this,				mpUser,				mpDomain				);		bFlag = false;	}	switch_event_destroy(&locate_params);	// 发送登录成功事件	ws_login();	return bFlag;}
开发者ID:KingsleyYau,项目名称:CamShareMiddleware,代码行数:54,


示例16: switch_core_session_get_channel

char *mtvm_menu_get_input_set(switch_core_session_t *session, vmivr_profile_t *profile, vmivr_menu_profile_t menu, const char *input_mask, const char *terminate_key) {	char *result = NULL;	int retry;	switch_channel_t *channel = switch_core_session_get_channel(session);	if (!menu.event_keys_dtmf || !menu.event_phrases) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Menu Phrases and Keys : %s/n", menu.name);		return result;	}	for (retry = MAX_ATTEMPT; switch_channel_ready(channel) && retry > 0; retry--) {		dtmf_ss_t loc;		char *dtmfa[16] = { 0 };		int i;		switch_event_t *phrase_params = NULL;		switch_event_create(&phrase_params, SWITCH_EVENT_REQUEST_PARAMS);		append_event_profile(phrase_params, profile, menu);		populate_dtmfa_from_event(phrase_params, profile, menu, dtmfa);				/* Find the last entry and append this one to it */		for (i=0; dtmfa[i] && i < 16; i++){		}                dtmfa[i] = (char *) input_mask;		captureMenuInitialize(&loc, dtmfa);		if (terminate_key)			loc.terminate_key = terminate_key[0]; /* TODO Make this load from the configuration */		captureMenu(session, &loc, switch_event_get_header(menu.event_phrases, "instructions"), NULL, phrase_params, NULL, DEFAULT_IVR_TIMEOUT);		if (loc.result == RES_TIMEOUT) {			/* TODO Ask for the prompt Again IF retry != 0 */		} else if (loc.result == RES_INVALID) {			/* TODO Say invalid option, and ask for the prompt again IF retry != 0 */		} else if (loc.result == RES_FOUND) {  /* Matching DTMF Key Pressed */			/* Reset the try count */			retry = MAX_ATTEMPT;			if (!strncasecmp(loc.completeMatch, input_mask, 1)) {				result = switch_core_session_strdup(session, loc.dtmf_stored);				retry = -1;			}		}		switch_event_destroy(&phrase_params);	}	return result;}
开发者ID:kgrofelnik,项目名称:mod_portaudio-endpoints,代码行数:52,


示例17: event_handler

static void event_handler(switch_event_t *event){	EventConsumer *E = (EventConsumer *) event->bind_user_data;	switch_event_t *dup;		switch_event_dup(&dup, event);	if (switch_queue_trypush(E->events, dup) != SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot queue any more events...../n");		switch_event_destroy(&dup);	}}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:13,


示例18: stop_all_websockets

void stop_all_websockets(){	switch_event_t *event;	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, "websocket::stophook") != SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Failed to create event!/n");	}	switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "stop", "now");	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "stopping all websockets .../n");	if (switch_event_fire(&event) != SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Failed to fire the event!/n");		switch_event_destroy(&event);	}}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:13,


示例19: SWITCH_DECLARE

SWITCH_DECLARE(switch_status_t) switch_xml_config_parse(switch_xml_t xml, switch_bool_t reload, switch_xml_config_item_t *instructions){	switch_event_t *event = NULL;	switch_status_t result;	int count = switch_event_import_xml(xml, "name", "value", &event);	result = switch_xml_config_parse_event(event, count, reload, instructions);	if (event) {		switch_event_destroy(&event);	}	return result;}
开发者ID:RodrigoNieves,项目名称:FreeSWITCH,代码行数:14,


示例20: chat_send

static switch_status_t chat_send(switch_event_t *message_event)								 {	switch_status_t status = SWITCH_STATUS_BREAK;	switch_event_t *exten;	int forwards = 0;	const char *var;	var = switch_event_get_header(message_event, "max_forwards");	if (!var) {		forwards = 70;	} else {		forwards = atoi(var);				if (forwards) {			forwards--;		}		if (!forwards) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Max forwards reached/n");			DUMP_EVENT(message_event);			return SWITCH_STATUS_FALSE;		}	}	if (forwards) {		switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "max_forwards", "%d", forwards);	}	if ((exten = chatplan_hunt(message_event))) {		switch_event_header_t *hp;				for (hp = exten->headers; hp; hp = hp->next) {			status = switch_core_execute_chat_app(message_event, hp->name, hp->value);			if (!SWITCH_READ_ACCEPTABLE(status)) {				status = SWITCH_STATUS_SUCCESS;					break;			}		}		switch_event_destroy(&exten);	} else {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SMS chatplan no actions found/n");	}	return status;}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:48,


示例21: dialplan_xml_locate

static switch_status_t dialplan_xml_locate(switch_core_session_t *session, switch_caller_profile_t *caller_profile, switch_xml_t *root,										   switch_xml_t *node){	switch_channel_t *channel = switch_core_session_get_channel(session);	switch_status_t status = SWITCH_STATUS_GENERR;	switch_event_t *params = NULL;	switch_event_create(&params, SWITCH_EVENT_REQUEST_PARAMS);	switch_assert(params);	switch_channel_event_set_data(channel, params);	switch_caller_profile_event_set_data(caller_profile, "Hunt", params);	status = switch_xml_locate("dialplan", NULL, NULL, NULL, root, node, params, SWITCH_FALSE);	switch_event_destroy(&params);	return status;}
开发者ID:DrumTechnologiesLtd,项目名称:FreeSWITCH,代码行数:16,


示例22: SWITCH_DECLARE

SWITCH_DECLARE(int) CoreSession::flushEvents() {	switch_event_t *event;	this_check(-1);	sanity_check(-1);	if (!session) {		return SWITCH_STATUS_FALSE;	}	while (switch_core_session_dequeue_event(session, &event, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {		switch_event_destroy(&event);	}	return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:16,


示例23: channel_on_destroy

static switch_status_t channel_on_destroy(switch_core_session_t *session){	switch_channel_t *channel = NULL;	private_t *tech_pvt = NULL;	void *pop;	switch_event_t *vars;	channel = switch_core_session_get_channel(session);	switch_assert(channel != NULL);	tech_pvt = switch_core_session_get_private(session);	if ((vars = (switch_event_t *) switch_channel_get_private(channel, "__loopback_vars__"))) {		switch_channel_set_private(channel, "__loopback_vars__", NULL);		switch_event_destroy(&vars);	}		if (tech_pvt) {		switch_core_timer_destroy(&tech_pvt->timer);		if (switch_core_codec_ready(&tech_pvt->read_codec)) {			switch_core_codec_destroy(&tech_pvt->read_codec);		}		if (switch_core_codec_ready(&tech_pvt->write_codec)) {			switch_core_codec_destroy(&tech_pvt->write_codec);		}		if (tech_pvt->write_frame) {			switch_frame_free(&tech_pvt->write_frame);		}		while (switch_queue_trypop(tech_pvt->frame_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {			switch_frame_t *frame = (switch_frame_t *) pop;			switch_frame_free(&frame);		}	}	return SWITCH_STATUS_SUCCESS;}
开发者ID:hsaid,项目名称:FreeSWITCH,代码行数:41,


示例24: jsonapi_populate_event

void jsonapi_populate_event(switch_core_session_t *session, switch_event_t *apply_event, const char *api, const char *data) {	switch_event_t *phrases_event = NULL;	switch_stream_handle_t stream = { 0 };	switch_event_header_t *hp;	switch_assert(apply_event);	SWITCH_STANDARD_STREAM(stream);	switch_api_execute(api, data, session, &stream);	switch_event_create_json(&phrases_event, (char *) stream.data);	switch_safe_free(stream.data);	for (hp = phrases_event->headers; hp; hp = hp->next) {		if (!strncasecmp(hp->name, "VM-", 3)) {			switch_event_add_header(apply_event, SWITCH_STACK_BOTTOM, hp->name, "%s", hp->value);		}	}	switch_event_destroy(&phrases_event);	phrases_event = apply_event;	return;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:21,


示例25: vmivr_menu_select_greeting_slot

void vmivr_menu_select_greeting_slot(switch_core_session_t *session, vmivr_profile_t *profile) {	vmivr_menu_t menu = { "std_select_greeting_slot" };	const char *result;	int gnum = -1;	/* Initialize Menu Configs */	menu_init(profile, &menu);	result = vmivr_menu_get_input_set(session, profile, &menu, "X");	if (result)		gnum = atoi(result);	if (gnum != -1) {		char * cmd = switch_core_session_sprintf(session, "%s %s %s %d", profile->api_profile, profile->domain, profile->id, gnum);		if (vmivr_api_execute(session, profile->api_pref_greeting_set, cmd) == SWITCH_STATUS_SUCCESS) {			char *str_num = switch_core_session_sprintf(session, "%d", gnum);			char *cmd = switch_core_session_sprintf(session, "json %s %s %s %d %s", profile->api_profile, profile->domain, profile->id);			switch_event_t *phrases = jsonapi2event(session, profile->api_pref_greeting_get, cmd);			ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "selected_slot"), str_num, phrases, NULL, 0);			if (switch_true(switch_event_get_header(phrases, "VM-Message-Private-Local-Copy"))) {				const char *file_path = switch_event_get_header(phrases, "VM-Preference-Greeting-File-Path");				if (file_path && unlink(file_path) != 0) {					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to delete temp file [%s]/n", file_path);				}			}			switch_event_destroy(&phrases);		} else {			ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "invalid_slot"), NULL, NULL, NULL, 0);		}	}	menu_free(&menu);}
开发者ID:odmanV2,项目名称:freecenter,代码行数:36,


示例26: parse_naptr

//.........这里部分代码省略.........	} else {		goto end;	}		for (p = replace; p && *p; p++) {		if (*p == '//') {			*p = '$';		}	}	if (service && regex && replace) {		switch_regex_t *re = NULL, *re2 = NULL;		int proceed = 0, ovector[30];		char *substituted = NULL;		char *substituted_2 = NULL;		char *orig_uri;		char *uri_expanded = NULL;		enum_route_t *route;		int supported = 0;		uint32_t len = 0;		if ((proceed = switch_regex_perform(number, regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {			if (strchr(regex, '(')) {				len = (uint32_t) (strlen(number) + strlen(replace) + 10) * proceed;				if (!(substituted = malloc(len))) {					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!/n");					switch_regex_safe_free(re);					goto end;				}				memset(substituted, 0, len);				switch_perform_substitution(re, proceed, replace, number, substituted, len, ovector);				orig_uri = substituted;			} else {				orig_uri = replace;			}						switch_mutex_lock(MUTEX);			for (route = globals.route_order; route; route = route->next) {				char *uri = orig_uri;								if (strcasecmp(service, route->service)) {					continue;				}				if ((proceed = switch_regex_perform(uri, route->regex, &re2, ovector, sizeof(ovector) / sizeof(ovector[0])))) {					switch_event_t *event = NULL;					if (strchr(route->regex, '(')) {						len = (uint32_t) (strlen(uri) + strlen(route->replace) + 10) * proceed;						if (!(substituted_2 = malloc(len))) {							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!/n");							switch_safe_free(substituted);							switch_regex_safe_free(re);							switch_regex_safe_free(re2);							switch_mutex_unlock(MUTEX);							goto end;						}						memset(substituted_2, 0, len);						switch_perform_substitution(re2, proceed, route->replace, uri, substituted_2, len, ovector);						uri = substituted_2;					} else {						uri = route->replace;					}					switch_event_create(&event, SWITCH_EVENT_REQUEST_PARAMS);					uri_expanded = switch_event_expand_headers(event, uri);					switch_event_destroy(&event);					if (uri_expanded == uri) {						uri_expanded = NULL;					} else {						uri = uri_expanded;					}					supported++;					add_result(results, order, preference, service, uri, supported);									}				switch_safe_free(uri_expanded);				switch_safe_free(substituted_2);				switch_regex_safe_free(re2);			}			switch_mutex_unlock(MUTEX);						if (!supported) {				add_result(results, order, preference, service, orig_uri, 0);			}			switch_safe_free(substituted);			switch_regex_safe_free(re);		}	} end:	switch_safe_free(str);		return;}
开发者ID:prashantchoudhary,项目名称:FreeswitchModified,代码行数:101,


示例27: my_on_reporting

static switch_status_t my_on_reporting(switch_core_session_t *session){	switch_channel_t *channel = switch_core_session_get_channel(session);	switch_status_t status = SWITCH_STATUS_SUCCESS;	const char *log_dir = NULL, *accountcode = NULL, *a_template_str = NULL, *g_template_str = NULL;	char *log_line, *path = NULL;	if (globals.shutdown) {		return SWITCH_STATUS_SUCCESS;	}	if (!((globals.legs & CDR_LEG_A) && (globals.legs & CDR_LEG_B))) {		if ((globals.legs & CDR_LEG_A)) {			if (switch_channel_get_originator_caller_profile(channel)) {				return SWITCH_STATUS_SUCCESS;			}		} else {			if (switch_channel_get_originatee_caller_profile(channel)) {				return SWITCH_STATUS_SUCCESS;			}		}	}	if (!(log_dir = switch_channel_get_variable(channel, "cdr_csv_base"))) {		log_dir = globals.log_dir;	}	if (switch_dir_make_recursive(log_dir, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s/n", log_dir);		return SWITCH_STATUS_FALSE;	}	if (globals.debug) {		switch_event_t *event;		if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {			char *buf;			switch_channel_event_set_data(channel, event);			switch_event_serialize(event, &buf, SWITCH_FALSE);			switch_assert(buf);			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "CHANNEL_DATA:/n%s/n", buf);			switch_event_destroy(&event);			free(buf);		}	}	g_template_str = (const char *) switch_core_hash_find(globals.template_hash, globals.default_template);	if ((accountcode = switch_channel_get_variable(channel, "ACCOUNTCODE"))) {		a_template_str = (const char *) switch_core_hash_find(globals.template_hash, accountcode);	}	if (!g_template_str) {		g_template_str =			"/"${accountcode}/",/"${caller_id_number}/",/"${destination_number}/",/"${context}/",/"${caller_id}/",/"${channel_name}/",/"${bridge_channel}/",/"${last_app}/",/"${last_arg}/",/"${start_stamp}/",/"${answer_stamp}/",/"${end_stamp}/",/"${duration}/",/"${billsec}/",/"${hangup_cause}/",/"${amaflags}/",/"${uuid}/",/"${userfield}/";";	}	if (!a_template_str) {		a_template_str = g_template_str;	}	log_line = switch_channel_expand_variables(channel, a_template_str);	if ((accountcode) && (!globals.masterfileonly)) {		path = switch_mprintf("%s%s%s.csv", log_dir, SWITCH_PATH_SEPARATOR, accountcode);		assert(path);		write_cdr(path, log_line);		free(path);	}	if (g_template_str != a_template_str) {		if (log_line != a_template_str) {			switch_safe_free(log_line);		}		log_line = switch_channel_expand_variables(channel, g_template_str);	}	if (!log_line) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating cdr/n");		return SWITCH_STATUS_FALSE;	}	path = switch_mprintf("%s%sMaster.csv", log_dir, SWITCH_PATH_SEPARATOR);	assert(path);	write_cdr(path, log_line);	free(path);	if (log_line != g_template_str) {		free(log_line);	}	return status;}
开发者ID:kgrofelnik,项目名称:mod_portaudio-endpoints,代码行数:93,


示例28: fsk_detect_callback

static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type){	switch_fsk_detect_t *pvt = (switch_fsk_detect_t *) user_data;	//switch_frame_t *frame = NULL;	switch_channel_t *channel = switch_core_session_get_channel(pvt->session);	switch (type) {	case SWITCH_ABC_TYPE_INIT: {		switch_codec_implementation_t read_impl = { 0 };		switch_core_session_get_read_impl(pvt->session, &read_impl);				if (fsk_demod_init(&pvt->fsk_data, read_impl.actual_samples_per_second, pvt->fbuf, sizeof(pvt->fbuf))) {			return SWITCH_FALSE;		}				break;	}	case SWITCH_ABC_TYPE_CLOSE:		{			fsk_demod_destroy(&pvt->fsk_data);		}		break;	case SWITCH_ABC_TYPE_WRITE_REPLACE:	case SWITCH_ABC_TYPE_READ_REPLACE:		{			switch_frame_t *rframe;			if (type == SWITCH_ABC_TYPE_READ_REPLACE) {				rframe = switch_core_media_bug_get_read_replace_frame(bug);			} else {				rframe = switch_core_media_bug_get_write_replace_frame(bug);			}			if (!pvt->skip && fsk_demod_feed(&pvt->fsk_data, rframe->data, rframe->datalen / 2) != SWITCH_STATUS_SUCCESS) {				char str[1024] = "";				size_t type, mlen;				char *sp;				switch_event_t *event;				const char *app_var;				int total = 0;				switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA);								while(fsk_data_parse(&pvt->fsk_data, &type, &sp, &mlen) == SWITCH_STATUS_SUCCESS) {					char *varname = NULL, *val, *p;										switch_copy_string(str, sp, mlen+1);					*(str+mlen) = '/0';					switch_clean_string(str);					//printf("TYPE %u LEN %u VAL [%s]/n", (unsigned)type, (unsigned)mlen, str);					val = str;					switch(type) {					case MDMF_DATETIME:						varname = "fsk_datetime";						break;					case MDMF_PHONE_NAME:						varname = "fsk_phone_name";						break;					case MDMF_PHONE_NUM:						varname = "fsk_phone_num";						break;					case MDMF_NAME_VALUE:						varname = switch_core_session_sprintf(pvt->session, "fsk_%s", val);						if ((p = strchr(varname, ':'))) {							*p++ = '/0';							val = p;						}						break;					default:						break;					}					if (varname && val) {						total++;						switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s setting FSK var [%s][%s]/n", 										  switch_channel_get_name(channel), varname, val);						switch_channel_set_variable(channel, varname, val);						if (event) {							switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, varname, val);						}					}				}				if (event) {					if (switch_core_session_queue_event(pvt->session, &event) != SWITCH_STATUS_SUCCESS) {						switch_event_destroy(&event);					}				}								if (total && (app_var = switch_channel_get_variable(channel, "execute_on_fsk"))) {					char *app_arg;					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s processing execute_on_fsk [%s]/n", 									  switch_channel_get_name(channel), app_var);					if ((app_arg = strchr(app_var, ' '))) {						*app_arg++ = '/0';					}//.........这里部分代码省略.........
开发者ID:odmanV2,项目名称:freecenter,代码行数:101,



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


C++ switch_event_fire函数代码示例
C++ switch_event_add_header_string函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。