allow invalid RTCP packets in both client and server

(https://github.com/aler9/rtsp-simple-server/issues/1085)

Invalid RTCP packets, in both server and client, do not trigger a fatal
error anymore but they're just blocked. OnDecodeError() is called in
order to emit a warning.
This commit is contained in:
aler9
2022-12-09 12:45:51 +01:00
parent 00efb912aa
commit 99855bd3a2
5 changed files with 40 additions and 6 deletions

View File

@@ -1494,6 +1494,7 @@ func TestServerPublishDecodeErrors(t *testing.T) {
{"udp", "rtp packets lost"},
{"udp", "rtp too big"},
{"udp", "rtcp too big"},
{"tcp", "rtcp invalid"},
{"tcp", "rtcp too big"},
} {
t.Run(ca.proto+" "+ca.name, func(t *testing.T) {
@@ -1533,6 +1534,9 @@ func TestServerPublishDecodeErrors(t *testing.T) {
case ca.proto == "udp" && ca.name == "rtcp too big":
require.EqualError(t, ctx.Error, "RTCP packet is too big to be read with UDP")
case ca.proto == "tcp" && ca.name == "rtcp invalid":
require.EqualError(t, ctx.Error, "rtcp: packet too short")
case ca.proto == "tcp" && ca.name == "rtcp too big":
require.EqualError(t, ctx.Error, "RTCP packet size (2000) is greater than maximum allowed (1472)")
}
@@ -1682,6 +1686,13 @@ func TestServerPublishDecodeErrors(t *testing.T) {
Port: resTH.ServerPorts[1],
})
case ca.proto == "tcp" && ca.name == "rtcp invalid":
err = conn.WriteInterleavedFrame(&base.InterleavedFrame{
Channel: 1,
Payload: []byte{0x01, 0x02},
}, make([]byte, 2048))
require.NoError(t, err)
case ca.proto == "tcp" && ca.name == "rtcp too big":
err = conn.WriteInterleavedFrame(&base.InterleavedFrame{
Channel: 1,