From 3ec06519c5eceeef093dfe858b5418af3198fca0 Mon Sep 17 00:00:00 2001 From: Gustavo Almeida Date: Fri, 3 Jul 2026 18:08:36 +0100 Subject: [PATCH] add option to allow disable of early-return on heuristic endpoint-learning when there is a match with address advertised in the SDP --- daemon/main.c | 1 + daemon/media_socket.c | 2 +- docs/rtpengine.md | 10 ++++++++++ etc/rtpengine.conf | 1 + include/main.h | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/daemon/main.c b/daemon/main.c index 49a3ae982..18b6553ea 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -882,6 +882,7 @@ static void options(int *argc, char ***argv, charp_ht templates) { { "mysql-pass", 0, 0, G_OPTION_ARG_STRING, &rtpe_config.mysql_pass,"MySQL connection credentials", "PASSWORD" }, { "mysql-query",0, 0, G_OPTION_ARG_STRING, &rtpe_config.mysql_query,"MySQL select query", "STRING" }, { "endpoint-learning",0,0,G_OPTION_ARG_STRING, &endpoint_learning, "RTP endpoint learning algorithm", "delayed|immediate|off|heuristic" }, + { "endpoint-learning-heuristic-disable-early-return",0,0,G_OPTION_ARG_NONE, &rtpe_config.el_heuristic_disable_early_return, "Disable early return on heuristic endpoint-learning when there is a match that equals SDP address", NULL }, { "jitter-buffer",0, 0, G_OPTION_ARG_INT, &rtpe_config.jb_length, "Size of jitter buffer", "INT" }, { "jb-clock-drift",0,0, G_OPTION_ARG_NONE, &rtpe_config.jb_clock_drift,"Compensate for source clock drift",NULL }, { "jb-adaptive",0,0, G_OPTION_ARG_NONE, &rtpe_config.jb_adaptive,"Enable adaptive jitter buffer sizing",NULL }, diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 595061e88..62ad762bd 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -3255,7 +3255,7 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc) } // confirm endpoint, if matches address advertised in SDP - if (idx == 0) + if (!rtpe_config.el_heuristic_disable_early_return && idx == 0) goto confirm_now; // finally, if there has been a better match and if strict-source is set, diff --git a/docs/rtpengine.md b/docs/rtpengine.md index 896082651..fb7d794a3 100644 --- a/docs/rtpengine.md +++ b/docs/rtpengine.md @@ -977,6 +977,16 @@ call to inject-DTMF won't be sent to __\-\-dtmf-log-dest=__ or __\-\-listen-tcp- (but different address) is seen, that address is used. Otherwise, the source address of any incoming packet seen is used. +- __\-\-endpoint-learning-heuristic-disable-early-return__ + + When __endpoint-learning=heuristic__ is in use, an incoming RTP packet whose + source address and port exactly match the address advertised in the SDP causes + immediate endpoint confirmation, without waiting for the usual 3-second learning + period. Enable this option to disable that early return and restore the previous + behaviour of waiting out the full learning period before confirming, even when + an SDP-matching packet is seen. Has no effect unless __heuristic__ endpoint + learning is active. Disabled by default. + - __\-\-jitter-buffer=__*INT* Size of (incoming) jitter buffer in packets. A value of zero (the default) diff --git a/etc/rtpengine.conf b/etc/rtpengine.conf index ef17a0582..d72bda232 100644 --- a/etc/rtpengine.conf +++ b/etc/rtpengine.conf @@ -42,6 +42,7 @@ tos = 184 # delete-delay = 30 # final-timeout = 10800 # endpoint-learning = heuristic +# endpoint-learning-heuristic-disable-early-return = true # reject-invalid-sdp = false # foreground = false diff --git a/include/main.h b/include/main.h index 79b1f2168..4728b5d8e 100644 --- a/include/main.h +++ b/include/main.h @@ -140,6 +140,7 @@ enum endpoint_learning { X(amr_cn_dtx) \ X(evs_cn_dtx) \ X(moh_prevent_double_hold) \ + X(el_heuristic_disable_early_return) \ #define RTPE_CONFIG_CHARP_PARAMS \ X(b2b_url) \