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/transport_srtp.c

    r3553 r3999  
    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; 
     
    908918    { 
    909919        /* Handle such condition that stream is updated (RTP seq is reinited 
    910         * & SRTP is restarted), but some old packets are still coming  
    911         * so SRTP is learning wrong RTP seq. While the newly inited RTP seq 
    912         * comes, SRTP thinks the RTP seq is replayed, so srtp_unprotect()  
    913         * will returning err_status_replay_*. Restarting SRTP can resolve  
    914         * this. 
    915         */ 
    916         if (pjmedia_transport_srtp_start((pjmedia_transport*)srtp,  
    917                                          &srtp->tx_policy, &srtp->rx_policy)  
    918                                          != PJ_SUCCESS) 
    919         { 
     920         * & SRTP is restarted), but some old packets are still coming  
     921         * so SRTP is learning wrong RTP seq. While the newly inited RTP seq 
     922         * comes, SRTP thinks the RTP seq is replayed, so srtp_unprotect()  
     923         * will return err_status_replay_*. Restarting SRTP can resolve this. 
     924         */ 
     925        pjmedia_srtp_crypto tx, rx; 
     926        pj_status_t status; 
     927 
     928        tx = srtp->tx_policy; 
     929        rx = srtp->rx_policy; 
     930        status = pjmedia_transport_srtp_start((pjmedia_transport*)srtp, 
     931                                              &tx, &rx); 
     932        if (status != PJ_SUCCESS) { 
    920933            PJ_LOG(5,(srtp->pool->obj_name, "Failed to restart SRTP, err=%s",  
    921934                      get_libsrtp_errstr(err))); 
    922         } else { 
     935        } else if (!srtp->bypass_srtp) { 
    923936            err = srtp_unprotect(srtp->srtp_rx_ctx, (pj_uint8_t*)pkt, &len); 
    924937        } 
Note: See TracChangeset for help on using the changeset viewer.