Changeset 2064


Ignore:
Timestamp:
Jun 26, 2008 7:12:09 PM (16 years ago)
Author:
nanang
Message:

Ticket #544: Fixed SRTP on hold+reinvite scenario

Location:
pjproject/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/config.h

    r2048 r2064  
    610610 */ 
    611611#ifndef PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE 
    612 #   define PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE  (12*sizeof(long)) 
     612#   define PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE  (16*sizeof(long)) 
    613613#endif 
    614614 
  • pjproject/trunk/pjmedia/include/pjmedia/transport_srtp.h

    r2039 r2064  
    139139     * Specify the usage policy. Default is PJMEDIA_SRTP_OPTIONAL. 
    140140     */ 
    141     pjmedia_srtp_use use; 
     141    pjmedia_srtp_use            use; 
    142142 
    143143    /** 
     
    180180     */ 
    181181    pjmedia_srtp_crypto         tx_policy; 
     182 
     183    /** 
     184     * Specify the usage policy. 
     185     */ 
     186    pjmedia_srtp_use            use; 
     187 
     188    /** 
     189     * Specify the peer's usage policy. 
     190     */ 
     191    pjmedia_srtp_use            peer_use; 
    182192 
    183193} pjmedia_srtp_info; 
  • pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c

    r2039 r2064  
    112112    pjmedia_transport   *member_tp; /**< Underlying transport.       */ 
    113113 
    114     /* When in SRTP optional mode, instead of always offering RTP/AVP, 
    115      * we should create offer based on remote preference. At the first time, 
    116      * remote preference is unknown, it is known after media_start() called. 
    117      * So next time the same session need to create an offer, it will create 
    118      * SDP with transport type based on remote preference. 
     114    /* SRTP usage policy of peer. This field is updated when media is starting. 
     115     * This is useful when SRTP is in optional mode and peer is using mandatory 
     116     * mode, so when local is about to reinvite/update, it should offer  
     117     * RTP/SAVP instead of offering RTP/AVP. 
    119118     */ 
    120     pj_bool_t            remote_prefer_rtp_savp; 
     119    pjmedia_srtp_use     peer_use; 
    121120 
    122121} transport_srtp; 
     
    349348    srtp->session_inited = PJ_FALSE; 
    350349    srtp->bypass_srtp = PJ_FALSE; 
    351     srtp->remote_prefer_rtp_savp = PJ_FALSE; 
     350    srtp->peer_use = opt->use; 
    352351 
    353352    if (opt) { 
     
    587586    srtp_info.rx_policy = srtp->rx_policy; 
    588587    srtp_info.tx_policy = srtp->tx_policy; 
     588    srtp_info.use = srtp->setting.use; 
     589    srtp_info.peer_use = srtp->peer_use; 
    589590 
    590591    spc_info_idx = info->specific_info_cnt++; 
     
    10771078                goto BYPASS_SRTP; 
    10781079            case PJMEDIA_SRTP_OPTIONAL: 
    1079                 m_loc->desc.transport = srtp->remote_prefer_rtp_savp? 
    1080                                         ID_RTP_SAVP : ID_RTP_AVP; 
     1080                m_loc->desc.transport =  
     1081                                (srtp->peer_use == PJMEDIA_SRTP_MANDATORY)? 
     1082                                ID_RTP_SAVP : ID_RTP_AVP; 
    10811083                break; 
    10821084            case PJMEDIA_SRTP_MANDATORY: 
     
    12841286    m_loc = sdp_local->media[media_index]; 
    12851287 
    1286     srtp->remote_prefer_rtp_savp = (pj_stricmp(&m_rem->desc.transport,  
    1287                                    &ID_RTP_SAVP) == 0); 
     1288    if (pj_stricmp(&m_rem->desc.transport, &ID_RTP_SAVP) == 0) 
     1289        srtp->peer_use = PJMEDIA_SRTP_MANDATORY; 
     1290    else 
     1291        srtp->peer_use = PJMEDIA_SRTP_OPTIONAL; 
    12881292 
    12891293    /* For answerer side, this function will just have to start SRTP */ 
     
    13831387BYPASS_SRTP: 
    13841388    srtp->bypass_srtp = PJ_TRUE; 
     1389    srtp->peer_use = PJMEDIA_SRTP_DISABLED; 
    13851390 
    13861391PROPAGATE_MEDIA_START: 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h

    r2039 r2064  
    7575    pj_timer_entry       hangup_tm; /**< Timer to hangup call.              */ 
    7676    pj_stun_nat_type     rem_nat_type; /**< NAT type of remote endpoint.    */ 
     77    pjmedia_srtp_use     rem_srtp_use; /**< Remote's SRTP usage policy.     */ 
    7778 
    7879    char    last_text_buf_[128];    /**< Buffer for last_text.              */ 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r2060 r2064  
    116116    call->res_time.msec = 0; 
    117117    call->rem_nat_type = PJ_STUN_NAT_TYPE_UNKNOWN; 
     118    call->rem_srtp_use = PJMEDIA_SRTP_DISABLED; 
    118119} 
    119120 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r2061 r2064  
    889889        pjmedia_srtp_setting_default(&srtp_opt); 
    890890        srtp_opt.close_member_tp = PJ_FALSE; 
    891         srtp_opt.use = acc->cfg.use_srtp; 
     891        /* If media session has been ever established, let's use remote's  
     892         * preference in SRTP usage policy, especially when it is stricter. 
     893         */ 
     894        if (call->rem_srtp_use > acc->cfg.use_srtp) 
     895            srtp_opt.use = call->rem_srtp_use; 
     896        else 
     897            srtp_opt.use = acc->cfg.use_srtp; 
     898 
    892899        status = pjmedia_transport_srtp_create(pjsua_var.med_endpt,  
    893900                                               call->med_tp, 
     
    11441151 
    11451152    } else { 
     1153        pjmedia_srtp_info srtp_info; 
     1154        pjmedia_transport_info tp_info; 
     1155 
    11461156        /* Start/restart media transport */ 
    11471157        status = pjmedia_transport_media_start(call->med_tp,  
     
    11521162 
    11531163        call->med_tp_st = PJSUA_MED_TP_RUNNING; 
     1164 
     1165        /* Get remote SRTP usage policy */ 
     1166        pjmedia_transport_info_init(&tp_info); 
     1167        pjmedia_transport_get_info(call->med_tp, &tp_info); 
     1168        if (tp_info.specific_info_cnt > 0) { 
     1169            int i; 
     1170            for (i = 0; i < tp_info.specific_info_cnt; ++i) { 
     1171                if (tp_info.spc_info[i].type == PJMEDIA_TRANSPORT_TYPE_SRTP)  
     1172                { 
     1173                    pjmedia_srtp_info *srtp_info =  
     1174                                (pjmedia_srtp_info*) tp_info.spc_info[i].buffer; 
     1175 
     1176                    call->rem_srtp_use = srtp_info->peer_use; 
     1177                    break; 
     1178                } 
     1179            } 
     1180        } 
    11541181 
    11551182        /* Override ptime, if this option is specified. */ 
Note: See TracChangeset for help on using the changeset viewer.