Ignore:
Timestamp:
Mar 6, 2006 1:30:39 PM (18 years ago)
Author:
bennylp
Message:

Fixed bug if payload type for rx and tx is different (i.e. dyn pt)

File:
1 edited

Legend:

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

    r276 r290  
    9696 
    9797        si->type = PJMEDIA_TYPE_UNKNOWN; 
    98  
     98        return PJMEDIA_EINVALIMEDIATYPE; 
    9999    } 
    100100 
     
    142142 
    143143    /* And codec must be numeric! */ 
    144     if (!pj_isdigit(*local_m->desc.fmt[0].ptr)) 
     144    if (!pj_isdigit(*local_m->desc.fmt[0].ptr) ||  
     145        !pj_isdigit(*rem_m->desc.fmt[0].ptr)) 
     146    { 
    145147        return PJMEDIA_EINVALIDPT; 
    146  
    147     /* Get the payload number. */ 
     148    } 
     149 
     150    /* Get the payload number for receive channel. */ 
    148151    pt = pj_strtoul(&local_m->desc.fmt[0]); 
    149152 
     
    162165            return status; 
    163166 
     167        /* For static payload type, pt's are symetric */ 
     168        si->tx_pt = pt; 
     169 
    164170    } else { 
    165  
    166171        attr = pjmedia_sdp_media_find_attr(local_m, &ID_RTPMAP,  
    167172                                           &local_m->desc.fmt[0]); 
     
    179184        pj_strdup(pool, &si->fmt.encoding_name, &rtpmap->enc_name); 
    180185        si->fmt.sample_rate = rtpmap->clock_rate; 
    181     } 
     186 
     187        /* Determine payload type for outgoing channel, by finding 
     188         * dynamic payload type in remote SDP that matches the answer. 
     189         */ 
     190        si->tx_pt = 0xFFFF; 
     191        for (i=0; i<rem_m->desc.fmt_count; ++i) { 
     192            unsigned rpt; 
     193            pjmedia_sdp_attr *r_attr; 
     194            pjmedia_sdp_rtpmap r_rtpmap; 
     195 
     196            rpt = pj_strtoul(&rem_m->desc.fmt[i]); 
     197            if (rpt < 96) 
     198                continue; 
     199 
     200            r_attr = pjmedia_sdp_media_find_attr(rem_m, &ID_RTPMAP, 
     201                                                 &rem_m->desc.fmt[i]); 
     202            if (!r_attr) 
     203                continue; 
     204 
     205            if (pjmedia_sdp_attr_get_rtpmap(attr, &r_rtpmap) != PJ_SUCCESS) 
     206                continue; 
     207 
     208            if (!pj_stricmp(&rtpmap->enc_name, &r_rtpmap.enc_name) && 
     209                rtpmap->clock_rate == r_rtpmap.clock_rate) 
     210            { 
     211                /* Found matched codec. */ 
     212                si->tx_pt = rpt; 
     213                break; 
     214            } 
     215        } 
     216 
     217        if (si->tx_pt == 0xFFFF) 
     218            return PJMEDIA_EMISSINGRTPMAP; 
     219    } 
     220 
     221   
    182222 
    183223    /* Get local DTMF payload type */ 
Note: See TracChangeset for help on using the changeset viewer.