mirror of https://bitbucket.org/ausocean/av.git
protocol/rtp: add Timestamp parsing function
This commit is contained in:
parent
6e3f0f2a61
commit
830d8ea647
|
@ -82,6 +82,16 @@ func Sequence(d []byte) (uint16, error) {
|
||||||
return binary.BigEndian.Uint16(d[2:]), nil
|
return binary.BigEndian.Uint16(d[2:]), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Timestamp returns the RTP timestamp of an RTP packet. An error is returned
|
||||||
|
// if the packet is not valid.
|
||||||
|
func Timestamp(d []byte) (uint32, error) {
|
||||||
|
err := checkPacket(d)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return binary.BigEndian.Uint32(d[4:]), nil
|
||||||
|
}
|
||||||
|
|
||||||
// checkPacket checks the validity of the packet, firstly by checking size and
|
// checkPacket checks the validity of the packet, firstly by checking size and
|
||||||
// then also checking that version is compatible with these utilities.
|
// then also checking that version is compatible with these utilities.
|
||||||
func checkPacket(d []byte) error {
|
func checkPacket(d []byte) error {
|
||||||
|
|
Loading…
Reference in New Issue