diff --git a/daemon/call.c b/daemon/call.c index ebae04356..90d08d949 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2216,7 +2216,6 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams, struct stream_params *sp; GList *media_iter, *ml_media, *other_ml_media; struct call_media *media, *other_media; - unsigned int num_ports; struct call_monologue *monologue; struct endpoint_map *em; struct call *call; @@ -2421,15 +2420,9 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams, } } - /* determine number of consecutive ports needed locally. - * XXX only do *=2 for RTP streams? */ - num_ports = sp->consecutive_ports; - num_ports *= 2; - - /* local interface selection */ - __init_interface(media, &sp->direction[1], num_ports); - __init_interface(other_media, &sp->direction[0], num_ports); + __init_interface(media, &sp->direction[1], sp->num_ports); + __init_interface(other_media, &sp->direction[0], sp->num_ports); if (media->logical_intf == NULL || other_media->logical_intf == NULL) { goto error_intf; @@ -2451,8 +2444,8 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams, * RFC 3264, chapter 6: * If a stream is rejected, the offerer and answerer MUST NOT * generate media (or RTCP packets) for that stream. */ - __disable_streams(media, num_ports); - __disable_streams(other_media, num_ports); + __disable_streams(media, sp->num_ports); + __disable_streams(other_media, sp->num_ports); goto init; } if (is_addr_unspecified(&sp->rtp_endpoint.address) && !MEDIA_ISSET(other_media, TRICKLE_ICE)) { @@ -2465,7 +2458,7 @@ 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, flags); + em = __get_endpoint_map(media, sp->num_ports, &sp->rtp_endpoint, flags); if (!em) { goto error_ports; } @@ -2473,14 +2466,14 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams, if(flags->disable_jb && media->call) media->call->disable_jb=1; - __num_media_streams(media, num_ports); + __num_media_streams(media, sp->num_ports); __assign_stream_fds(media, &em->intf_sfds); - if (__num_media_streams(other_media, num_ports)) { + if (__num_media_streams(other_media, sp->num_ports)) { /* 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, sp->num_ports)) goto error_ports; } diff --git a/daemon/sdp.c b/daemon/sdp.c index ee32d2a53..73ba0e242 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -1529,6 +1529,7 @@ int sdp_streams(const GQueue *sessions, GQueue *streams, struct sdp_ng_flags *fl goto error; sp->consecutive_ports = media->port_count; + sp->num_ports = sp->consecutive_ports * 2; // only do *=2 for RTP streams? sp->protocol = transport_protocol(&media->transport); sp->type = media->media_type_str; sp->type_id = media->media_type_id; diff --git a/include/call.h b/include/call.h index 75d8e72d0..0fdc5f0a0 100644 --- a/include/call.h +++ b/include/call.h @@ -243,6 +243,7 @@ struct stream_params { struct endpoint rtp_endpoint; struct endpoint rtcp_endpoint; unsigned int consecutive_ports; + unsigned int num_ports; const struct transport_protocol *protocol; str format_str; GQueue sdes_params; // slice-alloc'd