Ignore:
Timestamp:
Jun 16, 2011 5:10:45 AM (13 years ago)
Author:
ming
Message:

Closed #1173: PJSUA callback to allow creation of custom media transports by application

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_media.c

    r3571 r3585  
    11751175    pjsua_call *call = &pjsua_var.calls[call_id]; 
    11761176    pj_status_t status; 
     1177    pj_bool_t use_custom_med_tp = PJ_FALSE; 
     1178    unsigned custom_med_tp_flags = 0; 
    11771179 
    11781180#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 
     
    11931195    } 
    11941196 
     1197    if (!call->med_orig && 
     1198        pjsua_var.ua_cfg.cb.on_create_media_transport) 
     1199    { 
     1200        use_custom_med_tp = PJ_TRUE; 
     1201    } 
     1202 
    11951203#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 
    11961204    /* This function may be called when SRTP transport already exists  
    11971205     * (e.g: in re-invite, update), don't need to destroy/re-create. 
    11981206     */ 
    1199     if (!call->med_orig || call->med_tp == call->med_orig) { 
     1207    if (!call->med_orig) { 
    12001208 
    12011209        /* Check if SRTP requires secure signaling */ 
     
    12111219        pjmedia_srtp_setting_default(&srtp_opt); 
    12121220        srtp_opt.close_member_tp = PJ_FALSE; 
     1221        if (use_custom_med_tp) 
     1222            custom_med_tp_flags |= PJSUA_MED_TP_CLOSE_MEMBER; 
    12131223        /* If media session has been ever established, let's use remote's  
    12141224         * preference in SRTP usage policy, especially when it is stricter. 
     
    12681278    PJ_LOG(4,(THIS_FILE, "Media index %d selected for call %d", 
    12691279              call->audio_idx, call->index)); 
     1280 
     1281    if (use_custom_med_tp) { 
     1282        /* Use custom media transport returned by the application */ 
     1283        call->med_tp = (*pjsua_var.ua_cfg.cb.on_create_media_transport)( 
     1284                           call_id, call->audio_idx, call->med_tp, 
     1285                           custom_med_tp_flags); 
     1286        if (!call->med_tp) { 
     1287            if (sip_err_code) *sip_err_code = PJSIP_SC_NOT_ACCEPTABLE; 
     1288            pjsua_media_channel_deinit(call_id); 
     1289            return PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_NOT_ACCEPTABLE); 
     1290        } 
     1291    } 
    12701292 
    12711293    /* Create the media transport */ 
     
    15441566        pjmedia_transport_close(call->med_tp); 
    15451567        call->med_tp = call->med_orig; 
     1568        call->med_orig = NULL; 
    15461569    } 
    15471570 
Note: See TracChangeset for help on using the changeset viewer.