protocol/rtp: removed redundant version checks from helper funcs in parse.go

This commit is contained in:
Saxon 2019-04-07 14:50:48 +09:30
parent 09b8a2baff
commit df3e66e5b2
1 changed files with 0 additions and 12 deletions

View File

@ -51,12 +51,6 @@ func Payload(d []byte) ([]byte, error) {
// extHeaderLen returns the extension header length. The RTP packet must have
// a compatible version, and must have an extension field, otherwise we panic.
func extHeaderLen(d []byte) int {
if version(d) != rtpVer {
panic(badVer)
}
if !hasExt(d) {
panic("RTP packet does not have extension")
}
extIdx := optionalFieldIdx + 4*csrcCount(d)
return int(binary.BigEndian.Uint16(d[extIdx+2 : extIdx+4]))
}
@ -64,9 +58,6 @@ func extHeaderLen(d []byte) int {
// hasExt returns true if an extension is present in the RTP packet. The version
// must be compatible otherwise we panic.
func hasExt(d []byte) bool {
if version(d) != rtpVer {
panic(badVer)
}
if (d[0] & 0x10 >> 4) == 1 {
return true
}
@ -76,9 +67,6 @@ func hasExt(d []byte) bool {
// csrcCount returns the number of CSRC fields. If the version is not compatible
// we panic.
func csrcCount(d []byte) int {
if version(d) != rtpVer {
panic(badVer)
}
return int(d[0] & 0x0f)
}