Browse Source

MT#58535 rtpp_flags: add directional flag parsing

Is added by:
- explicit generic flag "directionl"; or
- if the "from-tag" flag is used

Introduce the `directional` flag for `sdp_ng_flags` struct.

In use by:
- `media_block_match1()`

Additionally:
add `IS_OP_DIRECTIONAL()` marco check.

Change-Id: Ifd56ea2ad8277d7dec136def1c028c5e2b680ff1
pull/1809/head
Donat Zenichev 2 years ago
parent
commit
15d0867737
4 changed files with 21 additions and 7 deletions
  1. +10
    -4
      daemon/call_interfaces.c
  2. +4
    -2
      daemon/control_ng_flags_parser.c
  3. +5
    -0
      include/call.h
  4. +2
    -1
      include/call_interfaces.h

+ 10
- 4
daemon/call_interfaces.c View File

@ -1036,6 +1036,9 @@ static void call_ng_flags_flags(sdp_ng_flags *out, str *s, helper_arg dummy) {
case CSH_LOOKUP("detect-dtmf"): case CSH_LOOKUP("detect-dtmf"):
out->detect_dtmf = 1; out->detect_dtmf = 1;
break; break;
case CSH_LOOKUP("directional"):
out->directional = 1;
break;
case CSH_LOOKUP("discard-recording"): case CSH_LOOKUP("discard-recording"):
out->discard_recording = 1; out->discard_recording = 1;
break; break;
@ -2841,7 +2844,7 @@ const char *call_stop_recording_ng(bencode_item_t *input, bencode_item_t *output
static const char *media_block_match1(call_t *call, struct call_monologue **monologue, static const char *media_block_match1(call_t *call, struct call_monologue **monologue,
sdp_ng_flags *flags)
sdp_ng_flags *flags, enum call_opmode opmode)
{ {
if (flags->label.s) { if (flags->label.s) {
*monologue = t_hash_table_lookup(call->labels, &flags->label); *monologue = t_hash_table_lookup(call->labels, &flags->label);
@ -2873,7 +2876,10 @@ static const char *media_block_match1(call_t *call, struct call_monologue **mono
found: found:
; ;
} }
else if (flags->from_tag.s) {
/* ignore from-tag, if directional is not set */
else if (flags->from_tag.s &&
(!IS_OP_DIRECTIONAL(opmode) ||
(IS_OP_DIRECTIONAL(opmode) && flags->directional))) {
*monologue = call_get_monologue(call, &flags->from_tag); *monologue = call_get_monologue(call, &flags->from_tag);
if (!*monologue) if (!*monologue)
return "From-tag given, but no such tag exists"; return "From-tag given, but no such tag exists";
@ -2900,7 +2906,7 @@ static const char *media_block_match(call_t **call, struct call_monologue **mono
if (flags->all == ALL_ALL) // explicitly non-directional, so skip the rest if (flags->all == ALL_ALL) // explicitly non-directional, so skip the rest
return NULL; return NULL;
const char *err = media_block_match1(*call, monologue, flags);
const char *err = media_block_match1(*call, monologue, flags, opmode);
if (err) if (err)
return err; return err;
@ -2945,7 +2951,7 @@ static const char *media_block_match_mult(call_t **call, subscription_q *medias,
/* is a single ml given? */ /* is a single ml given? */
struct call_monologue *ml = NULL; struct call_monologue *ml = NULL;
const char *err = media_block_match1(*call, &ml, flags);
const char *err = media_block_match1(*call, &ml, flags, opmode);
if (err) if (err)
return err; return err;
if (ml) { if (ml) {


+ 4
- 2
daemon/control_ng_flags_parser.c View File

@ -373,10 +373,12 @@ void parse_rtpp_flags(const str * rtpp_flags, bencode_item_t * root_dict,
transport = 0x101; transport = 0x101;
/* from-tag can be overriden, but originally has to be provided */ /* from-tag can be overriden, but originally has to be provided */
else if (str_eq(&key, "from-tag")) { else if (str_eq(&key, "from-tag")) {
if (!val.s)
if (!val.s) {
ilogs(control, LOG_DEBUG, "Error processing flag '"STR_FORMAT"' (will be ignored)", STR_FMT(&key)); ilogs(control, LOG_DEBUG, "Error processing flag '"STR_FORMAT"' (will be ignored)", STR_FMT(&key));
else
} else {
bencode_dictionary_add_str(root_dict, "from-tag", &val); bencode_dictionary_add_str(root_dict, "from-tag", &val);
out->directional = 1; /* explicitly add directional for this case */
}
} }
/* direction */ /* direction */
else if (str_eq(&key, "internal") || str_eq(&key, "external")) else if (str_eq(&key, "internal") || str_eq(&key, "external"))


+ 5
- 0
include/call.h View File

@ -107,6 +107,11 @@ enum call_opmode {
|| (opmode == OP_STOP_RECORDING || opmode == OP_PAUSE_RECORDING) \ || (opmode == OP_STOP_RECORDING || opmode == OP_PAUSE_RECORDING) \
|| (opmode == OP_OTHER)) || (opmode == OP_OTHER))
#define IS_OP_DIRECTIONAL(opmode) \
((opmode == OP_BLOCK_DTMF || opmode == OP_BLOCK_MEDIA) \
|| (opmode == OP_UNBLOCK_DTMF || opmode == OP_UNBLOCK_MEDIA) \
|| (opmode == OP_START_FORWARDING || opmode == OP_STOP_FORWARDING))
enum call_media_counted { enum call_media_counted {
CMC_INCREMENT = 0, CMC_INCREMENT = 0,
CMC_DECREMENT, CMC_DECREMENT,


+ 2
- 1
include/call_interfaces.h View File

@ -218,7 +218,8 @@ struct sdp_ng_flags {
block_short:1, block_short:1,
disable_jb:1, disable_jb:1,
nat_wait:1, nat_wait:1,
pierce_nat:1;
pierce_nat:1,
directional:1;
}; };


Loading…
Cancel
Save