Changeset 1107


Ignore:
Timestamp:
Mar 27, 2007 10:53:57 AM (17 years ago)
Author:
bennylp
Message:

Fixed ticket #202: Fix telephone-event order in SDP (thanks Chris Hamilton)

Location:
pjproject/branches/pjproject-0.5-stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/pjproject-0.5-stable/pjmedia/src/pjmedia/session.c

    r1007 r1107  
    126126    pjmedia_sdp_rtpmap *rtpmap; 
    127127    int local_fmtp_mode = 0, rem_fmtp_mode = 0; 
    128     unsigned i, pt; 
     128    unsigned i, pt, fmti; 
    129129    pj_status_t status; 
    130130 
     
    249249 
    250250 
    251     /* And codec must be numeric! */ 
     251    /* Get the payload number for receive channel. */ 
     252    /* 
     253       Previously we used to rely on fmt[0] being the selected codec, 
     254       but some UA sends telephone-event as fmt[0] and this would 
     255       cause assert failure below. 
     256 
     257       Thanks Chris Hamilton <chamilton .at. cs.dal.ca> for this patch. 
     258 
     259    // And codec must be numeric! 
    252260    if (!pj_isdigit(*local_m->desc.fmt[0].ptr) ||  
    253261        !pj_isdigit(*rem_m->desc.fmt[0].ptr)) 
     
    256264    } 
    257265 
    258     /* Get the payload number for receive channel. */ 
    259266    pt = pj_strtoul(&local_m->desc.fmt[0]); 
    260267    pj_assert(PJMEDIA_RTP_PT_TELEPHONE_EVENTS==0 || 
    261268              pt != PJMEDIA_RTP_PT_TELEPHONE_EVENTS); 
     269    */ 
     270 
     271    /* This is to suppress MSVC warning about uninitialized var */ 
     272    pt = 0; 
     273 
     274    /* Find the first codec which is not telephone-event */ 
     275    for ( fmti = 0; fmti < local_m->desc.fmt_count; ++fmti ) { 
     276        if ( !pj_isdigit(*local_m->desc.fmt[fmti].ptr) ) 
     277            return PJMEDIA_EINVALIDPT; 
     278        pt = pj_strtoul(&local_m->desc.fmt[fmti]); 
     279        if ( PJMEDIA_RTP_PT_TELEPHONE_EVENTS == 0 || 
     280                pt != PJMEDIA_RTP_PT_TELEPHONE_EVENTS ) 
     281                break; 
     282    } 
     283    if ( fmti >= local_m->desc.fmt_count ) 
     284        return PJMEDIA_EINVALIDPT; 
    262285 
    263286    /* Get codec info. 
     
    272295 
    273296        attr = pjmedia_sdp_media_find_attr(local_m, &ID_RTPMAP,  
    274                                            &local_m->desc.fmt[0]); 
     297                                           &local_m->desc.fmt[fmti]); 
    275298        if (attr == NULL) { 
    276299            has_rtpmap = PJ_FALSE; 
     
    285308        if (has_rtpmap) { 
    286309            si->fmt.type = si->type; 
    287             si->fmt.pt = pj_strtoul(&local_m->desc.fmt[0]); 
     310            si->fmt.pt = pj_strtoul(&local_m->desc.fmt[fmti]); 
    288311            pj_strdup(pool, &si->fmt.encoding_name, &rtpmap->enc_name); 
    289312            si->fmt.clock_rate = rtpmap->clock_rate; 
     
    323346 
    324347        attr = pjmedia_sdp_media_find_attr(local_m, &ID_RTPMAP,  
    325                                            &local_m->desc.fmt[0]); 
     348                                           &local_m->desc.fmt[fmti]); 
    326349        if (attr == NULL) 
    327350            return PJMEDIA_EMISSINGRTPMAP; 
     
    334357 
    335358        si->fmt.type = si->type; 
    336         si->fmt.pt = pj_strtoul(&local_m->desc.fmt[0]); 
     359        si->fmt.pt = pj_strtoul(&local_m->desc.fmt[fmti]); 
    337360        pj_strdup(pool, &si->fmt.encoding_name, &rtpmap->enc_name); 
    338361        si->fmt.clock_rate = rtpmap->clock_rate; 
     
    357380 
    358381        /* Get fmtp mode= param in local SDP, if any */ 
    359         get_fmtp_mode(local_m, &local_m->desc.fmt[0], &local_fmtp_mode); 
     382        get_fmtp_mode(local_m, &local_m->desc.fmt[fmti], &local_fmtp_mode); 
    360383 
    361384        /* Determine payload type for outgoing channel, by finding 
  • pjproject/branches/pjproject-0.5-stable/pjsip/src/pjsua-lib/pjsua_call.c

    r974 r1107  
    690690            pjsua_perror(THIS_FILE, "Error answering session", status); 
    691691 
     692        /* Note that inv may be invalid if 200/OK has caused error in 
     693         * starting the media. 
     694         */ 
    692695 
    693696        PJ_LOG(4,(THIS_FILE, "Disconnecting replaced call %d", 
     
    10151018        pjsip_dlg_dec_lock(dlg); 
    10161019        return status; 
     1020    } 
     1021 
     1022    /* Call might have been disconnected if application is answering with 
     1023     * 200/OK and the media failed to start. 
     1024     */ 
     1025    if (call->inv == NULL) { 
     1026        pjsip_dlg_dec_lock(dlg); 
     1027        return PJSIP_ESESSIONTERMINATED; 
    10171028    } 
    10181029 
Note: See TracChangeset for help on using the changeset viewer.