Skip to content

Commit

Permalink
Include XR.SenderSSRC in its DestinationSSRC
Browse files Browse the repository at this point in the history
Include XR.SenderSSRC in its DestinationSSRC
  • Loading branch information
cnderrauber committed Mar 1, 2024
1 parent f260c33 commit b26a618
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion extended_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()...)
}
Expand Down
10 changes: 10 additions & 0 deletions extended_report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
2 changes: 1 addition & 1 deletion fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions packet_stringifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func TestPrint(t *testing.T) {
},
},
},
// nolint
"rtcp.ExtendedReport:\n" +
"\tSenderSSRC: 0x1020304\n" +
"\tReports:\n" +
Expand Down Expand Up @@ -246,6 +247,7 @@ func TestPrint(t *testing.T) {
},
},
},
// nolint
"rtcp.FullIntraRequest:\n" +
"\tSenderSSRC: 0\n" +
"\tMediaSSRC: 1271200948\n" +
Expand Down Expand Up @@ -312,6 +314,7 @@ func TestPrint(t *testing.T) {
SenderSSRC: 0x902f9e2e,
MediaSSRC: 0x902f9e2e,
},
// nolint
"rtcp.PictureLossIndication:\n" +
"\tSenderSSRC: 2419039790\n" +
"\tMediaSSRC: 2419039790\n",
Expand Down

0 comments on commit b26a618

Please sign in to comment.