TT#12800 support custom monologue labels

Change-Id: I55b2db88307088c4d5e0161eae6e3aa0b5d1b053
changes/49/12749/8
Richard Fuchs 9 years ago
parent 2cf93904df
commit ab0dba7d14

@ -801,6 +801,11 @@ Optionally included keys are:
The SIP `Via` branch as string. Used to additionally refine the matching logic between media streams
and calls and call branches.
* `label`
A custom free-form string which *rtpengine* remembers for this participating endpoint and reports
back in logs and statistics output.
* `flags`
The value of the `flags` key is a list. The list contains zero or more of the following strings.
@ -1165,6 +1170,10 @@ The response dictionary contains the following keys:
Identical to the corresponding key of the `tags` dictionary. Provided to allow for easy
traversing of the dictionary values without paying attention to the keys.
- `label`
The label assigned to this endpoint in the `offer` or `answer` message.
- `in dialogue with`
Contains the SIP tag of the other side of this dialogue. May be missing in case of a

@ -1853,9 +1853,12 @@ void call_destroy(struct call *c) {
for (l = c->monologues.head; l; l = l->next) {
ml = l->data;
ilog(LOG_INFO, "--- Tag '"STR_FORMAT"', created "
ilog(LOG_INFO, "--- Tag '"STR_FORMAT"'%s"STR_FORMAT"%s, created "
"%u:%02u ago for branch '"STR_FORMAT"', in dialogue with '"STR_FORMAT"'",
STR_FMT(&ml->tag),
ml->label.s ? " (label '" : "",
STR_FMT(ml->label.s ? &ml->label : &STR_EMPTY),
ml->label.s ? "')" : "",
(unsigned int) (poller_now - ml->created) / 60,
(unsigned int) (poller_now - ml->created) % 60,
STR_FMT(&ml->viabranch),
@ -2238,14 +2241,22 @@ static int monologue_destroy(struct call_monologue *ml) {
__monologue_destroy(ml);
if (!g_hash_table_size(c->tags)) {
ilog(LOG_INFO, "Call branch '"STR_FORMAT"' (via-branch '"STR_FORMAT"') "
ilog(LOG_INFO, "Call branch '"STR_FORMAT"' (%s"STR_FORMAT"%svia-branch '"STR_FORMAT"') "
"deleted, no more branches remaining",
STR_FMT(&ml->tag), STR_FMT0(&ml->viabranch));
STR_FMT(&ml->tag),
ml->label.s ? "label '" : "",
STR_FMT(ml->label.s ? &ml->label : &STR_EMPTY),
ml->label.s ? "', " : "",
STR_FMT0(&ml->viabranch));
return 1; /* destroy call */
}
ilog(LOG_INFO, "Call branch '"STR_FORMAT"' (via-branch '"STR_FORMAT"') deleted",
STR_FMT(&ml->tag), STR_FMT0(&ml->viabranch));
ilog(LOG_INFO, "Call branch '"STR_FORMAT"' (%s"STR_FORMAT"%svia-branch '"STR_FORMAT"') deleted",
STR_FMT(&ml->tag),
ml->label.s ? "label '" : "",
STR_FMT(ml->label.s ? &ml->label : &STR_EMPTY),
ml->label.s ? "', " : "",
STR_FMT0(&ml->viabranch));
return 0;
}

@ -340,7 +340,8 @@ struct call_monologue {
str tag;
str viabranch;
enum tag_type tagtype;
enum tag_type tagtype;
str label;
time_t created; /* RO */
time_t deleted;
struct timeval started; /* for CDR */

@ -656,6 +656,7 @@ static const char *call_offer_answer_ng(bencode_item_t *input, struct callmaster
const endpoint_t *sin)
{
str sdp, fromtag, totag = STR_NULL, callid, viabranch;
str label = STR_NULL;
char *errstr;
GQueue parsed = G_QUEUE_INIT;
GQueue streams = G_QUEUE_INIT;
@ -678,6 +679,7 @@ static const char *call_offer_answer_ng(bencode_item_t *input, struct callmaster
str_swap(&totag, &fromtag);
}
bencode_dictionary_get_str(input, "via-branch", &viabranch);
bencode_dictionary_get_str(input, "label", &label);
if (sdp_parse(&sdp, &parsed))
return "Failed to parse SDP";
@ -737,6 +739,8 @@ static const char *call_offer_answer_ng(bencode_item_t *input, struct callmaster
} else {
monologue->tagtype = TO_TAG;
}
if (label.s && !monologue->label.s)
call_str_cpy(call, &monologue->label, &label);
chopper = sdp_chopper_new(&sdp);
bencode_buffer_destroy_add(output->buffer, (free_func_t) sdp_chopper_destroy, chopper);
@ -999,6 +1003,8 @@ static void ng_stats_monologue(bencode_item_t *dict, const struct call_monologue
bencode_dictionary_add_str(sub, "tag", &ml->tag);
if (ml->viabranch.s)
bencode_dictionary_add_str(sub, "via-branch", &ml->viabranch);
if (ml->label.s)
bencode_dictionary_add_str(sub, "label", &ml->label);
bencode_dictionary_add_integer(sub, "created", ml->created);
if (ml->active_dialogue)
bencode_dictionary_add_str(sub, "in dialogue with", &ml->active_dialogue->tag);

@ -1129,6 +1129,8 @@ static int redis_tags(struct call *c, struct redis_list *tags) {
__monologue_tag(ml, &s);
if (!redis_hash_get_str(&s, rh, "via-branch"))
__monologue_viabranch(ml, &s);
if (!redis_hash_get_str(&s, rh, "label"))
call_str_cpy(c, &ml->label, &s);
redis_hash_get_time_t(&ml->deleted, rh, "deleted");
tags->ptrs[i] = ml;
@ -1849,12 +1851,12 @@ char* redis_encode_json(struct call *c) {
JSON_SET_SIMPLE("active","%u",ml->active_dialogue ? ml->active_dialogue->unique_id : -1);
JSON_SET_SIMPLE("deleted","%llu",(long long unsigned) ml->deleted);
if (ml->tag.s) {
if (ml->tag.s)
JSON_SET_SIMPLE_STR("tag",&ml->tag);
}
if (ml->viabranch.s) {
if (ml->viabranch.s)
JSON_SET_SIMPLE_STR("via-branch",&ml->viabranch);
}
if (ml->label.s)
JSON_SET_SIMPLE_STR("label",&ml->label);
}
json_builder_end_object (builder);

@ -271,7 +271,7 @@ sub _default_req_args {
my $req = { command => $cmd, 'call-id' => $self->{parent}->{callid} };
for my $cp (qw(sdp from-tag to-tag ICE transport-protocol address-family)) {
for my $cp (qw(sdp from-tag to-tag ICE transport-protocol address-family label)) {
$args{$cp} and $req->{$cp} = $args{$cp};
}
for my $cp (@{$args{flags}}) {

@ -12,16 +12,16 @@ my ($a, $b) = $r->client_pair(
);
$r->timer_once(3, sub {
$b->answer($a, ICE => 'remove');
$b->answer($a, ICE => 'remove', label => "callee");
$a->start_rtp();
$a->start_rtcp();
});
$r->timer_once(10, sub { $r->stop(); });
$a->offer($b, ICE => 'remove');
$a->offer($b, ICE => 'remove', label => "caller");
$b->start_rtp();
$b->start_rtcp();
$r->run();
$a->teardown();
$a->teardown(dump => 1);

@ -666,6 +666,7 @@ a=rtpmap:111 opus/48000/2
#direction => [ $$pr{direction}, $$pr_o{direction} ],
'received from' => [ qw(IP4 127.0.0.1) ],
'rtcp-mux' => ['demux'],
label => rand(),
};
$PORT_LATCHING and push(@flags, 'port latching');
$RECORD and push(@flags, 'record call');

Loading…
Cancel
Save