diff --git a/daemon/main.c b/daemon/main.c index 08571c4c9..ae906818d 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -700,6 +700,7 @@ static void options(int *argc, char ***argv, GHashTable *templates) { { "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"}, + { "moh-attr-name", 0,0, G_OPTION_ARG_INT, &rtpe_config.moh_attr_name, "Controls the value to be added to the session level of SDP whenever MoH is triggered.", "STRING"}, { "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 cef427f8b..b3dc15606 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -1317,6 +1317,8 @@ const char * call_check_moh(struct call_monologue *from_ml, struct call_monologu { /* whom to stop the moh audio */ call_stop_media_for_ml(to_ml); + /* mark MoH as already not used (it can be unset now) */ + to_ml->player->moh = false; } return NULL; #else diff --git a/daemon/sdp.c b/daemon/sdp.c index 958699212..7688d600a 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -20,6 +20,7 @@ #include "call_interfaces.h" #include "rtplib.h" #include "codec.h" +#include "media_player.h" enum attr_id { ATTR_OTHER = 0, @@ -2821,7 +2822,11 @@ static void sdp_out_add_other(GString *out, struct call_monologue *monologue, /* add loop protectio if required */ if (flags->loop_protect) append_attr_to_gstring(out, "rtpengine", &rtpe_instance_id, flags, media->type_id); - +#ifdef WITH_TRANSCODING + if (monologue->player && monologue->player->moh && rtpe_config.moh_attr_name) { + append_attr_to_gstring(out, rtpe_config.moh_attr_name, NULL, flags, media->type_id); + } +#endif /* ice-lite */ if (media_has_ice && media_has_ice_lite_self) append_attr_to_gstring(out, "ice-lite", NULL, flags, media->type_id); diff --git a/etc/rtpengine.conf b/etc/rtpengine.conf index 301c5d100..98c297634 100644 --- a/etc/rtpengine.conf +++ b/etc/rtpengine.conf @@ -161,6 +161,10 @@ recording-method = proc # By default is always 999 if not defined otherwise. # moh-max-repeats = 999 +# controls the value to be added to the session level of SDP +# whenever MoH is triggered. If not defined, then not in use. +# moh-attr-name = rtpengine-hold + # 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 249feda11..0b9469770 100644 --- a/include/main.h +++ b/include/main.h @@ -125,6 +125,7 @@ enum endpoint_learning { X(redis_hostname) \ X(redis_write_hostname) \ X(redis_subscribe_hostname) \ + X(moh_attr_name) \ X(spooldir) \ X(rec_method) \ X(rec_format) \