From d4922681babb20d0b145f2515cacb333d7f44ba9 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 1 Sep 2022 12:25:49 -0400 Subject: [PATCH] TT#189201 upgrade `all` flag to key/value and enum Change-Id: I2e6c6507819b58b0b7995991d3abc6cb0597799e --- README.md | 19 ++++++++++++------- daemon/call_interfaces.c | 29 +++++++++++++++++++++-------- include/call_interfaces.h | 5 ++++- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index e63a9a059..6fd0b972c 100644 --- a/README.md +++ b/README.md @@ -836,10 +836,7 @@ Optionally included keys are: - `all` - Only relevant to the `unblock media` and `unsilence media` - messages. Instructs *rtpengine* to remove not only a full-call - media block, but also remove directional media blocks that were - imposed on individual participants. + Synonymous to `all=all` (see below). - `pad crypto` @@ -1631,6 +1628,13 @@ Optionally included keys are: reproduced after the given delay. DTMF blocking modes are honoured at the time when the DTMF events are reproduced. +* `all` + + Can be set to the string `none` to disable any extra behaviour (which + is the default if this key is omitted altogether) or to `all`. + Applicable to certain messages only. The behaviour is explained below + separately for each affected message. + An example of a complete `offer` request dictionary could be (SDP body abbreviated): { "command": "offer", "call-id": "cfBXzDSZqhYNcXM", "from-tag": "mS9rSAn0Cr", @@ -2003,9 +2007,10 @@ message. For an address, it can be an IPv4 or IPv6 address, and any participant found to have a matching address advertised as their SDP media address will have their originating RTP packets blocked (or unblocked). -Unblocking packets for the entire call (i.e. only `call-id` is given) does not automatically unblock packets for -participants which had their packets blocked directionally, unless the string `all` is included in the `flags` -section of the message. +Unblocking packets for the entire call (i.e. only `call-id` is given) does not +automatically unblock packets for participants which had their packets blocked +directionally, unless the string `all` (equivalent to setting `all=all`) is +included in the `flags` section of the message. When DTMF blocking is enabled, DTMF event packets will not be forwarded to the receiving peer. If DTMF logging is enabled, DTMF events will still be logged to syslog while blocking is enabled. Blocking diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 1d2187b5d..21a84a8f3 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -793,7 +793,7 @@ static void call_ng_flags_flags(struct sdp_ng_flags *out, str *s, void *dummy) { out->reset = 1; break; case CSH_LOOKUP("all"): - out->all = 1; + out->all = ALL_ALL; break; case CSH_LOOKUP("egress"): out->egress = 1; @@ -1470,6 +1470,19 @@ static void call_ng_main_flags(struct sdp_ng_flags *out, str *key, bencode_item_ case CSH_LOOKUP("pause"): out->pause = bencode_get_integer_str(value, out->pause); break; + case CSH_LOOKUP("all"): + switch (__csh_lookup(&s)) { + case CSH_LOOKUP("all"): + out->all = ALL_ALL; + break; + case CSH_LOOKUP("none"): + out->all = ALL_NONE; + break; + default: + ilog(LOG_WARN, "Unknown 'all' flag encountered: '" STR_FORMAT "'", + STR_FMT(&s)); + } + break; case CSH_LOOKUP("command"): break; default: @@ -2380,7 +2393,7 @@ static const char *media_block_match(struct call **call, struct call_monologue * return "Unknown call-ID"; // directional? - if (flags->all) // explicitly non-directional, so skip the rest + if (flags->all == ALL_ALL) // explicitly non-directional, so skip the rest return NULL; const char *err = media_block_match1(*call, monologue, flags); @@ -2411,7 +2424,7 @@ static const char *media_block_match_mult(struct call **call, GQueue *mls, if (!*call) return "Unknown call-ID"; - if (flags->all) { + if (flags->all == ALL_ALL) { // get and add all offer/answer mls for (GList *l = (*call)->monologues.head; l; l = l->next) { struct call_monologue *ml = l->data; @@ -2496,7 +2509,7 @@ const char *call_stop_forwarding_ng(bencode_item_t *input, bencode_item_t *outpu else { ilog(LOG_INFO, "Stop forwarding (entire call)"); call->rec_forwarding = 0; - if (flags.all) { + if (flags.all == ALL_ALL) { for (GList *l = call->monologues.head; l; l = l->next) { monologue = l->data; monologue->rec_forwarding = 0; @@ -2622,11 +2635,11 @@ const char *call_unblock_dtmf_ng(bencode_item_t *input, bencode_item_t *output) ilog(LOG_INFO, "Unblocking DTMF (entire call)"); enum block_dtmf_mode prev_mode = call->block_dtmf; call->block_dtmf = BLOCK_DTMF_OFF; - if (flags.all || is_dtmf_replace_mode(prev_mode) || flags.delay_buffer >= 0) { + if (flags.all == ALL_ALL || is_dtmf_replace_mode(prev_mode) || flags.delay_buffer >= 0) { for (GList *l = call->monologues.head; l; l = l->next) { monologue = l->data; enum block_dtmf_mode prev_ml_mode = BLOCK_DTMF_OFF; - if (flags.all) { + if (flags.all == ALL_ALL) { prev_ml_mode = monologue->block_dtmf; monologue->block_dtmf = BLOCK_DTMF_OFF; } @@ -2717,7 +2730,7 @@ static const char *call_block_silence_media(bencode_item_t *input, bool on_off, G_STRUCT_MEMBER(bool, call, call_offset) = on_off; if (!on_off) { ilog(LOG_INFO, "%s media (entire call and participants)", ucase_verb); - if (flags.all) { + if (flags.all == ALL_ALL) { for (GList *l = call->monologues.head; l; l = l->next) { monologue = l->data; G_STRUCT_MEMBER(bool, monologue, ml_offset) = on_off; @@ -2765,7 +2778,7 @@ static const char *play_media_select_party(struct call **call, GQueue *monologue const char *err = media_block_match(call, &monologue, flags_ptr, input, OP_OTHER); if (err) return err; - if (flags_ptr->all) + if (flags_ptr->all == ALL_ALL) g_queue_append(monologues, &(*call)->monologues); else if (!monologue) return "No participant party specified"; diff --git a/include/call_interfaces.h b/include/call_interfaces.h index 6dfa97677..4176c4134 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -76,6 +76,10 @@ struct sdp_ng_flags { MEO_BKW, MEO_BOTH, } media_echo:3; + enum { + ALL_NONE = 0, + ALL_ALL, + } all; enum endpoint_learning el_option; enum block_dtmf_mode block_dtmf_mode; int delay_buffer; @@ -129,7 +133,6 @@ struct sdp_ng_flags { osrtp_accept:1, osrtp_offer:1, reset:1, - all:1, egress:1, siprec:1, fragment:1,