mirror of https://bitbucket.org/ausocean/av.git
27 lines
679 B
Go
27 lines
679 B
Go
|
package rtcp
|
||
|
|
||
|
import (
|
||
|
"encoding/binary"
|
||
|
"errors"
|
||
|
)
|
||
|
|
||
|
// Timestamp gets the timestamp from a receiver report and returns as the most
|
||
|
// significant word, and the least significant word. If the given bytes do not
|
||
|
// represent a valid receiver report, and error is returned.
|
||
|
func Timestamp(buf []byte) (msw, lsw uint32, err error) {
|
||
|
// First check version of rtcp
|
||
|
if (buf[0] & 0xc0 >> 6) != 2 {
|
||
|
return 0, 0, errors.New("incompatible RTCP version")
|
||
|
}
|
||
|
|
||
|
// Check type of packet
|
||
|
if buf[1] != typeSenderReport {
|
||
|
return 0, 0, errors.New("rtcp packet is not of sender report type")
|
||
|
}
|
||
|
|
||
|
msw = binary.BigEndian.Uint32(buf[8:])
|
||
|
lsw = binary.BigEndian.Uint32(buf[12:])
|
||
|
|
||
|
return
|
||
|
}
|