static void mrcp_sofia_task_initialize(apt_task_t *task) { mrcp_sofia_agent_t *sofia_agent = apt_task_object_get(task); /* Initialize Sofia-SIP library and create event loop */ su_init(); sofia_agent->root = su_root_create(NULL); /* Create a user agent instance. The stack will call the 'event_callback()' * callback when events such as succesful registration to network, * an incoming call, etc, occur. */ sofia_agent->nua = nua_create( sofia_agent->root, /* Event loop */ mrcp_sofia_event_callback, /* Callback for processing events */ sofia_agent, /* Additional data to pass to callback */ NUTAG_URL(sofia_agent->sip_bind_str), /* Address to bind to */ TAG_END()); /* Last tag should always finish the sequence */ if(sofia_agent->nua) { nua_set_params( sofia_agent->nua, NUTAG_AUTOANSWER(0), NUTAG_APPL_METHOD("OPTIONS"), SIPTAG_USER_AGENT_STR(sofia_agent->config->user_agent_name), TAG_END()); } }
static void mrcp_sofia_task_initialize(apt_task_t *task) { mrcp_sofia_agent_t *sofia_agent = apt_task_object_get(task); mrcp_sofia_server_config_t *sofia_config = sofia_agent->config; /* Initialize Sofia-SIP library and create event loop */ su_init(); sofia_agent->root = su_root_create(NULL); /* Create a user agent instance. The stack will call the 'event_callback()' * callback when events such as succesful registration to network, * an incoming call, etc, occur. */ sofia_agent->nua = nua_create( sofia_agent->root, /* Event loop */ mrcp_sofia_event_callback, /* Callback for processing events */ sofia_agent, /* Additional data to pass to callback */ NUTAG_URL(sofia_agent->sip_bind_str), /* Address to bind to */ NUTAG_AUTOANSWER(0), NUTAG_APPL_METHOD("OPTIONS"), TAG_IF(sofia_config->sip_t1,NTATAG_SIP_T1(sofia_config->sip_t1)), TAG_IF(sofia_config->sip_t2,NTATAG_SIP_T2(sofia_config->sip_t2)), TAG_IF(sofia_config->sip_t4,NTATAG_SIP_T4(sofia_config->sip_t4)), TAG_IF(sofia_config->sip_t1x64,NTATAG_SIP_T1X64(sofia_config->sip_t1x64)), SIPTAG_USER_AGENT_STR(sofia_config->user_agent_name), TAG_IF(sofia_config->tport_log == TRUE,TPTAG_LOG(1)), /* Print out SIP messages to the console */ TAG_IF(sofia_config->tport_dump_file,TPTAG_DUMP(sofia_config->tport_dump_file)), /* Dump SIP messages to the file */ TAG_END()); /* Last tag should always finish the sequence */ if(!sofia_agent->nua) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create NUA [%s] %s", apt_task_name_get(task), sofia_agent->sip_bind_str); } }
static int luasofia_nua_create(lua_State *L) { luasofia_su_root_t *lroot = NULL; luasofia_nua_t *lnua = NULL; nua_t *nua = NULL; tagi_t *tags = NULL; su_home_t *home = su_home_create(); /* get and check first argument (should be a root_t) */ lroot = (luasofia_su_root_t*)luaL_checkudata(L, 1, SU_ROOT_MTABLE); /* check the callback table */ if (!lua_isnoneornil(L, 2)) luaL_checktype(L, 2, LUA_TTABLE); tags = luasofia_tags_table_to_taglist(L, 4, home); /* create a nua object */ lnua = (luasofia_nua_t*) lua_newuserdata(L, sizeof(luasofia_nua_t)); /* create the nua_t */ nua = nua_create(lroot->root, nua_event_callback, L, TAG_NEXT(tags)); if (!nua) { luaL_error(L, "nua_create failed!"); } /* save nua object */ lnua->nua = nua; /* set its metatable */ luaL_getmetatable(L, NUA_MTABLE); lua_setmetatable(L, -2); /* store nua at luasofia userdata table */ luasofia_userdata_table_set(L, nua); /* create env table */ lua_createtable(L, 2, 0); /* save second argument (callbacks) on env table */ if (!lua_isnoneornil(L, 2)) { lua_pushvalue(L, 2); lua_rawseti(L, -2, ENV_CALLBACK_INDEX); } /* save third argument (magic) on env table */ if (!lua_isnoneornil(L, 3)) { lua_pushvalue(L, 3); lua_rawseti(L, -2, ENV_MAGIC_INDEX); } /* set env table as environment for udata */ lua_setfenv(L, -2); su_home_unref(home); return 1; }
nua_t *s2_nua_setup(char const *label, tag_type_t tag, tag_value_t value, ...) { ta_list ta; s2_setup(label); s2 = su_home_new(sizeof *s2); s2_dns_setup(s2base->root); s2_setup_logs(0); s2_sip_setup("example.org", NULL, TAG_END()); assert(s2sip->contact); s2_dns_domain("example.org", 1, "s2", 1, s2sip->udp.contact->m_url, "s2", 1, s2sip->tcp.contact->m_url, NULL); /* enable/disable multithreading */ su_root_threading(s2base->root, s2_nua_thread); ta_start(ta, tag, value); s2->nua = nua_create(s2base->root, s2_nua_callback, s2, SIPTAG_FROM_STR("Alice <sip:[email protected]>"), /* NUTAG_PROXY((url_string_t *)s2sip->contact->m_url), */ /* Use internal DNS server */ NUTAG_PROXY("sip:example.org"), /* Force sresolv to use localhost and s2dns as DNS server */ #if HAVE_WIN32 SRESTAG_RESOLV_CONF("NUL"), #else SRESTAG_RESOLV_CONF("/dev/null"), #endif ta_tags(ta)); ta_end(ta); return s2->nua; }