Changeset 527


Ignore:
Timestamp:
Jun 19, 2006 2:48:06 PM (18 years ago)
Author:
bennylp
Message:

Fixed bugs in negotiating SDP answer from remote for dynamic payload types

File:
1 edited

Legend:

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

    r509 r527  
    492492        /* Remove all format in the offer that has no matching answer */ 
    493493        for (i=0; i<offer->desc.fmt_count;) { 
    494             unsigned j; 
     494            unsigned pt; 
     495            pj_uint32_t j; 
    495496            pj_str_t *fmt = &offer->desc.fmt[i]; 
    496  
    497             for (j=0; j<answer->desc.fmt_count; ++j) { 
    498                 if (pj_strcmp(fmt, &answer->desc.fmt[j])==0) 
    499                     break; 
     497             
     498 
     499            /* Find matching answer */ 
     500            pt = pj_strtoul(fmt); 
     501 
     502            if (pt < 96) { 
     503                for (j=0; j<answer->desc.fmt_count; ++j) { 
     504                    if (pj_strcmp(fmt, &answer->desc.fmt[j])==0) 
     505                        break; 
     506                } 
     507            } else { 
     508                /* This is dynamic payload type. 
     509                 * For dynamic payload type, we must look the rtpmap and 
     510                 * compare the encoding name. 
     511                 */ 
     512                const pjmedia_sdp_attr *a; 
     513                pjmedia_sdp_rtpmap or; 
     514 
     515                /* Get the rtpmap for the payload type in the offer. */ 
     516                a = pjmedia_sdp_media_find_attr2(offer, "rtpmap", fmt); 
     517                if (!a) { 
     518                    pj_assert(!"Bug! Offer should have been validated"); 
     519                    return PJ_EBUG; 
     520                } 
     521                pjmedia_sdp_attr_get_rtpmap(a, &or); 
     522 
     523                /* Find paylaod in answer SDP with matching  
     524                 * encoding name and clock rate. 
     525                 */ 
     526                for (j=0; j<answer->desc.fmt_count; ++j) { 
     527                    a = pjmedia_sdp_media_find_attr2(answer, "rtpmap",  
     528                                                     &answer->desc.fmt[j]); 
     529                    if (a) { 
     530                        pjmedia_sdp_rtpmap ar; 
     531                        pjmedia_sdp_attr_get_rtpmap(a, &ar); 
     532 
     533                        /* See if encoding name, clock rate, and channel 
     534                         * count match  
     535                         */ 
     536                        if (!pj_strcmp(&or.enc_name, &ar.enc_name) && 
     537                            or.clock_rate == ar.clock_rate && 
     538                            pj_strcmp(&or.param, &ar.param)==0) 
     539                        { 
     540                            /* Match! */ 
     541                            break; 
     542                        } 
     543                    } 
     544                } 
    500545            } 
    501546 
     
    679724                        pjmedia_sdp_attr_get_rtpmap(a, &lr); 
    680725 
    681                         /* See if encoding name and clock rate match */ 
     726                        /* See if encoding name, clock rate, and 
     727                         * channel count  match  
     728                         */ 
    682729                        if (!pj_strcmp(&or.enc_name, &lr.enc_name) && 
    683                             or.clock_rate == lr.clock_rate)  
     730                            or.clock_rate == lr.clock_rate && 
     731                            pj_strcmp(&or.param, &lr.param)==0)  
    684732                        { 
    685733                            /* Match! */ 
Note: See TracChangeset for help on using the changeset viewer.