Ignore:
Timestamp:
Mar 30, 2012 7:10:13 AM (12 years ago)
Author:
bennylp
Message:

Re #1474: Merged all changes from 1.12 - HEAD (from the 1.x branch)

Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk

  • pjproject/trunk/pjmedia/src/pjmedia/endpoint.c

    r3945 r3999  
    2525#include <pj/assert.h> 
    2626#include <pj/ioqueue.h> 
     27#include <pj/lock.h> 
    2728#include <pj/log.h> 
    2829#include <pj/os.h> 
     
    5859 
    5960 
     61/* List of media endpoint exit callback. */ 
     62typedef struct exit_cb 
     63{ 
     64    PJ_DECL_LIST_MEMBER             (struct exit_cb); 
     65    pjmedia_endpt_exit_callback     func; 
     66} exit_cb; 
     67 
     68 
    6069/** Concrete declaration of media endpoint. */ 
    6170struct pjmedia_endpt 
     
    8796    /** Is telephone-event enable */ 
    8897    pj_bool_t             has_telephone_event; 
     98 
     99    /** List of exit callback. */ 
     100    exit_cb               exit_cb_list; 
    89101}; 
    90102 
     
    130142        goto on_error; 
    131143 
     144    /* Initialize exit callback list. */ 
     145    pj_list_init(&endpt->exit_cb_list); 
     146 
    132147    /* Create ioqueue if none is specified. */ 
    133148    if (endpt->ioqueue == NULL) { 
     
    190205PJ_DEF(pj_status_t) pjmedia_endpt_destroy (pjmedia_endpt *endpt) 
    191206{ 
     207    exit_cb *ecb; 
    192208    unsigned i; 
    193209 
     
    215231    pjmedia_codec_mgr_destroy(&endpt->codec_mgr); 
    216232    pjmedia_aud_subsys_shutdown(); 
     233 
     234    /* Call all registered exit callbacks */ 
     235    ecb = endpt->exit_cb_list.next; 
     236    while (ecb != &endpt->exit_cb_list) { 
     237        (*ecb->func)(endpt); 
     238        ecb = ecb->next; 
     239    } 
     240 
    217241    pj_pool_release (endpt->pool); 
    218242 
     
    435459 
    436460        } else { 
    437             rtpmap.param.ptr = NULL; 
     461            rtpmap.param.ptr = ""; 
    438462            rtpmap.param.slen = 0; 
    439463        } 
     
    897921    return PJ_SUCCESS; 
    898922} 
     923 
     924PJ_DEF(pj_status_t) pjmedia_endpt_atexit( pjmedia_endpt *endpt, 
     925                                          pjmedia_endpt_exit_callback func) 
     926{ 
     927    exit_cb *new_cb; 
     928 
     929    PJ_ASSERT_RETURN(endpt && func, PJ_EINVAL); 
     930 
     931    if (endpt->quit_flag) 
     932        return PJ_EINVALIDOP; 
     933 
     934    new_cb = PJ_POOL_ZALLOC_T(endpt->pool, exit_cb); 
     935    new_cb->func = func; 
     936 
     937    pj_enter_critical_section(); 
     938    pj_list_push_back(&endpt->exit_cb_list, new_cb); 
     939    pj_leave_critical_section(); 
     940 
     941    return PJ_SUCCESS; 
     942} 
Note: See TracChangeset for help on using the changeset viewer.