From 5332e48a9697f2c50ba7821d9d123a9b8002666f Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 10 Nov 2023 12:01:20 +0100 Subject: [PATCH] MT#57550 `call_get_dialogue()` spot intactness (ft/tt) using media subs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From now on, the newer media subscriptions based concept has been introduced, which means the call monologue is able to have: - medias, which have non-even amount of subscribers and subscriptions - medias of different monologues in the media's subscriptions list - medias of different monologues in the media's subscribers list Further, improve the `call_get_dialogue()` accordingly so, that a detection, whether or not a from-monologue has already seen before given to-monologue, will be based on from-monologue's media subscriptions. Absent to-monologue medias in from-monologue subscriptions list means — to-monologue has been never seen before, and we have to update tags accordingly as well as subscribe matched medias of to/from-monologue to each other. Change-Id: Icef81d06ac2ee6e150ecdea7133547166290b015 --- daemon/call.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 9e2b96c3f..8b883abba 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -4728,29 +4728,24 @@ static int call_get_dialogue(struct call_monologue *monologues[2], struct call * if (ft) { __C_DBG("found existing dialogue"); - /* make sure that the dialogue is actually intact */ - if (ft->subscriptions.length != 1 || ft->subscribers.length != 1) - goto tag_setup; - if (tt->subscriptions.length != 1 || tt->subscribers.length != 1) - goto tag_setup; - - struct call_subscription *cs = ft->subscriptions.head->data; - if (cs->monologue != tt) - goto tag_setup; - cs = ft->subscribers.head->data; - if (cs->monologue != tt) - goto tag_setup; - - cs = tt->subscriptions.head->data; - if (cs->monologue != ft) - goto tag_setup; - cs = tt->subscribers.head->data; - if (cs->monologue != ft) - goto tag_setup; - - goto done; - } - else { + /* detect whether given ft's medias + * already seen as subscribers of tt's medias, otherwise setup tags */ + for (unsigned int i = 0; i < ft->medias->len; i++) + { + struct call_media *media = ft->medias->pdata[i]; + if (!media) + continue; + /* try to find tt in subscriptions of ft */ + for (GList *l = media->media_subscriptions.head; l; l = l->next) + { + struct media_subscription * ms = l->data; + if (ms->monologue && ms->monologue == tt) + goto done; + } + } + /* it seems ft hasn't seen tt before */ + goto tag_setup; + } else { /* perhaps we can determine the monologue from the viabranch */ if (viabranch) ft = g_hash_table_lookup(call->viabranches, viabranch);