From bfe747e9bc9686c2c003910fd55434293aef2893 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 3 Jan 2025 12:21:08 +0100 Subject: [PATCH] MT#61630 moh: introduce `moh-max-repeats` Introduce `moh-max-repeats` configuration option, which controls the `rtpe_config.moh_max_repeats` used when initializing media player options for the music-on-hold functionality. By default is always set to 999, if not defined otherwise. Change-Id: I247dc532a6871934e44f9c4002313363356937fb --- daemon/main.c | 2 ++ daemon/media_player.c | 2 +- etc/rtpengine.conf | 5 +++++ include/main.h | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/daemon/main.c b/daemon/main.c index 5d193d73e..08571c4c9 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -113,6 +113,7 @@ struct rtpengine_config rtpe_config = { .dtmf_digit_delay = 2500, .rtcp_interval = 5000, .moh_max_duration = -1, // disabled by default + .moh_max_repeats = 999, .common = { .log_levels = { [log_level_index_internals] = -1, @@ -698,6 +699,7 @@ static void options(int *argc, char ***argv, GHashTable *templates) { { "janus-secret", 0,0, G_OPTION_ARG_STRING, &rtpe_config.janus_secret,"Admin secret for Janus protocol","STRING"}, { "rtcp-interval", 0,0, G_OPTION_ARG_INT, &rtpe_config.rtcp_interval,"Delay in milliseconds between RTCP packets when generate-rtcp flag is on, where random dispersion < 1 sec is added on top","INT"}, { "moh-max-duration", 0,0, G_OPTION_ARG_INT, &rtpe_config.moh_max_duration, "Max possible duration (in milliseconds) that can be spent on playing a file. If set to 0 then will be ignored.", "INT"}, + { "moh-max-repeats", 0,0, G_OPTION_ARG_INT, &rtpe_config.moh_max_repeats, "Max possible amount of playback repeats for the music on hold. player-max-duration always takes a precedence over it.", "INT"}, { "max-recv-iters", 0, 0, G_OPTION_ARG_INT, &rtpe_config.max_recv_iters, "Maximum continuous reading cycles in UDP poller loop.", "INT"}, { "vsc-start-rec",0,0, G_OPTION_ARG_STRING, &rtpe_config.vsc_start_rec.s,"DTMF VSC to start recording.", "STRING"}, { "vsc-stop-rec",0,0, G_OPTION_ARG_STRING, &rtpe_config.vsc_stop_rec.s,"DTMF VSC to stop recording.", "STRING"}, diff --git a/daemon/media_player.c b/daemon/media_player.c index 3271d16c7..bf8142cee 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -1293,7 +1293,7 @@ const char * call_check_moh(struct call_monologue *from_ml, struct call_monologu { const char *errstr = NULL; media_player_opts_t opts = MPO( - .repeat = 999, + .repeat = rtpe_config.moh_max_repeats, /* MoH always has duration set (even if not defined) */ .duration_spent = rtpe_config.moh_max_duration, .start_pos = 0, diff --git a/etc/rtpengine.conf b/etc/rtpengine.conf index 9556f6296..301c5d100 100644 --- a/etc/rtpengine.conf +++ b/etc/rtpengine.conf @@ -156,6 +156,11 @@ recording-method = proc # When not defined (set to 0), it takes 1800000ms default value. # moh-max-duration = 1800000 +# music-on-hold max possible repeats. +# moh-max-duration always takes a precedence over it. +# By default is always 999 if not defined otherwise. +# moh-max-repeats = 999 + # signalling templates (see key `templates` above) [templates] WebRTC = transport-protocol=UDP/TLS/RTP/SAVPF ICE=force trickle-ICE rtcp-mux=[offer require] no-rtcp-attribute SDES=off generate-mid diff --git a/include/main.h b/include/main.h index 87c5351cc..249feda11 100644 --- a/include/main.h +++ b/include/main.h @@ -40,6 +40,7 @@ enum endpoint_learning { X(final_timeout) \ X(offer_timeout) \ X(moh_max_duration) \ + X(moh_max_repeats) \ X(delete_delay) \ X(redis_expires_secs) \ X(default_tos) \