// SPDX-FileCopyrightText: 2023 The Pion community // SPDX-License-Identifier: MIT // Package rtpbuffer provides a buffer for storing RTP packets package rtpbuffer import ( "fmt" ) const ( // Uint16SizeHalf is half of a math.Uint16. Uint16SizeHalf = 1 << 15 maxPayloadLen = 1460 ) // RTPBuffer stores RTP packets and allows custom logic // around the lifetime of them via the PacketFactory. type RTPBuffer struct { packets []*RetainablePacket size uint16 highestAdded uint16 started bool } // NewRTPBuffer constructs a new RTPBuffer. func NewRTPBuffer(size uint16) (*RTPBuffer, error) { allowedSizes := make([]uint16, 0) correctSize := false for i := 0; i < 16; i++ { if size == 1<= Uint16SizeHalf { return nil } if diff >= r.size { return nil } pkt := r.packets[seq%r.size] if pkt != nil { if pkt.sequenceNumber != seq { return nil } // already released if err := pkt.Retain(); err != nil { return nil } } return pkt }