diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 0412fd9bd412c15072cbcf34e706abaf352cc08e..a16057ae570a997dcfd2a1ae1973b226de7eebb7 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -5047,7 +5047,12 @@ static int rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame *fr
 			rtp->ssrc = frame->ssrc;
 		}
 
-		put_unaligned_uint32(rtpheader, htonl((2 << 30) | (ext << 28) | (codec << 16) | (frame->seqno ? frame->seqno : seqno) | (mark << 23)));
+		if (frame->seqno)
+			rtp->seqno = frame->seqno;
+		else
+			rtp->seqno++;
+
+		put_unaligned_uint32(rtpheader, htonl((2 << 30) | (ext << 28) | (codec << 16) | (rtp->seqno) | (mark << 23)));
 		put_unaligned_uint32(rtpheader + 4, htonl(frame->ts ? frame->ts : rtp->lastts));
 		put_unaligned_uint32(rtpheader + 8, htonl(rtp->ssrc));