diff --git a/protocol/rtp/parse.go b/protocol/rtp/parse.go index 22a663f8..63e5dc2d 100644 --- a/protocol/rtp/parse.go +++ b/protocol/rtp/parse.go @@ -84,5 +84,5 @@ func csrcCount(d []byte) int { // version returns the version of the RTP packet. func version(d []byte) int { - return int(d[0] & 0xb0 >> 4) + return int(d[0] & 0xc0 >> 6) } diff --git a/protocol/rtp/parse_test.go b/protocol/rtp/parse_test.go index 7c5a03e9..01de123d 100644 --- a/protocol/rtp/parse_test.go +++ b/protocol/rtp/parse_test.go @@ -26,3 +26,17 @@ LICENSE */ package rtp + +import ( + "testing" +) + +// TestVersion checks that we can correctly get the version from an RTP packet. +func TestVersion(t *testing.T) { + const expect = 1 + pkt := (&Pkt{V: expect}).Bytes(nil) + got := version(pkt) + if got != expect { + t.Errorf("unexpected version for RTP packet. Got: %v\n Want: %v\n", got, expect) + } +}