Browse Source

MT#55283 look up remote b= via subscriptions

Update the bandwidth in the media object only on the side that has
received the SDP. Then when printing the SDP, look up the peer's media
via the subscriptions and use that one's bandwidth values.

Change-Id: I53c99b3628f53b2469f4cd73eb486c0110d989ba
pull/1838/head
Richard Fuchs 1 year ago
parent
commit
d02ce7e81e
4 changed files with 41 additions and 36 deletions
  1. +5
    -11
      daemon/call.c
  2. +9
    -9
      daemon/redis.c
  3. +26
    -15
      daemon/sdp.c
  4. +1
    -1
      include/call.h

+ 5
- 11
daemon/call.c View File

@ -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,


+ 9
- 9
daemon/redis.c View File

@ -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);


+ 26
- 15
daemon/sdp.c View File

@ -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);
}
}


+ 1
- 1
include/call.h View File

@ -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;


Loading…
Cancel
Save