Browse Source

provide sendrecv mode in siprec tag-medias and media-labels

pull/1457/head
Razvan Crainea 4 years ago
parent
commit
9c62de8189
4 changed files with 492 additions and 6 deletions
  1. +2
    -0
      daemon/call_interfaces.c
  2. +11
    -6
      daemon/sdp.c
  3. +1
    -0
      include/sdp.h
  4. +478
    -0
      t/auto-daemon-tests-pubsub.pl

+ 2
- 0
daemon/call_interfaces.c View File

@ -3032,6 +3032,7 @@ const char *call_subscribe_request_ng(bencode_item_t *input, bencode_item_t *out
bencode_dictionary_add_integer(med_ent, "index", media->index);
bencode_dictionary_add_str(med_ent, "type", &media->type);
bencode_dictionary_add_str(med_ent, "label", &media->label);
bencode_dictionary_add_string(med_ent, "mode", sdp_get_sendrecv(media));
if (media_labels) {
bencode_item_t *label =
@ -3041,6 +3042,7 @@ const char *call_subscribe_request_ng(bencode_item_t *input, bencode_item_t *out
bencode_dictionary_add_str(label, "type", &media->type);
if (source_ml->label.len)
bencode_dictionary_add_str(label, "label", &source_ml->label);
bencode_dictionary_add_string(label, "mode", sdp_get_sendrecv(media));
}
}
}


+ 11
- 6
daemon/sdp.c View File

@ -2514,16 +2514,21 @@ dup:
monologue->last_out_sdp = g_string_new_len(chop->output->str, chop->output->len);
}
void print_sendrecv(GString *s, struct call_media *media) {
const char *sdp_get_sendrecv(struct call_media *media) {
if (MEDIA_ARESET2(media, SEND, RECV))
g_string_append(s, "a=sendrecv\r\n");
return "sendrecv";
else if (MEDIA_ISSET(media, SEND))
g_string_append(s, "a=sendonly\r\n");
return "sendonly";
else if (MEDIA_ISSET(media, RECV))
g_string_append(s, "a=recvonly\r\n");
return "recvonly";
else
g_string_append(s, "a=inactive\r\n");
return "inactive";
}
void print_sendrecv(GString *s, struct call_media *media) {
g_string_append(s, "a=");
g_string_append(s, sdp_get_sendrecv(media));
g_string_append(s, "\r\n");
}


+ 1
- 0
include/sdp.h View File

@ -27,6 +27,7 @@ void sdp_free(GQueue *sessions);
int sdp_replace(struct sdp_chopper *, GQueue *, struct call_monologue *, struct sdp_ng_flags *);
int sdp_is_duplicate(GQueue *sessions);
int sdp_create(str *out, struct call_monologue *, struct sdp_ng_flags *flags);
const char *sdp_get_sendrecv(struct call_media *media);
int sdp_parse_candidate(struct ice_candidate *cand, const str *s); // returns -1, 0, 1


+ 478
- 0
t/auto-daemon-tests-pubsub.pl View File

@ -102,6 +102,7 @@ is_deeply $tag_medias, [
index => 1,
type => 'audio',
label => '1',
mode => 'sendrecv',
},
],
},
@ -112,6 +113,7 @@ is_deeply $tag_medias, [
index => 1,
type => 'audio',
label => '0',
mode => 'sendrecv',
},
],
},
@ -121,11 +123,13 @@ is_deeply $media_labels, {
index => 1,
type => 'audio',
tag => ft(),
mode => 'sendrecv',
},
'0' => {
index => 1,
type => 'audio',
tag => tt(),
mode => 'sendrecv',
},
}, 'media-labels match';
@ -207,6 +211,7 @@ is_deeply $tag_medias, [
index => 1,
type => 'audio',
label => '1',
mode => 'sendrecv',
},
],
},
@ -218,6 +223,7 @@ is_deeply $tag_medias, [
index => 1,
type => 'audio',
label => '0',
mode => 'sendrecv',
},
],
},
@ -228,12 +234,14 @@ is_deeply $media_labels, {
type => 'audio',
tag => ft(),
label => 'caller',
mode => 'sendrecv',
},
'0' => {
index => 1,
type => 'audio',
tag => tt(),
label => 'called',
mode => 'sendrecv',
},
}, 'media-labels match';
@ -881,6 +889,476 @@ rcv($sock_c, $port_c, rtpm(0, 4001, 7640, $ssrc_b, "\x00" x 160));
($sock_a, $sock_b, $sock_c, $sock_d) =
new_call([qw(198.51.100.14 6118)], [qw(198.51.100.14 6120)], [qw(198.51.100.14 6122)],
[qw(198.51.100.14 6124)]);
($port_a) = offer('SIPREC sub pause/resume',
{ }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6118 RTP/AVP 0
c=IN IP4 198.51.100.14
a=sendrecv
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
($port_b) = answer('SIPREC sub pause/resume',
{ }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6120 RTP/AVP 0
c=IN IP4 198.51.100.14
a=sendrecv
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
snd($sock_b, $port_a, rtp(0, 2000, 4000, 0x3456, "\x00" x 160));
rcv($sock_a, $port_b, rtpm(0, 2000, 4000, 0x3456, "\x00" x 160));
snd($sock_a, $port_b, rtp(0, 4000, 7000, 0x6543, "\x00" x 160));
rcv($sock_b, $port_a, rtpm(0, 4000, 7000, 0x6543, "\x00" x 160));
(undef, $ttr, undef, undef, undef, $port_c, undef, $port_d) = subscribe_request('SIPREC sub pause/resume',
{ flags => ['all', 'SIPREC'] }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=label:1
a=rtpmap:0 PCMU/8000
a=sendonly
a=rtcp:PORT
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=label:0
a=rtpmap:0 PCMU/8000
a=sendonly
a=rtcp:PORT
SDP
subscribe_answer('SIPREC sub pause/resume',
{ 'to-tag' => $ttr }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6122 RTP/AVP 0
c=IN IP4 198.51.100.14
a=label:1
a=recvonly
m=audio 6124 RTP/AVP 0
c=IN IP4 198.51.100.14
a=label:0
a=recvonly
SDP
snd($sock_b, $port_a, rtp(0, 2001, 4160, 0x3456, "\x00" x 160));
rcv($sock_a, $port_b, rtpm(0, 2001, 4160, 0x3456, "\x00" x 160));
rcv($sock_d, $port_d, rtpm(0, 2001, 4160, 0x3456, "\x00" x 160));
snd($sock_a, $port_b, rtp(0, 4001, 7160, 0x6543, "\x00" x 160));
rcv($sock_b, $port_a, rtpm(0, 4001, 7160, 0x6543, "\x00" x 160));
rcv($sock_c, $port_c, rtpm(0, 4001, 7160, 0x6543, "\x00" x 160));
print("PORT_A: ".$port_a."\n");
print("PORT_B: ".$port_b."\n");
print("PORT_C: ".$port_c."\n");
print("PORT_D: ".$port_d."\n");
($port_b) = offer('SIPREC sub pause/resume',
{ 'from-tag' => tt(), 'to-tag' => ft() }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6120 RTP/AVP 0
c=IN IP4 198.51.100.14
a=sendonly
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=sendonly
a=rtcp:PORT
SDP
($port_a) = answer('SIPREC sub pause/resume',
{ 'from-tag' => tt(), 'to-tag' => ft() }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6118 RTP/AVP 0
c=IN IP4 198.51.100.14
a=recvonly
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=recvonly
a=rtcp:PORT
SDP
(undef, undef, undef, $tag_medias, $media_labels, $port_c, undef, $port_d) = subscribe_request('SIPREC sub pause/resume',
{ flags => ['all', 'SIPREC'], 'to-tag' => $ttr }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=label:1
a=rtpmap:0 PCMU/8000
a=inactive
a=rtcp:PORT
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=label:0
a=rtpmap:0 PCMU/8000
a=sendonly
a=rtcp:PORT
SDP
is_deeply $tag_medias, [
{
tag => ft(),
medias => [
{
index => 1,
type => 'audio',
label => '1',
mode => 'sendonly',
},
],
},
{
tag => tt(),
medias => [
{
index => 1,
type => 'audio',
label => '0',
mode => 'recvonly',
},
],
},
], 'SIPREC sub pause/resume - tag-medias match';
is_deeply $media_labels, {
'1' => {
index => 1,
type => 'audio',
tag => ft(),
mode => 'sendonly',
},
'0' => {
index => 1,
type => 'audio',
tag => tt(),
mode => 'recvonly',
},
}, 'SIPREC sub pause/resume - media-labels match';
subscribe_answer('SIPREC sub pause/resume',
{ 'to-tag' => $ttr }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6122 RTP/AVP 0
c=IN IP4 198.51.100.14
a=label:1
a=inactive
m=audio 6124 RTP/AVP 0
c=IN IP4 198.51.100.14
a=label:0
a=recvonly
SDP
snd($sock_b, $port_a, rtp(0, 2001, 4320, 0x3456, "\x00" x 160));
rcv($sock_a, $port_b, rtpm(0, 2001, 4320, 0x3456, "\x00" x 160));
rcv($sock_d, $port_d, rtpm(0, 2001, 4320, 0x3456, "\x00" x 160));
($port_b) = offer('SIPREC sub pause/resume',
{ 'from-tag' => tt(), 'to-tag' => ft() }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6120 RTP/AVP 0
c=IN IP4 198.51.100.14
a=sendrecv
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
($port_a) = answer('SIPREC sub pause/resume',
{ 'from-tag' => tt(), 'to-tag' => ft() }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6118 RTP/AVP 0
c=IN IP4 198.51.100.14
a=sendrecv
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
(undef, $ttr, undef, $tag_medias, $media_labels, $port_c, undef, $port_d) = subscribe_request('SIPREC sub pause/resume',
{ flags => ['all', 'SIPREC'], 'to-tag' => $ttr }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=label:1
a=rtpmap:0 PCMU/8000
a=sendonly
a=rtcp:PORT
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=label:0
a=rtpmap:0 PCMU/8000
a=sendonly
a=rtcp:PORT
SDP
is_deeply $tag_medias, [
{
tag => ft(),
medias => [
{
index => 1,
type => 'audio',
label => '1',
mode => 'sendrecv',
},
],
},
{
tag => tt(),
medias => [
{
index => 1,
type => 'audio',
label => '0',
mode => 'sendrecv',
},
],
},
], 'SIPREC sub pause/resume - tag-medias match';
is_deeply $media_labels, {
'1' => {
index => 1,
type => 'audio',
tag => ft(),
mode => 'sendrecv',
},
'0' => {
index => 1,
type => 'audio',
tag => tt(),
mode => 'sendrecv',
},
}, 'SIPREC sub pause/resume - media-labels match';
subscribe_answer('SIPREC sub pause/resume',
{ 'to-tag' => $ttr }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6122 RTP/AVP 0
c=IN IP4 198.51.100.14
a=label:1
a=recvonly
m=audio 6124 RTP/AVP 0
c=IN IP4 198.51.100.14
a=label:0
a=recvonly
SDP
snd($sock_b, $port_a, rtp(0, 2001, 4480, 0x3456, "\x00" x 160));
rcv($sock_a, $port_b, rtpm(0, 2001, 4480, 0x3456, "\x00" x 160));
rcv($sock_d, $port_d, rtpm(0, 2001, 4480, 0x3456, "\x00" x 160));
snd($sock_a, $port_b, rtp(0, 4001, 7320, 0x6543, "\x00" x 160));
rcv($sock_b, $port_a, rtpm(0, 4001, 7320, 0x6543, "\x00" x 160));
rcv($sock_c, $port_c, rtpm(0, 4001, 7320, 0x6543, "\x00" x 160));
($port_a) = offer('SIPREC sub pause/resume',
{ 'from-tag' => ft(), 'to-tag' => tt() }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6118 RTP/AVP 0
c=IN IP4 198.51.100.14
a=sendonly
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=sendonly
a=rtcp:PORT
SDP
($port_b) = answer('SIPREC sub pause/resume',
{ 'from-tag' => ft(), 'to-tag' => tt() }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6120 RTP/AVP 0
c=IN IP4 198.51.100.14
a=recvonly
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=recvonly
a=rtcp:PORT
SDP
(undef, undef, undef, $tag_medias, $media_labels, $port_c, undef, $port_d) = subscribe_request('SIPREC sub pause/resume',
{ flags => ['all', 'SIPREC'], 'to-tag' => $ttr }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=label:1
a=rtpmap:0 PCMU/8000
a=sendonly
a=rtcp:PORT
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=label:0
a=rtpmap:0 PCMU/8000
a=inactive
a=rtcp:PORT
SDP
is_deeply $tag_medias, [
{
tag => ft(),
medias => [
{
index => 1,
type => 'audio',
label => '1',
mode => 'recvonly',
},
],
},
{
tag => tt(),
medias => [
{
index => 1,
type => 'audio',
label => '0',
mode => 'sendonly',
},
],
},
], 'tag-medias match';
is_deeply $media_labels, {
'1' => {
index => 1,
type => 'audio',
tag => ft(),
mode => 'recvonly',
},
'0' => {
index => 1,
type => 'audio',
tag => tt(),
mode => 'sendonly',
},
}, 'media-labels match';
subscribe_answer('SIPREC sub pause/resume',
{ 'to-tag' => $ttr }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 6122 RTP/AVP 0
c=IN IP4 198.51.100.14
a=label:1
a=recvonly
m=audio 6124 RTP/AVP 0
c=IN IP4 198.51.100.14
a=label:0
a=inactive
SDP
snd($sock_a, $port_b, rtp(0, 4001, 7480, 0x6543, "\x00" x 160));
rcv($sock_b, $port_a, rtpm(0, 4001, 7480, 0x6543, "\x00" x 160));
rcv($sock_c, $port_c, rtpm(0, 4001, 7480, 0x6543, "\x00" x 160));
($sock_a, $sock_b, $sock_c) =
new_call([qw(198.51.100.14 6060)], [qw(198.51.100.14 6062)], [qw(198.51.100.14 6064)]);


Loading…
Cancel
Save