Browse Source

MT#57550 Improve `monologue_stop()`, add subs handling

Moving from call subscriptions to media subscriptions.

Add a possibility to run `media_stop()` and `__monologue_stop()`
for all related to this monologue media subscribers.
This is an improvement, which gives the following benefits:
- all subscribers are handled inside of the func, less code out of it
- the function gets in sync with new media subscriptions concept

Change-Id: Ia0b897f53438559a68c8b469c71fec72f0d562af
pull/1752/head
Donat Zenichev 2 years ago
parent
commit
fbf666f569
1 changed files with 34 additions and 7 deletions
  1. +34
    -7
      daemon/call.c

+ 34
- 7
daemon/call.c View File

@ -4817,13 +4817,42 @@ static void media_stop(struct call_media *m) {
rtcp_timer_stop(&m->rtcp_timer);
mqtt_timer_stop(&m->mqtt_timer);
}
/**
* Stops media player of given monologue.
*/
static void __monologue_stop(struct call_monologue *ml) {
media_player_stop(ml->player);
}
static void monologue_stop(struct call_monologue *ml) {
/**
* Stops media player and all medias of given monolgue.
* If asked, stops all media subscribers as well.
*/
static void monologue_stop(struct call_monologue *ml, bool stop_media_subsribers) {
/* monologue itself */
__monologue_stop(ml);
for (unsigned int i = 0; i < ml->medias->len; i++)
{
media_stop(ml->medias->pdata[i]);
}
/* monologue's subscribers */
if (stop_media_subsribers) {
AUTO_CLEANUP(GQueue mls, g_queue_clear) = G_QUEUE_INIT; /* to avoid duplications */
for (unsigned int i = 0; i < ml->medias->len; i++)
{
struct call_media *media = ml->medias->pdata[i];
if (!media)
continue;
for (GList *l = media->media_subscribers.head; l; l = l->next)
{
struct media_subscription * ms = l->data;
media_stop(ms->media);
if (!g_queue_find(&mls, ms->monologue)) {
__monologue_stop(ms->monologue);
g_queue_push_tail(&mls, ms->monologue);
}
}
}
}
}
@ -4890,11 +4919,9 @@ do_delete:
if (output)
ng_call_stats(c, fromtag, totag, output, NULL);
monologue_stop(ml);
for (GList *l = ml->subscribers.head; l; l = l->next) {
struct call_subscription *cs = l->data;
monologue_stop(cs->monologue);
}
/* stop media player and all medias of ml.
* same for media subscribers */
monologue_stop(ml, true);
/* check, if we have some associated monologues left, which have own associations
* which means they need a media to flow */
@ -4914,7 +4941,7 @@ do_delete:
del_all:
for (i = c->monologues.head; i; i = i->next) {
ml = i->data;
monologue_stop(ml);
monologue_stop(ml, false);
}
c->destroyed = rtpe_now;


Loading…
Cancel
Save