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

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

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

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

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

示例1: exec_app

static switch_status_t exec_app(switch_core_session_t *session, const char *app, const char *arg){	switch_application_interface_t *application_interface;	switch_status_t status = SWITCH_STATUS_SUCCESS;	switch_channel_t *channel = switch_core_session_get_channel(session);	switch_assert(channel);	if ((application_interface = switch_loadable_module_get_application_interface(app)) == 0) {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Application %s/n", app);		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);		return SWITCH_STATUS_FALSE;	}	if (!application_interface->application_function) {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No Function for %s/n", app);		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);		switch_goto_status(SWITCH_STATUS_FALSE, done);	}	if (!switch_test_flag(application_interface, SAF_ROUTING_EXEC)) {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "This application cannot be executed inline/n");		switch_goto_status(SWITCH_STATUS_FALSE, done);	}	switch_core_session_exec(session, application_interface, arg);  done:	UNPROTECT_INTERFACE(application_interface);	return status;}
开发者ID:DrumTechnologiesLtd,项目名称:FreeSWITCH,代码行数:33,


示例2: channel_kill_channel

static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig){    switch_channel_t *channel = NULL;    private_t *tech_pvt = NULL;    channel = switch_core_session_get_channel(session);    assert(channel != NULL);    tech_pvt = switch_core_session_get_private(session);    assert(tech_pvt != NULL);    switch (sig) {    case SWITCH_SIG_KILL:        switch_clear_flag_locked(tech_pvt, TFLAG_IO);        switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);        switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);        //switch_thread_cond_signal(tech_pvt->cond);        break;    case SWITCH_SIG_BREAK:        switch_set_flag_locked(tech_pvt, TFLAG_BREAK);        break;    default:        break;    }    return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:27,


示例3: fs_switch_ivr_originate

int fs_switch_ivr_originate(switch_core_session_t *session, switch_core_session_t **bleg, char *bridgeto, uint32_t timelimit_sec)/*const switch_state_handler_table_t *table,  char *  	cid_name_override,  char *  	cid_num_override,  switch_caller_profile_t *caller_profile_override)  */{	switch_channel_t *caller_channel;	switch_core_session_t *peer_session;	unsigned int timelimit = 60;	char *var;	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;	caller_channel = switch_core_session_get_channel(session);	assert(caller_channel != NULL);	if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {		timelimit = atoi(var);	}	if (switch_ivr_originate(session, &peer_session, &cause, bridgeto, timelimit, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Cannot Create Outgoing Channel!/n");		switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);		return;	} else {		switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);		switch_core_session_rwunlock(peer_session);	}}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:29,


示例4: channel_on_hangup

static switch_status_t channel_on_hangup(switch_core_session_t *session){	switch_channel_t *channel = NULL;	private_t *tech_pvt = NULL;	channel = switch_core_session_get_channel(session);	switch_assert(channel != NULL);	tech_pvt = switch_core_session_get_private(session);	switch_assert(tech_pvt != NULL);	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP/n", switch_channel_get_name(channel));	switch_clear_flag_locked(tech_pvt, TFLAG_LINKED);	switch_mutex_lock(tech_pvt->mutex);	if (tech_pvt->other_tech_pvt) {		switch_clear_flag_locked(tech_pvt->other_tech_pvt, TFLAG_LINKED);		tech_pvt->other_tech_pvt = NULL;	}	if (tech_pvt->other_session) {		switch_channel_hangup(tech_pvt->other_channel, switch_channel_get_cause(channel));		switch_core_session_rwunlock(tech_pvt->other_session);		tech_pvt->other_channel = NULL;		tech_pvt->other_session = NULL;	}	switch_mutex_unlock(tech_pvt->mutex);	return SWITCH_STATUS_SUCCESS;}
开发者ID:gujun,项目名称:sscore,代码行数:30,


示例5: channel_kill_channel

static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig){	switch_channel_t *channel = NULL;	private_t *tech_pvt = NULL;	channel = switch_core_session_get_channel(session);	switch_assert(channel != NULL);	tech_pvt = switch_core_session_get_private(session);	switch_assert(tech_pvt != NULL);	switch (sig) {	case SWITCH_SIG_BREAK:		break;	case SWITCH_SIG_KILL:		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);		switch_clear_flag_locked(tech_pvt, TFLAG_LINKED);		switch_mutex_lock(tech_pvt->mutex);		if (tech_pvt->other_tech_pvt) {			switch_clear_flag_locked(tech_pvt->other_tech_pvt, TFLAG_LINKED);		}		switch_mutex_unlock(tech_pvt->mutex);		break;	default:		break;	}	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL KILL/n", switch_channel_get_name(channel));	return SWITCH_STATUS_SUCCESS;}
开发者ID:hsaid,项目名称:FreeSWITCH,代码行数:31,


示例6: do_snap

static switch_status_t do_snap(switch_core_session_t *session){	switch_channel_t *channel = switch_core_session_get_channel(session);	switch_media_bug_t *bug = switch_channel_get_private(channel, "snapshot");	char *file;	switch_file_handle_t fh = { 0 };	switch_codec_implementation_t read_impl = { 0 };	switch_size_t bytes_read;	int16_t pdata[4096] = { 0 };	if (bug) {		switch_time_exp_t tm;		switch_size_t retsize;		char date[80] = "";		struct cap_cb *cb = (struct cap_cb *) switch_core_media_bug_get_user_data(bug);		if (!cb) {			return SWITCH_STATUS_FALSE;		}		switch_time_exp_lt(&tm, switch_time_make(switch_epoch_time_now(NULL), 0));		switch_strftime(date, &retsize, sizeof(date), "%Y_%m_%d_%H_%M_%S", &tm);		file = switch_core_session_sprintf(session, "%s%s%s_%s.wav", SWITCH_GLOBAL_dirs.sounds_dir, SWITCH_PATH_SEPARATOR, cb->base, date);		switch_core_session_get_read_impl(session, &read_impl);		fh.channels = 0;		fh.native_rate = read_impl.actual_samples_per_second;		if (switch_core_file_open(&fh,								  file,								  0,								  read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error opening %s/n", file);			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);			switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);			return SWITCH_STATUS_FALSE;		}		switch_mutex_lock(cb->mutex);		while ((bytes_read = switch_buffer_read(cb->buffer, pdata, sizeof(pdata)))) {			switch_size_t samples = bytes_read / 2;			if (switch_core_file_write(&fh, pdata, &samples) != SWITCH_STATUS_SUCCESS) {				break;			}		}		switch_mutex_unlock(cb->mutex);		switch_core_file_close(&fh);		switch_core_set_variable("file", file);		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Wrote %s/n", file);		return SWITCH_STATUS_SUCCESS;	}	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s Bug is not attached./n", switch_channel_get_name(channel));	return SWITCH_STATUS_FALSE;	}
开发者ID:DrumTechnologiesLtd,项目名称:FreeSWITCH,代码行数:58,


示例7: SWITCH_DECLARE

SWITCH_DECLARE(void) CoreSession::hangup(const char *cause){	this_check_void();	sanity_check_noreturn;	    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CoreSession::hangup/n");	this->begin_allow_threads();    switch_channel_hangup(channel, switch_channel_str2cause(cause));	this->end_allow_threads();}
开发者ID:gujun,项目名称:sscore,代码行数:9,


示例8: loopback_bowout_on_execute_state_handler

static switch_status_t loopback_bowout_on_execute_state_handler(switch_core_session_t *session){	switch_channel_t *channel = switch_core_session_get_channel(session);	switch_channel_state_t state = switch_channel_get_state(channel);	private_t *tech_pvt = NULL;	if (state == CS_EXECUTE) {		const char *uuid;		switch_core_session_t *other_session = NULL;		switch_channel_t *b_channel = NULL;		tech_pvt = switch_core_session_get_private(session);		if (switch_core_session_read_lock(tech_pvt->other_session) == SWITCH_STATUS_SUCCESS) {			b_channel = switch_core_session_get_channel(tech_pvt->other_session);			/* Wait for b_channel to be fully bridged */			switch_channel_wait_for_flag(b_channel, CF_BRIDGED, SWITCH_TRUE, 5000, NULL);			uuid = switch_channel_get_partner_uuid(b_channel);			if (uuid && (other_session = switch_core_session_locate(uuid))) {				switch_channel_t *other_channel = switch_core_session_get_channel(other_session);				switch_caller_profile_t *cp, *clone;				switch_channel_wait_for_state(other_channel, NULL, CS_EXCHANGE_MEDIA);				switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->other_session), SWITCH_LOG_INFO, "Replacing loopback channel: %s with real channel: %s/n",								  switch_channel_get_name(b_channel), switch_channel_get_name(other_channel));				if ((cp = switch_channel_get_caller_profile(channel))) {					clone = switch_caller_profile_clone(other_session, cp);					clone->originator_caller_profile = NULL;					clone->originatee_caller_profile = NULL;					switch_channel_set_caller_profile(other_channel, clone);				}				switch_channel_caller_extension_masquerade(channel, other_channel, 0);				switch_channel_set_state(other_channel, CS_RESET);				switch_channel_wait_for_state(other_channel, NULL, CS_RESET);				switch_channel_set_variable(channel, "process_cdr", "false");				switch_channel_set_variable(b_channel, "process_cdr", "false");				switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);				switch_channel_set_state(other_channel, CS_EXECUTE);				switch_core_session_rwunlock(other_session);			}			switch_core_session_rwunlock(tech_pvt->other_session);		}				switch_core_event_hook_remove_state_change(session, loopback_bowout_on_execute_state_handler);	}	return SWITCH_STATUS_SUCCESS;}
开发者ID:hsaid,项目名称:FreeSWITCH,代码行数:56,


示例9: switch_core_standard_on_execute

static void switch_core_standard_on_execute(switch_core_session_t *session){	switch_caller_extension_t *extension;	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Standard EXECUTE/n", switch_channel_get_name(session->channel));	if (switch_channel_get_variable(session->channel, "recovered") && !switch_channel_test_flag(session->channel, CF_RECOVERED)) {		switch_channel_set_flag(session->channel, CF_RECOVERED);	}  top:	switch_channel_clear_flag(session->channel, CF_RESET);		if ((extension = switch_channel_get_caller_extension(session->channel)) == 0) {		switch_channel_hangup(session->channel, SWITCH_CAUSE_NORMAL_CLEARING);		return;	}	while (switch_channel_get_state(session->channel) == CS_EXECUTE && extension->current_application) {		switch_caller_application_t *current_application = extension->current_application;		extension->current_application = extension->current_application->next;		if (switch_core_session_execute_application(session,													current_application->application_name,													current_application->application_data) != SWITCH_STATUS_SUCCESS) {			return;		}		if (switch_channel_test_flag(session->channel, CF_RESET)) {			goto top;		}	}	if (switch_channel_ready(session->channel) && switch_channel_get_state(session->channel) == CS_EXECUTE) {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "%s has executed the last dialplan instruction, hanging up./n",						  switch_channel_get_name(session->channel));		switch_channel_hangup(session->channel, SWITCH_CAUSE_NORMAL_CLEARING);	}}
开发者ID:kgrofelnik,项目名称:mod_portaudio-endpoints,代码行数:41,


示例10: modem_close

//.........这里部分代码省略.........	switch_codec_t write_codec;	switch_frame_t read_frame;	unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];	switch_timer_t timer;	modem_t *modem;	switch_caller_profile_t *caller_profile;	int dead;};typedef struct private_object private_t;static switch_status_t channel_on_init(switch_core_session_t *session);static switch_status_t channel_on_hangup(switch_core_session_t *session);static switch_status_t channel_on_destroy(switch_core_session_t *session);static switch_status_t channel_on_routing(switch_core_session_t *session);static switch_status_t channel_on_exchange_media(switch_core_session_t *session);static switch_status_t channel_on_soft_execute(switch_core_session_t *session);static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,													switch_caller_profile_t *outbound_profile,													switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,													switch_call_cause_t *cancel_cause);static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);/*    State methods they get called when the state changes to the specific state    returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next   so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.*/static switch_status_t channel_on_init(switch_core_session_t *session){	switch_channel_t *channel;	private_t *tech_pvt = NULL;	int to_ticks = 60, ring_ticks = 10, rt = ring_ticks;	int rest = 500000;		tech_pvt = switch_core_session_get_private(session);	switch_assert(tech_pvt != NULL);	channel = switch_core_session_get_channel(session);	switch_assert(channel != NULL);	if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {#ifndef WIN32		int tioflags;#endif		char call_time[16];		char call_date[16];		switch_size_t retsize;		switch_time_exp_t tm;		switch_time_exp_lt(&tm, switch_micro_time_now());		switch_strftime(call_date, &retsize, sizeof(call_date), "%m%d", &tm);		switch_strftime(call_time, &retsize, sizeof(call_time), "%H%M", &tm);#ifndef WIN32		ioctl(tech_pvt->modem->slave, TIOCMGET, &tioflags);		tioflags |= TIOCM_RI;		ioctl(tech_pvt->modem->slave, TIOCMSET, &tioflags);#endif		at_reset_call_info(&tech_pvt->modem->t31_state->at_state);		at_set_call_info(&tech_pvt->modem->t31_state->at_state, "DATE", call_date);		at_set_call_info(&tech_pvt->modem->t31_state->at_state, "TIME", call_time);		at_set_call_info(&tech_pvt->modem->t31_state->at_state, "NAME", tech_pvt->caller_profile->caller_id_name);		at_set_call_info(&tech_pvt->modem->t31_state->at_state, "NMBR", tech_pvt->caller_profile->caller_id_number);		at_set_call_info(&tech_pvt->modem->t31_state->at_state, "ANID", tech_pvt->caller_profile->ani);		at_set_call_info(&tech_pvt->modem->t31_state->at_state, "USER", tech_pvt->caller_profile->username);		at_set_call_info(&tech_pvt->modem->t31_state->at_state, "CDID", tech_pvt->caller_profile->context);		at_set_call_info(&tech_pvt->modem->t31_state->at_state, "NDID", tech_pvt->caller_profile->destination_number);		modem_set_state(tech_pvt->modem, MODEM_STATE_RINGING);		t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_ALERTING);				while(to_ticks > 0 && switch_channel_up(channel) && modem_get_state(tech_pvt->modem) == MODEM_STATE_RINGING) {			if (--rt <= 0) {				t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_ALERTING);				rt = ring_ticks;			}						switch_yield(rest);			to_ticks--;		}				if (to_ticks < 1 || modem_get_state(tech_pvt->modem) != MODEM_STATE_ANSWERED) {			t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_NO_ANSWER);			switch_channel_hangup(channel, SWITCH_CAUSE_NO_ANSWER);		} else {			t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_ANSWERED);			modem_set_state(tech_pvt->modem, MODEM_STATE_CONNECTED);			switch_channel_mark_answered(channel);		}	}	switch_channel_set_state(channel, CS_ROUTING);		return SWITCH_STATUS_SUCCESS;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:101,


示例11: channel_read_frame

static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id){	switch_channel_t *channel = NULL;	private_t *tech_pvt = NULL;	switch_status_t status = SWITCH_STATUS_FALSE;	switch_mutex_t *mutex = NULL;	void *pop = NULL;	channel = switch_core_session_get_channel(session);	switch_assert(channel != NULL);	tech_pvt = switch_core_session_get_private(session);	switch_assert(tech_pvt != NULL);	if (!switch_test_flag(tech_pvt, TFLAG_LINKED)) {		goto end;	}	*frame = NULL;	if (!switch_channel_ready(channel)) {		goto end;	}	switch_core_timer_next(&tech_pvt->timer);	mutex = tech_pvt->mutex;	switch_mutex_lock(mutex);	if (switch_queue_trypop(tech_pvt->frame_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {		if (tech_pvt->write_frame) {			switch_frame_free(&tech_pvt->write_frame);		}		tech_pvt->write_frame = (switch_frame_t *) pop;		tech_pvt->write_frame->codec = &tech_pvt->read_codec;		*frame = tech_pvt->write_frame;	} else {		switch_set_flag(tech_pvt, TFLAG_CNG);	}	if (switch_test_flag(tech_pvt, TFLAG_CNG)) {		unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE];		uint32_t flag = 0;		switch_status_t encode_status;		uint32_t rate = tech_pvt->read_codec.implementation->actual_samples_per_second;		*frame = &tech_pvt->cng_frame;		tech_pvt->cng_frame.codec = &tech_pvt->read_codec;		tech_pvt->cng_frame.datalen = tech_pvt->read_codec.implementation->decoded_bytes_per_packet;		memset(tech_pvt->cng_frame.data, 0, tech_pvt->cng_frame.datalen);		memset(&data, 0, tech_pvt->read_codec.implementation->decoded_bytes_per_packet);		if (strcasecmp(tech_pvt->read_codec.implementation->iananame, "L16")) {			encode_status = switch_core_codec_encode(&tech_pvt->read_codec,													 NULL,													 data,													 tech_pvt->read_codec.implementation->decoded_bytes_per_packet,													 tech_pvt->read_codec.implementation->actual_samples_per_second,													 tech_pvt->cng_frame.data, &tech_pvt->cng_frame.datalen, &rate, &flag);			if (encode_status != SWITCH_STATUS_SUCCESS) {				switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);			}		}		//switch_set_flag((&tech_pvt->cng_frame), SFF_CNG);		switch_clear_flag_locked(tech_pvt, TFLAG_CNG);	}	if (*frame) {		status = SWITCH_STATUS_SUCCESS;	} else {		status = SWITCH_STATUS_FALSE;	}  end:	if (mutex) {		switch_mutex_unlock(mutex);	}	return status;}
开发者ID:gujun,项目名称:sscore,代码行数:85,


示例12: create_session

static switch_status_t create_session(switch_core_session_t **new_session, modem_t *modem){	switch_status_t status = SWITCH_STATUS_FALSE;	switch_core_session_t *session;	switch_channel_t *channel;	private_t *tech_pvt = NULL;	char name[1024];	switch_caller_profile_t *caller_profile;	char *ani = NULL, *p, *digits = NULL;		if (!(session = switch_core_session_request(modem_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL))) {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Failure./n");		goto end;	}	switch_core_session_add_stream(session, NULL);	channel = switch_core_session_get_channel(session);	tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(*tech_pvt));		p = switch_core_session_strdup(session, modem->digits);	if (*p == '*') {		ani = p + 1;		if ((digits = strchr(ani, '*'))) {			*digits++ = '/0';		} else {			ani = NULL;		}	}		if (zstr(digits)) {		digits = p;	}	if (zstr(ani)) {		ani = modem->devlink + 5;	}	switch_snprintf(name, sizeof(name), "modem/%d/%s", modem->slot, digits);	switch_channel_set_name(channel, name);	if (tech_init(tech_pvt, session) != SWITCH_STATUS_SUCCESS) {		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);		switch_core_session_destroy(&session);		goto end;	}	caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),											   modem->devlink,											   spandsp_globals.modem_dialplan,											   "FSModem", 											   ani,											   NULL, 											   ani,											   NULL, 											   NULL, 											   "mod_spandsp", 											   spandsp_globals.modem_context, 											   digits);		caller_profile->source = switch_core_strdup(caller_profile->pool, "mod_spandsp");	switch_channel_set_caller_profile(channel, caller_profile);	tech_pvt->caller_profile = caller_profile;	switch_channel_set_state(channel, CS_INIT);	if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Error spawning thread/n");		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);		goto end;	}	status = SWITCH_STATUS_SUCCESS;	tech_attach(tech_pvt, modem);	*new_session = session; end:	return status;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:81,


示例13: channel_on_init

/*    State methods they get called when the state changes to the specific state    returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next   so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.*/static switch_status_t channel_on_init(switch_core_session_t *session){	switch_channel_t *channel, *b_channel;	private_t *tech_pvt = NULL, *b_tech_pvt = NULL;	switch_core_session_t *b_session;	char name[128];	switch_caller_profile_t *caller_profile;	tech_pvt = switch_core_session_get_private(session);	switch_assert(tech_pvt != NULL);	channel = switch_core_session_get_channel(session);	switch_assert(channel != NULL);	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && !switch_test_flag(tech_pvt, TFLAG_BLEG)) {		if (!(b_session = switch_core_session_request(loopback_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL))) {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Failure./n");			goto end;		}		if (switch_core_session_read_lock(b_session) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Failure./n");			switch_core_session_destroy(&b_session);			goto end;		}		switch_core_session_add_stream(b_session, NULL);		b_channel = switch_core_session_get_channel(b_session);		b_tech_pvt = (private_t *) switch_core_session_alloc(b_session, sizeof(*b_tech_pvt));		switch_snprintf(name, sizeof(name), "loopback/%s-b", tech_pvt->caller_profile->destination_number);		switch_channel_set_name(b_channel, name);		if (tech_init(b_tech_pvt, b_session, switch_core_session_get_read_codec(session)) != SWITCH_STATUS_SUCCESS) {			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);			switch_core_session_destroy(&b_session);			goto end;		}		caller_profile = switch_caller_profile_clone(b_session, tech_pvt->caller_profile);		caller_profile->source = switch_core_strdup(caller_profile->pool, modname);		switch_channel_set_caller_profile(b_channel, caller_profile);		b_tech_pvt->caller_profile = caller_profile;		switch_channel_set_state(b_channel, CS_INIT);		tech_pvt->other_session = b_session;		tech_pvt->other_tech_pvt = b_tech_pvt;		tech_pvt->other_channel = b_channel;		//b_tech_pvt->other_session = session;		//b_tech_pvt->other_tech_pvt = tech_pvt;		//b_tech_pvt->other_channel = channel;		b_tech_pvt->other_uuid = switch_core_session_strdup(b_session, switch_core_session_get_uuid(session));		switch_set_flag_locked(tech_pvt, TFLAG_LINKED);		switch_set_flag_locked(b_tech_pvt, TFLAG_LINKED);		switch_set_flag_locked(b_tech_pvt, TFLAG_BLEG);		switch_channel_set_flag(channel, CF_ACCEPT_CNG);		//switch_ivr_transfer_variable(session, tech_pvt->other_session, "process_cdr");		switch_ivr_transfer_variable(session, tech_pvt->other_session, NULL);		switch_channel_set_variable(channel, "other_loopback_leg_uuid", switch_channel_get_uuid(b_channel));		switch_channel_set_variable(b_channel, "other_loopback_leg_uuid", switch_channel_get_uuid(channel));		if (switch_core_session_thread_launch(b_session) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Error spawning thread/n");			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);			goto end;		}	} else if ((tech_pvt->other_session = switch_core_session_locate(tech_pvt->other_uuid))) {		tech_pvt->other_tech_pvt = switch_core_session_get_private(tech_pvt->other_session);		tech_pvt->other_channel = switch_core_session_get_channel(tech_pvt->other_session);	}	if (!tech_pvt->other_session) {		switch_clear_flag_locked(tech_pvt, TFLAG_LINKED);		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);		goto end;	}	switch_channel_set_variable(channel, "loopback_leg", switch_test_flag(tech_pvt, TFLAG_BLEG) ? "B" : "A");	switch_channel_set_state(channel, CS_ROUTING);  end:	return SWITCH_STATUS_SUCCESS;}
开发者ID:gujun,项目名称:sscore,代码行数:97,


示例14: switch_log_printf

bool WSClientParser::HangupCall() {	switch_core_session_t* session = NULL;	if( mpChannel ) {		// 挂断会话		char* uuid = mpChannel->uuid_str;		switch_log_printf(				SWITCH_CHANNEL_UUID_LOG(this->GetUUID()),				SWITCH_LOG_INFO,				"WSClientParser::HangupCall( "				"[Start], "				"this : %p, "				"wsChannel : %p, "				"session : '%s' "				") /n",				this,				mpChannel,				uuid				);		if( uuid ) {			// 挂断会话			session = switch_core_session_locate(uuid);			if ( session != NULL )  {				switch_channel_t* channel = switch_core_session_get_channel(session);				if( channel ) {					switch_log_printf(							SWITCH_CHANNEL_UUID_LOG(this->GetUUID()),							SWITCH_LOG_INFO,							"WSClientParser::HangupCall( "							"[Channel hang up], "							"this : %p, "							"wsChannel : %p, "							"session : '%s' "							") /n",							this,							mpChannel,							switch_core_session_get_uuid(session)							);					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);				} else {					switch_log_printf(							SWITCH_CHANNEL_UUID_LOG(this->GetUUID()),							SWITCH_LOG_INFO,							"WSClientParser::HangupCall( "							"[No channel to hang up], "							"this : %p, "							"wsChannel : %p, "							"session : '%s' "							") /n",							this,							mpChannel,							switch_core_session_get_uuid(session)							);				}				switch_core_session_rwunlock(session);			}		}		switch_log_printf(				SWITCH_CHANNEL_UUID_LOG(this->GetUUID()),				SWITCH_LOG_INFO,				"WSClientParser::HangupCall( "				"[Success], "				"this : %p, "				"wsChannel : %p, "				"session : '%s' "				") /n",				this,				mpChannel,				uuid				);	}	return (session != NULL);}
开发者ID:KingsleyYau,项目名称:CamShareMiddleware,代码行数:77,


示例15: control_handler

static int control_handler(modem_t *modem, const char *num, int op){	switch_core_session_t *session = NULL;		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Control Handler op:%d state:[%s] %s/n", 					  op, modem_state2name(modem_get_state(modem)), modem->devlink);    switch (op) {    case AT_MODEM_CONTROL_ANSWER:        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,						  "Modem %s [%s] - Answering/n", modem->devlink, modem_state2name(modem_get_state(modem)));		modem_set_state(modem, MODEM_STATE_ANSWERED);        break;    case AT_MODEM_CONTROL_CALL:		{			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,							  "Modem %s [%s] - Dialing '%s'/n", modem->devlink, modem_state2name(modem_get_state(modem)), num);			modem_set_state(modem, MODEM_STATE_DIALING);			switch_clear_flag(modem, MODEM_FLAG_XOFF);			wake_modem_thread(modem);			switch_set_string(modem->digits, num);						if (create_session(&session, modem) != SWITCH_STATUS_SUCCESS) {				t31_call_event(modem->t31_state, AT_CALL_EVENT_HANGUP);			} else {				switch_core_session_thread_launch(session);			}		}		break;    case AT_MODEM_CONTROL_OFFHOOK:        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,						  "Modem %s [%s] - Going off hook/n", modem->devlink, modem_state2name(modem_get_state(modem)));		modem_set_state(modem, MODEM_STATE_OFFHOOK);		break;    case AT_MODEM_CONTROL_ONHOOK:    case AT_MODEM_CONTROL_HANGUP: 		{			if (modem_get_state(modem) != MODEM_STATE_RINGING) {				int set_state = 1;								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,								  "Modem %s [%s] - Hanging up/n", modem->devlink, modem_state2name(modem_get_state(modem)));				switch_clear_flag(modem, MODEM_FLAG_XOFF);				wake_modem_thread(modem);								modem_set_state(modem, MODEM_STATE_HANGUP);							if (!zstr(modem->uuid_str)) {					switch_core_session_t *session;										if ((session = switch_core_session_force_locate(modem->uuid_str))) {						switch_channel_t *channel = switch_core_session_get_channel(session);												if (switch_channel_up(channel)) {							switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);							set_state = 0;						}						switch_core_session_rwunlock(session);					}				}								if (set_state) {					modem_set_state(modem, MODEM_STATE_ONHOOK);				}			}		}        break;    case AT_MODEM_CONTROL_DTR:        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,						  "Modem %s [%s] - DTR %d/n", modem->devlink, modem_state2name(modem_get_state(modem)), (int) (intptr_t) num);        break;    case AT_MODEM_CONTROL_RTS:        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,						  "Modem %s [%s] - RTS %d/n", modem->devlink, modem_state2name(modem_get_state(modem)), (int) (intptr_t) num);        break;    case AT_MODEM_CONTROL_CTS:		{			u_char x[1];			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1,							  "Modem %s [%s] - CTS %s/n", modem->devlink, modem_state2name(modem_get_state(modem)), (int) (intptr_t) num ? "XON" : "XOFF");			if (num) {				x[0] = 0x11;				t31_at_tx_handler(&modem->t31_state->at_state, modem, x, 1);				switch_clear_flag(modem, MODEM_FLAG_XOFF);				wake_modem_thread(modem);			} else {				x[0] = 0x13;				t31_at_tx_handler(&modem->t31_state->at_state, modem, x, 1);				switch_set_flag(modem, MODEM_FLAG_XOFF);			}		}        break;    case AT_MODEM_CONTROL_CAR:        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,//.........这里部分代码省略.........
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:101,


示例16: channel_on_execute

static switch_status_t channel_on_execute(switch_core_session_t *session){	switch_channel_t *channel = NULL;	loopback_private_t *tech_pvt = NULL;	switch_caller_extension_t *exten = NULL;	const char *bowout = NULL;	int bow = 0;	channel = switch_core_session_get_channel(session);	assert(channel != NULL);	tech_pvt = switch_core_session_get_private(session);	assert(tech_pvt != NULL);	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE/n", switch_channel_get_name(channel));	if ((bowout = switch_channel_get_variable(tech_pvt->channel, "loopback_bowout_on_execute")) && switch_true(bowout)) {		/* loopback_bowout_on_execute variable is set */		bow = 1;	} else if ((exten = switch_channel_get_caller_extension(channel))) {		/* check for bowout flag */		switch_caller_application_t *app_p;		for (app_p = exten->applications; app_p; app_p = app_p->next) {			int32_t flags;			switch_core_session_get_app_flags(app_p->application_name, &flags);			if ((flags & SAF_NO_LOOPBACK)) {				bow = 1;				break;			}		}	}	if (bow) {		switch_core_session_t *other_session = NULL;		switch_caller_profile_t *cp, *clone;		const char *other_uuid = NULL;		switch_event_t *event = NULL;		switch_set_flag(tech_pvt, TFLAG_BOWOUT);		if ((find_non_loopback_bridge(tech_pvt->other_session, &other_session, &other_uuid) == SWITCH_STATUS_SUCCESS)) {			switch_channel_t *other_channel = switch_core_session_get_channel(other_session);			switch_channel_wait_for_state_timeout(other_channel, CS_EXCHANGE_MEDIA, 5000);			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_INFO, "BOWOUT Replacing loopback channel with real channel: %s/n",							  switch_channel_get_name(other_channel));			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, "loopback::bowout") == SWITCH_STATUS_SUCCESS) {				switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Resigning-UUID", switch_channel_get_uuid(channel));				switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Acquired-UUID", switch_channel_get_uuid(other_channel));				switch_event_fire(&event);			}			if ((cp = switch_channel_get_caller_profile(channel))) {				clone = switch_caller_profile_clone(other_session, cp);				clone->originator_caller_profile = NULL;				clone->originatee_caller_profile = NULL;				switch_channel_set_caller_profile(other_channel, clone);			}			switch_channel_caller_extension_masquerade(channel, other_channel, 0);			switch_channel_set_state(other_channel, CS_RESET);			switch_channel_wait_for_state(other_channel, NULL, CS_RESET);			switch_channel_set_state(other_channel, CS_EXECUTE);			switch_core_session_rwunlock(other_session);			switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_UNSPECIFIED);		}	}	return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:75,


示例17: fs_channel_hangup

void fs_channel_hangup(switch_core_session_t *session, char *cause){	switch_channel_t *channel = switch_core_session_get_channel(session);	switch_channel_hangup(channel, switch_channel_str2cause(cause));}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:5,


示例18: channel_on_init

/*    State methods they get called when the state changes to the specific state    returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next   so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.*/static switch_status_t channel_on_init(switch_core_session_t *session){	switch_channel_t *channel, *b_channel;	private_t *tech_pvt = NULL, *b_tech_pvt = NULL;	switch_core_session_t *b_session;	char name[128];	switch_caller_profile_t *caller_profile;	switch_event_t *vars = NULL;	const char *var;	tech_pvt = switch_core_session_get_private(session);	switch_assert(tech_pvt != NULL);	channel = switch_core_session_get_channel(session);	switch_assert(channel != NULL);	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && !switch_test_flag(tech_pvt, TFLAG_BLEG)) {		if (!(b_session = switch_core_session_request(loopback_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL))) {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Failure./n");			goto end;		}		if (switch_core_session_read_lock(b_session) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Failure./n");			switch_core_session_destroy(&b_session);			goto end;		}		switch_core_session_add_stream(b_session, NULL);		b_channel = switch_core_session_get_channel(b_session);		b_tech_pvt = (private_t *) switch_core_session_alloc(b_session, sizeof(*b_tech_pvt));		switch_snprintf(name, sizeof(name), "loopback/%s-b", tech_pvt->caller_profile->destination_number);		switch_channel_set_name(b_channel, name);		if (tech_init(b_tech_pvt, b_session, switch_core_session_get_read_codec(session)) != SWITCH_STATUS_SUCCESS) {			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);			switch_core_session_destroy(&b_session);			goto end;		}		caller_profile = switch_caller_profile_clone(b_session, tech_pvt->caller_profile);		caller_profile->source = switch_core_strdup(caller_profile->pool, modname);		switch_channel_set_caller_profile(b_channel, caller_profile);		b_tech_pvt->caller_profile = caller_profile;		switch_channel_set_state(b_channel, CS_INIT);		tech_pvt->other_session = b_session;		tech_pvt->other_tech_pvt = b_tech_pvt;		tech_pvt->other_channel = b_channel;		//b_tech_pvt->other_session = session;		//b_tech_pvt->other_tech_pvt = tech_pvt;		//b_tech_pvt->other_channel = channel;		b_tech_pvt->other_uuid = switch_core_session_strdup(b_session, switch_core_session_get_uuid(session));		switch_set_flag_locked(tech_pvt, TFLAG_LINKED);		switch_set_flag_locked(b_tech_pvt, TFLAG_LINKED);		switch_set_flag_locked(b_tech_pvt, TFLAG_BLEG);		switch_channel_set_flag(channel, CF_ACCEPT_CNG);		if ((vars = (switch_event_t *) switch_channel_get_private(channel, "__loopback_vars__"))) {			switch_event_header_t *h;					switch_channel_set_private(channel, "__loopback_vars__", NULL);			for (h = vars->headers; h; h = h->next) {				switch_channel_set_variable(tech_pvt->other_channel, h->name, h->value);			}			switch_event_destroy(&vars);		}		if ((var = switch_channel_get_variable(channel, "loopback_export"))) {			int argc = 0;			char *argv[128] = { 0 };			char *dup = switch_core_session_strdup(session, var);			if ((argc = switch_split(dup, ',', argv))) {				int i;				for (i = 0; i < argc; i++) {										if (!zstr(argv[i])) {						const char *val = switch_channel_get_variable(channel, argv[i]);						if(!zstr(val)) {							switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Transfer variable [%s]=[%s] %s -> %s/n",											  argv[i], val, switch_channel_get_name(channel), switch_channel_get_name(tech_pvt->other_channel));											  							switch_channel_set_variable(tech_pvt->other_channel, argv[i], val);//.........这里部分代码省略.........
开发者ID:hsaid,项目名称:FreeSWITCH,代码行数:101,



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


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