Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#1466 closed enhancement (fixed)

Allow to use PJLIB API without PJSUA-LIB API

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-1.14
Component: common Version: common
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description

Some application wants to be able to use PJLIB before pjsua_create() and after pjsua_destroy() is called, or to continue using PJLIB objects while PJSUA-LIB is being restarted. This was not possible because when application is utilizing PJSUA-LIB, the PJLIB library is initialized in pjsua_create() and shutdown in pjsua_destroy().

The solution that this ticket implements is to allow pj_init() and pj_shutdown() to be called multiple times, and PJLIB should use internal reference counting to determine when it needs to actually be initialized or shutdown. Hence if application wants to use PJLIB before pjsua_create(), it should call pj_init() manually beforehand, and call pj_shutdown() when it's finished with using PJLIB.

Note that there MUST be equal number of calls to pj_shutdown() for every call to pj_init(), or otherwise PJLIB won't get shutdown!

Also note that this solution calls for moving some pj_atexit() use in higher library layers into a new equivalent functionality. This task will be implemented by this ticket too.

Change History (2)

comment:1 Changed 8 years ago by nanang

  • Resolution set to fixed
  • Status changed from new to closed

(In [3986]) 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.

comment:2 Changed 8 years ago by nanang

(In [3988]) Re #1466: Moved down the atexit callbacks execution in pjmedia & pjsip endpoints to the very end of endpoint destroy sequence.

Note: See TracTickets for help on using tickets.