mirror of
https://github.com/livekit/livekit.git
synced 2026-09-22 15:55:03 +00:00
SendPacket allocated four times per down track write: a 3 byte slice for abs-send-time, a 2 byte slice for transport-cc, and two appends to a nil Extensions slice because the pooled header was reset to a zero value. Give pacer.Packet fixed scratch arrays for the two extensions and marshal into them. The Packet is pooled and owned by one send until SendPacket returns, so nothing is shared across down tracks. Keep the pooled header's Extensions capacity across reuse, both when returning it to the pool and when a down track initializes it. Adds a test that asserts zero allocations per SendPacket. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>