Skip to main content

parse_chunks

Function parse_chunks 

Source
pub fn parse_chunks(payload: &[u8]) -> Result<Vec<ChunkRaw<'_>>, ChunkError>
Expand description

Split a GigE Vision chunk payload into its chunks, in payload order.

Each chunk is its data followed by an 8-byte tag — the chunk ID, then the data length, both 32-bit big-endian — so the payload can only be read from its end: the last 8 bytes are the last chunk’s tag, its length says where that chunk’s data begins, and the 8 bytes before that are the previous tag. With payload type 0x4001 the image is the first chunk, and the scan ends exactly at offset 0 after it.

The GigE Vision specification is not available to us; the layout is corroborated by aravis (arv_buffer_get_chunk_data walks {u32 id; u32 size} tags back from the received size, big-endian for GigE Vision) and by the vendor corpus’s 32-bit <ChunkID>s such as FLIR’s 0x0508000E (ADR-0026). payload must end where the camera’s data ends — the received length, not a buffer sized from PayloadSize.

Remote input: a tag that claims more than precedes it, or a front too short for a tag, is an error naming the offset. A zero-length chunk is a chunk; the scan still moves back by its tag, so it cannot loop.