diff --git a/pkg/aac/rtp.go b/pkg/aac/rtp.go index dd9de0e8..1df6e036 100644 --- a/pkg/aac/rtp.go +++ b/pkg/aac/rtp.go @@ -79,7 +79,7 @@ func RTPPay(handler core.HandlerFunc) core.HandlerFunc { func ADTStoRTP(src []byte) (dst []byte) { dst = make([]byte, 2) // header bytes - for i := 0; i < len(src); { + for i, n := 0, len(src)-ADTSHeaderSize; i < n; { auSize := ReadADTSSize(src[i:]) dst = append(dst, byte(auSize>>5), byte(auSize<<3)) // size in bits i += int(auSize)