diff --git a/protocol/rtp/parse_test.go b/protocol/rtp/parse_test.go index be521a3b..64be4ece 100644 --- a/protocol/rtp/parse_test.go +++ b/protocol/rtp/parse_test.go @@ -55,3 +55,30 @@ func TestCsrcCount(t *testing.T) { t.Errorf("unexpected csrc count for RTP packet. Got: %v\n Want: %v\n", got, expect) } } + +// TestHasExt checks the behaviour of hasExt with an RTP packet that has the +// extension indicator true, and one with the extension indicator set to false. +func TestHasExt(t *testing.T) { + const ver = 2 + + // First check for when there is an extension field. + pkt := &Pkt{ + V: ver, + X: true, + Extension: ExtensionHeader{ + ID: 0, + Header: make([][4]byte, 0), + }, + } + got := hasExt(pkt.Bytes(nil)) + if !got { + t.Error("RTP packet did not have true extension indicator as expected") + } + + // Now check when there is not an extension field. + pkt.X = false + got = hasExt(pkt.Bytes(nil)) + if got { + t.Error("did not expect to have extension indicator as true") + } +}