Browse Source

TT#147451 obsolete necessity for `from-tag` in unsub/sub ans

Change-Id: I409dbfb032265d0da39bff4cb63bf6dd5388cde4
mika/coverity
Richard Fuchs 4 years ago
parent
commit
4cbeb15c07
6 changed files with 76 additions and 58 deletions
  1. +7
    -5
      README.md
  2. +31
    -15
      daemon/call.c
  3. +16
    -18
      daemon/call_interfaces.c
  4. +2
    -1
      daemon/janus.c
  5. +2
    -2
      include/call.h
  6. +18
    -17
      t/auto-daemon-tests-pubsub.pl

+ 7
- 5
README.md View File

@ -2114,13 +2114,16 @@ the option to manipulate the codecs. The reply message will also contain the
`to-tag` (corresponding to the subscription, either generated or taken from the `to-tag` (corresponding to the subscription, either generated or taken from the
received message). received message).
If a `subscribe request` is made for an existing `to-tag` then all existing
subscriptions for that `to-tag` are deleted before the new subscriptions are
created.
`subscribe answer` Message `subscribe answer` Message
-------------------------- --------------------------
This message is expected to be received after responding to a `subscribe This message is expected to be received after responding to a `subscribe
request` message. The message should contain the same `from-tag` and `to-tag`
is the reply to the `subscribe request` (although `label` etc can also be used
instead of the `from-tag`), as well as the answer SDP in `sdp`.
request` message. The message should contain the same `to-tag` as the reply to
the `subscribe request` as well as the answer SDP in `sdp`.
By default, the answer SDP must accept all codecs that were presented in the By default, the answer SDP must accept all codecs that were presented in the
offer SDP (given in the reply to `subscribe request`). If not all codecs were offer SDP (given in the reply to `subscribe request`). If not all codecs were
@ -2139,8 +2142,7 @@ forwarding will start to the endpoint given in the answer SDP.
--------------------- ---------------------
This message is a counterpart to `subsscribe answer` to stop an established This message is a counterpart to `subsscribe answer` to stop an established
subscription. The subscription to be stopped is identified by `from-tag` and
`to`tag`.
subscription. The subscription to be stopped is identified by the `to-tag`.
The *tcp-ng* Control Protocol The *tcp-ng* Control Protocol
========================= =========================


+ 31
- 15
daemon/call.c View File

@ -2780,6 +2780,13 @@ static void __unsubscribe_all_offer_answer_subscribers(struct call_monologue *ml
l = next; l = next;
} }
} }
static void __unsubscribe_from_all(struct call_monologue *ml) {
for (GList *l = ml->subscriptions.head; l; ) {
GList *next = l->next;
__unsubscribe_one_link(ml, l);
l = next;
}
}
void __add_subscription(struct call_monologue *which, struct call_monologue *to, bool offer_answer) { void __add_subscription(struct call_monologue *which, struct call_monologue *to, bool offer_answer) {
if (g_hash_table_lookup(which->subscriptions_ht, to)) { if (g_hash_table_lookup(which->subscriptions_ht, to)) {
ilog(LOG_DEBUG, "Tag '" STR_FORMAT_M "' is already subscribed to '" STR_FORMAT_M "'", ilog(LOG_DEBUG, "Tag '" STR_FORMAT_M "' is already subscribed to '" STR_FORMAT_M "'",
@ -2886,6 +2893,8 @@ int monologue_publish(struct call_monologue *ml, GQueue *streams, struct sdp_ng_
int monologue_subscribe_request(struct call_monologue *src_ml, struct call_monologue *dst_ml, int monologue_subscribe_request(struct call_monologue *src_ml, struct call_monologue *dst_ml,
struct sdp_ng_flags *flags) struct sdp_ng_flags *flags)
{ {
__unsubscribe_from_all(dst_ml);
__call_monologue_init_from_flags(dst_ml, flags); __call_monologue_init_from_flags(dst_ml, flags);
GList *dst_media_it = NULL; GList *dst_media_it = NULL;
@ -2934,15 +2943,20 @@ int monologue_subscribe_request(struct call_monologue *src_ml, struct call_monol
return -1; return -1;
} }
__add_subscription(dst_ml, src_ml, false);
__update_init_subscribers(src_ml, NULL, NULL); __update_init_subscribers(src_ml, NULL, NULL);
__update_init_subscribers(dst_ml, NULL, NULL); __update_init_subscribers(dst_ml, NULL, NULL);
return 0; return 0;
} }
/* called with call->master_lock held in W */ /* called with call->master_lock held in W */
int monologue_subscribe_answer(struct call_monologue *src_ml, struct call_monologue *dst_ml,
struct sdp_ng_flags *flags, GQueue *streams)
{
int monologue_subscribe_answer(struct call_monologue *dst_ml, struct sdp_ng_flags *flags, GQueue *streams) {
if (!dst_ml->subscriptions.length)
return -1;
struct call_subscription *cs = dst_ml->subscriptions.head->data;
struct call_monologue *src_ml = cs->monologue;
GList *dst_media_it = NULL; GList *dst_media_it = NULL;
GList *src_media_it = NULL; GList *src_media_it = NULL;
@ -2981,9 +2995,6 @@ int monologue_subscribe_answer(struct call_monologue *src_ml, struct call_monolo
MEDIA_SET(dst_media, INITIALIZED); MEDIA_SET(dst_media, INITIALIZED);
} }
__unsubscribe_one(dst_ml, src_ml);
__add_subscription(dst_ml, src_ml, false);
__update_init_subscribers(dst_ml, streams, flags); __update_init_subscribers(dst_ml, streams, flags);
__update_init_subscribers(src_ml, NULL, NULL); __update_init_subscribers(src_ml, NULL, NULL);
@ -2994,17 +3005,22 @@ int monologue_subscribe_answer(struct call_monologue *src_ml, struct call_monolo
} }
/* called with call->master_lock held in W */ /* called with call->master_lock held in W */
int monologue_unsubscribe(struct call_monologue *src_ml, struct call_monologue *dst_ml,
struct sdp_ng_flags *flags)
{
if (!__unsubscribe_one(dst_ml, src_ml))
return -1;
int monologue_unsubscribe(struct call_monologue *dst_ml, struct sdp_ng_flags *flags) {
for (GList *l = dst_ml->subscriptions.head; l; ) {
GList *next = l->next;
struct call_subscription *cs = l->data;
struct call_monologue *src_ml = cs->monologue;
__update_init_subscribers(dst_ml, NULL, NULL);
__update_init_subscribers(src_ml, NULL, NULL);
__unsubscribe_one_link(dst_ml, l);
__dialogue_unkernelize(src_ml);
__dialogue_unkernelize(dst_ml);
__update_init_subscribers(dst_ml, NULL, NULL);
__update_init_subscribers(src_ml, NULL, NULL);
__dialogue_unkernelize(src_ml);
__dialogue_unkernelize(dst_ml);
l = next;
}
return 0; return 0;
} }


+ 16
- 18
daemon/call_interfaces.c View File

@ -2634,20 +2634,19 @@ const char *call_subscribe_request_ng(bencode_item_t *input, bencode_item_t *out
const char *call_subscribe_answer_ng(bencode_item_t *input, bencode_item_t *output) { const char *call_subscribe_answer_ng(bencode_item_t *input, bencode_item_t *output) {
const char *err = NULL;
AUTO_CLEANUP(struct sdp_ng_flags flags, call_ng_free_flags); AUTO_CLEANUP(struct sdp_ng_flags flags, call_ng_free_flags);
AUTO_CLEANUP(GQueue parsed, sdp_free) = G_QUEUE_INIT; AUTO_CLEANUP(GQueue parsed, sdp_free) = G_QUEUE_INIT;
AUTO_CLEANUP(GQueue streams, sdp_streams_free) = G_QUEUE_INIT; AUTO_CLEANUP(GQueue streams, sdp_streams_free) = G_QUEUE_INIT;
AUTO_CLEANUP_NULL(struct call *call, call_unlock_release); AUTO_CLEANUP_NULL(struct call *call, call_unlock_release);
struct call_monologue *source_ml;
// get source monologue
err = media_block_match(&call, &source_ml, &flags, input, OP_REQ_ANSWER);
if (err)
return err;
call_ng_process_flags(&flags, input, OP_REQ_ANSWER);
if (!flags.call_id.s)
return "No call-id in message";
call = call_get_opmode(&flags.call_id, OP_REQ_ANSWER);
if (!call)
return "Unknown call-ID";
if (!source_ml)
return "No call participant specified";
if (!flags.to_tag.s) if (!flags.to_tag.s)
return "No to-tag in message"; return "No to-tag in message";
if (!flags.sdp.len) if (!flags.sdp.len)
@ -2663,7 +2662,7 @@ const char *call_subscribe_answer_ng(bencode_item_t *input, bencode_item_t *outp
if (sdp_streams(&parsed, &streams, &flags)) if (sdp_streams(&parsed, &streams, &flags))
return "Incomplete SDP specification"; return "Incomplete SDP specification";
int ret = monologue_subscribe_answer(source_ml, dest_ml, &flags, &streams);
int ret = monologue_subscribe_answer(dest_ml, &flags, &streams);
if (ret) if (ret)
return "Failed to process subscription answer"; return "Failed to process subscription answer";
@ -2672,18 +2671,17 @@ const char *call_subscribe_answer_ng(bencode_item_t *input, bencode_item_t *outp
const char *call_unsubscribe_ng(bencode_item_t *input, bencode_item_t *output) { const char *call_unsubscribe_ng(bencode_item_t *input, bencode_item_t *output) {
const char *err = NULL;
AUTO_CLEANUP(struct sdp_ng_flags flags, call_ng_free_flags); AUTO_CLEANUP(struct sdp_ng_flags flags, call_ng_free_flags);
AUTO_CLEANUP_NULL(struct call *call, call_unlock_release); AUTO_CLEANUP_NULL(struct call *call, call_unlock_release);
struct call_monologue *source_ml;
// get source monologue
err = media_block_match(&call, &source_ml, &flags, input, OP_OTHER);
if (err)
return err;
call_ng_process_flags(&flags, input, OP_REQ_ANSWER);
if (!flags.call_id.s)
return "No call-id in message";
call = call_get_opmode(&flags.call_id, OP_REQ_ANSWER);
if (!call)
return "Unknown call-ID";
if (!source_ml)
return "No call participant specified";
if (!flags.to_tag.s) if (!flags.to_tag.s)
return "No to-tag in message"; return "No to-tag in message";
@ -2692,7 +2690,7 @@ const char *call_unsubscribe_ng(bencode_item_t *input, bencode_item_t *output) {
if (!dest_ml) if (!dest_ml)
return "To-tag not found"; return "To-tag not found";
int ret = monologue_unsubscribe(source_ml, dest_ml, &flags);
int ret = monologue_unsubscribe(dest_ml, &flags);
if (ret) if (ret)
return "Failed to unsubscribe"; return "Failed to unsubscribe";


+ 2
- 1
daemon/janus.c View File

@ -723,6 +723,7 @@ static const char *janus_videoroom_start(struct websocket_message *wm, struct ja
struct call_monologue *source_ml = call_get_monologue(call, &source_handle_str); struct call_monologue *source_ml = call_get_monologue(call, &source_handle_str);
if (!source_ml) if (!source_ml)
return "Feed not found"; return "Feed not found";
// XXX verify that dest_ml is subscribed to source_ml
AUTO_CLEANUP_GBUF(dest_handle_buf); AUTO_CLEANUP_GBUF(dest_handle_buf);
dest_handle_buf = g_strdup_printf("%" PRIu64, handle->id); dest_handle_buf = g_strdup_printf("%" PRIu64, handle->id);
@ -732,7 +733,7 @@ static const char *janus_videoroom_start(struct websocket_message *wm, struct ja
if (!dest_ml) if (!dest_ml)
return "Subscriber not found"; return "Subscriber not found";
int ret = monologue_subscribe_answer(source_ml, dest_ml, &flags, &streams);
int ret = monologue_subscribe_answer(dest_ml, &flags, &streams);
if (ret) if (ret)
return "Failed to process subscription answer"; return "Failed to process subscription answer";
} }


+ 2
- 2
include/call.h View File

@ -621,9 +621,9 @@ void codecs_offer_answer(struct call_media *media, struct call_media *other_medi
struct stream_params *sp, struct sdp_ng_flags *flags); struct stream_params *sp, struct sdp_ng_flags *flags);
int monologue_publish(struct call_monologue *ml, GQueue *streams, struct sdp_ng_flags *flags); int monologue_publish(struct call_monologue *ml, GQueue *streams, struct sdp_ng_flags *flags);
int monologue_subscribe_request(struct call_monologue *src, struct call_monologue *dst, struct sdp_ng_flags *); int monologue_subscribe_request(struct call_monologue *src, struct call_monologue *dst, struct sdp_ng_flags *);
int monologue_subscribe_answer(struct call_monologue *src, struct call_monologue *dst, struct sdp_ng_flags *,
int monologue_subscribe_answer(struct call_monologue *dst, struct sdp_ng_flags *,
GQueue *); GQueue *);
int monologue_unsubscribe(struct call_monologue *src, struct call_monologue *dst, struct sdp_ng_flags *);
int monologue_unsubscribe(struct call_monologue *dst, struct sdp_ng_flags *);
int monologue_destroy(struct call_monologue *ml); int monologue_destroy(struct call_monologue *ml);
int call_delete_branch(const str *callid, const str *branch, int call_delete_branch(const str *callid, const str *branch,
const str *fromtag, const str *totag, bencode_item_t *output, int delete_delay); const str *fromtag, const str *totag, bencode_item_t *output, int delete_delay);


+ 18
- 17
t/auto-daemon-tests-pubsub.pl View File

@ -96,7 +96,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('sub, multi codec, sub w diff codec', subscribe_answer('sub, multi codec, sub w diff codec',
{ 'from-tag' => ft(), 'to-tag' => $ttr, flags => ['allow transcoding'] }, <<SDP);
{ 'to-tag' => $ttr, flags => ['allow transcoding'] }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -271,7 +271,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('sub w tc - rej', subscribe_answer('sub w tc - rej',
{ 'from-tag' => ft(), 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -357,7 +357,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('simple sub', subscribe_answer('simple sub',
{ 'from-tag' => ft(), 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -443,7 +443,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('simple sub w label', subscribe_answer('simple sub w label',
{ label => 'foo', 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -514,7 +514,7 @@ snd($sock_a, $port_b, rtp(0, 4000, 7000, 0x6543, "\x00" x 160));
($ssrc_b) = rcv($sock_b, $port_a, rtpm(0, 4000, 7000, -1, "\x00" x 160)); ($ssrc_b) = rcv($sock_b, $port_a, rtpm(0, 4000, 7000, -1, "\x00" x 160));
($ftr, $ttr, $port_c) = subscribe_request('simple sub w to-tag label', ($ftr, $ttr, $port_c) = subscribe_request('simple sub w to-tag label',
{ label => 'foo' }, <<SDP);
{ label => 'bar' }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -526,10 +526,10 @@ a=sendonly
a=rtcp:PORT a=rtcp:PORT
SDP SDP
is $ftr, ft(), 'from-tag matches';
is $ftr, tt(), 'from-tag matches';
subscribe_answer('simple sub w to-tag label', subscribe_answer('simple sub w to-tag label',
{ label => 'bar', 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -628,7 +628,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('SRTP sub', subscribe_answer('SRTP sub',
{ 'from-tag' => ft(), 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -734,7 +734,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('SRTP sub', subscribe_answer('SRTP sub',
{ 'from-tag' => ft(), 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -854,7 +854,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('SRTP call RTP sub', subscribe_answer('SRTP call RTP sub',
{ 'from-tag' => ft(), 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -947,7 +947,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('ICE sub', subscribe_answer('ICE sub',
{ 'from-tag' => ft(), 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -1013,7 +1013,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('publish/subscribe', subscribe_answer('publish/subscribe',
{ 'from-tag' => ft(), 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -1042,7 +1042,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('publish/subscribe', subscribe_answer('publish/subscribe',
{ 'from-tag' => ft(), 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -1103,7 +1103,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('publish/subscribe w codec-accept', subscribe_answer('publish/subscribe w codec-accept',
{ 'from-tag' => ft(), 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -1132,7 +1132,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('publish/subscribe w codec-accept', subscribe_answer('publish/subscribe w codec-accept',
{ 'from-tag' => ft(), 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -1193,7 +1193,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('publish/subscribe w unsupp and t/c', subscribe_answer('publish/subscribe w unsupp and t/c',
{ 'from-tag' => ft(), 'to-tag' => $ttr }, <<SDP);
{ 'to-tag' => $ttr }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -1222,7 +1222,7 @@ SDP
is $ftr, ft(), 'from-tag matches'; is $ftr, ft(), 'from-tag matches';
subscribe_answer('publish/subscribe w unsupp and t/c', subscribe_answer('publish/subscribe w unsupp and t/c',
{ 'from-tag' => ft(), 'to-tag' => $ttr, flags => ['allow transcoding'] }, <<SDP);
{ 'to-tag' => $ttr, flags => ['allow transcoding'] }, <<SDP);
v=0 v=0
o=- 1545997027 1 IN IP4 198.51.100.1 o=- 1545997027 1 IN IP4 198.51.100.1
s=tester s=tester
@ -1239,3 +1239,4 @@ rcv($sock_c, $port_c, rtpm(0, 2002, 4320, 0x3456, "\x29" x 160));
done_testing(); done_testing();
#done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit;

Loading…
Cancel
Save