Class RawPacketCache

  • All Implemented Interfaces:
    AutoCloseable

    public class RawPacketCache
    extends Object
    implements AutoCloseable
    An simple interface which allows a packet to be retrieved from a cache/storage by an SSRC identifier and a sequence number.
    Author:
    Boris Grozev, George Politis
    • Field Detail

      • NACK_CACHE_SIZE_STREAMS

        public static final String NACK_CACHE_SIZE_STREAMS
        Configuration property for number of streams to cache
        See Also:
        Constant Field Values
      • NACK_CACHE_SIZE_PACKETS

        public static final String NACK_CACHE_SIZE_PACKETS
        Configuration property number of packets to cache.
        See Also:
        Constant Field Values
      • NACK_CACHE_SIZE_MILLIS

        public static final String NACK_CACHE_SIZE_MILLIS
        Configuration property for nack cache size in milliseconds.
        See Also:
        Constant Field Values
    • Constructor Detail

      • RawPacketCache

        public RawPacketCache​(int streamId)
        Initializes a new CachingTransformer instance.
        Parameters:
        streamId - the identifier of the owning stream.
    • Method Detail

      • getContainer

        public RawPacketCache.Container getContainer​(long ssrc,
                                                     int seq)
        Gets the packet, encapsulated in a RawPacketCache.Container with the given SSRC and RTP sequence number from the cache. If no such packet is found, returns null.
        Parameters:
        ssrc - The SSRC of the packet.
        seq - the RTP sequence number of the packet.
        Returns:
        the packet, encapsulated in a RawPacketCache.Container with the given SSRC and RTP sequence number from the cache. If no such packet is found, returns null.
      • get

        public RawPacket get​(long ssrc,
                             int seq)
        Gets the packet with the given SSRC and RTP sequence number from the cache. If no such packet is found, returns null.
        Parameters:
        ssrc - The SSRC of the packet.
        seq - the RTP sequence number of the packet.
        Returns:
        the packet with the given SSRC and RTP sequence number from the cache. If no such packet is found, returns null.
      • cachePacket

        public void cachePacket​(RawPacket pkt)
        Saves a packet in the cache.
        Parameters:
        pkt - the packet to save.
      • clean

        public void clean​(long now)
        Checks for RawPacketCache.Cache instances which have not received new packets for a period longer than SSRC_TIMEOUT_MILLIS and removes them.
      • getMany

        public Set<RawPacketCache.Container> getMany​(long ssrc,
                                                     int bytes)
        Gets the most recent packets from the cache that pertains to the SSRC that is specified as an argument, not exceeding the number of bytes specified as an argument.
        Parameters:
        ssrc - the SSRC whose most recent packets to retrieve.
        bytes - the maximum total size of the packets to retrieve.
        Returns:
        the set of the most recent packets to retrieve, not exceeding the number of bytes specified as an argument, or null if there are no packets in the cache
      • updateTimestamp

        public void updateTimestamp​(long ssrc,
                                    int seq,
                                    long ts)
        Updates the timestamp of the packet in the cache with SSRC ssrc and sequence number seq, if such a packet exists in the cache, setting it to ts.
        Parameters:
        ssrc - the SSRC of the packet.
        seq - the sequence number of the packet.
        ts - the timestamp to set.