diff --git a/extended_report.go b/extended_report.go index db7ca41..0f9ee2c 100644 --- a/extended_report.go +++ b/extended_report.go @@ -646,7 +646,8 @@ func (x *ExtendedReport) Unmarshal(b []byte) error { // DestinationSSRC returns an array of SSRC values that this packet refers to. func (x *ExtendedReport) DestinationSSRC() []uint32 { - ssrc := make([]uint32, 0) + ssrc := make([]uint32, 0, len(x.Reports)+1) + ssrc = append(ssrc, x.SenderSSRC) for _, p := range x.Reports { ssrc = append(ssrc, p.DestinationSSRC()...) } diff --git a/extended_report_test.go b/extended_report_test.go index df77184..1004a21 100644 --- a/extended_report_test.go +++ b/extended_report_test.go @@ -272,4 +272,14 @@ func TestDecode(t *testing.T) { if p.String() != pktStringer.String() { t.Errorf("(string compare) Decoded packet does not match expected packet") } + + var includeSenderSSRC bool + for _, ssrc := range p.DestinationSSRC() { + if ssrc == p.SenderSSRC { + includeSenderSSRC = true + } + } + if !includeSenderSSRC { + t.Errorf("DestinationSSRC does not include the SenderSSRC") + } } diff --git a/fuzz_test.go b/fuzz_test.go index 38f177b..1b0951f 100644 --- a/fuzz_test.go +++ b/fuzz_test.go @@ -10,7 +10,7 @@ import ( func FuzzUnmarshal(f *testing.F) { f.Add([]byte{}) - f.Fuzz(func(t *testing.T, data []byte) { + f.Fuzz(func(_ *testing.T, data []byte) { packets, err := Unmarshal(data) if err != nil { return diff --git a/packet_stringifier_test.go b/packet_stringifier_test.go index 12833ff..6628af0 100644 --- a/packet_stringifier_test.go +++ b/packet_stringifier_test.go @@ -117,6 +117,7 @@ func TestPrint(t *testing.T) { }, }, }, + // nolint "rtcp.ExtendedReport:\n" + "\tSenderSSRC: 0x1020304\n" + "\tReports:\n" + @@ -246,6 +247,7 @@ func TestPrint(t *testing.T) { }, }, }, + // nolint "rtcp.FullIntraRequest:\n" + "\tSenderSSRC: 0\n" + "\tMediaSSRC: 1271200948\n" + @@ -312,6 +314,7 @@ func TestPrint(t *testing.T) { SenderSSRC: 0x902f9e2e, MediaSSRC: 0x902f9e2e, }, + // nolint "rtcp.PictureLossIndication:\n" + "\tSenderSSRC: 2419039790\n" + "\tMediaSSRC: 2419039790\n",