Ignore:
Timestamp:
May 13, 2010 5:22:51 AM (14 years ago)
Author:
nanang
Message:

Re #1069:

  • Added new approach of SRTP optional mode in pjsua-lib by duplicating SDP media line for secured and unsecured version of media transport.
  • Integrated this feature into pjsua app, it is activated via --use-srtp=3 param.
File:
1 edited

Legend:

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

    r3153 r3172  
    13691369        return status; 
    13701370    } 
     1371 
     1372#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 
     1373    /* Check if SRTP is in optional mode and configured to use duplicated 
     1374     * media, i.e: secured and unsecured version, in the SDP offer. 
     1375     */ 
     1376    if (!rem_sdp && 
     1377        pjsua_var.acc[call->acc_id].cfg.use_srtp == PJMEDIA_SRTP_OPTIONAL && 
     1378        pjsua_var.acc[call->acc_id].cfg.srtp_optional_dup_offer) 
     1379    { 
     1380        unsigned i; 
     1381 
     1382        for (i = 0; i < sdp->media_count; ++i) { 
     1383            pjmedia_sdp_media *m = sdp->media[i]; 
     1384 
     1385            /* Check if this media is unsecured but has SDP "crypto"  
     1386             * attribute. 
     1387             */ 
     1388            if (pj_stricmp2(&m->desc.transport, "RTP/AVP") == 0 && 
     1389                pjmedia_sdp_media_find_attr2(m, "crypto", NULL) != NULL) 
     1390            { 
     1391                pjmedia_sdp_media *new_m; 
     1392 
     1393                /* Duplicate this media and apply secured transport */ 
     1394                new_m = pjmedia_sdp_media_clone(pool, m); 
     1395                pj_strdup2(pool, &new_m->desc.transport, "RTP/SAVP"); 
     1396 
     1397                /* Remove the "crypto" attribute in the unsecured media */ 
     1398                pjmedia_sdp_media_remove_all_attr(m, "crypto"); 
     1399 
     1400                /* Insert the new media before the unsecured media */ 
     1401                if (sdp->media_count < PJMEDIA_MAX_SDP_MEDIA) { 
     1402                    pj_array_insert(sdp->media, sizeof(new_m),  
     1403                                    sdp->media_count, i, &new_m); 
     1404                    ++sdp->media_count; 
     1405                    ++i; 
     1406                } 
     1407            } 
     1408        } 
     1409    } 
     1410#endif 
    13711411 
    13721412    /* Update currently advertised RTP source address */ 
Note: See TracChangeset for help on using the changeset viewer.