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

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

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

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

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

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


示例2: do_lookup_url

static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, char **response, const char *query, struct curl_httppost *post,						  switch_curl_slist_t *headers, int timeout){	switch_time_t start_time = switch_micro_time_now();	switch_time_t time_diff = 0;	CURL *curl_handle = NULL;	long httpRes = 0;	struct http_data http_data;	memset(&http_data, 0, sizeof(http_data));	http_data.max_bytes = 10240;	SWITCH_STANDARD_STREAM(http_data.stream);	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "url: %s/n", query);	curl_handle = switch_curl_easy_init();	switch_curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 0);	switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);	if (!strncasecmp(query, "https", 5)) {		switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);		switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);	}	if (post) {		switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, post);	} else {		switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1);	}	if (headers) {		switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);	}	switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);	switch_curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);	/*	   TIMEOUT_MS is introduced in 7.16.2, we have 7.16.0 in tree 	 */#ifdef CURLOPT_TIMEOUT_MS	if (timeout > 0) {		switch_curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT_MS, timeout);	} else {		switch_curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT_MS, globals.curl_timeout);	}#else	if (timeout > 0) {		switch_curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, timeout);	} else {		switch_curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, globals.curl_timeout / 1000);	}#endif	switch_curl_easy_setopt(curl_handle, CURLOPT_URL, query);	switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, file_callback);	switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &http_data);	switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-cidlookup/1.0");	switch_curl_easy_perform(curl_handle);	switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);	switch_curl_easy_cleanup(curl_handle);	if (http_data.stream.data && !zstr((char *) http_data.stream.data) && strcmp(" ", http_data.stream.data)) {		/* don't return UNKNOWN */		if (strcmp("UNKNOWN", http_data.stream.data) || strcmp("UNAVAILABLE", http_data.stream.data)) {			*response = switch_core_strdup(pool, http_data.stream.data);		}	}	time_diff = (switch_micro_time_now() - start_time);	/* convert to milli from micro */	if ((time_diff / 1000) >= globals.curl_warnduration) {		switch_core_time_duration_t duration;		switch_core_measure_time(time_diff, &duration);		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SLOW LOOKUP ("						  "%um, " "%us, " "%ums" "): url: %s/n", duration.min, duration.sec, duration.ms, query);	}	switch_safe_free(http_data.stream.data);	return httpRes;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:80,


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


示例4: SWITCH_DECLARE

SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_menu,													 switch_ivr_menu_t *main,													 const char *name,													 const char *greeting_sound,													 const char *short_greeting_sound,													 const char *invalid_sound,													 const char *exit_sound,													 const char *confirm_macro,													 const char *confirm_key,													 const char *tts_engine,													 const char *tts_voice,													 int confirm_attempts,													 int inter_timeout,													 int digit_len, int timeout, int max_failures, int max_timeouts, switch_memory_pool_t *pool){	switch_ivr_menu_t *menu;	uint8_t newpool = 0;	if (!pool) {		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool/n");			return SWITCH_STATUS_MEMERR;		}		newpool = 1;	}	if (!(menu = switch_core_alloc(pool, sizeof(*menu)))) {		if (newpool) {			switch_core_destroy_memory_pool(&pool);			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!/n");			return SWITCH_STATUS_MEMERR;		}	}	menu->pool = pool;	if (!confirm_attempts) {		confirm_attempts = 3;	}	if (!inter_timeout) {		inter_timeout = timeout / 2;	}	if (!zstr(name)) {		menu->name = switch_core_strdup(menu->pool, name);	}	if (!zstr(greeting_sound)) {		menu->greeting_sound = switch_core_strdup(menu->pool, greeting_sound);	}	if (!zstr(short_greeting_sound)) {		menu->short_greeting_sound = switch_core_strdup(menu->pool, short_greeting_sound);	}	if (!zstr(invalid_sound)) {		menu->invalid_sound = switch_core_strdup(menu->pool, invalid_sound);	}	if (!zstr(exit_sound)) {		menu->exit_sound = switch_core_strdup(menu->pool, exit_sound);	}	if (!zstr(confirm_key)) {		menu->confirm_key = switch_core_strdup(menu->pool, confirm_key);	}	if (!zstr(confirm_macro)) {		menu->confirm_macro = switch_core_strdup(menu->pool, confirm_macro);	}	if (!zstr(tts_engine)) {		menu->tts_engine = switch_core_strdup(menu->pool, tts_engine);	}	if (!zstr(tts_voice)) {		menu->tts_voice = switch_core_strdup(menu->pool, tts_voice);	}	menu->confirm_attempts = confirm_attempts;	menu->inlen = digit_len;	if (max_failures > 0) {		menu->max_failures = max_failures;	} else {		menu->max_failures = 3;	}	if (max_timeouts > 0) {		menu->max_timeouts = max_timeouts;	} else {		menu->max_timeouts = 3;	}	menu->timeout = timeout;	menu->inter_timeout = inter_timeout;//.........这里部分代码省略.........
开发者ID:hsaid,项目名称:FreeSWITCH,代码行数:101,


示例5: SWITCH_DECLARE

SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec, const char *codec_name, const char *fmtp,													   uint32_t rate, int ms, int channels, uint32_t flags,													   const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool){	switch_codec_interface_t *codec_interface;	const switch_codec_implementation_t *iptr, *implementation = NULL;	switch_assert(codec != NULL);	switch_assert(codec_name != NULL);	memset(codec, 0, sizeof(*codec));	if (channels == 2) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stereo is currently unsupported. please downsample audio source to mono./n");		return SWITCH_STATUS_GENERR;	}	if ((codec_interface = switch_loadable_module_get_codec_interface(codec_name)) == 0) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid codec %s!/n", codec_name);		return SWITCH_STATUS_GENERR;	}	/* If no specific codec interval is requested opt for 20ms above all else because lots of stuff assumes it */	if (!ms) {		for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) {			if ((!rate || rate == iptr->samples_per_second) &&				(20 == (iptr->microseconds_per_packet / 1000)) && (!channels || channels == iptr->number_of_channels)) {				implementation = iptr;				goto found;			}		}	}	/* Either looking for a specific interval or there was no interval specified and there wasn't one @20ms available */	for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) {		if ((!rate || rate == iptr->samples_per_second) &&			(!ms || ms == (iptr->microseconds_per_packet / 1000)) && (!channels || channels == iptr->number_of_channels)) {			implementation = iptr;			break;		}	}  found:	if (implementation) {		switch_status_t status;		codec->codec_interface = codec_interface;		codec->implementation = implementation;		codec->flags = flags;		if (pool) {			codec->memory_pool = pool;		} else {			if ((status = switch_core_new_memory_pool(&codec->memory_pool)) != SWITCH_STATUS_SUCCESS) {				return status;			}			switch_set_flag(codec, SWITCH_CODEC_FLAG_FREE_POOL);		}		if (fmtp) {			codec->fmtp_in = switch_core_strdup(codec->memory_pool, fmtp);		}		implementation->init(codec, flags, codec_settings);		switch_mutex_init(&codec->mutex, SWITCH_MUTEX_NESTED, codec->memory_pool);		switch_set_flag(codec, SWITCH_CODEC_FLAG_READY);		return SWITCH_STATUS_SUCCESS;	} else {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec %s Exists but not at the desired implementation. %dhz %dms/n", codec_name, rate,						  ms);	}	UNPROTECT_INTERFACE(codec_interface);	return SWITCH_STATUS_NOTIMPL;}
开发者ID:sl33nyc,项目名称:freeswitch,代码行数:76,


示例6: SWITCH_DECLARE

SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memory_pool_t *pool,																	const char *username,																	const char *dialplan,																	const char *caller_id_name,																	const char *caller_id_number,																	const char *network_addr,																	const char *ani,																	const char *aniii,																	const char *rdnis,																	const char *source, const char *context, const char *destination_number){	switch_caller_profile_t *profile = NULL;	char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];	profile = switch_core_alloc(pool, sizeof(*profile));	switch_assert(profile != NULL);	memset(profile, 0, sizeof(*profile));	switch_uuid_str(uuid_str, sizeof(uuid_str));	profile->uuid_str = switch_core_strdup(pool, uuid_str);		if (!context) {		context = "default";	}	if (zstr(caller_id_name)) {		caller_id_name = SWITCH_DEFAULT_CLID_NAME;	}	if (zstr(caller_id_number)) {		caller_id_number = SWITCH_DEFAULT_CLID_NUMBER;	}	/* ANI defaults to Caller ID Number when not specified */	if (zstr(ani)) {		ani = caller_id_number;	}	profile_dup_clean(username, profile->username, pool);	profile_dup_clean(dialplan, profile->dialplan, pool);	profile_dup_clean(caller_id_name, profile->caller_id_name, pool);	profile_dup_clean(caller_id_number, profile->caller_id_number, pool);	profile_dup_clean(caller_id_name, profile->orig_caller_id_name, pool);	profile_dup_clean(caller_id_number, profile->orig_caller_id_number, pool);	profile->caller_ton = SWITCH_TON_UNDEF;	profile->caller_numplan = SWITCH_NUMPLAN_UNDEF;	profile_dup_clean(network_addr, profile->network_addr, pool);	profile_dup_clean(ani, profile->ani, pool);	profile->ani_ton = SWITCH_TON_UNDEF;	profile->ani_numplan = SWITCH_NUMPLAN_UNDEF;	profile_dup_clean(aniii, profile->aniii, pool);	profile_dup_clean(rdnis, profile->rdnis, pool);	profile->rdnis_ton = SWITCH_TON_UNDEF;	profile->rdnis_numplan = SWITCH_NUMPLAN_UNDEF;	profile_dup_clean(source, profile->source, pool);	profile_dup_clean(context, profile->context, pool);	profile_dup_clean(destination_number, profile->destination_number, pool);	profile->destination_number_ton = SWITCH_TON_UNDEF;	profile->destination_number_numplan = SWITCH_NUMPLAN_UNDEF;	profile->uuid = SWITCH_BLANK_STRING;	profile->chan_name = SWITCH_BLANK_STRING;	profile->callee_id_name = SWITCH_BLANK_STRING;	profile->callee_id_number = SWITCH_BLANK_STRING;	switch_set_flag(profile, SWITCH_CPF_SCREEN);	profile->pool = pool;	return profile;}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:67,


示例7: load_config

static switch_status_t load_config(switch_memory_pool_t *pool){    switch_status_t status = SWITCH_STATUS_SUCCESS;    char *cf = "cdr_pg_csv.conf", *ptr;    switch_xml_t cfg, xml, schema, field;    const char *attr;    int num_fields = 0;    switch_size_t len = 0;    cdr_field_t *cdr_field;    if (globals.db_online) {        PQfinish(globals.db_connection);        switch_mutex_destroy(globals.db_mutex);        globals.db_online = 0;    }    memset(&globals, 0, sizeof(globals));    switch_core_hash_init(&globals.fd_hash, pool);    switch_mutex_init(&globals.db_mutex, SWITCH_MUTEX_NESTED, pool);    globals.pool = pool;    if (switch_xml_config_parse_module_settings(cf, SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) {        return SWITCH_STATUS_FALSE;    }    if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) {        if ((schema = switch_xml_child(cfg, "schema"))) {            /* Count fields in schema so we can calculate required buffer size */            for (field = switch_xml_child(schema, "field"); field; field = field->next) {                if (switch_xml_attr(field, "var")) {                    num_fields++;                }            }            globals.db_schema = switch_core_alloc(pool, (num_fields + 1) * sizeof(cdr_field_t));            cdr_field = globals.db_schema->fields;            for (field = switch_xml_child(schema, "field"); field; field = field->next) {                if ((attr = switch_xml_attr(field, "var"))) {                    cdr_field->var_name = switch_core_strdup(pool, attr);                    /* Assume SQL column name is the same as FreeSWITCH channel var name, unless specified otherwise */                    if ((attr = switch_xml_attr(field, "column"))) {                        cdr_field->col_name = switch_core_strdup(pool, attr);                    } else {                        cdr_field->col_name = switch_core_strdup(pool, cdr_field->var_name);                    }                    /* Assume all fields should be quoted (treated as strings), unless specified otherwise */                    if ((attr = switch_xml_attr(field, "quote")) && !strncmp(attr, "false", 5)) {                        cdr_field->quote = SWITCH_FALSE;                    } else {                        cdr_field->quote = SWITCH_TRUE;                    }                    /* Assume all fields allow SQL nulls, unless specified otherwise */                    if ((attr = switch_xml_attr(field, "not-null")) && !strncmp(attr, "true", 4)) {                        cdr_field->not_null = SWITCH_TRUE;                    } else {                        cdr_field->not_null = SWITCH_FALSE;                    }                    len += strlen(cdr_field->col_name) + 1;                    cdr_field++;                }            }            cdr_field->var_name = 0;            globals.db_schema->columns = switch_core_alloc(pool, len);            ptr = globals.db_schema->columns;            for (cdr_field = globals.db_schema->fields; cdr_field->col_name; cdr_field++) {                len = strlen(cdr_field->col_name);                memcpy(ptr, cdr_field->col_name, len);                ptr += len;                *ptr = ',';                ptr++;            }            *--ptr = '/0';        }        switch_xml_free(xml);    }    return status;}
开发者ID:publicreading,项目名称:FreeSWITCH,代码行数:86,


示例8: load_config

static switch_status_t load_config(switch_memory_pool_t *pool){	char *cf = "cdr_csv.conf";	switch_xml_t cfg, xml, settings, param;	switch_status_t status = SWITCH_STATUS_SUCCESS;	memset(&globals, 0, sizeof(globals));	switch_core_hash_init(&globals.fd_hash, pool);	switch_core_hash_init(&globals.template_hash, pool);	globals.pool = pool;	switch_core_hash_insert(globals.template_hash, "default", default_template);	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding default template./n");	globals.legs = CDR_LEG_A;	if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) {		if ((settings = switch_xml_child(cfg, "settings"))) {			for (param = switch_xml_child(settings, "param"); param; param = param->next) {				char *var = (char *) switch_xml_attr_soft(param, "name");				char *val = (char *) switch_xml_attr_soft(param, "value");				if (!strcasecmp(var, "debug")) {					globals.debug = switch_true(val);				} else if (!strcasecmp(var, "legs")) {					globals.legs = 0;					if (strchr(val, 'a')) {						globals.legs |= CDR_LEG_A;					}					if (strchr(val, 'b')) {						globals.legs |= CDR_LEG_B;					}				} else if (!strcasecmp(var, "log-base")) {					globals.log_dir = switch_core_sprintf(pool, "%s%scdr-csv", val, SWITCH_PATH_SEPARATOR);				} else if (!strcasecmp(var, "rotate-on-hup")) {					globals.rotate = switch_true(val);				} else if (!strcasecmp(var, "default-template")) {					globals.default_template = switch_core_strdup(pool, val);				} else if (!strcasecmp(var, "master-file-only")) {					globals.masterfileonly = switch_true(val);				}			}		}		if ((settings = switch_xml_child(cfg, "templates"))) {			for (param = switch_xml_child(settings, "template"); param; param = param->next) {				char *var = (char *) switch_xml_attr(param, "name");				if (var) {					char *tpl;					size_t len = strlen(param->txt) + 2;					if (end_of(param->txt) != '/n') {						tpl = switch_core_alloc(pool, len);						switch_snprintf(tpl, len, "%s/n", param->txt);					} else {						tpl = switch_core_strdup(pool, param->txt);					}					switch_core_hash_insert(globals.template_hash, var, tpl);					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding template %s./n", var);				}			}		}		switch_xml_free(xml);	}	if (zstr(globals.default_template)) {		globals.default_template = switch_core_strdup(pool, "default");	}	if (!globals.log_dir) {		globals.log_dir = switch_core_sprintf(pool, "%s%scdr-csv", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR);	}	return status;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:78,


示例9: SWITCH_DECLARE

SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, const char *func, int line,															  switch_file_handle_t *fh,															  const char *file_path,															  uint32_t channels, uint32_t rate, unsigned int flags, switch_memory_pool_t *pool){	char *ext;	switch_status_t status = SWITCH_STATUS_FALSE;	char stream_name[128] = "";	char *rhs = NULL;	const char *spool_path = NULL;	int is_stream = 0;	char *fp = NULL;	int to = 0;	if (switch_test_flag(fh, SWITCH_FILE_OPEN)) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Handle already open/n");		return SWITCH_STATUS_FALSE;	}	fh->samples_in = 0;	if (!fh->samplerate) {		if (!(fh->samplerate = rate)) {			fh->samplerate = 8000;		}	}	if (zstr(file_path)) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Filename/n");		return SWITCH_STATUS_FALSE;	}	fh->flags = flags;	if (pool) {		fh->memory_pool = pool;	} else {		if ((status = switch_core_new_memory_pool(&fh->memory_pool)) != SWITCH_STATUS_SUCCESS) {			UNPROTECT_INTERFACE(fh->file_interface);			return status;		}		switch_set_flag(fh, SWITCH_FILE_FLAG_FREE_POOL);	}	if (*file_path == '{') {		char *timeout;		char *new_fp;		fp = switch_core_strdup(fh->memory_pool, file_path);		if (switch_event_create_brackets(fp, '{', '}', ',', &fh->params, &new_fp, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {			if ((timeout = switch_event_get_header(fh->params, "timeout"))) {				if ((to = atoi(timeout)) < 1) {					to = 0;				}			}		} else {			new_fp = fp;		}		file_path = new_fp;	}	if (switch_directory_exists(file_path, fh->memory_pool) == SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "File [%s] is a directory not a file./n", file_path);		status = SWITCH_STATUS_GENERR;		goto fail;	}	if ((rhs = strstr(file_path, SWITCH_URL_SEPARATOR))) {		switch_copy_string(stream_name, file_path, (rhs + 1) - file_path);		ext = stream_name;		file_path = rhs + 3;		fh->file_path = switch_core_strdup(fh->memory_pool, file_path);		is_stream = 1;	} else {		if ((flags & SWITCH_FILE_FLAG_WRITE)) {			char *p, *e;			fh->file_path = switch_core_strdup(fh->memory_pool, file_path);			p = fh->file_path;			if (*p == '[' && *(p + 1) == *SWITCH_PATH_SEPARATOR) {				e = switch_find_end_paren(p, '[', ']');				if (e) {					*e = '/0';					spool_path = p + 1;					fh->file_path = e + 1;				}			}			if (!spool_path) {				spool_path = switch_core_get_variable_pdup(SWITCH_AUDIO_SPOOL_PATH_VARIABLE, fh->memory_pool);			}			file_path = fh->file_path;		}		if ((ext = strrchr(file_path, '.')) == 0) {//.........这里部分代码省略.........
开发者ID:utkarsh301994,项目名称:localhost,代码行数:101,


示例10: launch_thread

static void launch_thread(const char *name, const char *path, switch_xml_t directory){	local_stream_source_t *source = NULL;	switch_memory_pool_t *pool;	switch_xml_t param;	switch_thread_t *thread;	switch_threadattr_t *thd_attr = NULL;	if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool/n");		abort();	}	source = switch_core_alloc(pool, sizeof(*source));	assert(source != NULL);	source->pool = pool;	source->name = switch_core_strdup(source->pool, name);	source->location = switch_core_strdup(source->pool, path);	source->rate = 8000;	source->interval = 20;	source->channels = 1;	source->timer_name = "soft";	source->prebuf = DEFAULT_PREBUFFER_SIZE;	source->stopped = 0;	source->hup = 0;	source->chime_freq = 30;	for (param = switch_xml_child(directory, "param"); param; param = param->next) {		char *var = (char *) switch_xml_attr_soft(param, "name");		char *val = (char *) switch_xml_attr_soft(param, "value");		if (!strcasecmp(var, "rate")) {			int tmp = atoi(val);			if (tmp == 8000 || tmp == 12000 || tmp == 16000 || tmp == 24000 || tmp == 32000 || tmp == 48000) {				source->rate = tmp;			}		} else if (!strcasecmp(var, "shuffle")) {			source->shuffle = switch_true(val);		} else if (!strcasecmp(var, "prebuf")) {			int tmp = atoi(val);			if (tmp > 0) {				source->prebuf = (uint32_t) tmp;			}		} else if (!strcasecmp(var, "channels")) {			int tmp = atoi(val);			if (tmp == 1 || tmp == 2) {				source->channels = (uint8_t) tmp;			}		} else if (!strcasecmp(var, "chime-freq")) {			int tmp = atoi(val);			if (tmp > 1) {				source->chime_freq = tmp;			}		} else if (!strcasecmp(var, "chime-max")) {			int tmp = atoi(val);			if (tmp > 1) {				source->chime_max = tmp;			}		} else if (!strcasecmp(var, "chime-list")) {			char *list_dup = switch_core_strdup(source->pool, val);			source->chime_total =				switch_separate_string(list_dup, ',', source->chime_list, (sizeof(source->chime_list) / sizeof(source->chime_list[0])));		} else if (!strcasecmp(var, "interval")) {			int tmp = atoi(val);			if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {				source->interval = tmp;			} else {				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,								  "Interval must be multiple of 10 and less than %d, Using default of 20/n", SWITCH_MAX_INTERVAL);			}		} else if (!strcasecmp(var, "timer-name")) {			source->timer_name = switch_core_strdup(source->pool, val);		}	}	if (source->chime_max) {		source->chime_max *= source->rate;	}	if (source->chime_total) {		source->chime_counter = source->rate * source->chime_freq;	}	source->samples = switch_samples_per_packet(source->rate, source->interval);	switch_mutex_init(&source->mutex, SWITCH_MUTEX_NESTED, source->pool);	switch_threadattr_create(&thd_attr, source->pool);	switch_threadattr_detach_set(thd_attr, 1);	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);	switch_thread_create(&thread, thd_attr, read_stream_thread, source, source->pool);}
开发者ID:crazypenguincode,项目名称:freeswitch,代码行数:89,


示例11: load_config

static switch_status_t load_config(switch_bool_t reload){    switch_status_t status = SWITCH_STATUS_SUCCESS;    switch_xml_t cfg, xml = NULL, settings, param, x_profiles, x_profile;    switch_cache_db_handle_t *dbh = NULL;    if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) {        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed/n", global_cf);        return SWITCH_STATUS_TERM;    }    switch_mutex_lock(globals.mutex);    if ((settings = switch_xml_child(cfg, "settings"))) {        for (param = switch_xml_child(settings, "param"); param; param = param->next) {            char *var = (char *) switch_xml_attr_soft(param, "name");            char *val = (char *) switch_xml_attr_soft(param, "value");            if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {                if (switch_odbc_available()) {                    switch_set_string(globals.odbc_dsn, val);                    if ((globals.odbc_user = strchr(globals.odbc_dsn, ':'))) {                        *globals.odbc_user++ = '/0';                        if ((globals.odbc_pass = strchr(globals.odbc_user, ':'))) {                            *globals.odbc_pass++ = '/0';                        }                    }                } else {                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!/n");                }            } else if (!strcasecmp(var, "dbname") && !zstr(val)) {                globals.dbname = switch_core_strdup(globals.pool, val);            }            if (!strcasecmp(var, "debug")) {                globals.debug = atoi(val);            }        }    }    if ((x_profiles = switch_xml_child(cfg, "profiles"))) {        for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) {            load_profile(switch_xml_attr_soft(x_profile, "name"));        }    }    if (zstr(globals.odbc_dsn) && zstr(globals.dbname)) {        globals.dbname = switch_core_sprintf(globals.pool, "directory");    }    dbh = directory_get_db_handle();    if (dbh) {        if (!reload) {            switch_cache_db_test_reactive(dbh, "delete from directory_search where uuid != '' and name_visible != '' ", "drop table directory_search", dir_sql);        }        switch_cache_db_release_db_handle(&dbh);    } else {        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot open DB!2/n");        status = SWITCH_STATUS_TERM;        goto end;    }end:    switch_mutex_unlock(globals.mutex);    switch_xml_free(xml);    return status;}
开发者ID:jasonbourneh0810,项目名称:FreeSWITCH,代码行数:66,


示例12: do_config

static switch_status_t do_config(void){	char *cf = "xml_scgi.conf";	switch_xml_t cfg, xml, bindings_tag, binding_tag, param;	xml_binding_t *binding = NULL;	int x = 0;	int need_vars_map = 0;	switch_hash_t *vars_map = NULL;	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed/n", cf);		return SWITCH_STATUS_TERM;	}	if (!(bindings_tag = switch_xml_child(cfg, "bindings"))) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing <bindings> tag!/n");		goto done;	}	for (binding_tag = switch_xml_child(bindings_tag, "binding"); binding_tag; binding_tag = binding_tag->next) {		char *bname = (char *) switch_xml_attr_soft(binding_tag, "name");		char *host = "127.0.0.1";		char *port = "8080";		char *bind_mask = NULL;		int timeout = 0;		char *server = NULL;		hash_node_t *hash_node;		need_vars_map = 0;		vars_map = NULL;		for (param = switch_xml_child(binding_tag, "param"); param; param = param->next) {			char *var = (char *) switch_xml_attr_soft(param, "name");			char *val = (char *) switch_xml_attr_soft(param, "value");			if (!strcasecmp(var, "host")) {				bind_mask = (char *) switch_xml_attr_soft(param, "bindings");				if (val) {					host = val;				}			} else if (!strcasecmp(var, "port")) {				port = val;			} else if (!strcasecmp(var, "timeout")) {				int tmp = atoi(val);				if (tmp >= 0) {					timeout = tmp;				} else {					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set a negative timeout!/n");				}			} else if (!strcasecmp(var, "enable-post-var")) {				if (!vars_map && need_vars_map == 0) {					if (switch_core_hash_init(&vars_map, globals.pool) != SWITCH_STATUS_SUCCESS) {						need_vars_map = -1;						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't init params hash!/n");						continue;					}					need_vars_map = 1;				}				if (vars_map && val) {					if (switch_core_hash_insert(vars_map, val, ENABLE_PARAM_VALUE) != SWITCH_STATUS_SUCCESS) {						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't add %s to params hash!/n", val);					}				}			} else if (!strcasecmp(var, "server")) {				server = val;			}		}		if (!host) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Binding has no host!/n");			if (vars_map) {				switch_core_hash_destroy(&vars_map);			}			continue;		}		if (!(binding = switch_core_alloc(globals.pool, sizeof(*binding)))) {			if (vars_map) {				switch_core_hash_destroy(&vars_map);			}			goto done;		}		memset(binding, 0, sizeof(*binding));		binding->timeout = timeout;		binding->host = switch_core_strdup(globals.pool, host);		binding->port = atoi(port);		binding->vars_map = vars_map;		binding->uri = switch_mprintf("/%s", bname);		binding->url = switch_mprintf("scgi://%s:%s/%s", host, port, bname);		if (server) {			binding->server = switch_core_strdup(globals.pool, server);		}        if (bind_mask) {			binding->bindings = switch_core_strdup(globals.pool, bind_mask);		}                                         //.........这里部分代码省略.........
开发者ID:RodrigoNieves,项目名称:FreeSWITCH,代码行数:101,


示例13: portaudio_stream_file_open

static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle, const char *path){	portaudio_stream_context_t *context;	portaudio_stream_source_t *source;	switch_memory_pool_t *pool;	switch_status_t status = SWITCH_STATUS_FALSE;	switch_thread_t *thread;	switch_threadattr_t *thd_attr = NULL;	uint32_t rate = PREFERRED_RATE;	char *npath;	int devNumber;	int tmp;	handle->pre_buffer_datalen = 0;	if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This format does not support writing! (yet)/n");		return status;	}	npath = switch_core_strdup(module_pool, path);	tmp = handle->samplerate;	if (tmp == 8000 || tmp == 16000 || tmp == 32000 || tmp == 48000) {		rate = tmp;	}	if (*path == '#') {		devNumber = get_dev_by_number(npath + 1, 1);	} else {		devNumber = get_dev_by_name(npath, 1);	}	npath = switch_mprintf("device-%d at %d", devNumber, rate);	switch_mutex_lock(globals.mutex);	source = switch_core_hash_find(globals.source_hash, npath);	/* dev isnt there, try to start thread */	if (!source) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, " source isnt Created, create and start thread!/n");		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, " :S no pool/n");		} else {			source = switch_core_alloc(pool, sizeof(*source));			if (source != NULL) {				source->pool = pool;				source->sourcedev = devNumber;				source->sourcename = switch_core_strdup(source->pool, npath);				source->rate = rate;				source->interval = 20;				source->channels = 1;				source->timer_name = "soft";				source->prebuf = DEFAULT_PREBUFFER_SIZE;				source->stopped = 0;				source->ready = 0;				source->samples = switch_samples_per_packet(source->rate, source->interval);				switch_mutex_init(&source->mutex, SWITCH_MUTEX_NESTED, source->pool);				switch_threadattr_create(&thd_attr, source->pool);				switch_threadattr_detach_set(thd_attr, 1);				switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);				switch_thread_create(&thread, thd_attr, read_stream_thread, source, source->pool);			}		}	}	switch_mutex_unlock(globals.mutex);	switch_yield(1000000);	/* dev already engaged */	if (source) {		/*wait for source to be ready */		while (source->ready == 0) {			switch_yield(100000);		}		if (switch_thread_rwlock_tryrdlock(source->rwlock) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, " error rwlock !/n");			source = NULL;		}	}	if (source) {		status = SWITCH_STATUS_SUCCESS;		if ((context = switch_core_alloc(handle->memory_pool, sizeof(*context))) == 0) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, " error allocating context!/n");			status = SWITCH_STATUS_MEMERR;		} else {			/* everything goes fine at this point */			handle->samples = 0;			handle->samplerate = source->rate;			handle->channels = 1;			handle->format = 0;			handle->sections = 0;			handle->seekable = 0;			handle->speed = 0;			handle->private_info = context;//.........这里部分代码省略.........
开发者ID:crazypenguincode,项目名称:freeswitch,代码行数:101,


示例14: strlen

bool WSClientParser::ParseFirstLine(char* line) {	bool bFlag = false;	// Get Param	char* p = line;	char* delim = " ";	char decodeUrl[HTTP_URL_MAX_PATH] = {0};	char *array[HTTP_URL_FIRSTLINE_PARAM_MAX_COUNT];	if( switch_separate_string_string(p, delim, array, HTTP_URL_FIRSTLINE_PARAM_MAX_COUNT) >= HTTP_URL_FIRSTLINE_PARAM_COUNT ) {		Arithmetic ac;		ac.decode_url(array[1], strlen(array[1]), decodeUrl);		switch_log_printf(				SWITCH_CHANNEL_UUID_LOG(this->uuid),				SWITCH_LOG_INFO,				"WSClientParser::ParseFirstLine( "				"this : %p, "				"decodeUrl : '%s' "				") /n",				this,				decodeUrl				);		if( strlen(decodeUrl) > 0 ) {//			p = decodeUrl;			p = switch_core_strdup(mpPool, decodeUrl);			delim = "/";			if( *p == *delim ) {				p++;			}			char *array2[HTTP_URL_PATH_PARAM_MAX_COUNT];			if( switch_separate_string_string(p, delim, array2, HTTP_URL_PATH_PARAM_MAX_COUNT) >= HTTP_URL_PATH_PARAM_COUNT ) {				mpUser = switch_core_strdup(mpPool, array2[0]);				mpDomain = switch_core_strdup(mpPool, array2[1]);				mpDestNumber = switch_core_strdup(mpPool, array2[2]);				// 暂时不做PHP验证				mpSite = switch_core_strdup(mpPool, array2[3]);				mpCustom = switch_core_strdup(mpPool, array2[4]);//				mpSite = switch_core_strdup(mpPool, "");//				mpCustom = switch_core_strdup(mpPool, "");				switch_log_printf(						SWITCH_CHANNEL_UUID_LOG(this->uuid),						SWITCH_LOG_INFO,						"WSClientParser::ParseFirstLine( "						"this : %p, "						"user : '%s', "						"domain : '%s', "						"destnumber : '%s', "						"site : '%s', "						"custom : '%s' "						") /n",						this,						mpUser,						mpDomain,						mpDestNumber,						mpSite,						mpCustom						);				bFlag = true;			}		}	}	if( !bFlag ) {		switch_log_printf(				SWITCH_CHANNEL_UUID_LOG(this->uuid),				SWITCH_LOG_ERROR,				"WSClientParser::ParseFirstLine( "				"[Fail], "				"this : %p, "				"decodeUrl : '%s' "				") /n",				this,				decodeUrl				);	}	return bFlag;}
开发者ID:KingsleyYau,项目名称:CamShareMiddleware,代码行数:83,


示例15: vlc_file_open

static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *path){	vlc_file_context_t *context;	libvlc_event_manager_t *mp_event_manager, *m_event_manager;		context = switch_core_alloc(handle->memory_pool, sizeof(*context));	context->pool = handle->memory_pool;	context->path = switch_core_strdup(context->pool, path);	switch_buffer_create_dynamic(&(context->audio_buffer), VLC_BUFFER_SIZE, VLC_BUFFER_SIZE * 8, 0);	switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, context->pool);	switch_thread_cond_create(&(context->started), context->pool);	if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) {				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC open %s for reading/n", path);				/* Determine if this is a url or a path */		/* TODO: Change this so that it tries local files first, and then if it fails try location. */		if(! strncmp(context->path, "http", 4)){			context->m = libvlc_media_new_location(read_inst, context->path);			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "VLC Path is http %s/n", context->path);		} else if (! strncmp(context->path, "mms", 3)){			context->m = libvlc_media_new_path(read_inst, context->path);			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "VLC Path is mms %s/n", context->path);		} else if (! strncmp(context->path, "/", 1)){			context->m = libvlc_media_new_path(read_inst, context->path);			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "VLC Path is file %s/n", context->path);		} else {			context->m = libvlc_media_new_location(read_inst, context->path);			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "VLC Path is unknown type %s/n", context->path);		}		if ( context->m == NULL ) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC error opening %s for reading/n", path);			return SWITCH_STATUS_GENERR;		}				context->playing = 0;		context->err = 0;				context->mp = libvlc_media_player_new_from_media(context->m);				if (!handle->samplerate) {			handle->samplerate = 16000;		}		context->samplerate = handle->samplerate;		context->channels = handle->channels;		libvlc_audio_set_format(context->mp, "S16N", context->samplerate, handle->channels);				m_event_manager = libvlc_media_event_manager(context->m);		libvlc_event_attach(m_event_manager, libvlc_MediaStateChanged, vlc_media_state_callback, (void *) context);		mp_event_manager = libvlc_media_player_event_manager(context->mp);		libvlc_event_attach(mp_event_manager, libvlc_MediaPlayerEncounteredError, vlc_mediaplayer_error_callback, (void *) context);				libvlc_audio_set_callbacks(context->mp, vlc_auto_play_callback, NULL,NULL,NULL,NULL, (void *) context);		libvlc_media_player_play(context->mp);			} else if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {		const char * opts[10] = {			vlc_args,			switch_mprintf("--sout=%s", path)		};		int opts_count = 10;				if ( !handle->samplerate)			handle->samplerate = 16000;				context->samplerate = handle->samplerate;		opts[2] = switch_mprintf("--imem-get=%ld", vlc_imem_get_callback);		opts[3] = switch_mprintf("--imem-release=%ld", vlc_imem_release_callback);		opts[4] = switch_mprintf("--imem-cat=%d", 4);		opts[5] = "--demux=rawaud";		opts[6] = "--rawaud-fourcc=s16l";		opts[7] = switch_mprintf("--rawaud-samplerate=%d", context->samplerate);		opts[8] = switch_mprintf("--imem-data=%ld", context);		//opts[9] = "--rawaud-channels=1";		/* Prepare to write to an output stream. */		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC open %s for writing/n", path);		/* load the vlc engine. */		context->inst_out = libvlc_new(opts_count, opts);				/* Tell VLC the audio will come from memory, and to use the callbacks to fetch it. */		context->m = libvlc_media_new_location(context->inst_out, "imem/rawaud://");		context->mp = libvlc_media_player_new_from_media(context->m);		context->samples = 0;		context->pts = 0;		context->playing = 1;				libvlc_media_player_play(context->mp);	} else {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC tried to open %s for unknown reason/n", path);		return SWITCH_STATUS_GENERR;//.........这里部分代码省略.........
开发者ID:utkarsh301994,项目名称:localhost,代码行数:101,


示例16: channel_outgoing_channel

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){	char name[128];	if (session) {		switch_channel_t *channel = switch_core_session_get_channel(session);		switch_channel_clear_flag(channel, CF_PROXY_MEDIA);		switch_channel_clear_flag(channel, CF_PROXY_MODE);		switch_channel_pre_answer(channel);	}	if ((*new_session = switch_core_session_request(loopback_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {		private_t *tech_pvt;		switch_channel_t *channel;		switch_caller_profile_t *caller_profile;		switch_core_session_add_stream(*new_session, NULL);		if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {			channel = switch_core_session_get_channel(*new_session);			switch_snprintf(name, sizeof(name), "loopback/%s-a", outbound_profile->destination_number);			switch_channel_set_name(channel, name);			if (tech_init(tech_pvt, *new_session, session ? switch_core_session_get_read_codec(session) : NULL) != SWITCH_STATUS_SUCCESS) {				switch_core_session_destroy(new_session);				return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;			}		} else {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_CRIT, "Hey where is my memory pool?/n");			switch_core_session_destroy(new_session);			return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;		}		if (outbound_profile) {			char *dialplan = NULL, *context = NULL;			caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);			caller_profile->source = switch_core_strdup(caller_profile->pool, modname);			if (!strncasecmp(caller_profile->destination_number, "app=", 4)) {				char *dest = switch_core_session_strdup(*new_session, caller_profile->destination_number);				char *app = dest + 4;				char *arg = NULL;				if ((arg = strchr(app, ':'))) {					*arg++ = '/0';				}				switch_channel_set_variable(channel, "loopback_app", app);				if (arg) {					switch_channel_set_variable(channel, "loopback_app_arg", arg);				}				caller_profile->destination_number = switch_core_strdup(caller_profile->pool, app);			}			if ((context = strchr(caller_profile->destination_number, '/'))) {				*context++ = '/0';				if ((dialplan = strchr(context, '/'))) {					*dialplan++ = '/0';				}				if (!zstr(context)) {					caller_profile->context = switch_core_strdup(caller_profile->pool, context);				}				if (!zstr(dialplan)) {					caller_profile->dialplan = switch_core_strdup(caller_profile->pool, dialplan);				}			}			if (zstr(caller_profile->context)) {				caller_profile->context = switch_core_strdup(caller_profile->pool, "default");			}			if (zstr(caller_profile->dialplan)) {				caller_profile->dialplan = switch_core_strdup(caller_profile->pool, "xml");			}			switch_snprintf(name, sizeof(name), "loopback/%s-a", caller_profile->destination_number);			switch_channel_set_name(channel, name);			switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);			switch_channel_set_caller_profile(channel, caller_profile);			tech_pvt->caller_profile = caller_profile;		} else {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_ERROR, "Doh! no caller profile/n");			switch_core_session_destroy(new_session);			return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;		}		switch_channel_set_state(channel, CS_INIT);		return SWITCH_CAUSE_SUCCESS;	}	return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;}
开发者ID:gujun,项目名称:sscore,代码行数:99,


示例17: load_config

static switch_status_t load_config(void){	char *cf = "pocketsphinx.conf";	switch_xml_t cfg, xml = NULL, param, settings;	switch_status_t status = SWITCH_STATUS_SUCCESS;	/* Set defaults */	globals.thresh = 400;	globals.silence_hits = 35;	globals.listen_hits = 1;	globals.auto_reload = 1;	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed/n", cf);		status = SWITCH_STATUS_FALSE;		goto done;	}	if ((settings = switch_xml_child(cfg, "settings"))) {		for (param = switch_xml_child(settings, "param"); param; param = param->next) {			char *var = (char *) switch_xml_attr_soft(param, "name");			char *val = (char *) switch_xml_attr_soft(param, "value");			if (!strcasecmp(var, "threshold")) {				globals.thresh = atoi(val);			} else if (!strcasecmp(var, "silence-hits")) {				globals.silence_hits = atoi(val);			} else if (!strcasecmp(var, "language-weight")) {				globals.language_weight = switch_core_strdup(globals.pool, val);			} else if (!strcasecmp(var, "listen-hits")) {				globals.listen_hits = atoi(val);			} else if (!strcasecmp(var, "auto-reload")) {				globals.auto_reload = switch_true(val);			} else if (!strcasecmp(var, "narrowband-model")) {				globals.model8k = switch_core_strdup(globals.pool, val);			} else if (!strcasecmp(var, "wideband-model")) {				globals.model16k = switch_core_strdup(globals.pool, val);			} else if (!strcasecmp(var, "dictionary")) {				globals.dictionary = switch_core_strdup(globals.pool, val);			}		}	}	if (!globals.model8k) {		globals.model8k = switch_core_strdup(globals.pool, "communicator");	}	if (!globals.model16k) {		globals.model16k = switch_core_strdup(globals.pool, "wsj1");	}	if (!globals.dictionary) {		globals.dictionary = switch_core_strdup(globals.pool, "default.dic");	}	if (!globals.language_weight) {		globals.language_weight = switch_core_strdup(globals.pool, "6.5");	}  done:	if (xml) {		switch_xml_free(xml);	}	return status;}
开发者ID:hsaid,项目名称:FreeSWITCH,代码行数:65,


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


示例19: iks_find

/** * Start CPA */iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg, void *session_data){    iks *iq = msg->payload;    switch_core_session_t *session = (switch_core_session_t *)session_data;    iks *input = iks_find(iq, "input");    switch_memory_pool_t *pool = NULL;    struct cpa_component *component = NULL;    int have_grammar = 0;    iks *grammar = NULL;    /* create CPA component */    switch_core_new_memory_pool(&pool);    component = switch_core_alloc(pool, sizeof(*component));    component = CPA_COMPONENT(rayo_component_init((struct rayo_component *)component, pool, RAT_CALL_COMPONENT, "cpa", NULL, call, iks_find_attrib(iq, "from")));    if (!component) {        switch_core_destroy_memory_pool(&pool);        return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Failed to create CPA entity");    }    switch_core_hash_init(&component->signals);    /* start CPA detectors */    for (grammar = iks_find(input, "grammar"); grammar; grammar = iks_next_tag(grammar)) {        if (!strcmp("grammar", iks_name(grammar))) {            const char *error_str = "";            const char *url = iks_find_attrib_soft(grammar, "url");            char *url_dup;            char *url_params;            if (zstr(url)) {                stop_cpa_detectors(component);                RAYO_UNLOCK(component);                RAYO_DESTROY(component);                return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Missing grammar URL");            }            have_grammar = 1;            url_dup = strdup(url);            if ((url_params = strchr(url_dup, '?'))) {                *url_params = '/0';                url_params++;            }            if (switch_core_hash_find(component->signals, url)) {                free(url_dup);                stop_cpa_detectors(component);                RAYO_UNLOCK(component);                RAYO_DESTROY(component);                return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Duplicate URL");            }            /* start detector */            /* TODO return better reasons... */            if (rayo_cpa_detector_start(switch_core_session_get_uuid(session), url_dup, &error_str)) {                struct cpa_signal *cpa_signal = switch_core_alloc(pool, sizeof(*cpa_signal));                cpa_signal->terminate = !zstr(url_params) && strstr(url_params, "terminate=true");                cpa_signal->name = switch_core_strdup(pool, url_dup);                switch_core_hash_insert(component->signals, cpa_signal->name, cpa_signal);                subscribe(switch_core_session_get_uuid(session), cpa_signal->name, RAYO_JID(component));            } else {                free(url_dup);                stop_cpa_detectors(component);                RAYO_UNLOCK(component);                RAYO_DESTROY(component);                return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, error_str);            }            free(url_dup);        }    }    if (!have_grammar) {        stop_cpa_detectors(component);        RAYO_UNLOCK(component);        RAYO_DESTROY(component);        return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "No grammar defined");    }    /* acknowledge command */    rayo_component_send_start(RAYO_COMPONENT(component), iq);    /* TODO hangup race condition */    subscribe(switch_core_session_get_uuid(session), "hangup", RAYO_JID(component));    /* ready to forward detector events */    component->ready = 1;    return NULL;}
开发者ID:bodji,项目名称:freeswitch,代码行数:92,


示例20: read_stream_thread

//.........这里部分代码省略.........			if (RUNNING && source->shuffle) {				skip = do_rand();			}		}		switch_dir_close(source->dir_handle);		source->dir_handle = NULL;		if (source->full_reload) {			if (source->rwlock && switch_thread_rwlock_trywrlock(source->rwlock) != SWITCH_STATUS_SUCCESS) {				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot stop local_stream://%s because it is in use./n",source->name);				if (source->part_reload) {					switch_xml_t cfg, xml, directory, param;					if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) {						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed/n", global_cf);					}					if ((directory = switch_xml_find_child(cfg, "directory", "name", source->name))) {						for (param = switch_xml_child(directory, "param"); param; param = param->next) {							char *var = (char *) switch_xml_attr_soft(param, "name");							char *val = (char *) switch_xml_attr_soft(param, "value");							if (!strcasecmp(var, "shuffle")) {								source->shuffle = switch_true(val);							} else if (!strcasecmp(var, "chime-freq")) {								int tmp = atoi(val);								if (tmp > 1) {									source->chime_freq = tmp;								}							} else if (!strcasecmp(var, "chime-max")) {								int tmp = atoi(val);								if (tmp > 1) {									source->chime_max = tmp;								}							} else if (!strcasecmp(var, "chime-list")) {								char *list_dup = switch_core_strdup(source->pool, val);								source->chime_total =									switch_separate_string(list_dup, ',', source->chime_list, (sizeof(source->chime_list) / sizeof(source->chime_list[0])));							} else if (!strcasecmp(var, "interval")) {								int tmp = atoi(val);								if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {									source->interval = tmp;								} else {									switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,													  "Interval must be multiple of 10 and less than %d, Using default of 20/n", SWITCH_MAX_INTERVAL);								}							}							if (source->chime_max) {								source->chime_max *= source->rate;							}							if (source->chime_total) {								source->chime_counter = source->rate * source->chime_freq;							}						}					}					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "local_stream://%s partially reloaded./n",source->name);					source->part_reload = 0;				}			} else {				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "local_stream://%s fully reloaded./n",source->name);				launch_streams(source->name);				goto done;			}		}	}  done:
开发者ID:crazypenguincode,项目名称:freeswitch,代码行数:66,


示例21: switch_event_add_header_string

static cid_data_t *do_whitepages_lookup(switch_memory_pool_t *pool, switch_event_t *event, const char *num){	char *xml_s = NULL;	char *query = NULL;	char *name = NULL;	char *city = NULL;	char *state = NULL;	char *area = NULL;	switch_xml_t xml = NULL;	switch_xml_t node = NULL;	cid_data_t *cid = NULL;	/* NANPA check */	if (strlen(num) == 11 && num[0] == '1') {		num++;					/* skip past leading 1 */	} else {		goto done;	}	switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "whitepages-cid", num);	switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "whitepages-api-key", globals.whitepages_apikey);	query = switch_event_expand_headers(event, "http://api.whitepages.com/reverse_phone/1.0/?phone=${whitepages-cid};api_key=${whitepages-api-key}");	do_lookup_url(pool, event, &xml_s, query, NULL, NULL, 0);		if (zstr(xml_s)) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No XML returned for number %s/n", num);		goto done;	}		xml = switch_xml_parse_str_dup(xml_s);	if (!xml) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to parse XML: %s/n", xml_s);		goto done;	}	/* try for bizname first */	node = switch_xml_get(xml, "wp:listings", 0, "wp:listing", 0, "wp:business", 0, "wp:businessname", -1);	if (node) {		name = switch_core_strdup(pool, switch_xml_txt(node));		goto area;	}	node = switch_xml_get(xml, "wp:listings", 0, "wp:listing", 0, "wp:displayname", -1);	if (node) {		name = switch_core_strdup(pool, switch_xml_txt(node));	}  area:	node = switch_xml_get(xml, "wp:listings", 0, "wp:listing", 0, "wp:address", 0, "wp:city", -1);	if (node) {		city = switch_xml_txt(node);	}	node = switch_xml_get(xml, "wp:listings", 0, "wp:listing", 0, "wp:address", 0, "wp:state", -1);	if (node) {		state = switch_xml_txt(node);	}	if (city || state) {		area = switch_core_sprintf(pool, "%s %s", city ? city : "", state ? state : "");	}  done:	if (query) {		switch_safe_free(query);	}	if (xml) {		switch_xml_free(xml);	}	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "whitepages XML: %s/n", xml_s);	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "whitepages name: %s, area: %s/n", name ? name : "(null)", area ? area : "(null)");	cid = switch_core_alloc(pool, sizeof(cid_data_t));	switch_assert(cid);	cid->name = name;	cid->area = area;	cid->src = "whitepages";	return cid;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:84,


示例22: channel_outgoing_channel

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){	char name[128];	switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;	if ((*new_session = switch_core_session_request(modem_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool)) != 0) {		private_t *tech_pvt;		switch_channel_t *channel;		switch_caller_profile_t *caller_profile;		char *dest = switch_core_session_strdup(*new_session, outbound_profile->destination_number);		char *modem_id_string = NULL;		char *number = NULL;		int modem_id = 0;		modem_t *modem = NULL;		if ((modem_id_string = dest)) {			if ((number = strchr(modem_id_string, '/'))) {				*number++ = '/0';			}		}		if (zstr(modem_id_string) || zstr(number)) {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_ERROR, "Invalid dial string./n");			cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT; goto fail;		}		if (!strcasecmp(modem_id_string, "a")) {			modem_id = -1;		} else {			modem_id = atoi(modem_id_string);		}		if (!(modem = acquire_modem(modem_id))) {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_ERROR, "Cannot find a modem./n");			cause = SWITCH_CAUSE_USER_BUSY; goto fail;		}				switch_core_session_add_stream(*new_session, NULL);		if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {			channel = switch_core_session_get_channel(*new_session);			switch_snprintf(name, sizeof(name), "modem/%d/%s", modem->slot, number);			switch_channel_set_name(channel, name);			if (tech_init(tech_pvt, *new_session) != SWITCH_STATUS_SUCCESS) {				cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; goto fail;			}			switch_set_string(modem->digits, number);			tech_attach(tech_pvt, modem);		} else {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_CRIT, "Hey where is my memory pool?/n");			switch_core_session_destroy(new_session);			cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; goto fail;		}		if (outbound_profile) {			caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);			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;		} else {			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_ERROR, "Doh! no caller profile/n");			cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; goto fail;		}		switch_channel_set_state(channel, CS_INIT);		return SWITCH_CAUSE_SUCCESS;	fail:		if (new_session) {			switch_core_session_destroy(new_session);		}		if (modem) {			modem_set_state(modem, MODEM_STATE_ONHOOK);		}	}	return cause;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:86,



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


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