protocol/rtcp/parse.go: removed ParseSSRC and checkPacket functions as not required anymore

This commit is contained in:
Saxon 2019-05-27 14:31:14 +09:30
parent ad241abdfd
commit 03c45b1bcf
1 changed files with 9 additions and 25 deletions

View File

@ -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
}