From 89547e9f9d2eff5aa4dd7bbd212ebd7cee8b4e96 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Tue, 20 Oct 2009 13:56:26 +0000 Subject: Initial commit for ticket #937: Revamping of presence management to make it more efficient Presence enhancements: - finer grained buddy lock object, instead of using global PJSUA-LIB's mutex - individual resubscription timer for buddies and also add random delay interval so that resubscriptions don't happen simultaneously (may hog processing and bandwidth). - in general reduced the use of global PJSUA-LIB's mutex for more efficiency - added last termination code in buddy info - use the RPID note's text for buddy's offline status rather than the default "offline" status, if available - resubscribe automatically on several termination causes as explained in the ticket (still untested) General enhancements: - added pjsua_schedule_timer() and pjsua_cancel_timer() APIs git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2956 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsua-lib/pjsua.h | 37 +++++++++++++++++++++++++++++++- pjsip/include/pjsua-lib/pjsua_internal.h | 3 ++- 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'pjsip/include/pjsua-lib') diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index c0eb8b25..93167785 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -1396,6 +1396,32 @@ PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token, PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url); +/** + * Schedule a timer entry. Note that the timer callback may be executed + * by different thread, depending on whether worker thread is enabled or + * not. + * + * @param entry Timer heap entry. + * @param delay The interval to expire. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + * + * @see pjsip_endpt_schedule_timer() + */ +PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry, + const pj_time_val *delay); + + +/** + * Cancel the previously scheduled timer. + * + * @param entry Timer heap entry. + * + * @see pjsip_endpt_cancel_timer() + */ +PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry); + + /** * This is a utility function to display error message for the specified * error code. The error message will be sent to the log. @@ -3128,7 +3154,16 @@ typedef struct pjsua_buddy_info const char *sub_state_name; /** - * Specifies the last presence subscription terminatino reason. If + * Specifies the last presence subscription termination code. This would + * return the last status of the SUBSCRIBE request. If the subscription + * is terminated with NOTIFY by the server, this value will be set to + * 200, and subscription termination reason will be given in the + * \a sub_term_reason field. + */ + unsigned sub_term_code; + + /** + * Specifies the last presence subscription termination reason. If * presence subscription is currently active, the value will be empty. */ pj_str_t sub_term_reason; diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h index e4691868..0f777967 100644 --- a/pjsip/include/pjsua-lib/pjsua_internal.h +++ b/pjsip/include/pjsua-lib/pjsua_internal.h @@ -185,9 +185,10 @@ typedef struct pjsua_buddy pj_bool_t monitor; /**< Should we monitor? */ pjsip_dialog *dlg; /**< The underlying dialog. */ pjsip_evsub *sub; /**< Buddy presence subscription */ + unsigned term_code; /**< Subscription termination code */ pj_str_t term_reason;/**< Subscription termination reason */ pjsip_pres_status status; /**< Buddy presence status. */ - + pj_timer_entry timer; /**< Resubscription timer */ } pjsua_buddy; -- cgit v1.2.3