TT#189201 allow `to-label` usage for media blocking

This distinguishes `to-label` from `set-label` for media blocking
methods, when previously they were synonymous.

Upgrade sink determination to list at the same time.

Change-Id: I5b35c78f2f307867b51b5376d5a6afbd79128d99
pull/1546/head
Richard Fuchs 3 years ago
parent 4a19714cd1
commit 71a5cec45d

@ -695,7 +695,7 @@ Optionally included keys are:
back in logs and statistics output. For some commands (e.g. `block media`) the given label is not back in logs and statistics output. For some commands (e.g. `block media`) the given label is not
used to set the label of the call participant, but rather to select an existing call participant. used to set the label of the call participant, but rather to select an existing call participant.
* `set-label` or `to-label` * `set-label`
Some commands (e.g. `block media`) use the given `label` to select Some commands (e.g. `block media`) use the given `label` to select
an existing call participant. For these commands, `set-label` instead an existing call participant. For these commands, `set-label` instead
@ -703,6 +703,15 @@ Optionally included keys are:
the selected call participant (if selected via `from-tag`) or for the the selected call participant (if selected via `from-tag`) or for the
newly created participant (e.g. for `subscribe request`). newly created participant (e.g. for `subscribe request`).
* `to-label`
Commands that allow selection of two call participants (e.g. `block
media`) can use `label` instead of `from-tag` to select the first call
participant. The `to-label` can then be used instead of `to-tag` to
select the other call participant.
For `subscribe request` the `to-label` is synonymous with `set-label`.
* `flags` * `flags`
The value of the `flags` key is a list. The list contains zero or more of the following strings. The value of the `flags` key is a list. The list contains zero or more of the following strings.
@ -2014,7 +2023,7 @@ block media for just a single media flow. This is relevant to scenarios that
involve forked media that were established with one or more `subscribe involve forked media that were established with one or more `subscribe
request`. To select just one media flow for media blocking, in addition to request`. To select just one media flow for media blocking, in addition to
selecting a source call participant as above, a destination call participant selecting a source call participant as above, a destination call participant
must be specified using the `to-tag` key in the message. must be specified using the `to-tag` or `to-label`key in the message.
`silence media` and `unsilence media` Messages `silence media` and `unsilence media` Messages
---------------------------------------------- ----------------------------------------------

@ -1105,10 +1105,12 @@ static void call_ng_main_flags(struct sdp_ng_flags *out, str *key, bencode_item_
case CSH_LOOKUP("label"): case CSH_LOOKUP("label"):
out->label = s; out->label = s;
break; break;
case CSH_LOOKUP("to-label"):
case CSH_LOOKUP("set-label"): case CSH_LOOKUP("set-label"):
out->set_label = s; out->set_label = s;
break; break;
case CSH_LOOKUP("to-label"):
out->to_label = s;
break;
case CSH_LOOKUP("address"): case CSH_LOOKUP("address"):
out->address = s; out->address = s;
break; break;
@ -2659,6 +2661,7 @@ static const char *call_block_silence_media(bencode_item_t *input, bool on_off,
return errstr; return errstr;
if (monologue) { if (monologue) {
AUTO_CLEANUP(GQueue sinks, g_queue_clear) = G_QUEUE_INIT;
if (flags.to_tag.len) { if (flags.to_tag.len) {
struct call_monologue *sink = g_hash_table_lookup(call->tags, &flags.to_tag); struct call_monologue *sink = g_hash_table_lookup(call->tags, &flags.to_tag);
if (!sink) { if (!sink) {
@ -2668,6 +2671,22 @@ static const char *call_block_silence_media(bencode_item_t *input, bool on_off,
lcase_verb); lcase_verb);
return "Media flow not found (to-tag not found)"; return "Media flow not found (to-tag not found)";
} }
g_queue_push_tail(&sinks, sink);
}
else if (flags.to_label.len) {
struct call_monologue *sink = g_hash_table_lookup(call->labels, &flags.to_label);
if (!sink) {
ilog(LOG_WARN, "Media flow '" STR_FORMAT_M "' -> label '" STR_FORMAT "' doesn't "
"exist for media %s (to-label not found)",
STR_FMT_M(&monologue->tag), STR_FMT(&flags.to_label),
lcase_verb);
return "Media flow not found (to-label not found)";
}
g_queue_push_tail(&sinks, sink);
}
if (sinks.length) {
for (GList *l = sinks.head; l; l = l->next) {
struct call_monologue *sink = l->data;
GList *link = g_hash_table_lookup(monologue->subscribers_ht, sink); GList *link = g_hash_table_lookup(monologue->subscribers_ht, sink);
if (!link) { if (!link) {
ilog(LOG_WARN, "Media flow '" STR_FORMAT_M "' -> '" STR_FORMAT_M "' doesn't " ilog(LOG_WARN, "Media flow '" STR_FORMAT_M "' -> '" STR_FORMAT_M "' doesn't "
@ -2683,6 +2702,7 @@ static const char *call_block_silence_media(bencode_item_t *input, bool on_off,
ucase_verb, ucase_verb,
STR_FMT_M(&monologue->tag), STR_FMT_M(&sink->tag)); STR_FMT_M(&monologue->tag), STR_FMT_M(&sink->tag));
G_STRUCT_MEMBER(bool, &cs->attrs, attr_offset) = on_off; G_STRUCT_MEMBER(bool, &cs->attrs, attr_offset) = on_off;
}
update_init_subscribers(monologue, OP_OTHER); update_init_subscribers(monologue, OP_OTHER);
} }
else { else {
@ -2999,6 +3019,8 @@ const char *call_subscribe_request_ng(bencode_item_t *input, bencode_item_t *out
// the `label=` option was possibly used above to select the from-tag -- // the `label=` option was possibly used above to select the from-tag --
// switch it out with `to-label=` or `set-label=` for monologue_subscribe_request // switch it out with `to-label=` or `set-label=` for monologue_subscribe_request
// below which sets the label based on `label` for a newly created monologue // below which sets the label based on `label` for a newly created monologue
flags.label = flags.to_label;
if (flags.set_label.len) // set-label takes priority
flags.label = flags.set_label; flags.label = flags.set_label;
// get destination monologue // get destination monologue

@ -40,6 +40,7 @@ struct sdp_ng_flags {
str metadata; str metadata;
str label; str label;
str set_label; str set_label;
str to_label;
str address; str address;
sockaddr_t xmlrpc_callback; sockaddr_t xmlrpc_callback;
GQueue codec_strip; GQueue codec_strip;

Loading…
Cancel
Save