summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsua-lib/pjsua_media.c
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2012-01-27 09:12:59 +0000
committerNanang Izzuddin <nanang@teluu.com>2012-01-27 09:12:59 +0000
commit9944702e692e3dc8ab6afb53c78c1e66da6bff9f (patch)
tree30acc3d59bdc59f0f6bca3aaa4406b553fc5e8c8 /pjsip/src/pjsua-lib/pjsua_media.c
parentd3d6518fe7176c4312394686275e11788200fbc1 (diff)
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.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3945 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib/pjsua_media.c')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index 66cecf58..917dadcb 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -1938,6 +1938,7 @@ pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
pjsua_call *call = &pjsua_var.calls[call_id];
pjmedia_sdp_neg_state sdp_neg_state = PJMEDIA_SDP_NEG_STATE_NULL;
unsigned mi;
+ unsigned tot_bandw_tias = 0;
pj_status_t status;
if (pjsua_get_state() != PJSUA_STATE_RUNNING)
@@ -2011,6 +2012,7 @@ pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
pjsua_call_media *call_med = &call->media[mi];
pjmedia_sdp_media *m = NULL;
pjmedia_transport_info tpinfo;
+ unsigned i;
if (rem_sdp && mi >= rem_sdp->media_count) {
/* Remote might have removed some media lines. */
@@ -2108,6 +2110,17 @@ pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
if (sdp->conn == NULL) {
sdp->conn = pjmedia_sdp_conn_clone(pool, m->conn);
}
+
+
+ /* Find media bandwidth info */
+ for (i = 0; i < m->bandw_count; ++i) {
+ const pj_str_t STR_BANDW_MODIFIER_TIAS = { "TIAS", 4 };
+ if (!pj_stricmp(&m->bandw[i]->modifier, &STR_BANDW_MODIFIER_TIAS))
+ {
+ tot_bandw_tias += m->bandw[i]->value;
+ break;
+ }
+ }
}
/* Add NAT info in the SDP */
@@ -2135,6 +2148,26 @@ pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
}
+ /* Add bandwidth info in session level using bandwidth modifier "AS". */
+ if (tot_bandw_tias) {
+ unsigned bandw;
+ const pj_str_t STR_BANDW_MODIFIER_AS = { "AS", 2 };
+ pjmedia_sdp_bandw *b;
+
+ /* AS bandwidth = RTP bitrate + RTCP bitrate.
+ * RTP bitrate = payload bitrate (total TIAS) + overheads (~16kbps).
+ * RTCP bitrate = est. 5% of RTP bitrate.
+ * Note that AS bandwidth is in kbps.
+ */
+ bandw = tot_bandw_tias + 16000;
+ bandw += bandw * 5 / 100;
+ b = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_bandw);
+ b->modifier = STR_BANDW_MODIFIER_AS;
+ b->value = bandw / 1000;
+ sdp->bandw[sdp->bandw_count++] = b;
+ }
+
+
#if DISABLED_FOR_TICKET_1185 && defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
/* Check if SRTP is in optional mode and configured to use duplicated
* media, i.e: secured and unsecured version, in the SDP offer.