diff --git a/protocol/rtp/parse.go b/protocol/rtp/parse.go index 16e64c5d..6daa5469 100644 --- a/protocol/rtp/parse.go +++ b/protocol/rtp/parse.go @@ -82,6 +82,16 @@ func Sequence(d []byte) (uint16, error) { 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 // then also checking that version is compatible with these utilities. func checkPacket(d []byte) error {