Chunking stream groups

For an overview, refer to Chunking stream groups. This page is a reference for the Python API. It extends the API for chunks.

class spead2.recv.ChunkStreamGroupConfig(**kwargs)

Parameters for a chunk stream group. The configuration options can either be passed to the constructor (as keyword arguments) or set as properties after construction.

Parameters:
  • max_chunks (int) – The maximum number of chunks that can be live at the same time.

  • eviction_mode (EvictionMode) – The chunk eviction mode.

class EvictionMode

Eviction mode when it is necessary to advance the group window. See the overview for more details.

LOSSY

force streams to release incomplete chunks

LOSSLESS

a chunk will only be marked ready when all streams have marked it ready

class spead2.recv.ChunkStreamRingGroup(config, data_ringbuffer, free_ringbuffer)

Stream group that uses ringbuffers to manage chunks.

When a fresh chunk is needed, it is retrieved from a ringbuffer of free chunks (the “free ring”). When a chunk is flushed, it is pushed to a “data ring”. These may be shared between groups, but both will be stopped as soon as any of the members streams are stopped. The intended use case is parallel groups that are started and stopped together.

It behaves like a Sequence of the contained streams.

Parameters:
data_ringbuffer

The data ringbuffer given to the constructor.

free_ringbuffer

The free ringbuffer given to the constructor.

add_free_chunk(chunk)

Add a chunk to the free ringbuffer. This takes care of zeroing out the Chunk.present array, and it will suppress the spead2.Stopped exception if the free ringbuffer has been stopped.

If the free ring is full, it will raise spead2.Full rather than blocking. The free ringbuffer should be constructed with enough slots that this does not happen.

emplace_back(thread_pool, config, chunk_stream_config)

Add a new stream.

Parameters:
Return type:

spead2.recv.ChunkStreamGroupMember

class spead2.recv.ChunkStreamGroupMember

A component stream in a ChunkStreamRingGroup. This class cannot be instantiated directly. Use ChunkStreamRingGroup.emplace_back() instead.

It provides the same methods for adding readers as spead2.recv.Stream.