diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2020-09-03 03:00:30 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2020-09-03 03:00:30 +0200 |
commit | 5172421d248250b4ab3b69eb57fd83656e23a4da (patch) | |
tree | a499d9f1dd0b74b754816884a59927b3171656fc /src/roof-read.c | |
parent | 7b2e6168b049be9e7852b2d364d897592eff69fc (diff) | |
download | ufo-roof-temp-5172421d248250b4ab3b69eb57fd83656e23a4da.tar.gz ufo-roof-temp-5172421d248250b4ab3b69eb57fd83656e23a4da.tar.bz2 ufo-roof-temp-5172421d248250b4ab3b69eb57fd83656e23a4da.tar.xz ufo-roof-temp-5172421d248250b4ab3b69eb57fd83656e23a4da.zip |
Diffstat (limited to 'src/roof-read.c')
-rw-r--r-- | src/roof-read.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/src/roof-read.c b/src/roof-read.c new file mode 100644 index 0000000..18a7508 --- /dev/null +++ b/src/roof-read.c @@ -0,0 +1,107 @@ +#include <stdio.h> + +#include "roof.h" +#include "roof-read.h" + +RoofReadContext *roof_read_context_new(RoofConfig *cfg, RoofReadInterface *rdi, GError **error) { + guint i; + GError *gerr = NULL; + + RoofReadContext *rdc = (RoofReadContext*)calloc(1, sizeof(RoofReadContext)); + if (!rdc) roof_new_error(error, "Can't allocate RoofReadContext"); + + rdc->cfg = cfg; + rdc->rdi = rdi; + + return rdc; +} + +void roof_read_context_free(RoofReadContext *rdc) { + if (rdc) { + free(rdc); + } +} + +void roof_read(RoofReadContext *rdc, RoofBufferInterface *bfi, GError *error) { + uint8_t *rdbuf = rdc->rdbuf; + guint n_packets = rdc->n_packets; + guint packet_id = rdc->packet_id; + guint fragment_id = rdc->fragment_id; + GError *gerr = NULL; + + ReadRoofInterface *rdi = rdc->rdi; + + if (rdc->rdbuf) { + rdbuf = rdc->rdbuf; + packets + else { + guint packets = rdi->read(rdi[stream_id], &rdbuf, &gerr); + if (gerr) roof_propagate_error(error, gerr, "roof_read: "); + packet_id = 0; + fragment_id = 0; + } + + packet = rdbuf + packet_id * (size + padding + + while (packet) { + + + while (rdbuf) { + // + + for (guint i = 0; i < packets; i++) { + guint64 packet_id = 0; + + // Otherwise considered consecutive and handled by the buffer + if (cfg->header_size >= sizeof(RoofPacketHeader)) { + RoofPacketHeader *pheader = ROOF_PACKET_HEADER(fragment); + packet_id = be64toh(pheader->packet_id) + 1; + } else { + // FIXME: consider consecutive + //fragment_id = ++buffer->stream_fragment[stream_id]; + } + + // FIXME: packet may contain fragments for multiple datasets + fragment_id = packet_id * fragments_per_packet; + guint64 dataset_id = (packet_id - 1) / cfg->fragments_per_stream; + guint64 fragment_id = (packet_id - 1) % cfg->fragments_per_stream; + + // FIXME: verify that packet is consecutive + // if + + // Drop packets of already skipped datasets + if (dataset_id < priv->current_id) + continue; + + // FIXME: stop processing and return.... + if (dataset_id < priv->current_id) + + uint8_t *fragment_buffer = dataset_buffer + + stream_id * fragment_dims[0] + // x-coordinate + (fragment_id * fragment_dims[1]) * dataset_dims[0]; // y-coordinate + + for (guint i = 0; i < buffer->fragment_dims[1]; ++i) { + memcpy(fragment_buffer + i * buffer->dataset_dims[0], (uint8_t*)fragment + i * buffer->fragment_dims[0], buffer->fragment_dims[0]); + + +// buffer->last_id[stream_id] = dataset_id; + + ready |= roof_buffer_set_fragment(buf, sid, packet_id, fragment, &gerr); + if (gerr) roof_print_error(gerr); + + fragment += cfg->max_packet_size; + + + } + + + } + + + + + void *buf = roof_buffer_get_dataset(bfi, ?); + + // Computing offsets each time, etc. + roof_buffer_set_fragment +}
\ No newline at end of file |