diff --git a/extended_report.go b/extended_report.go index 9bf50e7..57ea47b 100644 --- a/extended_report.go +++ b/extended_report.go @@ -562,7 +562,7 @@ func (b *UnknownReportBlock) unpackBlockHeader() { // MarshalSize returns the size of the packet once marshaled. func (x ExtendedReport) MarshalSize() int { - return wireSize(x) + return headerLength + wireSize(x) } // Marshal encodes the ExtendedReport in binary. diff --git a/extended_report_test.go b/extended_report_test.go index ec1cd55..9c975d5 100644 --- a/extended_report_test.go +++ b/extended_report_test.go @@ -264,3 +264,22 @@ func TestDecode(t *testing.T) { } assert.True(t, includeSenderSSRC, "DestinationSSRC does not include the SenderSSRC") } + +func TestExtendedReportMarshalSize(t *testing.T) { + packet := testPacket() + rawPacket, err := packet.Marshal() + assert.NoError(t, err) + assert.Equal(t, len(rawPacket), packet.MarshalSize()) + + compound := CompoundPacket{ + &SenderReport{SSRC: 1}, + &SourceDescription{Chunks: []SourceDescriptionChunk{{ + Source: 1, + Items: []SourceDescriptionItem{{Type: SDESCNAME, Text: "cname"}}, + }}}, + packet, + } + rawCompound, err := compound.Marshal() + assert.NoError(t, err) + assert.Equal(t, len(rawCompound), compound.MarshalSize()) +}