Ignore:
Timestamp:
Mar 22, 2012 11:29:20 AM (9 years ago)
Author:
nanang
Message:

Close #1466 (using PJLIB outside PJSUA-LIB context):

  • static reference counter for PJLIB init/shutdown.
  • implemented atexit() in PJMEDIA and PJSIP level: pjmedia_endpt_atexit() & pjsip_endpt_atexit().
  • updated pjmedia/transport_srtp.c, pjsip/sip_timer.c, and pjsip/sip_replaces.c to use the new atexit() functions.
  • API change: pjmedia_srtp_init_lib() now requires 'pjmedia_endpt' param.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.x/pjmedia/src/pjmedia/transport_srtp.c

    r3961 r3986  
    271271 
    272272static pj_bool_t libsrtp_initialized; 
    273 static void pjmedia_srtp_deinit_lib(void); 
    274  
    275 PJ_DEF(pj_status_t) pjmedia_srtp_init_lib(void) 
     273static void pjmedia_srtp_deinit_lib(pjmedia_endpt *endpt); 
     274 
     275PJ_DEF(pj_status_t) pjmedia_srtp_init_lib(pjmedia_endpt *endpt) 
    276276{ 
    277277    if (libsrtp_initialized == PJ_FALSE) { 
     
    285285        } 
    286286 
    287         if (pj_atexit(pjmedia_srtp_deinit_lib) != PJ_SUCCESS) { 
     287        if (pjmedia_endpt_atexit(endpt, pjmedia_srtp_deinit_lib) != PJ_SUCCESS) 
     288        { 
    288289            /* There will be memory leak when it fails to schedule libsrtp  
    289290             * deinitialization, however the memory leak could be harmless, 
     
    300301} 
    301302 
    302 static void pjmedia_srtp_deinit_lib(void) 
     303static void pjmedia_srtp_deinit_lib(pjmedia_endpt *endpt) 
    303304{ 
    304305    err_status_t err; 
     306 
     307    /* Note that currently this SRTP init/deinit is not equipped with 
     308     * reference counter, it should be safe as normally there is only 
     309     * one single instance of media endpoint and even if it isn't, the 
     310     * pjmedia_transport_srtp_create() will invoke SRTP init (the only 
     311     * drawback should be the delay described by #788). 
     312     */ 
     313 
     314    PJ_UNUSED_ARG(endpt); 
    305315 
    306316    err = srtp_deinit(); 
     
    411421 
    412422    /* Init libsrtp. */ 
    413     status = pjmedia_srtp_init_lib(); 
     423    status = pjmedia_srtp_init_lib(endpt); 
    414424    if (status != PJ_SUCCESS) 
    415425        return status; 
Note: See TracChangeset for help on using the changeset viewer.