|
|
|
@ -122,7 +122,7 @@ sub rcv { |
|
|
|
my $addr = $sock->recv($p, 65535, 0) or die; |
|
|
|
alarm(0); |
|
|
|
my ($hdr_mark, $pt, $seq, $ts, $ssrc, $payload) = unpack('CCnNN a*', $p); |
|
|
|
print("rtp recv $pt $seq $ts $ssrc\n"); |
|
|
|
print("rtp recv $pt $seq $ts $ssrc " . unpack('H*', $payload) . "\n"); |
|
|
|
if ($cb) { |
|
|
|
$p = $cb->($hdr_mark, $pt, $seq, $ts, $ssrc, $payload, $p, $cb_arg); |
|
|
|
} |
|
|
|
@ -158,7 +158,7 @@ sub escape { |
|
|
|
} |
|
|
|
sub rtpm { |
|
|
|
my ($pt, $seq, $ts, $ssrc, $payload) = @_; |
|
|
|
print("rtp matcher $pt $seq $ts $ssrc\n"); |
|
|
|
print("rtp matcher $pt $seq $ts $ssrc " . unpack('H*', $payload) . "\n"); |
|
|
|
my $re = ''; |
|
|
|
$re .= escape(pack('C', 0x80)); |
|
|
|
$re .= escape(pack('C', $pt)); |
|
|
|
@ -1969,8 +1969,8 @@ rcv($sock_a, $port_b, rtpm(0, 4002, 5800, $ssrc, "\x88" x 400)); |
|
|
|
|
|
|
|
($sock_a, $sock_b) = new_call([qw(198.51.100.1 3016)], [qw(198.51.100.3 3018)]); |
|
|
|
|
|
|
|
($port_a) = offer('ptime=50 in, change to 30, response 30, change to 50', { |
|
|
|
ICE => 'remove', replace => ['origin'], ptime => 30 }, <<SDP); |
|
|
|
($port_a) = offer('ptime=50 in, change to 30, reverse to 50, response 30', { |
|
|
|
ICE => 'remove', replace => ['origin'], ptime => 30, 'ptime-reverse' => 50 }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.1 |
|
|
|
s=tester |
|
|
|
@ -1992,8 +1992,8 @@ a=rtcp:PORT |
|
|
|
a=ptime:30 |
|
|
|
SDP |
|
|
|
|
|
|
|
($port_b) = answer('ptime=50 in, change to 30, response 30, change to 50', |
|
|
|
{ ICE => 'remove', replace => ['origin'], ptime => 50 }, <<SDP); |
|
|
|
($port_b) = answer('ptime=50 in, change to 30, reverse to 50, response 30', |
|
|
|
{ ICE => 'remove', replace => ['origin'] }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.3 |
|
|
|
s=tester |
|
|
|
@ -2042,7 +2042,7 @@ rcv($sock_a, $port_b, rtpm(0, 4002, 5800, $ssrc, "\x88" x 400)); |
|
|
|
|
|
|
|
($sock_a, $sock_b) = new_call([qw(198.51.100.1 3012)], [qw(198.51.100.3 3014)]); |
|
|
|
|
|
|
|
($port_a) = offer('ptime=50 in, change to 30, response 30, no change', { |
|
|
|
($port_a) = offer('ptime=50 in, change to 30, response 30', { |
|
|
|
ICE => 'remove', replace => ['origin'], ptime => 30 }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.1 |
|
|
|
@ -2065,7 +2065,7 @@ a=rtcp:PORT |
|
|
|
a=ptime:30 |
|
|
|
SDP |
|
|
|
|
|
|
|
($port_b) = answer('ptime=50 in, change to 30, response 30, no change', |
|
|
|
($port_b) = answer('ptime=50 in, change to 30, response 30', |
|
|
|
{ ICE => 'remove', replace => ['origin'] }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.3 |
|
|
|
@ -2113,6 +2113,296 @@ rcv($sock_a, $port_b, rtpm(0, 4002, 5800, $ssrc, "\x88" x 400)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
($sock_a, $sock_b) = new_call([qw(198.51.100.1 3016)], [qw(198.51.100.3 3018)]); |
|
|
|
|
|
|
|
($port_a) = offer('ptime=50 in, change to 30, reverse to 50, default response', { |
|
|
|
ICE => 'remove', replace => ['origin'], ptime => 30, 'ptime-reverse' => 50 }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.1 |
|
|
|
s=tester |
|
|
|
t=0 0 |
|
|
|
m=audio 3016 RTP/AVP 0 |
|
|
|
c=IN IP4 198.51.100.1 |
|
|
|
a=sendrecv |
|
|
|
a=ptime:50 |
|
|
|
---------------------------------- |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 203.0.113.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 |
|
|
|
a=ptime:30 |
|
|
|
SDP |
|
|
|
|
|
|
|
($port_b) = answer('ptime=50 in, change to 30, reverse to 50, default response', |
|
|
|
{ ICE => 'remove', replace => ['origin'] }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.3 |
|
|
|
s=tester |
|
|
|
t=0 0 |
|
|
|
m=audio 3018 RTP/AVP 0 |
|
|
|
c=IN IP4 198.51.100.3 |
|
|
|
a=sendrecv |
|
|
|
-------------------------------------- |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 203.0.113.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 |
|
|
|
a=ptime:50 |
|
|
|
SDP |
|
|
|
|
|
|
|
# A->B: 2x 50 ms -> 3x 30 ms (plus 10 ms left) |
|
|
|
snd($sock_a, $port_b, rtp(0, 1000, 3000, 0x1234, "\00" x 400)); |
|
|
|
($ssrc) = rcv($sock_b, $port_a, rtpm(0, 1000, 3000, -1, "\00" x 240)); |
|
|
|
snd($sock_a, $port_b, rtp(0, 1001, 3400, 0x1234, "\00" x 400)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1001, 3240, $ssrc, "\00" x 240)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1002, 3480, $ssrc, "\00" x 240)); |
|
|
|
# A->B: add another 20 ms for another full 30 ms |
|
|
|
snd($sock_a, $port_b, rtp(0, 1002, 3800, 0x1234, "\00" x 160)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1003, 3720, $ssrc, "\00" x 240)); |
|
|
|
|
|
|
|
# B->A: 4x 30 ms -> 2x 50 ms (plus 20 ms left) |
|
|
|
snd($sock_b, $port_a, rtp(0, 4000, 5000, 0x4567, "\x88" x 240)); |
|
|
|
Time::HiRes::usleep(20000); # 20 ms, needed to ensure that packet 1000 is received first |
|
|
|
snd($sock_b, $port_a, rtp(0, 4001, 5240, 0x4567, "\x88" x 240)); |
|
|
|
($ssrc) = rcv($sock_a, $port_b, rtpm(0, 4000, 5000, -1, "\x88" x 400)); |
|
|
|
snd($sock_b, $port_a, rtp(0, 4002, 5480, 0x4567, "\x88" x 240)); |
|
|
|
snd($sock_b, $port_a, rtp(0, 4003, 5720, 0x4567, "\x88" x 240)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4001, 5400, $ssrc, "\x88" x 400)); |
|
|
|
# B->A: add another 30 ms for another full 50 ms |
|
|
|
snd($sock_b, $port_a, rtp(0, 4004, 5960, 0x4567, "\x88" x 240)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4002, 5800, $ssrc, "\x88" x 400)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
($sock_a, $sock_b) = new_call([qw(198.51.100.1 3016)], [qw(198.51.100.3 3018)]); |
|
|
|
|
|
|
|
($port_a) = offer('ptime=50 in, change to 30, reverse to 20, default response', { |
|
|
|
ICE => 'remove', replace => ['origin'], ptime => 30, 'ptime-reverse' => 20 }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.1 |
|
|
|
s=tester |
|
|
|
t=0 0 |
|
|
|
m=audio 3016 RTP/AVP 0 |
|
|
|
c=IN IP4 198.51.100.1 |
|
|
|
a=sendrecv |
|
|
|
a=ptime:50 |
|
|
|
---------------------------------- |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 203.0.113.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 |
|
|
|
a=ptime:30 |
|
|
|
SDP |
|
|
|
|
|
|
|
($port_b) = answer('ptime=50 in, change to 30, reverse to 20, default response', |
|
|
|
{ ICE => 'remove', replace => ['origin'] }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.3 |
|
|
|
s=tester |
|
|
|
t=0 0 |
|
|
|
m=audio 3018 RTP/AVP 0 |
|
|
|
c=IN IP4 198.51.100.3 |
|
|
|
a=sendrecv |
|
|
|
-------------------------------------- |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 203.0.113.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 |
|
|
|
a=ptime:20 |
|
|
|
SDP |
|
|
|
|
|
|
|
# A->B: 2x 50 ms -> 3x 30 ms (plus 10 ms left) |
|
|
|
snd($sock_a, $port_b, rtp(0, 1000, 3000, 0x1234, "\00" x 400)); |
|
|
|
($ssrc) = rcv($sock_b, $port_a, rtpm(0, 1000, 3000, -1, "\00" x 240)); |
|
|
|
snd($sock_a, $port_b, rtp(0, 1001, 3400, 0x1234, "\00" x 400)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1001, 3240, $ssrc, "\00" x 240)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1002, 3480, $ssrc, "\00" x 240)); |
|
|
|
# A->B: add another 20 ms for another full 30 ms |
|
|
|
snd($sock_a, $port_b, rtp(0, 1002, 3800, 0x1234, "\00" x 160)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1003, 3720, $ssrc, "\00" x 240)); |
|
|
|
|
|
|
|
# B->A: 4x 30 ms -> 6x 20 ms |
|
|
|
snd($sock_b, $port_a, rtp(0, 4000, 5000, 0x4567, "\x88" x 240)); |
|
|
|
($ssrc) = rcv($sock_a, $port_b, rtpm(0, 4000, 5000, -1, "\x88" x 160)); |
|
|
|
snd($sock_b, $port_a, rtp(0, 4001, 5240, 0x4567, "\x88" x 240)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4001, 5160, $ssrc, "\x88" x 160)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4002, 5320, $ssrc, "\x88" x 160)); |
|
|
|
snd($sock_b, $port_a, rtp(0, 4002, 5480, 0x4567, "\x88" x 240)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4003, 5480, $ssrc, "\x88" x 160)); |
|
|
|
snd($sock_b, $port_a, rtp(0, 4003, 5720, 0x4567, "\x88" x 240)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4004, 5640, $ssrc, "\x88" x 160)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4005, 5800, $ssrc, "\x88" x 160)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
($sock_a, $sock_b) = new_call([qw(198.51.100.1 3016)], [qw(198.51.100.3 3018)]); |
|
|
|
|
|
|
|
($port_a) = offer('ptime=50 in, change to 30, reverse to 20, response 40', { |
|
|
|
ICE => 'remove', replace => ['origin'], ptime => 30, 'ptime-reverse' => 20 }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.1 |
|
|
|
s=tester |
|
|
|
t=0 0 |
|
|
|
m=audio 3016 RTP/AVP 0 |
|
|
|
c=IN IP4 198.51.100.1 |
|
|
|
a=sendrecv |
|
|
|
a=ptime:50 |
|
|
|
---------------------------------- |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 203.0.113.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 |
|
|
|
a=ptime:30 |
|
|
|
SDP |
|
|
|
|
|
|
|
($port_b) = answer('ptime=50 in, change to 30, reverse to 20, response 40', |
|
|
|
{ ICE => 'remove', replace => ['origin'] }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.3 |
|
|
|
s=tester |
|
|
|
t=0 0 |
|
|
|
m=audio 3018 RTP/AVP 0 |
|
|
|
c=IN IP4 198.51.100.3 |
|
|
|
a=sendrecv |
|
|
|
a=ptime:40 |
|
|
|
-------------------------------------- |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 203.0.113.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 |
|
|
|
a=ptime:20 |
|
|
|
SDP |
|
|
|
|
|
|
|
# A->B: 2x 50 ms -> 3x 30 ms (plus 10 ms left) |
|
|
|
snd($sock_a, $port_b, rtp(0, 1000, 3000, 0x1234, "\00" x 400)); |
|
|
|
($ssrc) = rcv($sock_b, $port_a, rtpm(0, 1000, 3000, -1, "\00" x 240)); |
|
|
|
snd($sock_a, $port_b, rtp(0, 1001, 3400, 0x1234, "\00" x 400)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1001, 3240, $ssrc, "\00" x 240)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1002, 3480, $ssrc, "\00" x 240)); |
|
|
|
# A->B: add another 20 ms for another full 30 ms |
|
|
|
snd($sock_a, $port_b, rtp(0, 1002, 3800, 0x1234, "\00" x 160)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1003, 3720, $ssrc, "\00" x 240)); |
|
|
|
|
|
|
|
# B->A: 4x 30 ms -> 6x 20 ms |
|
|
|
snd($sock_b, $port_a, rtp(0, 4000, 5000, 0x4567, "\x88" x 240)); |
|
|
|
($ssrc) = rcv($sock_a, $port_b, rtpm(0, 4000, 5000, -1, "\x88" x 160)); |
|
|
|
snd($sock_b, $port_a, rtp(0, 4001, 5240, 0x4567, "\x88" x 240)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4001, 5160, $ssrc, "\x88" x 160)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4002, 5320, $ssrc, "\x88" x 160)); |
|
|
|
snd($sock_b, $port_a, rtp(0, 4002, 5480, 0x4567, "\x88" x 240)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4003, 5480, $ssrc, "\x88" x 160)); |
|
|
|
snd($sock_b, $port_a, rtp(0, 4003, 5720, 0x4567, "\x88" x 240)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4004, 5640, $ssrc, "\x88" x 160)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4005, 5800, $ssrc, "\x88" x 160)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
($sock_a, $sock_b) = new_call([qw(198.51.100.1 3016)], [qw(198.51.100.3 3018)]); |
|
|
|
|
|
|
|
($port_a) = offer('ptime=30 in, no change, reverse to 20, response 40', { |
|
|
|
ICE => 'remove', replace => ['origin'], 'ptime-reverse' => 20 }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.1 |
|
|
|
s=tester |
|
|
|
t=0 0 |
|
|
|
m=audio 3016 RTP/AVP 0 |
|
|
|
c=IN IP4 198.51.100.1 |
|
|
|
a=sendrecv |
|
|
|
a=ptime:30 |
|
|
|
---------------------------------- |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 203.0.113.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 |
|
|
|
a=ptime:30 |
|
|
|
SDP |
|
|
|
|
|
|
|
($port_b) = answer('ptime=30 in, no change, reverse to 20, response 40', |
|
|
|
{ ICE => 'remove', replace => ['origin'] }, <<SDP); |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 198.51.100.3 |
|
|
|
s=tester |
|
|
|
t=0 0 |
|
|
|
m=audio 3018 RTP/AVP 0 |
|
|
|
c=IN IP4 198.51.100.3 |
|
|
|
a=sendrecv |
|
|
|
a=ptime:40 |
|
|
|
-------------------------------------- |
|
|
|
v=0 |
|
|
|
o=- 1545997027 1 IN IP4 203.0.113.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 |
|
|
|
a=ptime:20 |
|
|
|
SDP |
|
|
|
|
|
|
|
# A->B: 2x 50 ms -> 3x 30 ms (plus 10 ms left) |
|
|
|
snd($sock_a, $port_b, rtp(0, 1000, 3000, 0x1234, "\00" x 400)); |
|
|
|
($ssrc) = rcv($sock_b, $port_a, rtpm(0, 1000, 3000, -1, "\00" x 240)); |
|
|
|
snd($sock_a, $port_b, rtp(0, 1001, 3400, 0x1234, "\00" x 400)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1001, 3240, $ssrc, "\00" x 240)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1002, 3480, $ssrc, "\00" x 240)); |
|
|
|
# A->B: add another 20 ms for another full 30 ms |
|
|
|
snd($sock_a, $port_b, rtp(0, 1002, 3800, 0x1234, "\00" x 160)); |
|
|
|
rcv($sock_b, $port_a, rtpm(0, 1003, 3720, $ssrc, "\00" x 240)); |
|
|
|
|
|
|
|
# B->A: 4x 30 ms -> 6x 20 ms |
|
|
|
snd($sock_b, $port_a, rtp(0, 4000, 5000, 0x4567, "\x88" x 240)); |
|
|
|
($ssrc) = rcv($sock_a, $port_b, rtpm(0, 4000, 5000, -1, "\x88" x 160)); |
|
|
|
snd($sock_b, $port_a, rtp(0, 4001, 5240, 0x4567, "\x88" x 240)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4001, 5160, $ssrc, "\x88" x 160)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4002, 5320, $ssrc, "\x88" x 160)); |
|
|
|
snd($sock_b, $port_a, rtp(0, 4002, 5480, 0x4567, "\x88" x 240)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4003, 5480, $ssrc, "\x88" x 160)); |
|
|
|
snd($sock_b, $port_a, rtp(0, 4003, 5720, 0x4567, "\x88" x 240)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4004, 5640, $ssrc, "\x88" x 160)); |
|
|
|
rcv($sock_a, $port_b, rtpm(0, 4005, 5800, $ssrc, "\x88" x 160)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
END { |
|
|
|
if ($rtpe_pid) { |
|
|
|
kill('INT', $rtpe_pid) or die; |
|
|
|
|