diff --git a/README.md b/README.md index c9838d7c5..4eb58316e 100644 --- a/README.md +++ b/README.md @@ -697,6 +697,13 @@ Optionally included keys are: Forces *rtpengine* to retain its local ports during a signalling exchange even when the remote endpoint changes its port. + - `no port latching` + + Port latching is enabled by default for endpoints which speak + ICE. With this option preset, a remote port change will result + in a local port change even for endpoints which speak ICE, + which will imply an ICE restart. + - `record call` Identical to setting `record call` to `on` (see below). diff --git a/daemon/call.c b/daemon/call.c index 2f65d515f..52a8a52a2 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -832,6 +832,8 @@ static struct endpoint_map *__get_endpoint_map(struct call_media *media, unsigne if (flags && flags->port_latching) /* do nothing - ignore endpoint addresses */ ; + else if (MEDIA_ISSET(media, ICE) && (!flags || !flags->no_port_latching)) + ; // don't change endpoint address if we're talking ICE else if (is_addr_unspecified(&ep->address) || is_addr_unspecified(&em->endpoint.address)) { /* handle zero endpoint address: only compare ports */ if (ep->port != em->endpoint.port) @@ -893,23 +895,22 @@ next_il: } static void __assign_stream_fds(struct call_media *media, GQueue *intf_sfds) { - GList *l, *k; - struct packet_stream *ps; - struct stream_fd *sfd, *intf_sfd; - struct intf_list *il; - int sfd_found; + int reset_ice = 0; + + for (GList *k = media->streams.head; k; k = k->next) { + struct packet_stream *ps = k->data; - for (k = media->streams.head; k; k = k->next) { - ps = k->data; + // use opaque pointer to detect changes + void *old_selected_sfd = ps->selected_sfd; g_queue_clear(&ps->sfds); - sfd_found = 0; - intf_sfd = NULL; + int sfd_found = 0; + struct stream_fd *intf_sfd = NULL; - for (l = intf_sfds->head; l; l = l->next) { - il = l->data; + for (GList *l = intf_sfds->head; l; l = l->next) { + struct intf_list *il = l->data; - sfd = g_queue_peek_nth(&il->list, ps->component - 1); + struct stream_fd *sfd = g_queue_peek_nth(&il->list, ps->component - 1); if (!sfd) return ; sfd->stream = ps; @@ -928,11 +929,12 @@ static void __assign_stream_fds(struct call_media *media, GQueue *intf_sfds) { ps->selected_sfd = g_queue_peek_nth(&ps->sfds, 0); } - /* XXX: - * handle crypto/dtls resets by moving contexts into sfd struct. - * handle ice resets too. - */ + if (old_selected_sfd && ps->selected_sfd && old_selected_sfd != ps->selected_sfd) + reset_ice = 1; } + + if (reset_ice && media->ice_agent) + ice_restart(media->ice_agent); } static int __wildcard_endpoint_map(struct call_media *media, unsigned int num_ports) { diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index ffe40cdbf..40914c340 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -789,6 +789,9 @@ static void call_ng_flags_flags(struct sdp_ng_flags *out, str *s, void *dummy) { case CSH_LOOKUP("port-latching"): out->port_latching = 1; break; + case CSH_LOOKUP("no-port-latching"): + out->no_port_latching = 1; + break; case CSH_LOOKUP("generate-mid"): out->generate_mid = 1; break; diff --git a/include/call_interfaces.h b/include/call_interfaces.h index 88ccc0677..05d9e3469 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -60,6 +60,7 @@ struct sdp_ng_flags { unidirectional:1, trust_address:1, port_latching:1, + no_port_latching:1, replace_origin:1, replace_sess_conn:1, rtcp_mux_offer:1,