MT#62272 Introduce `moh-prevent-double-hold` config option

Protects against double MoH played,
e.g. when inadvertently two rtpengine instances try to trigger MoH.

This gives a clue to the current rtpengine instance,
that another one already started MoH for this call.

By default is set to false.

Change-Id: I7cc36a177b0ce1bdb64ff8b42bf31f13fb1e4c91
pull/1923/head
Donat Zenichev 1 month ago
parent 26072ed6a1
commit 9a3c54a523

@ -842,6 +842,7 @@ static void options(int *argc, char ***argv, charp_ht templates) {
{ "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_STRING, &rtpe_config.moh_attr_name, "Controls the value to be added to the session level of SDP whenever MoH is triggered.", "STRING"},
{ "moh-prevent-double-hold", 'F',0, G_OPTION_ARG_NONE, &rtpe_config.moh_prevent_double_hold, "Protects against double MoH played.", NULL},
{ "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"},

@ -1568,7 +1568,7 @@ const char * call_check_moh(struct call_monologue *from_ml, struct call_monologu
sdp_ng_flags *flags)
{
#ifdef WITH_TRANSCODING
if (call_ml_wants_moh(from_ml, flags->opmode))
if (!flags->moh_double_hold && call_ml_wants_moh(from_ml, flags->opmode))
{
const char *errstr = NULL;

@ -65,6 +65,7 @@ enum attr_id {
ATTR_MAXPTIME,
ATTR_TLS_ID,
ATTR_END_OF_CANDIDATES,
ATTR_MOH_ATTR_NAME,
};
// make sure g_int_hash can be used
static_assert(sizeof(gint) == sizeof(enum attr_id), "sizeof enum attr_id wrong");
@ -1215,6 +1216,10 @@ static int parse_attribute(struct sdp_attribute *a) {
case CSH_LOOKUP("maxptime"):
a->attr = ATTR_MAXPTIME;
break;
default:
/* check moh-attr-name (can be a variable attribute value) */
if (rtpe_config.moh_attr_name && !str_cmp(&a->strs.name, rtpe_config.moh_attr_name))
a->attr = ATTR_MOH_ATTR_NAME;
}
return ret;
@ -1852,6 +1857,12 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
if (attr)
flags->session_group = attr->strs.value;
if (rtpe_config.moh_prevent_double_hold) {
attr = attr_get_by_id(&session->attributes, ATTR_MOH_ATTR_NAME);
if (attr)
flags->moh_double_hold = 1;
}
for (__auto_type k = session->media_streams.head; k; k = k->next) {
media = k->data;

@ -167,6 +167,10 @@ recording-method = proc
# whenever MoH is triggered. If not defined, then not in use.
# moh-attr-name = rtpengine-hold
# protects against double MoH played
# (e.g. when inadvertently two rtpengine instances try to trigger MoH)
# moh-prevent-double-hold = false
# preload-media-files = /var/media/file1.wav ; /var/media/file2.wav ; /var/media/file3.wav ; on-demand
# media-files-reload = 60
# preload-db-media = 1; 2; 3; 4; on-demand

@ -290,7 +290,9 @@ RTPE_NG_FLAGS_STR_CASE_HT_PARAMS
to_tag_flag:1,
moh_zero_connection:1,
/* by default sendonly */
moh_sendrecv:1;
moh_sendrecv:1,
/* prevents double MoH holds */
moh_double_hold:1;
};

@ -128,6 +128,7 @@ enum endpoint_learning {
X(measure_rtp) \
X(amr_cn_dtx) \
X(evs_cn_dtx) \
X(moh_prevent_double_hold) \
#define RTPE_CONFIG_CHARP_PARAMS \
X(b2b_url) \

Loading…
Cancel
Save