From af79ec6a91733eb1e559789a7b6c0a993dcaa153 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 16 Sep 2021 12:23:55 -0400 Subject: [PATCH] TT#14008 rework offer/answer subscriptions While doing the A/B reassociation during an offer/answer exchange, we don't (necessarily) want to remove all existing subscriptions. Instead we cant to unsubscribe all subscribers so we don't do media forking, but leaving existing subscriptions alone to make early media reception possible. This mirros the old behaviour. Change-Id: Ib9e6671ca2d23d1eb4509d7cf939015c816cc622 --- daemon/call.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index bc29c5a6c..dded7c95f 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2692,10 +2692,6 @@ static void __unsubscribe_one_link(struct call_monologue *which, GList *which_cs g_slice_free1(sizeof(*cs), cs); g_slice_free1(sizeof(*rev_cs), rev_cs); } -//static void __unsubscribe_all(struct call_monologue *which) { -// while (which->subscriptions.head) -// __unsubscribe_one_link(which, which->subscriptions.head); -//} static bool __unsubscribe_one(struct call_monologue *which, struct call_monologue *from) { GList *l = g_hash_table_lookup(which->subscriptions_ht, from); if (!l) { @@ -2707,15 +2703,15 @@ static bool __unsubscribe_one(struct call_monologue *which, struct call_monologu __unsubscribe_one_link(which, l); return true; } -static void __unsubscribe_all_offer_answer(struct call_monologue *ml) { - for (GList *l = ml->subscriptions.head; l; ) { +static void __unsubscribe_all_offer_answer_subscribers(struct call_monologue *ml) { + for (GList *l = ml->subscribers.head; l; ) { struct call_subscription *cs = l->data; if (!cs->offer_answer) { l = l->next; continue; } GList *next = l->next; - __unsubscribe_one_link(ml, l); + __unsubscribe_one(cs->monologue, ml); l = next; } } @@ -2751,9 +2747,11 @@ void __add_subscription(struct call_monologue *which, struct call_monologue *to, g_hash_table_insert(which->subscriptions_ht, to, to_rev_cs->link); g_hash_table_insert(to->subscribers_ht, which, which_cs->link); } -static void __subscribe_only_one_offer_answer(struct call_monologue *which, struct call_monologue *to) { - __unsubscribe_all_offer_answer(which); - __add_subscription(which, to, true); +static void __subscribe_offer_answer_both_ways(struct call_monologue *a, struct call_monologue *b) { + __unsubscribe_all_offer_answer_subscribers(a); + __unsubscribe_all_offer_answer_subscribers(b); + __add_subscription(a, b, true); + __add_subscription(b, a, true); } @@ -3752,8 +3750,7 @@ static int call_get_monologue_new(struct call_monologue *dialogue[2], struct cal goto new_branch; // use existing to-tag __monologue_unkernelize(csm); - __subscribe_only_one_offer_answer(ret, csm); - __subscribe_only_one_offer_answer(csm, ret); + __subscribe_offer_answer_both_ways(ret, csm); break; } break; // there should only be one @@ -3782,8 +3779,7 @@ static int call_get_monologue_new(struct call_monologue *dialogue[2], struct cal if (os) { /* previously seen branch. use it */ __monologue_unkernelize(os); - __subscribe_only_one_offer_answer(ret, os); - __subscribe_only_one_offer_answer(os, ret); + __subscribe_offer_answer_both_ways(ret, os); goto ok_check_tag; } @@ -3792,8 +3788,7 @@ static int call_get_monologue_new(struct call_monologue *dialogue[2], struct cal new_branch: __C_DBG("create new \"other side\" monologue for viabranch "STR_FORMAT, STR_FMT0(viabranch)); os = __monologue_create(call); - __subscribe_only_one_offer_answer(ret, os); - __subscribe_only_one_offer_answer(os, ret); + __subscribe_offer_answer_both_ways(ret, os); __monologue_viabranch(os, viabranch); ok_check_tag: @@ -3883,8 +3878,7 @@ tag_setup: __dialogue_unkernelize(ft); __dialogue_unkernelize(tt); - __subscribe_only_one_offer_answer(ft, tt); - __subscribe_only_one_offer_answer(tt, ft); + __subscribe_offer_answer_both_ways(ft, tt); __fix_other_tags(ft); done: