mirror of https://bitbucket.org/ausocean/av.git
protocol/rtcp/parse.go: removed ParseSSRC and checkPacket functions as not required anymore
This commit is contained in:
parent
ad241abdfd
commit
03c45b1bcf
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue