Ignore:
Timestamp:
Jan 27, 2012 9:12:59 AM (12 years ago)
Author:
nanang
Message:

Re #1244: Added bandwidth info in SDP ("b=" lines) based on codec bitrate settings. Two SDP bandwidth types/modifiers are used: AS in session level & TIAS in media level.

File:
1 edited

Legend:

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

    r3776 r3945  
    373373    pjmedia_sdp_attr *attr; 
    374374    unsigned i; 
     375    unsigned max_bitrate = 0; 
    375376    pj_status_t status; 
    376377 
     
    494495            m->attr[m->attr_count++] = attr; 
    495496        } 
     497 
     498        /* Find maximum bitrate in this media */ 
     499        if (max_bitrate < codec_param.info.max_bps) 
     500            max_bitrate = codec_param.info.max_bps; 
    496501    } 
    497502 
     
    520525#endif 
    521526 
     527    /* Put bandwidth info in media level using bandwidth modifier "TIAS" 
     528     * (RFC3890). 
     529     */ 
     530    if (max_bitrate) { 
     531        const pj_str_t STR_BANDW_MODIFIER = { "TIAS", 4 }; 
     532        pjmedia_sdp_bandw *b; 
     533             
     534        b = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_bandw); 
     535        b->modifier = STR_BANDW_MODIFIER; 
     536        b->value = max_bitrate; 
     537        m->bandw[m->bandw_count++] = b; 
     538    } 
     539 
    522540    *p_m = m; 
    523541    return PJ_SUCCESS; 
     
    542560    pjmedia_sdp_attr *attr; 
    543561    unsigned cnt, i; 
     562    unsigned max_bitrate = 0; 
    544563    pj_status_t status; 
    545564 
     
    569588        pjmedia_vid_codec_param codec_param; 
    570589        pj_str_t *fmt; 
     590        pjmedia_video_format_detail *vfd; 
    571591 
    572592        pj_bzero(&rtpmap, sizeof(rtpmap)); 
     
    661681            m->attr[m->attr_count++] = attr; 
    662682        } 
     683     
     684        /* Find maximum bitrate in this media */ 
     685        vfd = pjmedia_format_get_video_format_detail(&codec_param.enc_fmt, 
     686                                                     PJ_TRUE); 
     687        if (vfd && max_bitrate < vfd->max_bps) 
     688            max_bitrate = vfd->max_bps; 
     689    } 
     690 
     691    /* Put bandwidth info in media level using bandwidth modifier "TIAS" 
     692     * (RFC3890). 
     693     */ 
     694    if (max_bitrate) { 
     695        const pj_str_t STR_BANDW_MODIFIER = { "TIAS", 4 }; 
     696        pjmedia_sdp_bandw *b; 
     697             
     698        b = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_bandw); 
     699        b->modifier = STR_BANDW_MODIFIER; 
     700        b->value = max_bitrate; 
     701        m->bandw[m->bandw_count++] = b; 
    663702    } 
    664703 
Note: See TracChangeset for help on using the changeset viewer.