Problem is it wont work in on_call_state_changed, whole app crashing. I've tried using pj_timer_heap_schedule, but without success ;/ pj_time_val timeDelay; pj_timer_entry timerEntry; pj_timer_heap_t *timer; pj_pool_t *pool; timeDelay.sec=5; timeDelay.msec=0; pj_timer_entry_init(&timerEntry, 1, NULL, &timerCallback); pool = pj_pool_create( pjsua_get_pool_factory(), NULL, pj_timer_heap_mem_size(1), 4000, NULL); pj_timer_heap_create(pool, 1, &timer); pj_timer_heap_schedule(timer, &timerEntry,&timeDelay); With such code it doesn't crash but it dont work too ;/ W dniu 26 marca 2012 10:19 u?ytkownik coopara <coopara at go2.pl> napisa?: > Hi, > > Use something like this: > > pj_time_val timeDelay; > pj_timer_entry timerEntry; > > timeDelay.sec=5; > timeDelay.msec=0; > > //initialize timer > pj_timer_entry_init(&timerEntry, 0, NULL, &timerCallback); > > //set timer > pjsip_endpt_schedule_timer(pjsua_get_pjsip_endpt(), &timerEntry, > &timeDelay); > > > //timer operation > static void timerCallback(pj_timer_heap_t *timer_heap, pj_timer_entry > *entry) > { > ? ?PJ_UNUSED_ARG(timer_heap); > > ? ? ? ?//some action > > ? ? ? ?//cancel timer > ? ? ? ?pjsip_endpt_cancel_timer(pjsua_get_pjsip_endpt(), entry); > ? ? ? ?//or start all over again > ? ? ? ?//pjsip_endpt_schedule_timer(pjsua_get_pjsip_endpt(), entry, > ? ? ? ?//&timeDelay); > } > > > > > Dnia 25 marca 2012 15:26 Andrzej Grzelak <andrew8666 at gmail.com> napisa?(a): > >> I'm using sample pjsua code, and i need to do some threading or just >> set timer on action... Here is code: >> >> /* Callback called by the library when call's state has changed */ >> static void on_call_state(pjsua_call_id call_id, pjsip_event *e) >> { >> ? ? pjsua_call_info ci; >> >> ? ? PJ_UNUSED_ARG(e); >> ? ? pjsua_call_get_info(call_id, &ci); >> ? ? PJ_LOG(2,(THIS_FILE, "Call %d state=%.*s", call_id, >> ? ? ? ? ? ? ? ? ? ? ? ?(int)ci.state_text.slen, >> ? ? ? ? ? ? ? ? ? ? ? ?ci.state_text.ptr)); >> ? ? ? if(ci.state == PJSIP_INV_STATE_EARLY){ >> ? ? ? ? ? ? ? ? ? ? ? // >> ? ? ? ? ? ? ? ? ? ? ? // >> ? ? ? ? ? ? ? ? ? ? ? //after 5 secs hangup call >> ? ? ? ? ? ? ? ? ? ? ? // >> ? ? ? ? ? ? ? ? ? ? ? // >> ? ? ? } >> ? ? ? if(ci.state == PJSIP_INV_STATE_DISCONNECTED ){ >> ? ? ? ? ? ? ? PJ_LOG(2,(THIS_FILE, "Call %d reason: =%.*s (%d)", call_id, >> ? ? ? ? ? ? ? ? ? ? ? (int)ci.last_status_text.slen, >> ? ? ? ? ? ? ? ? ? ? ? ?ci.last_status_text.ptr, >> ? ? ? ? ? ? ? ? ? ? ? ?(int)ci.last_status)); >> ? ? ? } >> } >> >> >> Can someone help me, and give just hints how to do it? >> >> _______________________________________________ >> Visit our blog: http://blog.pjsip.org >> >> pjsip mailing list >> pjsip at lists.pjsip.org >> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >> > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org