summaryrefslogtreecommitdiffstats
path: root/src/roof-buffer.h
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2020-09-03 03:00:30 +0200
committerSuren A. Chilingaryan <csa@suren.me>2020-09-03 03:00:30 +0200
commit5172421d248250b4ab3b69eb57fd83656e23a4da (patch)
treea499d9f1dd0b74b754816884a59927b3171656fc /src/roof-buffer.h
parent7b2e6168b049be9e7852b2d364d897592eff69fc (diff)
downloadufo-roof-temp-5172421d248250b4ab3b69eb57fd83656e23a4da.tar.gz
ufo-roof-temp-5172421d248250b4ab3b69eb57fd83656e23a4da.tar.bz2
ufo-roof-temp-5172421d248250b4ab3b69eb57fd83656e23a4da.tar.xz
ufo-roof-temp-5172421d248250b4ab3b69eb57fd83656e23a4da.zip
This is unfinished work implemeting out-of-UFO network serversHEADmaster
Diffstat (limited to 'src/roof-buffer.h')
-rw-r--r--src/roof-buffer.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/roof-buffer.h b/src/roof-buffer.h
new file mode 100644
index 0000000..a95dbaa
--- /dev/null
+++ b/src/roof-buffer.h
@@ -0,0 +1,52 @@
+#ifndef __ROOF_BUFFER_H
+#define __ROOF_BUFFER_H
+
+ // This IS harmful! Just for testing
+#define ROOF_INDEPENDENT_STREAMS
+
+#include <stdatomic.h>
+#include <stdint.h>
+#include "ufo-roof-config.h"
+
+struct _RoofBuffer {
+ guint64 current_id; // The ID of the first (active) dataset in the buffer
+#ifdef ROOF_INDEPENDENT_STREAMS
+ guint64 *first_id; // The ID of the first received dataset (used for numbering), -1 means not yet known
+#else
+ guint64 first_id; // The ID of the first received dataset (used for numbering), -1 means not yet known
+#endif
+ guint64 *last_id;
+ guint64 n_ready;
+
+ guint n_streams;
+ guint ring_size; // Number of datasets to buffer
+ guint drop_buffers; // If we need to catch up
+ guint latency_buffers; // we skip incomplete buffers if current_id + latency_buffers is ready
+ 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)
+
+
+ guint64 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 _RoofBuffer RoofBuffer;
+
+RoofBuffer *roof_buffer_new(RoofConfig *cfg, guint n_dims, guint max_datasets, GError **error);
+void roof_buffer_free(RoofBuffer *buf);
+
+gboolean roof_buffer_set_fragment(RoofBuffer *buffer, guint stream_id, guint64 fragment_id, gconstpointer fragment, GError **error);
+gboolean roof_buffer_skip_to_ready(RoofBuffer *buffer);
+gboolean roof_buffer_get_dataset(RoofBuffer *buffer, gpointer output_buffer, gulong *seqid, GError **error);
+gboolean roof_buffer_wait_dataset(RoofBuffer *buffer, gpointer output_buffer, gulong *seqid, gulong timeout, GError **error);
+
+#endif