From 7e378ebb4d106cd5ecca73a1ea13c5a4f6127002 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 1 Mar 2013 11:10:05 -0500 Subject: [PATCH] attempt to fix the "multiple media streams with same endpoints" case --- daemon/call.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index fa877d3e6..c364b9b5c 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1064,7 +1064,7 @@ static void steal_peer(struct peer *dest, struct peer *src) { src->confirmed = 0; unkernelize(src); - dest->filled = 1; + dest->filled = src->filled; dest->mediatype = src->mediatype; dest->tag = src->tag; src->mediatype = ""; @@ -1270,13 +1270,25 @@ found: } /* lookup */ + x = t->num; +restart_hunt: for (l = c->callstreams->head; l; l = l->next) { cs = l->data; if (cs != cs_o) mutex_lock(&cs->lock); - DBG("hunting for callstream, %i <> %i", cs->num, t->num); - if (cs->num == t->num) - goto got_cs; + DBG("hunting for callstream, %i <> %i", cs->num, x); + if (cs->num == x) { + /* special case: lowered numbered media streams may + * have been "stolen away" by higher numbered streams + * with identical endpoints. keep going until we find + * one with an open fd. */ + if (cs->peers[0].rtps[0].fd != -1) + goto got_cs; + x++; + if (cs != cs_o) + mutex_unlock(&cs->lock); + goto restart_hunt; + } if (cs != cs_o) mutex_unlock(&cs->lock); }