Changeset 1109 for pjproject/trunk


Ignore:
Timestamp:
Mar 27, 2007 11:01:45 AM (18 years ago)
Author:
bennylp
Message:

Fixed ticket #203: Fix error when telephone-event is set as the first format in SDP (thanks Chris Hamilton)

Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/session.c

    r1006 r1109  
    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/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r1098 r1109  
    709709            pjsua_perror(THIS_FILE, "Error answering session", status); 
    710710 
     711        /* Note that inv may be invalid if 200/OK has caused error in 
     712         * starting the media. 
     713         */ 
    711714 
    712715        PJ_LOG(4,(THIS_FILE, "Disconnecting replaced call %d", 
     
    10341037        pjsip_dlg_dec_lock(dlg); 
    10351038        return status; 
     1039    } 
     1040 
     1041    /* Call might have been disconnected if application is answering with 
     1042     * 200/OK and the media failed to start. 
     1043     */ 
     1044    if (call->inv == NULL) { 
     1045        pjsip_dlg_dec_lock(dlg); 
     1046        return PJSIP_ESESSIONTERMINATED; 
    10361047    } 
    10371048 
Note: See TracChangeset for help on using the changeset viewer.