diff --git a/daemon/call.c b/daemon/call.c index fe5879126..00b81cb5c 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1750,7 +1750,7 @@ struct stream_fd *__stream_fd_new(struct udp_fd *fd, struct call *call) { } static struct endpoint_map *__get_endpoint_map(struct call_media *media, unsigned int num_ports, - const struct endpoint *ep) + const struct endpoint *ep, unsigned int wanted_start_port) { GSList *l; struct endpoint_map *em; @@ -1802,7 +1802,7 @@ static struct endpoint_map *__get_endpoint_map(struct call_media *media, unsigne alloc: if (num_ports > G_N_ELEMENTS(fd_arr)) return NULL; - if (__get_consecutive_ports(fd_arr, num_ports, 0, media->call)) + if (__get_consecutive_ports(fd_arr, num_ports, wanted_start_port, media->call)) return NULL; __C_DBG("allocating stream_fds for %u ports", num_ports); @@ -1841,10 +1841,10 @@ static void __assign_stream_fds(struct call_media *media, GList *sfds) { ice_restart(media->ice_agent); } -static int __wildcard_endpoint_map(struct call_media *media, unsigned int num_ports) { +static int __wildcard_endpoint_map(struct call_media *media, unsigned int num_ports, unsigned int wanted_start_port) { struct endpoint_map *em; - em = __get_endpoint_map(media, num_ports, NULL); + em = __get_endpoint_map(media, num_ports, NULL, wanted_start_port); if (!em) return -1; @@ -2595,7 +2595,9 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams, /* get that many ports for each side, and one packet stream for each port, then * assign the ports to the streams */ - em = __get_endpoint_map(media, num_ports, &sp->rtp_endpoint); + em = __get_endpoint_map(media, num_ports, &sp->rtp_endpoint, + (unsigned int)GPOINTER_TO_UINT(g_queue_pop_head(&call->rtp_bridge_ports))); + if (!em) goto error; @@ -2606,7 +2608,8 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams, /* new streams created on OTHER side. normally only happens in * initial offer. create a wildcard endpoint_map to be filled in * when the answer comes. */ - if (__wildcard_endpoint_map(other_media, num_ports)) + if (__wildcard_endpoint_map(other_media, num_ports, + (unsigned int)GPOINTER_TO_UINT(g_queue_pop_head(&call->rtp_bridge_ports)))) goto error; } @@ -3152,6 +3155,8 @@ static void __call_free(void *p) { g_slice_free1(sizeof(*ps), ps); } + g_queue_clear(&c->rtp_bridge_ports); + assert(c->stream_fds == NULL); } @@ -3170,6 +3175,7 @@ static struct call *call_create(const str *callid, struct callmaster *m) { c->created = poller_now; c->dtls_cert = dtls_cert(); c->tos = m->conf.default_tos; + g_queue_init(&c->rtp_bridge_ports); return c; } diff --git a/daemon/call.h b/daemon/call.h index 184f56f42..64123eebc 100644 --- a/daemon/call.h +++ b/daemon/call.h @@ -386,17 +386,18 @@ struct call { mutex_t buffer_lock; call_buffer_t buffer; + GQueue rtp_bridge_ports; /* everything below protected by master_lock */ rwlock_t master_lock; GSList *monologues; - GHashTable *tags; + GHashTable *tags; GHashTable *viabranches; GSList *streams; GSList *stream_fds; struct dtls_cert *dtls_cert; /* for outgoing */ - str callid; + str callid; time_t created; time_t last_signal; time_t deleted;