Package org.jitsi.impl.neomedia.rtp
Class RawPacketCache
- java.lang.Object
-
- org.jitsi.impl.neomedia.rtp.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classRawPacketCache.ContainerA container for packets in the cache.
-
Field Summary
Fields Modifier and Type Field Description static StringNACK_CACHE_SIZE_MILLISConfiguration property for nack cache size in milliseconds.static StringNACK_CACHE_SIZE_PACKETSConfiguration property number of packets to cache.static StringNACK_CACHE_SIZE_STREAMSConfiguration property for number of streams to cache
-
Constructor Summary
Constructors Constructor Description RawPacketCache(int streamId)Initializes a newCachingTransformerinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcachePacket(RawPacket pkt)Saves a packet in the cache.voidclean(long now)Checks forRawPacketCache.Cacheinstances which have not received new packets for a period longer thanSSRC_TIMEOUT_MILLISand removes them.voidclose()RawPacketget(long ssrc, int seq)Gets the packet with the given SSRC and RTP sequence number from the cache.RawPacketCache.ContainergetContainer(long ssrc, int seq)Gets the packet, encapsulated in aRawPacketCache.Containerwith the given SSRC and RTP sequence number from the cache.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.voidupdateTimestamp(long ssrc, int seq, long ts)Updates the timestamp of the packet in the cache with SSRCssrcand sequence numberseq, if such a packet exists in the cache, setting it tots.
-
-
-
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 newCachingTransformerinstance.- Parameters:
streamId- the identifier of the owning stream.
-
-
Method Detail
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
getContainer
public RawPacketCache.Container getContainer(long ssrc, int seq)
Gets the packet, encapsulated in aRawPacketCache.Containerwith 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.Containerwith 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 forRawPacketCache.Cacheinstances which have not received new packets for a period longer thanSSRC_TIMEOUT_MILLISand 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 SSRCssrcand sequence numberseq, if such a packet exists in the cache, setting it tots.- Parameters:
ssrc- the SSRC of the packet.seq- the sequence number of the packet.ts- the timestamp to set.
-
-