Ignore:
Timestamp:
Mar 15, 2018 3:00:59 AM (6 years ago)
Author:
nanang
Message:

Close #2100:

  • Added new APIs:
    • PJMEDIA: pjmedia_srtp_enum_crypto(), pjmedia_srtp_enum_keying()
    • PJSUA: pjsua_config.srtp_opt, pjsua_acc_config.srtp_opt, pjsua_srtp_opt_default()
    • PJSUA2: AccountMediaConfig::srtpOpt, Endpoint::srtpCryptoEnum()
  • Deprecated PJSUA callback on_create_media_transport_srtp() (not removed yet, just warnings).
  • Slightly refactored SRTP code:
    • Fixed potential issue with on_create_media_transport_srtp(), some PJSUA internal values in pjmedia_srtp_setting may be overridden by app.
    • Fixed few issues in SRTP and keying mechanism, e.g: premature local SDP modification (it should be done after verification).
    • Potential minor backward compatibility issue: default value of pjmedia_srtp_setting.crypto_count is now zero, previously it was initialized with all crypto via pjmedia_srtp_setting_default(), actually zero and all cryptos in this setting semantically are the same.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r5748 r5755  
    15361536    if (!call_med->tp_orig) { 
    15371537        pjmedia_srtp_setting srtp_opt; 
     1538        pjsua_srtp_opt *acc_srtp_opt = &acc->cfg.srtp_opt; 
    15381539        pjmedia_transport *srtp = NULL; 
     1540        unsigned i; 
    15391541 
    15401542        /* Check if SRTP requires secure signaling */ 
     
    15521554        srtp_opt.cb.on_srtp_nego_complete = &on_srtp_nego_complete; 
    15531555        srtp_opt.user_data = call_med; 
     1556 
     1557        /* Get crypto and keying settings from account settings */ 
     1558        srtp_opt.crypto_count = acc_srtp_opt->crypto_count; 
     1559        for (i = 0; i < srtp_opt.crypto_count; ++i) 
     1560            srtp_opt.crypto[i] = acc_srtp_opt->crypto[i]; 
     1561        srtp_opt.keying_count = acc_srtp_opt->keying_count; 
     1562        for (i = 0; i < srtp_opt.keying_count; ++i) 
     1563            srtp_opt.keying[i] = acc_srtp_opt->keying[i]; 
    15541564 
    15551565        /* If media session has been ever established, let's use remote's  
     
    15601570        else 
    15611571            srtp_opt.use = acc->cfg.use_srtp; 
    1562              
     1572 
    15631573        if (pjsua_var.ua_cfg.cb.on_create_media_transport_srtp) { 
     1574            pjmedia_srtp_setting srtp_opt2 = srtp_opt; 
    15641575            pjsua_call *call = call_med->call; 
    1565             pjmedia_srtp_use srtp_use = srtp_opt.use; 
     1576 
     1577            /* Warn that this callback is deprecated (see also #2100) */ 
     1578            PJ_LOG(1,(THIS_FILE, "Warning: on_create_media_transport_srtp " 
     1579                                 "is deprecated and will be removed in the " 
     1580                                 "future release")); 
    15661581 
    15671582            (*pjsua_var.ua_cfg.cb.on_create_media_transport_srtp) 
    1568                 (call->index, call_med->idx, &srtp_opt); 
    1569  
    1570             /* Close_member_tp must not be overwritten by app */ 
    1571             srtp_opt.close_member_tp = PJ_TRUE; 
    1572  
    1573             /* Revert SRTP usage policy if media is reinitialized */ 
    1574             if (call->inv && call->inv->state == PJSIP_INV_STATE_CONFIRMED) { 
    1575                 srtp_opt.use = srtp_use; 
    1576             } 
     1583                (call->index, call_med->idx, &srtp_opt2); 
     1584 
     1585            /* Only apply SRTP usage policy if this is initial INVITE */ 
     1586            if (call->inv && call->inv->state < PJSIP_INV_STATE_CONFIRMED) { 
     1587                srtp_opt.use = srtp_opt2.use; 
     1588            } 
     1589 
     1590            /* Apply crypto and keying settings from callback */ 
     1591            srtp_opt.crypto_count = srtp_opt2.crypto_count; 
     1592            for (i = 0; i < srtp_opt.crypto_count; ++i) 
     1593                srtp_opt.crypto[i] = srtp_opt2.crypto[i]; 
     1594            srtp_opt.keying_count = srtp_opt2.keying_count; 
     1595            for (i = 0; i < srtp_opt.keying_count; ++i) 
     1596                srtp_opt.keying[i] = srtp_opt2.keying[i]; 
    15771597        } 
    15781598 
Note: See TracChangeset for help on using the changeset viewer.