From 03c45b1bcfac90ac04ef7c373dfd93e3e202d58a Mon Sep 17 00:00:00 2001 From: Saxon Date: Mon, 27 May 2019 14:31:14 +0930 Subject: [PATCH] protocol/rtcp/parse.go: removed ParseSSRC and checkPacket functions as not required anymore --- protocol/rtcp/parse.go | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/protocol/rtcp/parse.go b/protocol/rtcp/parse.go index 458be546..2007a26d 100644 --- a/protocol/rtcp/parse.go +++ b/protocol/rtcp/parse.go @@ -42,9 +42,15 @@ type Timestamp struct { // a Timestamp as defined above. If the given bytes do not represent a valid // receiver report, an error is returned. func ParseTimestamp(buf []byte) (Timestamp, error) { - err := checkPacket(buf) - if err != nil { - return Timestamp{}, err + if len(buf) < 4 { + return Timestamp{}, errors.New("bad RTCP packet, not of sufficient length") + } + if (buf[0]&0xc0)>>6 != rtcpVer { + return Timestamp{}, errors.New("incompatible RTCP version") + } + + if buf[1] != typeSenderReport { + return Timestamp{}, errors.New("RTCP packet is not of sender report type") } return Timestamp{ @@ -52,25 +58,3 @@ func ParseTimestamp(buf []byte) (Timestamp, error) { Fraction: binary.BigEndian.Uint32(buf[12:]), }, nil } - -func ParseSSRC(buf []byte) (uint32, error) { - err := checkPacket(buf) - if err != nil { - return 0, err - } - return binary.BigEndian.Uint32(buf[4:]), nil -} - -func checkPacket(buf []byte) error { - if len(buf) < 4 { - return errors.New("bad RTCP packet, not of sufficient length") - } - if (buf[0]&0xc0)>>6 != rtcpVer { - return errors.New("incompatible RTCP version") - } - - if buf[1] != typeSenderReport { - return errors.New("RTCP packet is not of sender report type") - } - return nil -}