Ignore:
Timestamp:
Dec 28, 2007 8:51:58 AM (12 years ago)
Author:
bennylp
Message:

Ticket #433: Failure in media negotiation when SDP contains two audio media lines (thanks Arie Velthoen)

File:
1 edited

Legend:

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

    r1636 r1639  
    885885                                       const pjmedia_sdp_session *remote_sdp) 
    886886{ 
     887    unsigned i; 
    887888    int prev_media_st = 0; 
    888889    pjsua_call *call = &pjsua_var.calls[call_id]; 
    889890    pjmedia_session_info sess_info; 
     891    pjmedia_stream_info *si = NULL; 
    890892    pjmedia_port *media_port; 
    891893    pj_str_t port_name; 
     
    898900 
    899901    /* Create media session info based on SDP parameters.  
    900      * We only support one stream per session at the moment 
    901902     */     
    902903    status = pjmedia_session_info_from_sdp( call->inv->dlg->pool,  
    903904                                            pjsua_var.med_endpt,  
    904                                             1,&sess_info,  
     905                                            PJMEDIA_MAX_SDP_MEDIA, &sess_info, 
    905906                                            local_sdp, remote_sdp); 
    906907    if (status != PJ_SUCCESS) 
    907908        return status; 
    908909 
     910    /* Find which session is audio (we only support audio for now) */ 
     911    for (i=0; i < sess_info.stream_cnt; ++i) { 
     912        if (sess_info.stream_info[i].type == PJMEDIA_TYPE_AUDIO && 
     913            sess_info.stream_info[i].proto == PJMEDIA_TP_PROTO_RTP_AVP) 
     914        { 
     915            si = &sess_info.stream_info[i]; 
     916            break; 
     917        } 
     918    } 
     919 
     920    if (si == NULL) { 
     921        /* Not found */ 
     922        return PJMEDIA_EINVALIMEDIATYPE; 
     923    } 
     924 
     925     
     926    /* Reset session info with only one media stream */ 
     927    sess_info.stream_cnt = 1; 
     928    if (si != &sess_info.stream_info[0]) 
     929        pj_memcpy(&sess_info.stream_info[0], si, sizeof(pjmedia_stream_info)); 
    909930 
    910931    /* Check if media is put on-hold */ 
    911     if (sess_info.stream_cnt == 0 ||  
    912         sess_info.stream_info[0].dir == PJMEDIA_DIR_NONE) 
     932    if (sess_info.stream_cnt == 0 || si->dir == PJMEDIA_DIR_NONE) 
    913933    { 
    914934 
     
    944964        /* Override ptime, if this option is specified. */ 
    945965        if (pjsua_var.media_cfg.ptime != 0) { 
    946             sess_info.stream_info[0].param->setting.frm_per_pkt = (pj_uint8_t) 
    947                 (pjsua_var.media_cfg.ptime / sess_info.stream_info[0].param->info.frm_ptime); 
    948             if (sess_info.stream_info[0].param->setting.frm_per_pkt == 0) 
    949                 sess_info.stream_info[0].param->setting.frm_per_pkt = 1; 
     966            si->param->setting.frm_per_pkt = (pj_uint8_t) 
     967                (pjsua_var.media_cfg.ptime / si->param->info.frm_ptime); 
     968            if (si->param->setting.frm_per_pkt == 0) 
     969                si->param->setting.frm_per_pkt = 1; 
    950970        } 
    951971 
    952972        /* Disable VAD, if this option is specified. */ 
    953973        if (pjsua_var.media_cfg.no_vad) { 
    954             sess_info.stream_info[0].param->setting.vad = 0; 
     974            si->param->setting.vad = 0; 
    955975        } 
    956976 
     
    959979         * (such as jitter buffer parameters, codec ptime, etc.) 
    960980         */ 
    961         sess_info.stream_info[0].jb_init = pjsua_var.media_cfg.jb_init; 
    962         sess_info.stream_info[0].jb_min_pre = pjsua_var.media_cfg.jb_min_pre; 
    963         sess_info.stream_info[0].jb_max_pre = pjsua_var.media_cfg.jb_max_pre; 
    964         sess_info.stream_info[0].jb_max = pjsua_var.media_cfg.jb_max; 
     981        si->jb_init = pjsua_var.media_cfg.jb_init; 
     982        si->jb_min_pre = pjsua_var.media_cfg.jb_min_pre; 
     983        si->jb_max_pre = pjsua_var.media_cfg.jb_max_pre; 
     984        si->jb_max = pjsua_var.media_cfg.jb_max; 
    965985 
    966986        /* Set SSRC */ 
    967         sess_info.stream_info[0].ssrc = call->ssrc; 
     987        si->ssrc = call->ssrc; 
    968988 
    969989        /* Create session based on session info. */ 
     
    10101030        /* Call's media state is active */ 
    10111031        call->media_st = PJSUA_CALL_MEDIA_ACTIVE; 
    1012         call->media_dir = sess_info.stream_info[0].dir; 
     1032        call->media_dir = si->dir; 
    10131033    } 
    10141034 
Note: See TracChangeset for help on using the changeset viewer.