summaryrefslogtreecommitdiffstats
path: root/src/ufo-roof-buffer.h
blob: 7ebaec90bde709c9975c409aab72955beaa3a33e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef __UFO_ROOF_BUFFER_H
#define __UFO_ROOF_BUUFER_H

#include <stdatomic.h>

struct _UfoRoofBuffer {
    guint                       current_id;                             // The ID of the first (active) dataset in the buffer

    guint                       ring_size;                              // Number of datasets to buffer
    guint			drop_buffers;				// If we need to catch up
    uint8_t			*ring_buffer;				// The ring buffer
    _Atomic guint               *n_fragments;                           // Number of completed fragments in each buffer
    guint                       *stream_fragment;                       // Currently processed fragment in the stream (for ordered streams)
//    int		                *fragments;				// Mark individual completed fragments (if we care for partial data)


    guint			max_datasets;				// Only the specified number of datasets will be buffered, the rest will be silently dropped
    guint			n_dims;					// Indicates if we just assemble one fragment after another or there is 2D/3D data structure (ROOF)
    guint                       dataset_size;                           // Size (in bytes) of a full dataset
    guint			dataset_dims[2];			// x (in bytes), y (in rows)
    guint                       fragment_size;                          // Size (in bytes) of a single fragment (we expect fixed-size fragments at the moment)
    guint			fragment_dims[2];			// x (in bytes), y (in rows)

    guint                       fragments_per_dataset;                  // Number of packets in dataset (used to compute when dataset is ready)
    guint                       fragments_per_stream;                   // Number of packets in each of data streams (used to compute when dataset is ready)
};

typedef struct _UfoRoofBuffer	UfoRoofBuffer;

UfoRoofBuffer *ufo_roof_buffer_new(UfoRoofConfig *cfg, guint n_dims, guint max_datasets, GError **error);
void ufo_roof_buffer_free(UfoRoofBuffer *buf);

gboolean ufo_roof_buffer_set_fragment(UfoRoofBuffer *buffer, guint stream_id, guint fragment_id, gconstpointer fragment, GError **error);
gboolean ufo_roof_buffer_get_dataset(UfoRoofBuffer *buffer, gpointer output_buffer, GError **error);

#endif