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/pjsip/src/pjsua-lib/pjsua_media.c

    r3938 r3945  
    19391939    pjmedia_sdp_neg_state sdp_neg_state = PJMEDIA_SDP_NEG_STATE_NULL; 
    19401940    unsigned mi; 
     1941    unsigned tot_bandw_tias = 0; 
    19411942    pj_status_t status; 
    19421943 
     
    20122013        pjmedia_sdp_media *m = NULL; 
    20132014        pjmedia_transport_info tpinfo; 
     2015        unsigned i; 
    20142016 
    20152017        if (rem_sdp && mi >= rem_sdp->media_count) { 
     
    21092111            sdp->conn = pjmedia_sdp_conn_clone(pool, m->conn); 
    21102112        } 
     2113 
     2114         
     2115        /* Find media bandwidth info */ 
     2116        for (i = 0; i < m->bandw_count; ++i) { 
     2117            const pj_str_t STR_BANDW_MODIFIER_TIAS = { "TIAS", 4 }; 
     2118            if (!pj_stricmp(&m->bandw[i]->modifier, &STR_BANDW_MODIFIER_TIAS)) 
     2119            { 
     2120                tot_bandw_tias += m->bandw[i]->value; 
     2121                break; 
     2122            } 
     2123        } 
    21112124    } 
    21122125 
     
    21332146        pjmedia_sdp_attr_add(&sdp->attr_count, sdp->attr, a); 
    21342147 
     2148    } 
     2149 
     2150 
     2151    /* Add bandwidth info in session level using bandwidth modifier "AS". */ 
     2152    if (tot_bandw_tias) { 
     2153        unsigned bandw; 
     2154        const pj_str_t STR_BANDW_MODIFIER_AS = { "AS", 2 }; 
     2155        pjmedia_sdp_bandw *b; 
     2156 
     2157        /* AS bandwidth = RTP bitrate + RTCP bitrate. 
     2158         * RTP bitrate  = payload bitrate (total TIAS) + overheads (~16kbps). 
     2159         * RTCP bitrate = est. 5% of RTP bitrate. 
     2160         * Note that AS bandwidth is in kbps. 
     2161         */ 
     2162        bandw = tot_bandw_tias + 16000; 
     2163        bandw += bandw * 5 / 100; 
     2164        b = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_bandw); 
     2165        b->modifier = STR_BANDW_MODIFIER_AS; 
     2166        b->value = bandw / 1000; 
     2167        sdp->bandw[sdp->bandw_count++] = b; 
    21352168    } 
    21362169 
Note: See TracChangeset for help on using the changeset viewer.