packetcache

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package packetcache implement a packet cache that maintains a history of recently seen packets, the last keyframe, and a number of statistics that are needed for sending receiver reports.

Index

Constants

View Source
const BufSize = 1504

The maximum size of packets stored in the cache. Chosen to be a multiple of 8.

Variables

This section is empty.

Functions

func ToBitmap

func ToBitmap(seqnos []uint16) (first uint16, bitmap uint16, remain []uint16)

ToBitmap takes a non-empty sorted list of seqnos, and computes a bitmap covering a prefix of the list. It returns the part of the list that couldn't be covered.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func New

func New(capacity int) *Cache

New creates a cache with the given capacity.

func (*Cache) BitmapGet

func (cache *Cache) BitmapGet(next uint16) (bool, uint16, uint16)

BitmapGet shifts up to 17 bits out of the bitmap. It returns a boolean indicating if any were 0, the index of the first 0 bit, and a bitmap indicating any 0 bits after the first one.

func (*Cache) Expect

func (cache *Cache) Expect(n int)

Expect records that we expect n additional packets.

func (*Cache) Get

func (cache *Cache) Get(seqno uint16, result []byte) uint16

Get retrieves a packet from the cache, returns the number of bytes copied. If result is of length 0, returns the size of the packet.

func (*Cache) GetAt

func (cache *Cache) GetAt(seqno uint16, index uint16, result []byte) uint16

GetAt retrieves a packet from the cache assuming it is at the given index.

func (*Cache) GetStats

func (cache *Cache) GetStats(reset bool) Stats

GetStats returns statistics about received packets. If reset is true, the statistics are reset.

func (*Cache) Keyframe

func (cache *Cache) Keyframe() (uint16, bool)

Keyframe returns the seqno of the last seen keyframe

func (*Cache) Last

func (cache *Cache) Last() (uint16, bool)

func (*Cache) Resize

func (cache *Cache) Resize(capacity int)

Resize resizes the cache to the given capacity. This might invalidate indices of recently stored packets.

func (*Cache) ResizeCond

func (cache *Cache) ResizeCond(capacity int) bool

ResizeCond is like Resize, but avoids invalidating recent indices.

func (*Cache) Store

func (cache *Cache) Store(seqno uint16, timestamp uint32, keyframe bool, marker bool, buf []byte) (uint16, uint16)

Store stores a packet in the cache. It returns the first seqno in the bitmap, and the index at which the packet was stored.

type Stats

type Stats struct {
	Received, TotalReceived uint32
	Expected, TotalExpected uint32
	ESeqno                  uint32
}

Stats contains cache statistics

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL