Changeset 3938 for pjproject/trunk
- Timestamp:
- Jan 9, 2012 11:51:56 AM (13 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r3925 r3938 1997 1997 * 1998 1998 * @param entry Timer heap entry. 1999 * @param delay The interval to expire.1999 * @param delay The interval to expire. 2000 2000 * 2001 2001 * @return PJ_SUCCESS on success, or the appropriate error code. … … 2006 2006 const pj_time_val *delay); 2007 2007 2008 /** 2009 * Schedule a callback function to be called after a specified time interval. 2010 * Note that the callback may be executed by different thread, depending on 2011 * whether worker thread is enabled or not. 2012 * 2013 * @param cb The callback function. 2014 * @param user_data The user data. 2015 * @param msec_delay The time interval in msec. 2016 * 2017 * @return PJ_SUCCESS on success, or the appropriate error code. 2018 */ 2019 PJ_DECL(pj_status_t) pjsua_schedule_timer2(void (*cb)(void *user_data), 2020 void *user_data, 2021 unsigned msec_delay); 2008 2022 2009 2023 /** -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r3928 r3938 77 77 pjmedia_transport *tp; /**< Current media transport (can be 0) */ 78 78 pj_status_t tp_ready; /**< Media transport status. */ 79 pj_status_t tp_result; /**< Media transport creation result. */ 79 80 pjmedia_transport *tp_orig; /**< Original media transport */ 80 81 pj_bool_t tp_auto_del; /**< May delete media transport */ … … 457 458 pjsua_vid_win win[PJSUA_MAX_VID_WINS]; /**< Array of windows */ 458 459 #endif 460 461 /* Timer entry list */ 462 struct timer_list 463 { 464 PJ_DECL_LIST_MEMBER(struct timer_list); 465 pj_timer_entry entry; 466 void (*cb)(void *user_data); 467 void *user_data; 468 } timer_list; 469 pj_mutex_t *timer_mutex; 459 470 }; 460 471 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r3891 r3938 713 713 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 714 714 715 /* Init timer entry list */ 716 pj_list_init(&pjsua_var.timer_list); 717 718 /* Create timer mutex */ 719 status = pj_mutex_create_recursive(pjsua_var.pool, "pjsua_timer", 720 &pjsua_var.timer_mutex); 721 if (status != PJ_SUCCESS) { 722 pj_log_pop_indent(); 723 pjsua_perror(THIS_FILE, "Unable to create mutex", status); 724 return status; 725 } 726 715 727 pjsua_set_state(PJSUA_STATE_CREATED); 716 728 pj_log_pop_indent(); … … 2604 2616 } 2605 2617 2618 /* Timer callback */ 2619 static void timer_cb( pj_timer_heap_t *th, 2620 pj_timer_entry *entry) 2621 { 2622 struct timer_list *tmr = (struct timer_list *)entry->user_data; 2623 void (*cb)(void *user_data) = tmr->cb; 2624 void *user_data = tmr->user_data; 2625 2626 PJ_UNUSED_ARG(th); 2627 2628 pj_mutex_lock(pjsua_var.timer_mutex); 2629 pj_list_push_back(&pjsua_var.timer_list, tmr); 2630 pj_mutex_unlock(pjsua_var.timer_mutex); 2631 2632 if (cb) 2633 (*cb)(user_data); 2634 } 2635 2636 /* 2637 * Schedule a timer callback. 2638 */ 2639 PJ_DEF(pj_status_t) pjsua_schedule_timer2( void (*cb)(void *user_data), 2640 void *user_data, 2641 unsigned msec_delay) 2642 { 2643 struct timer_list *tmr = NULL; 2644 pj_status_t status; 2645 pj_time_val delay; 2646 2647 pj_mutex_lock(pjsua_var.timer_mutex); 2648 2649 if (pj_list_empty(&pjsua_var.timer_list)) { 2650 tmr = PJ_POOL_ALLOC_T(pjsua_var.pool, struct timer_list); 2651 } else { 2652 tmr = pjsua_var.timer_list.next; 2653 pj_list_erase(tmr); 2654 } 2655 pj_timer_entry_init(&tmr->entry, 0, tmr, timer_cb); 2656 tmr->cb = cb; 2657 tmr->user_data = user_data; 2658 delay.sec = 0; 2659 delay.msec = msec_delay; 2660 2661 status = pjsip_endpt_schedule_timer(pjsua_var.endpt, &tmr->entry, &delay); 2662 if (status != PJ_SUCCESS) { 2663 pj_list_push_back(&pjsua_var.timer_list, tmr); 2664 } 2665 2666 pj_mutex_unlock(pjsua_var.timer_mutex); 2667 2668 return status; 2669 } 2670 2606 2671 /* 2607 2672 * Cancel the previously scheduled timer. -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r3929 r3938 767 767 #endif 768 768 769 static void med_tp_timer_cb(void *user_data) 770 { 771 pjsua_call_media *call_med = (pjsua_call_media*)user_data; 772 773 PJSUA_LOCK(); 774 775 call_med->tp_ready = call_med->tp_result; 776 if (call_med->med_create_cb) 777 (*call_med->med_create_cb)(call_med, call_med->tp_ready, 778 call_med->call->secure_level, NULL); 779 780 PJSUA_UNLOCK(); 781 } 782 769 783 /* This callback is called when ICE negotiation completes */ 770 784 static void on_ice_complete(pjmedia_transport *tp, … … 779 793 switch (op) { 780 794 case PJ_ICE_STRANS_OP_INIT: 781 PJSUA_LOCK(); 782 call_med->tp_ready = result; 783 if (call_med->med_create_cb) 784 (*call_med->med_create_cb)(call_med, result, 785 call_med->call->secure_level, NULL); 786 PJSUA_UNLOCK(); 795 call_med->tp_result = result; 796 pjsua_schedule_timer2(&med_tp_timer_cb, call_med, 1); 787 797 break; 788 798 case PJ_ICE_STRANS_OP_NEGOTIATION: … … 1539 1549 pjsua_call_media *call_med = &call->media[mi]; 1540 1550 1541 if (call_med->med_init_cb || 1542 call_med->tp_st == PJSUA_MED_TP_NULL) 1543 { 1551 if (call_med->med_init_cb) { 1544 1552 pj_mutex_unlock(call->med_ch_mutex); 1545 1553 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.