+/** Determines SRTP Roll-Over-Counter (in host-byte order) */
+static uint32_t
+srtp_compute_roc (const srtp_session_t *s, uint16_t seq)
+{
+ uint32_t roc = s->rtp_roc;
+
+ if (((seq - s->rtp_seq) & 0xffff) < 0x8000)
+ {
+ /* Sequence is ahead, good */
+ if (seq < s->rtp_seq)
+ roc++; /* Sequence number wrap */
+ }
+ else
+ {
+ /* Sequence is late, bad */
+ if (seq > s->rtp_seq)
+ roc--; /* Wrap back */
+ }
+ return roc;
+}
+
+
+/** Returns RTP sequence (in host-byte order) */
+static inline uint16_t rtp_seq (const uint8_t *buf)
+{
+ return (buf[2] << 8) | buf[3];
+}
+
+