diff --git a/daemon/call.c b/daemon/call.c index 9f4886f2c..ad9ebee70 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -664,7 +664,7 @@ struct call_media *call_media_new(call_t *call) { med->media_subscriptions_ht = subscription_ht_new(); mutex_init(&med->dtmf_lock); med->sdp_attr_print = sdp_insert_media_attributes; - med->desired_bandwidth_as = med->desired_bandwidth_rr = med->desired_bandwidth_rs = -1; + med->bandwidth_as = med->bandwidth_rr = med->bandwidth_rs = -1; return med; } @@ -2881,16 +2881,10 @@ static void __media_init_from_flags(struct call_media *other_media, struct call_ media->desired_family = sp->desired_family; } - - /* desired bandwidth */ - other_media->desired_bandwidth_as = sp->media_session_as; - other_media->desired_bandwidth_rr = sp->media_session_rr; - other_media->desired_bandwidth_rs = sp->media_session_rs; - if (media) { - media->desired_bandwidth_as = sp->media_session_as; - media->desired_bandwidth_rr = sp->media_session_rr; - media->desired_bandwidth_rs = sp->media_session_rs; - } + /* bandwidth */ + other_media->bandwidth_as = sp->media_session_as; + other_media->bandwidth_rr = sp->media_session_rr; + other_media->bandwidth_rs = sp->media_session_rs; } unsigned int proto_num_ports(unsigned int sp_ports, struct call_media *media, sdp_ng_flags *flags, diff --git a/daemon/redis.c b/daemon/redis.c index 665b8fc1d..b6b2f02c2 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -1614,9 +1614,9 @@ static int json_medias(call_t *c, struct redis_list *medias, struct redis_list * return -1; /* bandwidth data is not critical */ - med->desired_bandwidth_as = (!redis_hash_get_int(&ii, rh, "bandwidth_as")) ? ii : -1; - med->desired_bandwidth_rr = (!redis_hash_get_int(&ii, rh, "bandwidth_rr")) ? ii : -1; - med->desired_bandwidth_rs = (!redis_hash_get_int(&ii, rh, "bandwidth_rs")) ? ii : -1; + med->bandwidth_as = (!redis_hash_get_int(&ii, rh, "bandwidth_as")) ? ii : -1; + med->bandwidth_rr = (!redis_hash_get_int(&ii, rh, "bandwidth_rr")) ? ii : -1; + med->bandwidth_rs = (!redis_hash_get_int(&ii, rh, "bandwidth_rs")) ? ii : -1; json_build_list_cb(NULL, c, "payload_types", i, NULL, rbl_cb_plts_r, med, root_reader); /* XXX dtls */ @@ -2639,12 +2639,12 @@ char* redis_encode_json(call_t *c) { JSON_SET_SIMPLE("ptime","%i", media->ptime); JSON_SET_SIMPLE("media_flags", "%" PRIu64, atomic64_get_na(&media->media_flags)); - if (media->desired_bandwidth_as >= 0) - JSON_SET_SIMPLE("bandwidth_as","%i", media->desired_bandwidth_as); - if (media->desired_bandwidth_rr >= 0) - JSON_SET_SIMPLE("bandwidth_rr","%i", media->desired_bandwidth_rr); - if (media->desired_bandwidth_rs >= 0) - JSON_SET_SIMPLE("bandwidth_rs","%i", media->desired_bandwidth_rs); + if (media->bandwidth_as >= 0) + JSON_SET_SIMPLE("bandwidth_as","%i", media->bandwidth_as); + if (media->bandwidth_rr >= 0) + JSON_SET_SIMPLE("bandwidth_rr","%i", media->bandwidth_rr); + if (media->bandwidth_rs >= 0) + JSON_SET_SIMPLE("bandwidth_rs","%i", media->bandwidth_rs); json_update_sdes_params(builder, "media", media->unique_id, "sdes_in", &media->sdes_in); diff --git a/daemon/sdp.c b/daemon/sdp.c index a7c7bf55c..af8bae01b 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -3477,27 +3477,38 @@ static void sdp_out_add_timing(GString *out, struct call_monologue *monologue) static void sdp_out_add_bandwidth(GString *out, struct call_monologue *monologue, struct call_media *media) { - struct call_monologue *ml = monologue; - struct media_subscription *ms = call_get_top_media_subscription(monologue); - if (ms && ms->monologue) - ml = ms->monologue; + struct call_media *sub_media = NULL; + struct call_monologue *sub_ml = NULL; - /* sdp bandwidth per media level */ if (media) { - if (media->desired_bandwidth_as >= 0) - g_string_append_printf(out, "b=AS:%d\r\n", media->desired_bandwidth_as); - if (media->desired_bandwidth_rr >= 0) - g_string_append_printf(out, "b=RR:%d\r\n", media->desired_bandwidth_rr); - if (media->desired_bandwidth_rs >= 0) - g_string_append_printf(out, "b=RS:%d\r\n", media->desired_bandwidth_rs); + struct media_subscription *ms = media->media_subscriptions.head ? media->media_subscriptions.head->data : NULL; + if (!ms || !ms->media) + return; + sub_media = ms->media; + } + else { + struct media_subscription *ms = call_get_top_media_subscription(monologue); + if (!ms || !ms->monologue) + return; + sub_ml = ms->monologue; + } + + /* sdp bandwidth per media level */ + if (sub_media) { + if (sub_media->bandwidth_as >= 0) + g_string_append_printf(out, "b=AS:%d\r\n", sub_media->bandwidth_as); + if (sub_media->bandwidth_rr >= 0) + g_string_append_printf(out, "b=RR:%d\r\n", sub_media->bandwidth_rr); + if (sub_media->bandwidth_rs >= 0) + g_string_append_printf(out, "b=RS:%d\r\n", sub_media->bandwidth_rs); } else { /* sdp bandwidth per session/media level * 0 value is supported (e.g. b=RR:0 and b=RS:0), to be able to disable rtcp */ - if (ml->sdp_session_rr >= 0) - g_string_append_printf(out, "b=RR:%d\r\n", ml->sdp_session_rr); - if (ml->sdp_session_rs >= 0) - g_string_append_printf(out, "b=RS:%d\r\n", ml->sdp_session_rs); + if (sub_ml->sdp_session_rr >= 0) + g_string_append_printf(out, "b=RR:%d\r\n", sub_ml->sdp_session_rr); + if (sub_ml->sdp_session_rs >= 0) + g_string_append_printf(out, "b=RS:%d\r\n", sub_ml->sdp_session_rs); } } diff --git a/include/call.h b/include/call.h index e44030379..fa4ad5cc6 100644 --- a/include/call.h +++ b/include/call.h @@ -551,7 +551,7 @@ struct call_media { int media_sdp_id; /* bandwidth */ - int desired_bandwidth_as, desired_bandwidth_rr, desired_bandwidth_rs; + int bandwidth_as, bandwidth_rr, bandwidth_rs; #ifdef WITH_TRANSCODING encoder_callback_t encoder_callback;