Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 7 commits
  • 19 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 11, 2012
@lemenkov Added note about encrypted payloads within zrtp packets
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
a5764b8
@lemenkov Don't try to search for purged patch-file
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
8df64ca
@lemenkov Add proper uninstall target
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
8dd91bd
@lemenkov Refactor RTCP test a bit
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
1a0d89e
@lemenkov Fix API for RTCP payload
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
cbcb10c
@lemenkov Use new RTCP API in the RTP module
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
025c691
@lemenkov Kill MBZ define in rtcp header
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
da50742
View
9 Makefile.am
@@ -17,5 +17,12 @@ install-exec-local:
$(mkdir_p) $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/include/
$(install_sh_DATA) include/*.hrl $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/include/
+uninstall-local:
+ @rm $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/ebin/*.beam
+ @rm $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/ebin/rtplib.app
+ @rm $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/include/*.hrl
+ @rm -r $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/ebin/
+ @rm -r $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/include/
+ @rm -r $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/
-EXTRA_DIST = priv/erlang-rtplib-0001-Disable-Opus-on-RHEL5.patch include/*.hrl src/*.erl src/rtplib.app.src test/samples test/*.erl rebar rebar.config
+EXTRA_DIST = include/*.hrl src/*.erl src/rtplib.app.src test/samples test/*.erl rebar rebar.config
View
4 c_src/Makefile.am
@@ -93,3 +93,7 @@ resampler_drv_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version
install:
$(mkdir_p) $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/priv/
$(install_sh_PROGRAM) .libs/*.so $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/priv/
+
+uninstall-local:
+ @rm $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/priv/*.so
+ @rm -r $(DESTDIR)@ERLANG_DIR@/lib/rtplib-@PACKAGE_VERSION@/priv/
View
7 include/rtcp.hrl
@@ -72,8 +72,11 @@
-define(PADDING_YES, 1).
-define(PADDING_NO, 0).
-% Must be zero
--define(MBZ, 0).
+% A compound structure for RTCP (or multiple RTCP packets stacked together
+-record(rtcp, {
+ payloads = [],
+ encrypted = <<>>
+ }).
% Full INTRA-frame Request (h.261 specific)
-record(fir, {ssrc}).
View
7 src/rtcp.erl
@@ -48,6 +48,9 @@
-include("../include/rtcp.hrl").
+% FIXME move to the header?
+-define(MBZ, 0).
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%% Decoding functions
@@ -59,7 +62,7 @@ decode(Data) when is_binary(Data) ->
decode(<<>>, DecodedRtcps) ->
% No data left, so we simply return list of decoded RTCP-packets
- {ok, DecodedRtcps};
+ {ok, #rtcp{payloads = DecodedRtcps}};
decode(<<1:8, Rest/binary>>, DecodedRtcps) ->
% FIXME Should we do this at all?
@@ -332,7 +335,7 @@ decode_bye(<<SSRC:32, Tail/binary>>, RC, Ret) when RC>0 ->
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-encode(List) when is_list(List) ->
+encode(#rtcp{payloads = List}) when is_list(List) ->
<< <<(encode(X))/binary>> || X <- List >>;
encode(#fir{ssrc = SSRC}) ->
View
5 src/rtp.erl
@@ -34,6 +34,7 @@
% FIXME - don't forget to remove from final version!
-compile(export_all).
+-include("../include/rtcp.hrl").
-include("../include/rtp.hrl").
-include("../include/zrtp.hrl").
-include("../include/stun.hrl").
@@ -132,8 +133,8 @@ encode(#zrtp{} = Zrtp) ->
encode(#stun{} = Stun) ->
stun:encode(Stun);
-encode(Pkts) ->
- rtcp:encode(Pkts).
+encode(#rtcp{} = Rtcp) ->
+ rtcp:encode(Rtcp).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
View
2  src/zrtp.erl
@@ -159,6 +159,7 @@ decode_message(<<?ZRTP_SIGNATURE_HELLO:16, Length:16, ?ZRTP_MSG_CONFIRM1, ConfMa
cache_exp_interval = CacheExpInterval,
signature = Signature
}};
+% We need this for the case when we can't decrypt the payload (full proxy mode)
decode_message(<<?ZRTP_SIGNATURE_HELLO:16, Length:16, ?ZRTP_MSG_CONFIRM1, ConfMac:8/binary, CFBInitVect:16/binary, EncryptedData/binary>>) ->
{ok, #confirm1{
conf_mac = ConfMac,
@@ -184,6 +185,7 @@ decode_message(<<?ZRTP_SIGNATURE_HELLO:16, Length:16, ?ZRTP_MSG_CONFIRM2, ConfMa
cache_exp_interval = CacheExpInterval,
signature = Signature
}};
+% We need this for the case when we can't decrypt the payload (full proxy mode)
decode_message(<<?ZRTP_SIGNATURE_HELLO:16, Length:16, ?ZRTP_MSG_CONFIRM2, ConfMac:8/binary, CFBInitVect:16/binary, EncryptedData/binary>>) ->
{ok, #confirm2{
conf_mac = ConfMac,
View
7 test/rtcp_app_test.erl
@@ -35,15 +35,16 @@
rtcp_APP_test_() ->
AppBin = <<133,204,0,8,0,0,4,0,83,84,82,49,72,101,108,108,111,33,32,84,104,105,115,32,105,115,32,97,32,115,116,114,105,110,103,46>>,
+ App = #rtcp{payloads = [#app{subtype = 5, ssrc = 1024, name = <<"STR1">>, data = <<"Hello! This is a string.">>}]},
+
[
{"Simple encoding of APP RTCP data stream",
fun() -> ?assertEqual(AppBin, rtcp:encode_app(5, 1024, "STR1", <<"Hello! This is a string.">>)) end
},
{"Simple decoding APP RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [#app{subtype = 5, ssrc = 1024, name = <<"STR1">>, data = <<"Hello! This is a string.">>}]},
- rtcp:decode(AppBin)) end
+ fun() -> ?assertEqual({ok, App}, rtcp:decode(AppBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(AppBin, rtcp:encode(#app{subtype = 5, ssrc = 1024, name = <<"STR1">>, data = <<"Hello! This is a string.">>})) end
+ fun() -> ?assertEqual(AppBin, rtcp:encode(App)) end
}
].
View
9 test/rtcp_bye_test.erl
@@ -35,15 +35,16 @@
rtcp_BYE_test_() ->
ByeBin = <<161,203,0,3,0,0,4,0,6,67,97,110,99,101,108,0>>,
+ Bye = #rtcp{payloads = [#bye{message = "Cancel", ssrc = [1024]}]},
[
{"Simple encoding of BYE RTCP data stream",
fun() -> ?assertEqual(ByeBin, rtcp:encode_bye([1024], "Cancel")) end
},
{"Simple decoding BYE RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [#bye{message = "Cancel", ssrc = [1024]}]}, rtcp:decode(ByeBin)) end
+ fun() -> ?assertEqual({ok, Bye}, rtcp:decode(ByeBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(ByeBin, rtcp:encode(#bye{message = "Cancel", ssrc = [1024]})) end
+ fun() -> ?assertEqual(ByeBin, rtcp:encode(Bye)) end
}
].
@@ -52,10 +53,10 @@ rtcp_BYE_padding_test_() ->
% Padding at the end <<0,0,0,0>>
ByeBin = <<129,203,0,5,128,171,245,31,15,68,105,115,99,111,110,110,101,99,116,32,67,97,108,108,0,0,0,0>>,
ByeBinNoPadding = <<129,203,0,5,128,171,245,31,15,68,105,115,99,111,110,110,101,99,116,32,67,97,108,108>>,
- Bye = #bye{message="Disconnect Call",ssrc=[2158753055]},
+ Bye = #rtcp{payloads = [#bye{message="Disconnect Call",ssrc=[2158753055]}]},
[
{"Decode BYE RTCP with unnecessary padding",
- fun() -> ?assertEqual({ok, [Bye]}, rtcp:decode(ByeBin)) end
+ fun() -> ?assertEqual({ok, Bye}, rtcp:decode(ByeBin)) end
},
{"Encode BYE RTCP properly (w/o padding)",
fun() -> ?assertEqual(ByeBinNoPadding, rtcp:encode(Bye)) end
View
8 test/rtcp_fir_test.erl
@@ -34,14 +34,16 @@
-include_lib("eunit/include/eunit.hrl").
rtcp_FIR_test_() ->
+ FirBin = <<128,192,0,1,0,0,4,0>>,
+ Fir = #rtcp{payloads = [#fir{ssrc = 1024}]},
[
{"Simple encoding of FIR RTCP data stream",
- fun() -> ?assertEqual(<<128,192,0,1,0,0,4,0>>, rtcp:encode_fir(1024)) end
+ fun() -> ?assertEqual(FirBin, rtcp:encode_fir(1024)) end
},
{"Simple decoding FIR RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [#fir{ssrc = 1024}]}, rtcp:decode(<<128,192,0,1,0,0,4,0>>)) end
+ fun() -> ?assertEqual({ok, Fir}, rtcp:decode(FirBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(<<128,192,0,1,0,0,4,0>>, rtcp:encode(#fir{ssrc = 1024})) end
+ fun() -> ?assertEqual(FirBin, rtcp:encode(Fir)) end
}
].
View
8 test/rtcp_nack_test.erl
@@ -34,14 +34,16 @@
-include_lib("eunit/include/eunit.hrl").
rtcp_NACK_test_() ->
+ NackBin = <<128,193,0,2,0,0,4,0,8,1,16,1>>,
+ Nack = #rtcp{payloads = [#nack{ssrc=1024, fsn=2049, blp=4097}]},
[
{"Simple encoding of NACK RTCP data stream",
- fun() -> ?assertEqual(<<128,193,0,2,0,0,4,0,8,1,16,1>>, rtcp:encode_nack(1024, 2049, 4097)) end
+ fun() -> ?assertEqual(NackBin, rtcp:encode_nack(1024, 2049, 4097)) end
},
{"Simple decoding NACK RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [#nack{ssrc=1024, fsn=2049, blp=4097}]}, rtcp:decode(<<128,193,0,2,0,0,4,0,8,1,16,1>>)) end
+ fun() -> ?assertEqual({ok, Nack}, rtcp:decode(NackBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(<<128,193,0,2,0,0,4,0,8,1,16,1>>, rtcp:encode(#nack{ssrc=1024, fsn=2049, blp=4097})) end
+ fun() -> ?assertEqual(NackBin, rtcp:encode(Nack)) end
}
].
View
4 test/rtcp_rr_test.erl
@@ -43,7 +43,7 @@ rtcp_RR_test_() ->
RBlock1 = #rblock{ssrc=1024, fraction=2, lost=1026, last_seq=1027, jitter=1028, lsr=1029, dlsr=1030},
RBlock2 = #rblock{ssrc=100024, fraction=2, lost=100026, last_seq=100027, jitter=100028, lsr=100029, dlsr=100030},
- RR = #rr{ssrc=4096, rblocks=[RBlock1, RBlock2]},
+ RR = #rtcp{payloads = [#rr{ssrc=4096, rblocks=[RBlock1, RBlock2]}]},
[
{"Encode one RBlock",
@@ -62,7 +62,7 @@ rtcp_RR_test_() ->
fun() -> ?assertEqual(RRBin, rtcp:encode_rr(4096, [RBlock1, RBlock2])) end
},
{"Simple decoding RR RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [RR]}, rtcp:decode(RRBin)) end
+ fun() -> ?assertEqual({ok, RR}, rtcp:decode(RRBin)) end
},
{"Check that we can reproduce original data stream from record",
fun() -> ?assertEqual(RRBin, rtcp:encode(RR)) end
View
17 test/rtcp_sdes_test.erl
@@ -35,19 +35,16 @@
rtcp_SDES_test_() ->
SdesBin = <<129,202,0,6,0,0,4,0,1,7,104,101,108,108,111,32,49,2,7,104,101,108,108,111,32,50,0,0>>,
+ Sdes = #rtcp{payloads = [#sdes{list=[[{ssrc, 1024}, {cname,"hello 1"}, {name, "hello 2"}, {eof, true}]]}]},
[
{"Simple encoding of SDES RTCP data stream",
fun() -> ?assertEqual(SdesBin, rtcp:encode_sdes([[{ssrc, 1024}, {cname,"hello 1"}, {name, "hello 2"}, {eof, true}]])) end
},
{"Simple decoding SDES RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual(
- {ok, [#sdes{list=[[{ssrc, 1024}, {cname,"hello 1"}, {name, "hello 2"}, {eof, true}]]}]},
- rtcp:decode(SdesBin)) end
+ fun() -> ?assertEqual({ok, Sdes}, rtcp:decode(SdesBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(<<129,202,0,6,0,0,4,0,1,7,104,101,108,108,111,32,49,2,7,104,101,108,108,111,32,50,0,0>>,
- rtcp:encode(#sdes{list=[[{ssrc, 1024}, {cname,"hello 1"}, {name, "hello 2"}, {eof, true}]]})
- ) end
+ fun() -> ?assertEqual(SdesBin, rtcp:encode(Sdes)) end
}
].
@@ -64,20 +61,20 @@ rtcp_SDES_damaged_test_() ->
51,57,57,53,52,50,64,117,110,105,113,117,101,46,122,57,
67,48,65,70,53,56,51,67,54,51,56,52,52,50,56,46,111,114,
103,0>>,
- Sdes1 = #sdes{list=[[{ssrc,31600},{cname,"FDBB0B4C8CA24935A22AE0DD94399542@unique.z9C0AF583C6384428.org"},{eof,true}]]},
+ Sdes1 = #rtcp{payloads = [#sdes{list=[[{ssrc,31600},{cname,"FDBB0B4C8CA24935A22AE0DD94399542@unique.z9C0AF583C6384428.org"},{eof,true}]]}]},
% Another broken SDES
Sdes2Bin = <<1,202,0,2,0,0,120,143,0,0,0,0>>,
Sdes2Fix = <<129,202,0,2,0,0,120,143,0,0,0,0>>,
- Sdes2 = #sdes{list=[[{ssrc,30863},{eof,true}]]},
+ Sdes2 = #rtcp{payloads = [#sdes{list=[[{ssrc,30863},{eof,true}]]}]},
[
{"Correctly decode first broken SDES",
- fun() -> ?assertEqual({ok, [Sdes1]}, rtcp:decode(Sdes1Bin)) end
+ fun() -> ?assertEqual({ok, Sdes1}, rtcp:decode(Sdes1Bin)) end
},
{"Correctly decode second broken SDES",
- fun() -> ?assertEqual({ok, [Sdes2]}, rtcp:decode(Sdes2Bin)) end
+ fun() -> ?assertEqual({ok, Sdes2}, rtcp:decode(Sdes2Bin)) end
},
{"Correctly encode first SDES",
fun() -> ?assertEqual(Sdes1Fix, rtcp:encode(Sdes1)) end
View
19 test/rtcp_sr_test.erl
@@ -48,13 +48,16 @@ rtcp_SR_test_() ->
SRBin = <<130,200,0,18,0,0,16,0,210,79,225,24,250,129,85,222,0,0,16,2,0,
0,255,255,0,1,0,0, RBlocksBin/binary>>,
- SR = #sr{
- ssrc=4096,
- ntp=15154578768523253214,
- timestamp=4098,
- packets=65535,
- octets=65536,
- rblocks=[RBlock1, RBlock2]
+ SR = #rtcp{payloads = [
+ #sr{
+ ssrc=4096,
+ ntp=15154578768523253214,
+ timestamp=4098,
+ packets=65535,
+ octets=65536,
+ rblocks=[RBlock1, RBlock2]
+ }
+ ]
},
[
@@ -77,7 +80,7 @@ rtcp_SR_test_() ->
) end
},
{"Simple decoding SR RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok,[SR]}, rtcp:decode(SRBin)) end
+ fun() -> ?assertEqual({ok,SR}, rtcp:decode(SRBin)) end
},
{"Check that we can reproduce original data stream from record",
fun() -> ?assertEqual(SRBin, rtcp:encode(SR)) end
View
6 test/rtcp_xr_test.erl
@@ -46,6 +46,8 @@ rtcp_XR_test_() ->
98,108,111,99,107,32,100,97,116,97,32,49,127,128,0,5,116,101,115,
116,50,32,120,114,98,108,111,99,107,32,100,97,116,97,32,50>>,
+ Xr = #rtcp{ payloads = [#xr{ssrc=1024, xrblocks=[XrBlock1, XrBlock2]}]},
+
[
{"Check correct eXtended Report Blocks processing",
fun() -> ?assertEqual(XrBlocksBin, rtcp:encode_xrblocks([XrBlock1, XrBlock2])) end
@@ -54,9 +56,9 @@ rtcp_XR_test_() ->
fun() -> ?assertEqual(XrBin, rtcp:encode_xr(1024, [XrBlock1, XrBlock2])) end
},
{"Simple decoding XR RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [#xr{ssrc=1024, xrblocks=[XrBlock1, XrBlock2]}]}, rtcp:decode(XrBin)) end
+ fun() -> ?assertEqual({ok, Xr}, rtcp:decode(XrBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(XrBin, rtcp:encode(#xr{ssrc=1024, xrblocks=[XrBlock1, XrBlock2]})) end
+ fun() -> ?assertEqual(XrBin, rtcp:encode(Xr)) end
}
].
View
75 test/rtp_rtcp_muxed_test.erl
@@ -37,98 +37,95 @@
rtp_rtcp_muxed_test_() ->
AppBin = <<133,204,0,8,0,0,4,0,83,84,82,49,72,101,108,108,111,33,32,84,104,105,115,32,105,115,32,97,32,115,116,114,105,110,103,46>>,
ByeBin = <<161,203,0,3,0,0,4,0,6,67,97,110,99,101,108,0>>,
+ FirBin = <<128,192,0,1,0,0,4,0>>,
+ NackBin = <<128,193,0,2,0,0,4,0,8,1,16,1>>,
RBlock1Bin = <<0,0,4,0,2,0,4,2,0,0,4,3,0,0,4,4,0,0,4,5,0,0,4,6>>,
RBlock2Bin = <<0,1,134,184,2,1,134,186,0,1,134,187,0,1,134,188,0,1,134,189,0,1,134,190>>,
RBlocksBin = <<RBlock1Bin/binary, RBlock2Bin/binary>>,
RRBin = <<130,201,0,13,0,0,16,0,RBlocksBin/binary>>,
- RBlock1 = #rblock{ssrc=1024, fraction=2, lost=1026, last_seq=1027, jitter=1028, lsr=1029, dlsr=1030},
- RBlock2 = #rblock{ssrc=100024, fraction=2, lost=100026, last_seq=100027, jitter=100028, lsr=100029, dlsr=100030},
- RR = #rr{ssrc=4096, rblocks=[RBlock1, RBlock2]},
SdesBin = <<129,202,0,6,0,0,4,0,1,7,104,101,108,108,111,32,49,2,7,104,101,108,108,111,32,50,0,0>>,
- RBlock1Bin = <<0,0,4,0,2,0,4,2,0,0,4,3,0,0,4,4,0,0,4,5,0,0,4,6>>,
- RBlock2Bin = <<0,1,134,184,2,1,134,186,0,1,134,187,0,1,134,188,0,1,134,189,0,1,134,190>>,
- RBlocksBin = <<RBlock1Bin/binary, RBlock2Bin/binary>>,
-
- RBlock1 = #rblock{ssrc=1024, fraction=2, lost=1026, last_seq=1027, jitter=1028, lsr=1029, dlsr=1030},
- RBlock2 = #rblock{ssrc=100024, fraction=2, lost=100026, last_seq=100027, jitter=100028, lsr=100029, dlsr=100030},
-
% random NTP timestamp with rtp_utils:now2ntp(now())
<<NTP:64>> = <<210,79,225,24,250,129,85,222>>,
% valid SR packet
SRBin = <<130,200,0,18,0,0,16,0,210,79,225,24,250,129,85,222,0,0,16,2,0,
0,255,255,0,1,0,0, RBlocksBin/binary>>,
- SR = #sr{
- ssrc=4096,
- ntp=15154578768523253214,
- timestamp=4098,
- packets=65535,
- octets=65536,
- rblocks=[RBlock1, RBlock2]
- },
XrBlock1Bin = <<254,255,0,5,116,101,115,116,49,32,120,114,98,108,111,99,107,32,100,97,116,97,32,49>>,
XrBlock2Bin = <<127,128,0,5,116,101,115,116,50,32,120,114,98,108,111,99, 107,32,100,97,116,97,32,50>>,
XrBlocksBin = <<XrBlock1Bin/binary, XrBlock2Bin/binary>>,
- XrBlock1 = #xrblock{type = 254, ts = 255, data = <<"test1 xrblock data 1">>},
- XrBlock2 = #xrblock{type = 127, ts = 128, data = <<"test2 xrblock data 2">>},
XrBin = <<128,207,0,13,0,0,4,0,254,255,0,5,116,101,115,116,49,32,120,114,
98,108,111,99,107,32,100,97,116,97,32,49,127,128,0,5,116,101,115,
116,50,32,120,114,98,108,111,99,107,32,100,97,116,97,32,50>>,
+ App = #rtcp{payloads = [#app{subtype = 5, ssrc = 1024, name = <<"STR1">>, data = <<"Hello! This is a string.">>}]},
+ Bye = #rtcp{payloads = [#bye{message = "Cancel", ssrc = [1024]}]},
+ Fir = #rtcp{payloads = [#fir{ssrc = 1024}]},
+ Nack = #rtcp{payloads = [#nack{ssrc=1024, fsn=2049, blp=4097}]},
+ RBlock1 = #rblock{ssrc=1024, fraction=2, lost=1026, last_seq=1027, jitter=1028, lsr=1029, dlsr=1030},
+ RBlock2 = #rblock{ssrc=100024, fraction=2, lost=100026, last_seq=100027, jitter=100028, lsr=100029, dlsr=100030},
+ RR = #rtcp{payloads = [#rr{ssrc=4096, rblocks=[RBlock1, RBlock2]}]},
+ Sdes = #rtcp{payloads = [#sdes{list=[[{ssrc, 1024}, {cname,"hello 1"}, {name, "hello 2"}, {eof, true}]]}]},
+ SR = #rtcp{payloads = [#sr{
+ ssrc=4096,
+ ntp=15154578768523253214,
+ timestamp=4098,
+ packets=65535,
+ octets=65536,
+ rblocks=[RBlock1, RBlock2]
+ }]},
+ XrBlock1 = #xrblock{type = 254, ts = 255, data = <<"test1 xrblock data 1">>},
+ XrBlock2 = #xrblock{type = 127, ts = 128, data = <<"test2 xrblock data 2">>},
+ Xr = #rtcp{payloads = [#xr{ssrc=1024, xrblocks=[XrBlock1, XrBlock2]}]},
+
[
{"Simple decoding APP RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [#app{subtype = 5, ssrc = 1024, name = <<"STR1">>, data = <<"Hello! This is a string.">>}]},
- rtp:decode(AppBin)) end
+ fun() -> ?assertEqual({ok, App}, rtp:decode(AppBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(AppBin, rtp:encode(#app{subtype = 5, ssrc = 1024, name = <<"STR1">>, data = <<"Hello! This is a string.">>})) end
+ fun() -> ?assertEqual(AppBin, rtp:encode(App)) end
},
{"Simple decoding BYE RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [#bye{message = "Cancel", ssrc = [1024]}]}, rtp:decode(ByeBin)) end
+ fun() -> ?assertEqual({ok, Bye}, rtp:decode(ByeBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(ByeBin, rtp:encode(#bye{message = "Cancel", ssrc = [1024]})) end
+ fun() -> ?assertEqual(ByeBin, rtp:encode(Bye)) end
},
{"Simple decoding FIR RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [#fir{ssrc = 1024}]}, rtp:decode(<<128,192,0,1,0,0,4,0>>)) end
+ fun() -> ?assertEqual({ok, Fir}, rtp:decode(FirBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(<<128,192,0,1,0,0,4,0>>, rtp:encode(#fir{ssrc = 1024})) end
+ fun() -> ?assertEqual(FirBin, rtp:encode(Fir)) end
},
{"Simple decoding NACK RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [#nack{ssrc=1024, fsn=2049, blp=4097}]}, rtp:decode(<<128,193,0,2,0,0,4,0,8,1,16,1>>)) end
+ fun() -> ?assertEqual({ok, Nack}, rtp:decode(NackBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(<<128,193,0,2,0,0,4,0,8,1,16,1>>, rtp:encode(#nack{ssrc=1024, fsn=2049, blp=4097})) end
+ fun() -> ?assertEqual(NackBin, rtp:encode(Nack)) end
},
{"Simple decoding RR RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [RR]}, rtp:decode(RRBin)) end
+ fun() -> ?assertEqual({ok, RR}, rtp:decode(RRBin)) end
},
{"Check that we can reproduce original data stream from record",
fun() -> ?assertEqual(RRBin, rtp:encode(RR)) end
},
{"Simple decoding SDES RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual(
- {ok, [#sdes{list=[[{ssrc, 1024}, {cname,"hello 1"}, {name, "hello 2"}, {eof, true}]]}]},
- rtp:decode(SdesBin)) end
+ fun() -> ?assertEqual({ok, Sdes}, rtp:decode(SdesBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(<<129,202,0,6,0,0,4,0,1,7,104,101,108,108,111,32,49,2,7,104,101,108,108,111,32,50,0,0>>,
- rtp:encode(#sdes{list=[[{ssrc, 1024}, {cname,"hello 1"}, {name, "hello 2"}, {eof, true}]]})
- ) end
+ fun() -> ?assertEqual(SdesBin, rtp:encode(Sdes)) end
},
{"Simple decoding SR RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok,[SR]}, rtp:decode(SRBin)) end
+ fun() -> ?assertEqual({ok,SR}, rtp:decode(SRBin)) end
},
{"Check that we can reproduce original data stream from record",
fun() -> ?assertEqual(SRBin, rtp:encode(SR)) end
},
{"Simple decoding XR RTCP data stream and returning a list with only member - record",
- fun() -> ?assertEqual({ok, [#xr{ssrc=1024, xrblocks=[XrBlock1, XrBlock2]}]}, rtp:decode(XrBin)) end
+ fun() -> ?assertEqual({ok, Xr}, rtp:decode(XrBin)) end
},
{"Check that we can reproduce original data stream from record",
- fun() -> ?assertEqual(XrBin, rtp:encode(#xr{ssrc=1024, xrblocks=[XrBlock1, XrBlock2]})) end
+ fun() -> ?assertEqual(XrBin, rtp:encode(Xr)) end
}
].
View
6 test/vendor_addpac_test.erl
@@ -68,11 +68,13 @@ vendor_addpac_test_() ->
]
},
+ SrSdes = #rtcp{payloads = [Sr, Sdes]},
+
[
{"Decode the entire SR+SDES packet",
- fun() -> ?assertEqual({ok, [Sr, Sdes]}, rtcp:decode(SrSdesBin)) end
+ fun() -> ?assertEqual({ok, SrSdes}, rtcp:decode(SrSdesBin)) end
},
{"Encode the entire SR+SDES packet",
- fun() -> ?assertEqual(SrSdesBinFixed, rtcp:encode([Sr, Sdes])) end
+ fun() -> ?assertEqual(SrSdesBinFixed, rtcp:encode(SrSdes)) end
}
].
View
16 test/vendor_erlyvideo_test.erl
@@ -228,6 +228,8 @@ vendor_erlyvideo_test_() ->
},
Sdes1 = #sdes{list=[[{ssrc,355697},{cname,"QTS 5110381"},{eof,true}]]},
+ SrSdes1 = #rtcp{payloads = [Sr1, Sdes1]},
+
Sr2Bin = <<128,200,0,6,0,70,87,111,209,42,13,22,152,254,225,253,0,13,240,18,0,0,4,105,0,16,221,37>>,
Sdes2Bin = <<129,202,0,5,0,70,87,111,1,11,81,84,83,32,53,49,49,48,51,56,49,0,0,0>>,
@@ -241,12 +243,14 @@ vendor_erlyvideo_test_() ->
},
Sdes2 = #sdes{list=[[{ssrc,4609903},{cname,"QTS 5110381"},{eof,true}]]},
+ SrSdes2 = #rtcp{payloads = [Sr2, Sdes2]},
+
[
{"Decode first SR+SDES pair",
- fun() -> ?assertEqual({ok, [Sr1, Sdes1]}, rtcp:decode(<<Sr1Bin/binary, Sdes1Bin/binary>>)) end
+ fun() -> ?assertEqual({ok, SrSdes1}, rtcp:decode(<<Sr1Bin/binary, Sdes1Bin/binary>>)) end
},
{"Decode second SR+SDES pair",
- fun() -> ?assertEqual({ok, [Sr2, Sdes2]}, rtcp:decode(<<Sr2Bin/binary, Sdes2Bin/binary>>)) end
+ fun() -> ?assertEqual({ok, SrSdes2}, rtcp:decode(<<Sr2Bin/binary, Sdes2Bin/binary>>)) end
},
{"Decode Audio RTP packet #1 (unknown dynamically assigned type)",
fun() -> ?assertEqual({ok, RtpAudio1}, rtp:decode(RtpAudio1Bin)) end
@@ -261,16 +265,16 @@ vendor_erlyvideo_test_() ->
fun() -> ?assertEqual({ok, Rtp2}, rtp:decode(Rtp2Bin)) end
},
{"Encode first SR",
- fun() -> ?assertEqual(Sr1Bin, rtcp:encode(Sr1)) end
+ fun() -> ?assertEqual(Sr1Bin, rtcp:encode(#rtcp{payloads = [Sr1]})) end
},
{"Encode second SR",
- fun() -> ?assertEqual(Sr2Bin, rtcp:encode(Sr2)) end
+ fun() -> ?assertEqual(Sr2Bin, rtcp:encode(#rtcp{payloads = [Sr2]})) end
},
{"Encode first SDES",
- fun() -> ?assertEqual(Sdes1Bin, rtcp:encode(Sdes1)) end
+ fun() -> ?assertEqual(Sdes1Bin, rtcp:encode(#rtcp{payloads = [Sdes1]})) end
},
{"Encode second SDES",
- fun() -> ?assertEqual(Sdes2Bin, rtcp:encode(Sdes2)) end
+ fun() -> ?assertEqual(Sdes2Bin, rtcp:encode(#rtcp{payloads = [Sdes2]})) end
},
{"Encode Audio RTP packet #1 (unknown dynamically assigned type)",
fun() -> ?assertEqual(RtpAudio1Bin, rtp:encode(RtpAudio1)) end
View
18 test/vendor_pbxnsip_test.erl
@@ -38,17 +38,17 @@ vendor_pbxnsip_test_() ->
% There is a miscalculated size of the SR block this packet - 4th octet
% must be 9 instead of 8. Also there is a strange padding at the end.
% -=9=-
- RtcpSrBin =
+ SrBin =
<<129,200,0,8,17,195,69,247,209,206,159,196,201,251,230,131,59,
71,192,80,0,0,0,5,0,0,3,32,0,0,0,0,0,0,0,0,0,0,0,0>>,
- RtcpSrBinCorrect =
+ SrBinCorrect =
<<128,200,0,6,17,195,69,247,209,206,159,196,201,251,230,
131,59,71,192,80,0,0,0,5,0,0,3,32>>,
- RtcpSdesBin = <<129,202,0,9,17,195,69,247,1,27,116,101,115,116,97,99,
+ SdesBin = <<129,202,0,9,17,195,69,247,1,27,116,101,115,116,97,99,
99,116,64,115,105,112,46,101,120,97,109,112,108,101,48,48,46,
110,101,116,0,0,0,0>>,
- RtcpSr = #sr{
+ Sr = #sr{
ssrc=298010103,
ntp=15118196666680469123,
timestamp=994558032,
@@ -56,20 +56,22 @@ vendor_pbxnsip_test_() ->
octets=800,
rblocks=[]
},
- RtcpSdes = #sdes{list=[[
+ Sdes = #sdes{list=[[
{ssrc,298010103},
{cname,"testacct@sip.example00.net" ++ [0]},
{eof,true}
]]},
+ SrSdes = #rtcp{payloads = [Sr, Sdes]},
+
[
{"Check that we still can decode broken RTCP packet correctly",
- fun() -> ?assertEqual({ok, [RtcpSr, RtcpSdes]},rtcp:decode(<<RtcpSrBin/binary, RtcpSdesBin/binary>>)) end
+ fun() -> ?assertEqual({ok, SrSdes},rtcp:decode(<<SrBin/binary, SdesBin/binary>>)) end
},
{"Check that we can produce fixed RTCP SR",
- fun() -> ?assertEqual(RtcpSrBinCorrect, rtcp:encode(RtcpSr)) end
+ fun() -> ?assertEqual(SrBinCorrect, rtcp:encode(#rtcp{payloads = [Sr]})) end
},
{"Check that we can reproduce original RTCP SDES",
- fun() -> ?assertEqual(RtcpSdesBin, rtcp:encode(RtcpSdes)) end
+ fun() -> ?assertEqual(SdesBin, rtcp:encode(#rtcp{payloads = [Sdes]})) end
}
].
View
13 test/vendor_unknown_test.erl
@@ -44,6 +44,9 @@ vendor_unknown_test_() ->
Sdes1 = #sdes{list=[[{ssrc,262129718},{cname,"0.0.0@192.168.100.54"},{eof,true}]]},
Bye1 = #bye{message=[],ssrc=[262129718]},
+ RrSdesBye1 = #rtcp{payloads = [Rr1, Sdes1, Bye1]},
+
+
% Another quite complex RTCP packet with coupled SR, SDES and BYE
% SDES packet contains 'priv' extension
SrSdesBye2Bin = <<128,200,0,6,55,82,152,102,209,215,221,218,198,102,
@@ -60,17 +63,19 @@ vendor_unknown_test_() ->
Sdes2 = #sdes{list=[[{ssrc,928159846},{cname,"A424CC73125A420DBD5BCF1AABED9CCF@unique.z23EA517BD3034B5B.org"},{priv,{"x-rtp-session-id",<<"30F2E3713D4E469BA32BEC4A05E629DB">>}},{eof,true}]]},
Bye2 = #bye{message=[], ssrc=[928159846]},
+ SrSdesBye2 = #rtcp{payloads = [Sr2, Sdes2, Bye2]},
+
[
{"Encode the entire RR+SDES+BYE packet",
- fun() -> ?assertEqual({ok, [Rr1, Sdes1, Bye1]}, rtcp:decode(RrSdesBye1Bin)) end
+ fun() -> ?assertEqual({ok, RrSdesBye1}, rtcp:decode(RrSdesBye1Bin)) end
},
{"Encode the entire SR+SDES+BYE packet",
- fun() -> ?assertEqual({ok, [Sr2, Sdes2, Bye2]}, rtcp:decode(SrSdesBye2Bin)) end
+ fun() -> ?assertEqual({ok, SrSdesBye2}, rtcp:decode(SrSdesBye2Bin)) end
},
{"Check what we could reproduce previous packet from RR+SDES+BYE",
- fun() -> ?assertEqual(RrSdesBye1Bin, rtcp:encode([Rr1, Sdes1, Bye1])) end
+ fun() -> ?assertEqual(RrSdesBye1Bin, rtcp:encode(RrSdesBye1)) end
},
{"Check what we could reproduce previous packet from SR+SDES+BYE",
- fun() -> ?assertEqual(SrSdesBye2Bin, rtcp:encode([Sr2, Sdes2, Bye2])) end
+ fun() -> ?assertEqual(SrSdesBye2Bin, rtcp:encode(SrSdesBye2)) end
}
].

No commit comments for this range

Something went wrong with that request. Please try again.