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

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

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

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

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

示例1: SWITCH_DECLARE

SWITCH_DECLARE(switch_status_t) switch_nat_add_mapping_internal(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t * external_port,																switch_bool_t sticky, switch_bool_t publish){	switch_status_t status = SWITCH_STATUS_FALSE;	switch_event_t *event = NULL;	switch (nat_globals.nat_type) {	case SWITCH_NAT_TYPE_PMP:		status = switch_nat_add_mapping_pmp(port, proto, external_port);		break;	case SWITCH_NAT_TYPE_UPNP:		if ((status = switch_nat_add_mapping_upnp(port, proto)) == SWITCH_STATUS_SUCCESS) {			if (external_port) {				*external_port = port;			}		}		break;	default:		break;	}	if (publish && status == SWITCH_STATUS_SUCCESS) {		switch_event_create(&event, SWITCH_EVENT_NAT);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "op", "add");		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "port", "%d", port);		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "%d", proto);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sticky", (sticky ? "true" : "false"));		switch_event_fire(&event);	}	return status;}
开发者ID:moises-silva,项目名称:mod_handsfree,代码行数:32,


示例2: switch_event_add_header_string

bool WSClientParser::ws_disconnect() {	switch_status_t status = SWITCH_STATUS_FALSE;	switch_event_t *event;	if ( (status = switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, WS_EVENT_MAINT)) == SWITCH_STATUS_SUCCESS) {		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "User", mpUser);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Domain", mpDomain);		status = switch_event_fire(&event);	}	if( status != SWITCH_STATUS_SUCCESS ) {		switch_log_printf(				SWITCH_CHANNEL_UUID_LOG(this->uuid),				SWITCH_LOG_ERROR,				"WSClientParser::ws_disconnect( "				"[Send event Fail], "				"this : %p, "				"user : '%s', "				"domain : '%s' "				") /n",				this,				mpUser,				mpDomain				);	}	return status == SWITCH_STATUS_SUCCESS;}
开发者ID:KingsleyYau,项目名称:CamShareMiddleware,代码行数:27,


示例3: send_report

static void send_report(switch_event_t *event, const char * Status) {	switch_event_t *report = NULL;	switch_event_header_t *header;	if (switch_event_create_subclass(&report, SWITCH_EVENT_CUSTOM, MY_EVENT_DELIVERY_REPORT) == SWITCH_STATUS_SUCCESS) {		switch_event_add_header_string(report, SWITCH_STACK_BOTTOM, "Status", Status);		for (header = event->headers; header; header = header->next) {			if (!strcmp(header->name, "Event-Subclass")) {				continue;			}			if (!strcmp(header->name, "Event-Name")) {				continue;			}	        if (header->idx) {	            int i;	            for (i = 0; i < header->idx; i++) {	                switch_event_add_header_string(report, SWITCH_STACK_PUSH, header->name, header->array[i]);	            }	        } else {	            switch_event_add_header_string(report, SWITCH_STACK_BOTTOM, header->name, header->value);	        }		}		switch_event_fire(&report);	}}
开发者ID:odmanV2,项目名称:freecenter,代码行数:28,


示例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: switch_scheduler_execute

static void switch_scheduler_execute(switch_scheduler_task_container_t *tp){	switch_event_t *event;	//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Executing task %u %s (%s)/n", tp->task.task_id, tp->desc, switch_str_nil(tp->task.group));	tp->func(&tp->task);	if (tp->task.repeat) {		tp->task.runtime = switch_epoch_time_now(NULL) + tp->task.repeat;	}	if (tp->task.runtime > tp->executed) {		tp->executed = 0;		if (switch_event_create(&event, SWITCH_EVENT_RE_SCHEDULE) == SWITCH_STATUS_SUCCESS) {			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id);			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Task-Desc", tp->desc);			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Task-Group", switch_str_nil(tp->task.group));			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" SWITCH_INT64_T_FMT, tp->task.runtime);			switch_queue_push(globals.event_queue, event);			event = NULL;		}	} else {		tp->destroyed = 1;	}}
开发者ID:bodji,项目名称:freeswitch,代码行数:25,


示例6: conference_loop_exec_app

void conference_loop_exec_app(conference_member_t *member, caller_control_action_t *action){	char *app = NULL;	char *arg = "";	char *argv[2] = { 0 };	int argc;	char *mydata = NULL;	switch_event_t *event = NULL;	switch_channel_t *channel = NULL;	if (!action->expanded_data) return;	if (test_eflag(member->conference, EFLAG_DTMF) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {		conference_member_add_event_data(member, event);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "execute_app");		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Application", action->expanded_data);		switch_event_fire(&event);	}	mydata = strdup(action->expanded_data);	switch_assert(mydata);	if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {		if (argc > 0) {			app = argv[0];		}		if (argc > 1) {			arg = argv[1];		}	} else {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR, "Empty execute app string [%s]/n",						  (char *) action->expanded_data);		goto done;	}	if (!app) {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR, "Unable to find application./n");		goto done;	}	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_INFO, "Execute app: %s, %s/n", app, arg);	channel = switch_core_session_get_channel(member->session);	switch_channel_set_app_flag(channel, CF_APP_TAGGED);	switch_core_session_set_read_codec(member->session, NULL);	switch_core_session_execute_application(member->session, app, arg);	switch_core_session_set_read_codec(member->session, &member->read_codec);	switch_channel_clear_app_flag(channel, CF_APP_TAGGED); done:	switch_safe_free(mydata);	return;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:58,


示例7: callprogress_detector_process_buffer

/** * Process a buffer of audio data for call progress tones * * @param bug the session's media bug  * @param user_data the detector * @param type the type of data available from the bug * @return SWITCH_TRUE */static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type){	uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];	switch_frame_t frame = { 0 };	tone_detector_t *detector = (tone_detector_t *)user_data;	switch_core_session_t *session = switch_core_media_bug_get_session(bug);	switch_channel_t *channel = switch_core_session_get_channel(session);	frame.data = data;	frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;	switch(type) {	case SWITCH_ABC_TYPE_INIT:		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) initializing tone detector/n", switch_channel_get_name(channel));		tone_detector_init(detector);		break;	case SWITCH_ABC_TYPE_READ:	{		const char *detected_tone = NULL;		if (!detector->spandsp_detector) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) detector is destroyed/n", switch_channel_get_name(channel));			return SWITCH_FALSE;		}		if (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) error reading frame/n", switch_channel_get_name(channel));			return SWITCH_FALSE;		}		tone_detector_process_buffer(detector, frame.data, frame.samples, &detected_tone);		if (detected_tone) {			switch_event_t *event = NULL;			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) DETECTED TONE: %s/n", switch_channel_get_name(channel), detected_tone);			if (switch_event_create(&event, SWITCH_EVENT_DETECTED_TONE) == SWITCH_STATUS_SUCCESS) {				switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detected-Tone", detected_tone);				switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session));				switch_event_fire(&event);			}		}		break;	}	case SWITCH_ABC_TYPE_WRITE:		break;	case SWITCH_ABC_TYPE_WRITE_REPLACE:		break;	case SWITCH_ABC_TYPE_READ_REPLACE:		break;	case SWITCH_ABC_TYPE_READ_PING:		break;	case SWITCH_ABC_TYPE_CLOSE:		if (detector->spandsp_detector) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) destroying tone detector/n", switch_channel_get_name(channel));			tone_detector_destroy(detector);		}		break;	}	return SWITCH_TRUE;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:64,


示例8: 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,


示例9: SWITCH_DECLARE

SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,												   switch_scheduler_func_t func,												   const char *desc, const char *group, uint32_t cmd_id, void *cmd_arg, switch_scheduler_flag_t flags){	switch_scheduler_task_container_t *container, *tp;	switch_event_t *event;	switch_time_t now = switch_epoch_time_now(NULL);	switch_ssize_t hlen = -1;	switch_mutex_lock(globals.task_mutex);	switch_zmalloc(container, sizeof(*container));	switch_assert(func);	if (task_runtime < now) {		container->task.repeat = (uint32_t)task_runtime;		task_runtime += now;	}	container->func = func;	container->task.created = now;	container->task.runtime = task_runtime;	container->task.group = strdup(group ? group : "none");	container->task.cmd_id = cmd_id;	container->task.cmd_arg = cmd_arg;	container->flags = flags;	container->desc = strdup(desc ? desc : "none");	container->task.hash = switch_ci_hashfunc_default(container->task.group, &hlen);	for (tp = globals.task_list; tp && tp->next; tp = tp->next);	if (tp) {		tp->next = container;	} else {		globals.task_list = container;	}	for (container->task.task_id = 0; !container->task.task_id; container->task.task_id = ++globals.task_id);	switch_mutex_unlock(globals.task_mutex);	tp = container;	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Added task %u %s (%s) to run at %" SWITCH_INT64_T_FMT "/n",					  tp->task.task_id, tp->desc, switch_str_nil(tp->task.group), tp->task.runtime);	if (switch_event_create(&event, SWITCH_EVENT_ADD_SCHEDULE) == SWITCH_STATUS_SUCCESS) {		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Task-Desc", tp->desc);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Task-Group", switch_str_nil(tp->task.group));		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" SWITCH_INT64_T_FMT, tp->task.runtime);		switch_queue_push(globals.event_queue, event);		event = NULL;	}	return container->task.task_id;}
开发者ID:bodji,项目名称:freeswitch,代码行数:54,


示例10: conference_loop_event

void conference_loop_event(conference_member_t *member, caller_control_action_t *action){	switch_event_t *event;	if (test_eflag(member->conference, EFLAG_DTMF) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {		conference_member_add_event_data(member, event);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "dtmf");		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "DTMF-Key", action->binded_dtmf);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Data", action->expanded_data);		switch_event_fire(&event);	}}
开发者ID:odmanV2,项目名称:freecenter,代码行数:11,


示例11: conference_event_add_data

switch_status_t conference_event_add_data(conference_obj_t *conference, switch_event_t *event){	switch_status_t status = SWITCH_STATUS_SUCCESS;	switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);	switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Size", "%u", conference->count);	switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Ghosts", "%u", conference->count_ghosts);	switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Conference-Profile-Name", conference->profile_name);	switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Conference-Unique-ID", conference->uuid_str);	return status;}
开发者ID:prashantchoudhary,项目名称:FreeswitchModified,代码行数:12,


示例12: cc_agent_get

cc_status_t cc_agent_get(const char *key, const char *agent, char *ret_result, size_t ret_result_size){	cc_status_t result = CC_STATUS_SUCCESS;	char *sql;	switch_event_t *event;	char res[256];	/* Check to see if agent already exists */	sql = switch_mprintf("SELECT count(*) FROM agents WHERE name = '%q'", agent);	cc_execute_sql2str(NULL, NULL, sql, res, sizeof(res));	switch_safe_free(sql);	if (atoi(res) == 0) {		result = CC_STATUS_AGENT_NOT_FOUND;		goto done;	}	if (!strcasecmp(key, "status") || !strcasecmp(key, "state") || !strcasecmp(key, "uuid") ) { 		/* Check to see if agent already exists */		sql = switch_mprintf("SELECT %q FROM agents WHERE name = '%q'", key, agent);		cc_execute_sql2str(NULL, NULL, sql, res, sizeof(res));		switch_safe_free(sql);		switch_snprintf(ret_result, ret_result_size, "%s", res);		result = CC_STATUS_SUCCESS;		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CALLCENTER_EVENT) == SWITCH_STATUS_SUCCESS) {			char tmpname[256];			if (!strcasecmp(key, "uuid")) {				switch_snprintf(tmpname, sizeof(tmpname), "CC-Agent-UUID");				} else {				switch_snprintf(tmpname, sizeof(tmpname), "CC-Agent-%c%s", (char) switch_toupper(key[0]), key+1);			}			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Agent", agent);			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "CC-Action", "agent-%s-get", key);			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, tmpname, res);			switch_event_fire(&event);		}	} else {		result = CC_STATUS_INVALID_KEY;		goto done;	}done:   	if (result == CC_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Get Info Agent %s %s = %s/n", agent, key, res);	}	return result;}
开发者ID:hellooragne,项目名称:yun_callcenter,代码行数:51,


示例13: utils_send_request_all

/* * chiedo alla patch tutte le chiamate. Probabilmente ritorna una una insert con tutte le chiamate da inserire. * usata all'avvio di un nuovo nodo che deve ricostrurie lo stato delle chiamate in corso alla sua accensione. */void utils_send_request_all(char *profile_name){    switch_event_t *event = NULL;    if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, "sofia::recovery_recv") == SWITCH_STATUS_SUCCESS) {        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile_name", profile_name);        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "request_all","true");        switch_event_fire(&event);        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "request_all sent to sofia/n");    } else {        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "request_all not sent to sofia/n");    }}
开发者ID:VoiSmart,项目名称:freeswitch-mod-cpg,代码行数:18,


示例14: SWITCH_DECLARE

SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line, const char *fmt, ...){	char *data = NULL;	int ret = 0;	va_list ap;	FILE *handle = switch_core_data_channel(channel);	const char *filep = switch_cut_path(file);	char date[80] = "";	switch_size_t retsize;	switch_time_exp_t tm;	switch_event_t *event;	va_start(ap, fmt);	ret = switch_vasprintf(&data, fmt, ap);	va_end(ap);	if (ret == -1) {		fprintf(stderr, "Memory Error/n");		goto done;	}	if (channel == SWITCH_CHANNEL_ID_LOG_CLEAN) {		fprintf(handle, "%s", data);		goto done;	}	switch_time_exp_lt(&tm, switch_micro_time_now());	switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);	if (channel == SWITCH_CHANNEL_ID_LOG) {		fprintf(handle, "[%d] %s %s:%d %s() %s", (int) getpid(), date, filep, line, func, data);		goto done;	}	if (channel == SWITCH_CHANNEL_ID_EVENT &&		switch_event_running() == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) {		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Log-Data", data);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Log-File", filep);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Log-Function", func);		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Line", "%d", line);		switch_event_fire(&event);	}  done:	if (data) {		free(data);	}	fflush(handle);}
开发者ID:RodrigoNieves,项目名称:FreeSWITCH,代码行数:50,


示例15: SWITCH_DECLARE

SWITCH_DECLARE(void) switch_limit_fire_event(const char *backend, const char *realm, const char *key, uint32_t usage, uint32_t rate, uint32_t max, uint32_t ratemax){	switch_event_t *event;	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, LIMIT_EVENT_USAGE) == SWITCH_STATUS_SUCCESS) {		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "backend", backend);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "realm", realm);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "key", key);		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "usage", "%d", usage);		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rate", "%d", rate);		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "max", "%d", max);		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "ratemax", "%d", ratemax);		switch_event_fire(&event);	}}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:15,


示例16: append_event_message

void append_event_message(switch_core_session_t *session, vmivr_profile_t *profile, switch_event_t *phrase_params, switch_event_t *msg_list_event, size_t current_msg) {	char *varname;	char *apicmd;	char *total_msg = NULL;	if (!msg_list_event || !(total_msg = switch_event_get_header(msg_list_event, "VM-List-Count")) || current_msg > atoi(total_msg)) {		/* TODO Error MSG */		return;	}	varname = switch_mprintf("VM-List-Message-%" SWITCH_SIZE_T_FMT "-UUID", current_msg);	apicmd = switch_mprintf("json %s %s %s %s", profile->api_profile, profile->domain, profile->id, switch_event_get_header(msg_list_event, varname));	switch_safe_free(varname);	jsonapi2event(session, phrase_params, profile->api_msg_get, apicmd);	/* TODO Set these 2 header correctly */	switch_event_add_header(phrase_params, SWITCH_STACK_BOTTOM, "VM-Message-Type", "%s", "new");	switch_event_add_header(phrase_params, SWITCH_STACK_BOTTOM, "VM-Message-Number", "%"SWITCH_SIZE_T_FMT, current_msg);	switch_event_add_header_string(phrase_params, SWITCH_STACK_BOTTOM, "VM-Message-Private-Local-Copy", "False");	switch_safe_free(apicmd);}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:26,


示例17: conference_loop_energy_dn

void conference_loop_energy_dn(conference_member_t *member, caller_control_action_t *action){	char msg[512], str[30] = "", *p;	switch_event_t *event;	if (member == NULL)		return;	member->energy_level -= 200;	if (member->energy_level < 0) {		member->energy_level = 0;	}	if (test_eflag(member->conference, EFLAG_ENERGY_LEVEL) &&		switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {		conference_member_add_event_data(member, event);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "energy-level");		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);		switch_event_fire(&event);	}	//switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);	//conference_member_say(member, msg, 0);	switch_snprintf(str, sizeof(str), "%d", abs(member->energy_level) / 200);	for (p = str; p && *p; p++) {		switch_snprintf(msg, sizeof(msg), "digits/%c.wav", *p);		conference_member_play_file(member, msg, 0, SWITCH_TRUE);	}}
开发者ID:odmanV2,项目名称:freecenter,代码行数:31,


示例18: conference_loop_volume_listen_dn

void conference_loop_volume_listen_dn(conference_member_t *member, caller_control_action_t *action){	char msg[512];	switch_event_t *event;	if (member == NULL)		return;	member->volume_in_level--;	switch_normalize_volume(member->volume_in_level);	if (test_eflag(member->conference, EFLAG_GAIN_LEVEL) &&		switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {		conference_member_add_event_data(member, event);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "gain-level");		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);		switch_event_fire(&event);	}	//switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);	//conference_member_say(member, msg, 0);	if (member->volume_in_level < 0) {		switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_in_level);		conference_member_play_file(member, msg, 0, SWITCH_TRUE);	}	switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_in_level));	conference_member_play_file(member, msg, 0, SWITCH_TRUE);}
开发者ID:odmanV2,项目名称:freecenter,代码行数:30,


示例19: 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,


示例20: SWITCH_DECLARE

SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_write_codec(switch_core_session_t *session, switch_codec_t *codec){	switch_event_t *event;	switch_channel_t *channel = switch_core_session_get_channel(session);	char tmp[30];	switch_status_t status = SWITCH_STATUS_SUCCESS;	if (!codec || !codec->implementation || !switch_core_codec_ready(codec)) {		if (session->video_write_codec) {			session->video_write_codec = NULL;			status = SWITCH_STATUS_SUCCESS;			goto end;		}		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot set NULL codec!/n");		status = SWITCH_STATUS_FALSE;		goto end;	}	if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {		switch_channel_event_set_data(session->channel, event);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-video-write-codec-name", codec->implementation->iananame);		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-video-write-codec-rate", "%d", codec->implementation->actual_samples_per_second);		switch_event_fire(&event);	}	switch_channel_set_variable(channel, "video_write_codec", codec->implementation->iananame);	switch_snprintf(tmp, sizeof(tmp), "%d", codec->implementation->actual_samples_per_second);	switch_channel_set_variable(channel, "video_write_rate", tmp);	session->video_write_codec = codec;	session->video_write_impl = *codec->implementation;  end:	return status;}
开发者ID:hsaid,项目名称:FreeSWITCH,代码行数:35,


示例21: 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,


示例22: http_stream_write

static switch_status_t http_stream_write(switch_stream_handle_t *handle, const char *fmt, ...){	TSession *r = (TSession *) handle->data;	int ret = 1;	char *data;	switch_event_t *evnt = handle->param_event;	va_list ap;	va_start(ap, fmt);	ret = switch_vasprintf(&data, fmt, ap);	va_end(ap);	if (data) {		/* Stream Content-Type (http header) to the xmlrpc (web) client, if fs api command did not do it yet.        */		/* If (Content-Type in event) then the header was already replied.                                           */		/* If fs api command is not "web aware", this will set the Content-Type to "text/plain".                     */		const char *http_refresh = NULL;		const char *ct = NULL;		const char *refresh = NULL;		if (evnt && !(ct = switch_event_get_header(evnt, "Content-Type"))){			const char *val = switch_stristr("Content-Type", data);			if (!val) {				val = "Content-Type: text/plain/r/n/r/n";				ret = HTTPWrite(r, val, (uint32_t) strlen(val));			}			/* flag to prevent running this more than once per http reply  */			switch_event_add_header_string(evnt, SWITCH_STACK_BOTTOM, "Content-Type", strstr(val,":")+2);			ct = switch_event_get_header(evnt, "Content-Type");		}		if (ret) {			ret = HTTPWrite(r, data, (uint32_t) strlen(data));		}		switch_safe_free(data);		/* e.g. "http://www.cluecon.fs/api/show?calls &refresh=5"  */		/* fs api command can set event header "HTTP-REFRESH" so that the web page will automagically refresh, if    */		/* "refresh=xxx" was part of the http query kv pairs */		if (ret && ct && *ct && (http_refresh = switch_event_get_header(evnt, "HTTP-REFRESH"))			                 && (refresh = switch_event_get_header(evnt, "refresh"))			                 && !strstr("text/html", ct)							 && (atoi(refresh) > 0 )) {			const char *query = switch_event_get_header(evnt, "HTTP-QUERY");			const char *uri = switch_event_get_header(evnt, "HTTP-URI");			if (uri && query && *uri && *query) {				char *buf = switch_mprintf("<META HTTP-EQUIV=REFRESH CONTENT=/"%s; URL=%s?%s/">/n", refresh, uri, query);				ret = HTTPWrite(r, buf, (uint32_t) strlen(buf));				switch_safe_free(buf);			}		}		/* only one refresh meta header per reply */		if (http_refresh) {			switch_event_del_header(evnt, "HTTP-REFRESH");		}	}	return ret ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;}
开发者ID:jrd,项目名称:FreeSWITCH,代码行数:59,


示例23: conference_loop_transfer

void conference_loop_transfer(conference_member_t *member, caller_control_action_t *action){	char *exten = NULL;	char *dialplan = "XML";	char *context = "default";	char *argv[3] = { 0 };	int argc;	char *mydata = NULL;	switch_event_t *event;	if (test_eflag(member->conference, EFLAG_DTMF) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {		conference_member_add_event_data(member, event);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "transfer");		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Dialplan", action->expanded_data);		switch_event_fire(&event);	}	conference_utils_member_clear_flag_locked(member, MFLAG_RUNNING);	if ((mydata = switch_core_session_strdup(member->session, action->expanded_data))) {		if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {			if (argc > 0) {				exten = argv[0];			}			if (argc > 1) {				dialplan = argv[1];			}			if (argc > 2) {				context = argv[2];			}		} else {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR, "Empty transfer string [%s]/n", (char *) action->expanded_data);			goto done;		}	} else {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR, "Unable to allocate memory to duplicate transfer data./n");		goto done;	}	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_INFO, "Transfering to: %s, %s, %s/n", exten, dialplan, context);	switch_ivr_session_transfer(member->session, exten, dialplan, context); done:	return;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:46,


示例24: callprogress_detector_process_buffer

/** * Process a buffer of audio data for call progress tones * * @param bug the session's media bug  * @param user_data the detector * @param type the type of data available from the bug * @return SWITCH_TRUE */static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type){	tone_detector_t *detector = (tone_detector_t *)user_data;	switch_core_session_t *session = detector->session;	switch(type) {	case SWITCH_ABC_TYPE_INIT:		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "initializing tone detector/n");		tone_detector_init(detector);		break;	case SWITCH_ABC_TYPE_READ_REPLACE:	{		switch_frame_t *frame;		const char *detected_tone = NULL;		if (!detector->spandsp_detector) {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "detector is destroyed/n");			return SWITCH_FALSE;		}		if (!(frame = switch_core_media_bug_get_read_replace_frame(bug))) {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "error reading frame/n");			return SWITCH_FALSE;		}		tone_detector_process_buffer(detector, frame->data, frame->samples, &detected_tone);		if (detected_tone) {			switch_event_t *event = NULL;			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "DETECTED TONE: %s/n", detected_tone);			if (switch_event_create(&event, SWITCH_EVENT_DETECTED_TONE) == SWITCH_STATUS_SUCCESS) {				switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detected-Tone", detected_tone);				switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session));				switch_event_fire(&event);			}		}		break;	}	case SWITCH_ABC_TYPE_CLOSE:		if (detector->spandsp_detector) {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "destroying tone detector/n");			tone_detector_destroy(detector);		}		break;	default:		break;	}	return SWITCH_TRUE;}
开发者ID:RodrigoNieves,项目名称:FreeSWITCH,代码行数:53,


示例25: put_text_msg

static void put_text_msg(void *user_data, const uint8_t *msg, int len){	switch_tdd_t *pvt = (switch_tdd_t *) user_data;	switch_event_t *event, *clone;	switch_channel_t *channel = switch_core_session_get_channel(pvt->session);	switch_core_session_t *other_session;	switch_channel_add_variable_var_check(channel, "tdd_messages", (char *)msg, SWITCH_FALSE, SWITCH_STACK_PUSH);	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_TDD_RECV_MESSAGE) == SWITCH_STATUS_SUCCESS) {		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", "mod_spandsp");		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "tdd");		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "TDD MESSAGE");		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "TDD-Data", (char *)msg);		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(pvt->session));		switch_event_add_body(event, "%s/n/n", (char *)msg);		if (switch_core_session_get_partner(pvt->session, &other_session) == SWITCH_STATUS_SUCCESS) {			if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) {				switch_core_session_receive_event(other_session, &clone);			}			if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) {				switch_core_session_queue_event(other_session, &clone);			}			switch_core_session_rwunlock(other_session);		}		switch_event_fire(&event);	}	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s got TDD Message [%s]/n", switch_channel_get_name(channel), (char *)msg);}
开发者ID:RodrigoNieves,项目名称:FreeSWITCH,代码行数:41,


示例26: SWITCH_DECLARE

SWITCH_DECLARE(bool) Event::addHeader(const char *header_name, const char *value){	this_check(false);	if (event) {		return switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, value) == SWITCH_STATUS_SUCCESS ? true : false;	} else {		switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to addHeader an event that does not exist!/n");	}	return false;}
开发者ID:gujun,项目名称:sscore,代码行数:12,



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


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