示例#1
0
/** Load profiles */
static apt_bool_t unimrcp_client_profiles_load(unimrcp_client_loader_t *loader, const apr_xml_elem *root)
{
	const apr_xml_elem *elem;
	const apr_xml_attr *id_attr;
	const apr_xml_attr *enable_attr;
	const char *id;

	apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Profiles");
	for(elem = root->first_child; elem; elem = elem->next) {
		/* get common "id" and "enable" attributes */
		if(header_attribs_get(elem,&id_attr,&enable_attr) == FALSE) {
			/* invalid id */
			continue;
		}
		if(is_attr_enabled(enable_attr) == FALSE) {
			/* disabled element, just skip it */
			continue;
		}
		id = apr_pstrdup(loader->pool,id_attr->value);

		if(strcasecmp(elem->name,"mrcpv2-profile") == 0) {
			unimrcp_client_mrcpv2_profile_load(loader,elem,id);
		}
		else if(strcasecmp(elem->name,"mrcpv1-profile") == 0) {
			unimrcp_client_mrcpv1_profile_load(loader,elem,id);
		}
		else {
			apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name);
		}
	}    
	return TRUE;
}
示例#2
0
/** Load components */
static apt_bool_t unimrcp_server_components_load(unimrcp_server_loader_t *loader, const apr_xml_elem *root)
{
	const apr_xml_elem *elem;
	const apr_xml_attr *id_attr;
	const apr_xml_attr *enable_attr;
	const char *id;

	/* Create codec manager first (probably it should be loaded from config either) */
	mpf_codec_manager_t *codec_manager = mpf_engine_codec_manager_create(loader->pool);
	if(codec_manager) {
		mrcp_server_codec_manager_register(loader->server,codec_manager);
	}

	apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Components");
	for(elem = root->first_child; elem; elem = elem->next) {
		if(strcasecmp(elem->name,"resource-factory") == 0) {
			unimrcp_server_resource_factory_load(loader,elem);
			continue;
		}
		if(strcasecmp(elem->name,"plugin-factory") == 0) {
			unimrcp_server_plugin_factory_load(loader,elem);
			continue;
		}
		
		/* get common "id" and "enable" attributes */
		if(header_attribs_get(elem,&id_attr,&enable_attr) == FALSE) {
			/* invalid id */
			continue;
		}
		if(is_attr_enabled(enable_attr) == FALSE) {
			/* disabled element, just skip it */
			continue;
		}
		id = apr_pstrdup(loader->pool,id_attr->value);

		if(strcasecmp(elem->name,"sip-uas") == 0) {
			unimrcp_server_sip_uas_load(loader,elem,id);
		}
		else if(strcasecmp(elem->name,"rtsp-uas") == 0) {
			unimrcp_server_rtsp_uas_load(loader,elem,id);
		}
		else if(strcasecmp(elem->name,"mrcpv2-uas") == 0) {
			unimrcp_server_mrcpv2_uas_load(loader,elem,id);
		}
		else if(strcasecmp(elem->name,"media-engine") == 0) {
			unimrcp_server_media_engine_load(loader,elem,id);
		}
		else if(strcasecmp(elem->name,"rtp-factory") == 0) {
			unimrcp_server_rtp_factory_load(loader,elem,id);
		}
		else if(strcasecmp(elem->name,"plugin-factory") == 0) {
			unimrcp_server_plugin_factory_load(loader,elem);
		}
		else {
			apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name);
		}
	}
	return TRUE;
}
示例#3
0
/** Load resource */
static apt_bool_t unimrcp_client_resource_load(mrcp_resource_loader_t *resource_loader, const apr_xml_elem *root, apr_pool_t *pool)
{
	apt_str_t resource_class;
	const apr_xml_attr *id_attr;
	const apr_xml_attr *enable_attr;
	apt_string_reset(&resource_class);

	if(header_attribs_get(root,&id_attr,&enable_attr) == FALSE) {
		return FALSE;
	}
	
	if(is_attr_enabled(enable_attr) == FALSE) {
		return TRUE;
	}

	apt_string_set(&resource_class,id_attr->value);
	return mrcp_resource_load(resource_loader,&resource_class);
}
示例#4
0
/** Load RTP settings */
static apt_bool_t unimrcp_server_rtp_settings_load(unimrcp_server_loader_t *loader, const apr_xml_elem *root, const char *id)
{
	const apr_xml_elem *elem;
	mpf_rtp_settings_t *rtp_settings = mpf_rtp_settings_alloc(loader->pool);

	apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading RTP Settings <%s>",id);
	for(elem = root->first_child; elem; elem = elem->next) {
		apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Element <%s>",elem->name);
		if(strcasecmp(elem->name,"jitter-buffer") == 0) {
			unimrcp_server_jb_settings_load(loader,&rtp_settings->jb_config,elem);
		}
		else if(strcasecmp(elem->name,"ptime") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				rtp_settings->ptime = (apr_uint16_t)atol(cdata_text_get(elem));
			}
		}
		else if(strcasecmp(elem->name,"codecs") == 0) {
			const apr_xml_attr *attr;
			const mpf_codec_manager_t *codec_manager = mrcp_server_codec_manager_get(loader->server);
			if(is_cdata_valid(elem) == TRUE && codec_manager) {
				mpf_codec_manager_codec_list_load(
					codec_manager,
					&rtp_settings->codec_list,
					cdata_text_get(elem),
					loader->pool);
			}
			for(attr = elem->attr; attr; attr = attr->next) {
				if(strcasecmp(attr->name,"own-preference") == 0) {
					rtp_settings->own_preferrence = is_attr_enabled(attr);
					break;
				}
			}
		}
		else if(strcasecmp(elem->name,"rtcp") == 0) {
			unimrcp_server_rtcp_settings_load(loader,rtp_settings,elem);
		}
		else {
			apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name);
		}
	}    

	return mrcp_server_rtp_settings_register(loader->server,rtp_settings,id);
}
示例#5
0
/** Load RTCP settings */
static apt_bool_t unimrcp_client_rtcp_settings_load(unimrcp_client_loader_t *loader, mpf_rtp_settings_t *rtcp_settings, const apr_xml_elem *root)
{
	const apr_xml_elem *elem;
	const apr_xml_attr *attr = NULL;
	for(attr = root->attr; attr; attr = attr->next) {
		if(strcasecmp(attr->name,"enable") == 0) {
			break;
		}
	}

	if(is_attr_enabled(attr) == FALSE) {
		/* RTCP is disabled, skip the rest */
		return TRUE;
	}

	rtcp_settings->rtcp = TRUE;
	apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading RTCP Settings");
	for(elem = root->first_child; elem; elem = elem->next) {
		apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Element <%s>",elem->name);
		if(strcasecmp(elem->name,"rtcp-bye") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				rtcp_settings->rtcp_bye_policy = atoi(cdata_text_get(elem));
			}
		}
		else if(strcasecmp(elem->name,"tx-interval") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				rtcp_settings->rtcp_tx_interval = (apr_uint16_t)atoi(cdata_text_get(elem));
			}
		}
		else if(strcasecmp(elem->name,"rx-resolution") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				rtcp_settings->rtcp_rx_resolution = (apr_uint16_t)atol(cdata_text_get(elem));
			}
		}
		else {
			apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name);
		}
	}
	return TRUE;
}
示例#6
0
/** Load plugin */
static apt_bool_t unimrcp_server_plugin_load(unimrcp_server_loader_t *loader, const apr_xml_elem *root)
{
	mrcp_engine_t *engine;
	mrcp_engine_config_t *config;
	const char *plugin_id = NULL;
	const char *plugin_name = NULL;
	const char *plugin_ext = NULL;
	const char *plugin_path = NULL;
	apt_bool_t plugin_enabled = TRUE;
	const apr_xml_attr *attr;
	for(attr = root->attr; attr; attr = attr->next) {
		if(strcasecmp(attr->name,"id") == 0) {
			plugin_id = apr_pstrdup(loader->pool,attr->value);
		}
		else if(strcasecmp(attr->name,"name") == 0) {
			plugin_name = attr->value;
		}
		else if(strcasecmp(attr->name,"ext") == 0) {
			plugin_ext = attr->value;
		}
		else if(strcasecmp(attr->name,"enable") == 0) {
			plugin_enabled = is_attr_enabled(attr);
		}
		else {
			apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Attribute <%s>",attr->name);
		}
	}

	if(!plugin_id || !plugin_name) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Missing plugin id or name");
		return FALSE;
	}
		
	if(!plugin_enabled) {
		/* disabled plugin, just skip it */
		return TRUE;
	}

	if(!plugin_ext) {
		plugin_ext = DEFAULT_PLUGIN_EXT;
	}

	if(*loader->dir_layout->plugin_dir_path == '\0') {
		plugin_path = apr_psprintf(loader->pool,"%s.%s",
						plugin_name,plugin_ext);
	}
	else {
		plugin_path = apr_psprintf(loader->pool,"%s/%s.%s",
						loader->dir_layout->plugin_dir_path,plugin_name,plugin_ext);
	}

	config = mrcp_engine_config_alloc(loader->pool);

	/* load optional named and generic name/value params */
	if(root->first_child){
		const apr_xml_attr *attr_name;
		const apr_xml_attr *attr_value;
		const apr_xml_elem *elem;
		apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Engine Params");
		config->params = apr_table_make(loader->pool,1);
		for(elem = root->first_child; elem; elem = elem->next) {
			if(strcasecmp(elem->name,"max-channel-count") == 0) {
				if(is_cdata_valid(elem) == TRUE) {
					config->max_channel_count = atol(cdata_text_get(elem));
				}
			}
			else if(strcasecmp(elem->name,"param") == 0) {
				if(name_value_attribs_get(elem,&attr_name,&attr_value) == TRUE) {
					apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Param %s:%s",attr_name->value,attr_value->value);
					apr_table_set(config->params,attr_name->value,attr_value->value);
				}
			}
		}
	}

	engine = mrcp_server_engine_load(loader->server,plugin_id,plugin_path,config);
	return mrcp_server_engine_register(loader->server,engine);
}
示例#7
0
/** Load SofiaSIP signaling agent */
static apt_bool_t unimrcp_client_sip_uac_load(unimrcp_client_loader_t *loader, const apr_xml_elem *root, const char *id)
{
	const apr_xml_elem *elem;
	mrcp_sig_agent_t *agent;
	mrcp_sofia_client_config_t *config;

	config = mrcp_sofiasip_client_config_alloc(loader->pool);
	config->local_port = DEFAULT_SIP_PORT;
	config->user_agent_name = DEFAULT_SOFIASIP_UA_NAME;
	config->origin = DEFAULT_SDP_ORIGIN;

	apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading SofiaSIP Agent <%s>",id);
	for(elem = root->first_child; elem; elem = elem->next) {
		apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Element <%s>",elem->name);
		if(strcasecmp(elem->name,"sip-ip") == 0) {
			config->local_ip = unimrcp_client_ip_address_get(loader,elem,loader->ip);
		}
		else if(strcasecmp(elem->name,"sip-ext-ip") == 0) {
			config->ext_ip = unimrcp_client_ip_address_get(loader,elem,loader->ext_ip);
		}
		else if(strcasecmp(elem->name,"sip-port") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				config->local_port = (apr_port_t)atol(cdata_text_get(elem));
			}
		}
		else if(strcasecmp(elem->name,"sip-transport") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				config->transport = cdata_copy(elem,loader->pool);
			}
		}
		else if(strcasecmp(elem->name,"ua-name") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				const apr_xml_attr *attr = NULL;
				for(attr = elem->attr; attr; attr = attr->next) {
					if(strcasecmp(attr->name,"appendversion") == 0) {
						break;
					}
				}
				if(is_attr_enabled(attr)) {
					config->user_agent_name = apr_psprintf(loader->pool,"%s "UNI_VERSION_STRING,cdata_text_get(elem));
				}
				else {
					config->user_agent_name = cdata_copy(elem,loader->pool);
				}
			}
		}
		else if(strcasecmp(elem->name,"sdp-origin") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				config->origin = cdata_copy(elem,loader->pool);
			}
		}
		else if(strcasecmp(elem->name,"sip-t1") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				config->sip_t1 = atol(cdata_text_get(elem));
			}
		}
		else if(strcasecmp(elem->name,"sip-t2") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				config->sip_t2 = atol(cdata_text_get(elem));
			}
		}
		else if(strcasecmp(elem->name,"sip-t4") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				config->sip_t4 = atol(cdata_text_get(elem));
			}
		}
		else if(strcasecmp(elem->name,"sip-t1x64") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				config->sip_t1x64 = atol(cdata_text_get(elem));
			}
		}
		else if(strcasecmp(elem->name,"sip-message-output") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				config->tport_log = cdata_bool_get(elem);
			}
		}
		else if(strcasecmp(elem->name,"sip-message-dump") == 0) {
			if(is_cdata_valid(elem) == TRUE) {
				const char *root_path;
				const char *path = cdata_text_get(elem);
				if(loader->dir_layout && apr_filepath_root(&root_path,&path,0,loader->pool) == APR_ERELATIVE)
					config->tport_dump_file = apt_dir_layout_path_compose(
													loader->dir_layout,
													APT_LAYOUT_LOG_DIR,
													path,
													loader->pool);
				else
					config->tport_dump_file = cdata_copy(elem,loader->pool);
			}
		}
		else {
			apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name);
		}
	}

	if(!config->local_ip) {
		/* use default IP address if not specified */
		config->local_ip = apr_pstrdup(loader->pool,loader->ip);
	}
	if(!config->ext_ip && loader->ext_ip) {
		/* use default ext IP address if not specified */
		config->ext_ip = apr_pstrdup(loader->pool,loader->ext_ip);
	}

	agent = mrcp_sofiasip_client_agent_create(id,config,loader->pool);
	return mrcp_client_signaling_agent_register(loader->client,agent);
}