Exemplo n.º 1
0
/* Set SofiaSIP client config struct with param, val pair. */
static int process_mrcpv2_config(mrcp_sofia_client_config_t *config, mrcp_sig_settings_t *sig_settings, const char *param, const char *val, apr_pool_t *pool)
{
	int mine = 1;

	if ((config == NULL) || (param == NULL) || (sig_settings == NULL) || (val == NULL) || (pool == NULL))
		return mine;

	if (strcasecmp(param, "client-ip") == 0)
		config->local_ip = ip_addr_get(val, pool);
	else if (strcasecmp(param,"client-ext-ip") == 0)
		config->ext_ip = ip_addr_get(val, pool);
	else if (strcasecmp(param,"client-port") == 0)
		config->local_port = (apr_port_t)atol(val);
	else if (strcasecmp(param, "server-ip") == 0)
		sig_settings->server_ip = ip_addr_get(val, pool);
	else if (strcasecmp(param, "server-port") == 0)
		sig_settings->server_port = (apr_port_t)atol(val);
	else if (strcasecmp(param, "server-username") == 0)
		sig_settings->user_name = apr_pstrdup(pool, val);
	else if (strcasecmp(param, "force-destination") == 0)
		sig_settings->force_destination = atoi(val);
	else if (strcasecmp(param, "sip-transport") == 0)
		config->transport = apr_pstrdup(pool, val);
	else if (strcasecmp(param, "ua-name") == 0)
		config->user_agent_name = apr_pstrdup(pool, val);
	else if (strcasecmp(param, "sdp-origin") == 0)
		config->origin = apr_pstrdup(pool, val);
	else
		mine = 0;

	return mine;
}
Exemplo n.º 2
0
/** Load MRCPv2 connection agent */
static mrcp_connection_agent_t* unimrcp_server_connection_agent_load(mrcp_server_t *server, const apr_xml_elem *root, apr_pool_t *pool)
{
    const apr_xml_elem *elem;
    char *mrcp_ip = DEFAULT_IP_ADDRESS;
    apr_port_t mrcp_port = DEFAULT_MRCP_PORT;
    apr_size_t max_connection_count = 100;

    apt_log(APT_PRIO_DEBUG,"Loading MRCPv2 Agent");
    for(elem = root->first_child; elem; elem = elem->next) {
        if(strcasecmp(elem->name,"param") == 0) {
            const apr_xml_attr *attr_name;
            const apr_xml_attr *attr_value;
            if(param_name_value_get(elem,&attr_name,&attr_value) == TRUE) {
                apt_log(APT_PRIO_DEBUG,"Loading Param %s:%s",attr_name->value,attr_value->value);
                if(strcasecmp(attr_name->value,"mrcp-ip") == 0) {
                    mrcp_ip = ip_addr_get(attr_value->value,pool);
                }
                else if(strcasecmp(attr_name->value,"mrcp-port") == 0) {
                    mrcp_port = (apr_port_t)atol(attr_value->value);
                }
                else if(strcasecmp(attr_name->value,"max-connection-count") == 0) {
                    max_connection_count = atol(attr_value->value);
                }
                else {
                    apt_log(APT_PRIO_WARNING,"Unknown Attribute <%s>",attr_name->value);
                }
            }
        }
    }
    return mrcp_server_connection_agent_create(mrcp_ip,mrcp_port,max_connection_count,pool);
}
Exemplo n.º 3
0
/** Load UniRTSP signaling agent */
static mrcp_sig_agent_t* unimrcp_server_rtsp_agent_load(mrcp_server_t *server, const apr_xml_elem *root, apr_pool_t *pool)
{
    const apr_xml_elem *elem;
    rtsp_server_config_t *config = mrcp_unirtsp_server_config_alloc(pool);
    config->local_ip = DEFAULT_IP_ADDRESS;
    config->local_port = DEFAULT_RTSP_PORT;
    config->origin = DEFAULT_SDP_ORIGIN;

    apt_log(APT_PRIO_DEBUG,"Loading UniRTSP Agent");
    for(elem = root->first_child; elem; elem = elem->next) {
        if(strcasecmp(elem->name,"param") == 0) {
            const apr_xml_attr *attr_name;
            const apr_xml_attr *attr_value;
            if(param_name_value_get(elem,&attr_name,&attr_value) == TRUE) {
                apt_log(APT_PRIO_DEBUG,"Loading Param %s:%s",attr_name->value,attr_value->value);
                if(strcasecmp(attr_name->value,"rtsp-ip") == 0) {
                    config->local_ip = ip_addr_get(attr_value->value,pool);
                }
                else if(strcasecmp(attr_name->value,"rtsp-port") == 0) {
                    config->local_port = (apr_port_t)atol(attr_value->value);
                }
                else if(strcasecmp(attr_name->value,"sdp-origin") == 0) {
                    config->origin = apr_pstrdup(pool,attr_value->value);
                }
                else if(strcasecmp(attr_name->value,"max-connection-count") == 0) {
                    config->max_connection_count = atol(attr_value->value);
                }
                else {
                    apt_log(APT_PRIO_WARNING,"Unknown Attribute <%s>",attr_name->value);
                }
            }
        }
    }
    return mrcp_unirtsp_server_agent_create(config,pool);
}
Exemplo n.º 4
0
/* Set RTSP client config struct with param, val pair. */
static int process_mrcpv1_config(rtsp_client_config_t *config, mrcp_sig_settings_t *sig_settings, const char *param, const char *val, apr_pool_t *pool)
{
	int mine = 1;

	if ((config == NULL) || (param == NULL) || (sig_settings == NULL) || (val == NULL) || (pool == NULL))
		return mine;

	if (strcasecmp(param, "server-ip") == 0)
		sig_settings->server_ip = ip_addr_get(val, pool);
	else if (strcasecmp(param, "server-port") == 0)
		sig_settings->server_port = (apr_port_t)atol(val);
	else if (strcasecmp(param, "resource-location") == 0)
		sig_settings->resource_location = apr_pstrdup(pool, val);
	else if (strcasecmp(param, "sdp-origin") == 0)
		config->origin = apr_pstrdup(pool, val);
	else if (strcasecmp(param, "max-connection-count") == 0)
		config->max_connection_count = atol(val);
	else if (strcasecmp(param, "force-destination") == 0)
		sig_settings->force_destination = atoi(val);
	else if ((strcasecmp(param, "speechsynth") == 0) || (strcasecmp(param, "speechrecog") == 0))
		apr_table_set(sig_settings->resource_map, param, val);
	else
		mine = 0;

	return mine;
}
Exemplo n.º 5
0
/* Set RTP config struct with param, val pair. */
static int process_rtp_config(mrcp_client_t *client, mpf_rtp_config_t *rtp_config, mpf_rtp_settings_t *rtp_settings, const char *param, const char *val, apr_pool_t *pool)
{
	int mine = 1;

	if ((client == NULL) || (rtp_config == NULL) || (rtp_settings == NULL) || (param == NULL) || (val == NULL) || (pool == NULL))
		return mine;

	if (strcasecmp(param, "rtp-ip") == 0)
		apt_string_set(&rtp_config->ip, ip_addr_get(val, pool));
	else if (strcasecmp(param, "rtp-ext-ip") == 0)
		apt_string_set(&rtp_config->ext_ip, ip_addr_get(val, pool));
	else if (strcasecmp(param, "rtp-port-min") == 0)
		rtp_config->rtp_port_min = (apr_port_t)atol(val);
	else if (strcasecmp(param, "rtp-port-max") == 0)
		rtp_config->rtp_port_max = (apr_port_t)atol(val);
	else if (strcasecmp(param, "playout-delay") == 0)
		rtp_settings->jb_config.initial_playout_delay = atol(val);
	else if (strcasecmp(param, "min-playout-delay") == 0)
		rtp_settings->jb_config.min_playout_delay = atol(val);
	else if (strcasecmp(param, "max-playout-delay") == 0)
		rtp_settings->jb_config.max_playout_delay = atol(val);
	else if (strcasecmp(param, "codecs") == 0) {
		/* Make sure that /etc/mrcp.conf contains the desired codec first in the codecs parameter. */
		const mpf_codec_manager_t *codec_manager = mrcp_client_codec_manager_get(client);
		if (codec_manager != NULL) {
			if (!mpf_codec_manager_codec_list_load(codec_manager, &rtp_settings->codec_list, val, pool))
				ast_log(LOG_WARNING, "Unable to load codecs\n");
		}
	} else if (strcasecmp(param, "ptime") == 0)
		rtp_settings->ptime = (apr_uint16_t)atol(val);
	else if (strcasecmp(param, "rtcp") == 0)
		rtp_settings->rtcp = atoi(val);
	else if  (strcasecmp(param, "rtcp-bye") == 0)
		rtp_settings->rtcp_bye_policy = atoi(val);
	else if (strcasecmp(param, "rtcp-tx-interval") == 0)
		rtp_settings->rtcp_tx_interval = (apr_uint16_t)atoi(val);
	else if (strcasecmp(param, "rtcp-rx-resolution") == 0)
		rtp_settings->rtcp_rx_resolution = (apr_uint16_t)atol(val);
	else
		mine = 0;

	return mine;
}
Exemplo n.º 6
0
/** Load RTP termination factory */
static mpf_termination_factory_t* unimrcp_server_rtp_factory_load(mrcp_server_t *server, const apr_xml_elem *root, apr_pool_t *pool)
{
	const apr_xml_elem *elem;
	char *rtp_ip = DEFAULT_IP_ADDRESS;
	mpf_rtp_config_t *rtp_config = mpf_rtp_config_create(pool);
	rtp_config->rtp_port_min = DEFAULT_RTP_PORT_MIN;
	rtp_config->rtp_port_max = DEFAULT_RTP_PORT_MAX;
	apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading RTP Termination Factory");
	for(elem = root->first_child; elem; elem = elem->next) {
		if(strcasecmp(elem->name,"param") == 0) {
			const apr_xml_attr *attr_name;
			const apr_xml_attr *attr_value;
			if(param_name_value_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);
				if(strcasecmp(attr_name->value,"rtp-ip") == 0) {
					rtp_ip = ip_addr_get(attr_value->value,pool);
				}
				else if(strcasecmp(attr_name->value,"rtp-port-min") == 0) {
					rtp_config->rtp_port_min = (apr_port_t)atol(attr_value->value);
				}
				else if(strcasecmp(attr_name->value,"rtp-port-max") == 0) {
					rtp_config->rtp_port_max = (apr_port_t)atol(attr_value->value);
				}
				else if(strcasecmp(attr_name->value,"playout-delay") == 0) {
					rtp_config->jb_config.initial_playout_delay = atol(attr_value->value);
				}
				else if(strcasecmp(attr_name->value,"min-playout-delay") == 0) {
					rtp_config->jb_config.min_playout_delay = atol(attr_value->value);
				}
				else if(strcasecmp(attr_name->value,"max-playout-delay") == 0) {
					rtp_config->jb_config.max_playout_delay = atol(attr_value->value);
				}
				else if(strcasecmp(attr_name->value,"codecs") == 0) {
					const mpf_codec_manager_t *codec_manager = mrcp_server_codec_manager_get(server);
					if(codec_manager) {
						mpf_codec_manager_codec_list_load(codec_manager,&rtp_config->codec_list,attr_value->value,pool);
					}
				}
				else if(strcasecmp(attr_name->value,"ptime") == 0) {
					rtp_config->ptime = (apr_uint16_t)atol(attr_value->value);
				}
				else if(strcasecmp(attr_name->value,"own-preference") == 0) {
					rtp_config->own_preferrence = atoi(attr_value->value);
				}
				else {
					apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Attribute <%s>",attr_name->value);
				}
			}
		}
	}
	apt_string_set(&rtp_config->ip,rtp_ip);
	return mpf_rtp_termination_factory_create(rtp_config,pool);
}
Exemplo n.º 7
0
/** Load SofiaSIP signaling agent */
static mrcp_sig_agent_t* unimrcp_server_sofiasip_agent_load(mrcp_server_t *server, const apr_xml_elem *root, apr_pool_t *pool)
{
    const apr_xml_elem *elem;
    mrcp_sofia_server_config_t *config = mrcp_sofiasip_server_config_alloc(pool);
    config->local_ip = DEFAULT_IP_ADDRESS;
    config->local_port = DEFAULT_SIP_PORT;
    config->user_agent_name = DEFAULT_SOFIASIP_UA_NAME;
    config->origin = DEFAULT_SDP_ORIGIN;

    apt_log(APT_PRIO_DEBUG,"Loading SofiaSIP Agent");
    for(elem = root->first_child; elem; elem = elem->next) {
        if(strcasecmp(elem->name,"param") == 0) {
            const apr_xml_attr *attr_name;
            const apr_xml_attr *attr_value;
            if(param_name_value_get(elem,&attr_name,&attr_value) == TRUE) {
                apt_log(APT_PRIO_DEBUG,"Loading Param %s:%s",attr_name->value,attr_value->value);
                if(strcasecmp(attr_name->value,"sip-ip") == 0) {
                    config->local_ip = ip_addr_get(attr_value->value,pool);
                }
                else if(strcasecmp(attr_name->value,"sip-port") == 0) {
                    config->local_port = (apr_port_t)atol(attr_value->value);
                }
                else if(strcasecmp(attr_name->value,"sip-transport") == 0) {
                    config->transport = apr_pstrdup(pool,attr_value->value);
                }
                else if(strcasecmp(attr_name->value,"ua-name") == 0) {
                    config->user_agent_name = apr_pstrdup(pool,attr_value->value);
                }
                else if(strcasecmp(attr_name->value,"sdp-origin") == 0) {
                    config->origin = apr_pstrdup(pool,attr_value->value);
                }
                else {
                    apt_log(APT_PRIO_WARNING,"Unknown Attribute <%s>",attr_name->value);
                }
            }
        }
    }
    return mrcp_sofiasip_server_agent_create(config,pool);
}