static char* unimrcp_client_ip_address_get(unimrcp_client_loader_t *loader, const apr_xml_elem *elem, const char *default_ip) { const apr_xml_attr *attr = NULL; for(attr = elem->attr; attr; attr = attr->next) { if(strcasecmp(attr->name,"type") == 0) { break; } } if(attr && strcasecmp(attr->value,"auto") == 0) { /* implicitly detect ip address, if not already detected */ if(!loader->auto_ip) { char *auto_addr = DEFAULT_IP_ADDRESS; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Detecting IP Address"); apt_ip_get(&auto_addr,loader->pool); loader->auto_ip = auto_addr; } return apr_pstrdup(loader->pool,loader->auto_ip); } if(is_cdata_valid(elem)) { /* use specified ip address */ return cdata_copy(elem,loader->pool); } /* use default ip address */ return apr_pstrdup(loader->pool,loader->ip); }
/** Load UniRTSP signaling agent */ static apt_bool_t unimrcp_client_rtsp_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; rtsp_client_config_t *config; config = mrcp_unirtsp_client_config_alloc(loader->pool); config->origin = DEFAULT_SDP_ORIGIN; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading UniRTSP 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,"sdp-origin") == 0) { if(is_cdata_valid(elem) == TRUE) { config->origin = cdata_copy(elem,loader->pool); } } else if(strcasecmp(elem->name,"max-connection-count") == 0) { if(is_cdata_valid(elem) == TRUE) { config->max_connection_count = atol(cdata_text_get(elem)); } } else if(strcasecmp(elem->name,"request-timeout") == 0) { if(is_cdata_valid(elem) == TRUE) { config->request_timeout = atol(cdata_text_get(elem)); } } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } } agent = mrcp_unirtsp_client_agent_create(id,config,loader->pool); return mrcp_client_signaling_agent_register(loader->client,agent); }
/** Load UniRTSP signaling agent */ static apt_bool_t unimrcp_server_rtsp_uas_load(unimrcp_server_loader_t *loader, const apr_xml_elem *root, const char *id) { const apr_xml_elem *elem; mrcp_sig_agent_t *agent; rtsp_server_config_t *config; config = mrcp_unirtsp_server_config_alloc(loader->pool); config->origin = DEFAULT_SDP_ORIGIN; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading UniRTSP 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,"rtsp-ip") == 0) { config->local_ip = unimrcp_server_ip_address_get(loader,elem); } else if(strcasecmp(elem->name,"rtsp-port") == 0) { if(is_cdata_valid(elem) == TRUE) { config->local_port = (apr_port_t)atol(cdata_text_get(elem)); } } 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,"max-connection-count") == 0) { if(is_cdata_valid(elem) == TRUE) { config->max_connection_count = atol(cdata_text_get(elem)); } } else if(strcasecmp(elem->name,"force-destination") == 0) { if(is_cdata_valid(elem) == TRUE) { config->force_destination = cdata_bool_get(elem); } } else if(strcasecmp(elem->name,"resource-map") == 0) { const apr_xml_attr *name_attr; const apr_xml_attr *value_attr; const apr_xml_elem *child_elem; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Resource Map"); for(child_elem = elem->first_child; child_elem; child_elem = child_elem->next) { if(name_value_attribs_get(child_elem,&name_attr,&value_attr) == TRUE) { apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Param %s:%s",name_attr->value,value_attr->value); apr_table_set(config->resource_map,name_attr->value,value_attr->value); } } } 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); } agent = mrcp_unirtsp_server_agent_create(id,config,loader->pool); return mrcp_server_signaling_agent_register(loader->server,agent); }
/** Load SIP settings */ static apt_bool_t unimrcp_client_sip_settings_load(unimrcp_client_loader_t *loader, const apr_xml_elem *root, const char *id) { const apr_xml_elem *elem; mrcp_sig_settings_t *settings = mrcp_signaling_settings_alloc(loader->pool); apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading SIP 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,"server-ip") == 0) { settings->server_ip = unimrcp_client_ip_address_get(loader,elem,loader->server_ip); } else if(strcasecmp(elem->name,"server-port") == 0) { if(is_cdata_valid(elem) == TRUE) { settings->server_port = (apr_port_t)atol(cdata_text_get(elem)); } } else if(strcasecmp(elem->name,"server-username") == 0) { if(is_cdata_valid(elem) == TRUE) { settings->user_name = cdata_copy(elem,loader->pool); } } else if(strcasecmp(elem->name,"force-destination") == 0) { if(is_cdata_valid(elem) == TRUE) { settings->force_destination = cdata_bool_get(elem); } } else if(strcasecmp(elem->name,"feature-tags") == 0) { if(is_cdata_valid(elem) == TRUE) { settings->feature_tags = cdata_copy(elem,loader->pool); } } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } } if(!settings->server_ip) { settings->server_ip = apr_pstrdup(loader->pool,loader->server_ip); } apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create SIP Settings %s:%hu",settings->server_ip,settings->server_port); return mrcp_client_signaling_settings_register(loader->client,settings,id); }
/** Load RTSP settings */ static apt_bool_t unimrcp_client_rtsp_settings_load(unimrcp_client_loader_t *loader, const apr_xml_elem *root, const char *id) { const apr_xml_elem *elem; mrcp_sig_settings_t *settings = mrcp_signaling_settings_alloc(loader->pool); settings->resource_location = DEFAULT_RESOURCE_LOCATION; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading RTSP 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,"server-ip") == 0) { settings->server_ip = unimrcp_client_ip_address_get(loader,elem,loader->server_ip); } else if(strcasecmp(elem->name,"server-port") == 0) { if(is_cdata_valid(elem) == TRUE) { settings->server_port = (apr_port_t)atol(cdata_text_get(elem)); } } else if(strcasecmp(elem->name,"force-destination") == 0) { if(is_cdata_valid(elem) == TRUE) { settings->force_destination = cdata_bool_get(elem); } } else if(strcasecmp(elem->name,"resource-location") == 0) { if(is_cdata_valid(elem) == TRUE) { settings->resource_location = cdata_copy(elem,loader->pool); } else { settings->resource_location = ""; } } else if(strcasecmp(elem->name,"resource-map") == 0) { const apr_xml_attr *name_attr; const apr_xml_attr *value_attr; const apr_xml_elem *child_elem; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Resource Map"); for(child_elem = elem->first_child; child_elem; child_elem = child_elem->next) { if(name_value_attribs_get(child_elem,&name_attr,&value_attr) == TRUE) { apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Param %s:%s",name_attr->value,value_attr->value); apr_table_set(settings->resource_map,name_attr->value,value_attr->value); } } } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } } if(!settings->server_ip) { settings->server_ip = apr_pstrdup(loader->pool,loader->server_ip); } apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create RTSP Settings %s:%hu",settings->server_ip,settings->server_port); return mrcp_client_signaling_settings_register(loader->client,settings,id); }
static char* unimrcp_client_ip_address_get(unimrcp_client_loader_t *loader, const apr_xml_elem *elem, const char *default_ip) { const apr_xml_attr *attr = NULL; for(attr = elem->attr; attr; attr = attr->next) { if(strcasecmp(attr->name,"type") == 0) { break; } } if(attr && strcasecmp(attr->value,"auto") == 0) { /* implicitly detect IP address, if not already detected */ if(!loader->auto_ip) { char *auto_addr = DEFAULT_IP_ADDRESS; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Detecting IP Address"); apt_ip_get(&auto_addr,loader->pool); loader->auto_ip = auto_addr; } return apr_pstrdup(loader->pool,loader->auto_ip); } else if(attr && strcasecmp(attr->value,"iface") == 0) { /* get IP address by network interface name */ char *ip_addr = DEFAULT_IP_ADDRESS; if(is_cdata_valid(elem) == TRUE) { const char *iface_name = cdata_text_get(elem); apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Get IP Address by Interface [%s]", iface_name); apt_ip_get_by_iface(iface_name,&ip_addr,loader->pool); } return ip_addr; } if(is_cdata_valid(elem)) { /* use specified IP address */ return cdata_copy(elem,loader->pool); } /* use default IP address */ return apr_pstrdup(loader->pool,loader->ip); }
/** 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) { 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 { 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); }
/** 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); }