diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 91ae98863..12272986d 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1646,6 +1646,12 @@ static int media_packet_address_check(struct packet_handler_ctx *phc) && phc->mp.stream->advertised_endpoint.address.family && phc->mp.stream->advertised_endpoint.port) { + // check if we need to reset our learned endpoints + if (memcmp(&rtpe_now, &phc->mp.stream->ep_detect_signal, sizeof(rtpe_now))) { + memset(&phc->mp.stream->detected_endpoints, 0, sizeof(phc->mp.stream->detected_endpoints)); + phc->mp.stream->ep_detect_signal = rtpe_now; + } + // possible endpoints that can be detected in order of preference: // 0: endpoint that matches the address advertised in the SDP // 1: endpoint with the same address but different port @@ -1664,11 +1670,8 @@ static int media_packet_address_check(struct packet_handler_ctx *phc) // now grab the best matched endpoint for (idx = 0; idx < 4; idx++) { use_endpoint_confirm = &phc->mp.stream->detected_endpoints[idx]; - if (use_endpoint_confirm->address.family) { - if (idx == 0) // doesn't get any better than this - goto confirm_now; + if (use_endpoint_confirm->address.family) break; - } } } diff --git a/include/call.h b/include/call.h index fde0cccf5..23ec07dd8 100644 --- a/include/call.h +++ b/include/call.h @@ -266,6 +266,7 @@ struct packet_stream { const struct streamhandler *handler; /* LOCK: in_lock */ struct endpoint endpoint; /* LOCK: out_lock */ struct endpoint detected_endpoints[4]; /* LOCK: out_lock */ + struct timeval ep_detect_signal; /* LOCK: out_lock */ struct endpoint advertised_endpoint; /* RO */ struct crypto_context crypto; /* OUT direction, LOCK: out_lock */ struct ssrc_ctx *ssrc_in, /* LOCK: in_lock */ // XXX eliminate these