Newer
Older
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Copyright (c) 2015-2016, Luca Fulchir<luca@fulchir.it>, All rights reserved.
*
* This file is part of "libRaptorQ".
*
* libRaptorQ is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* libRaptorQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* and a copy of the GNU Lesser General Public License
* along with libRaptorQ. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "RaptorQ/v1/common.hpp"
#include "RaptorQ/v1/wrapper/C_common.h"
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C"
{
#endif
struct RAPTORQ_LOCAL RaptorQ_ptr;
struct RAPTORQ_LOCAL RaptorQ_future;
struct RAPTORQ_LOCAL RaptorQ_future_enc;
struct RAPTORQ_LOCAL RaptorQ_future_dec;
struct RAPTORQ_API RaptorQ_dec_result {
RaptorQ_Error err;
uint16_t esi;
};
struct RaptorQ_base_api* RAPTORQ_API RaptorQ_api (uint32_t version);
struct RAPTORQ_API RaptorQ_base_api
{ uint32_t version; };
struct RAPTORQ_API RaptorQ_v1
{
struct RaptorQ_base_api base;
// precomputation caching
RaptorQ_Compress (*supported_compressions)();
RaptorQ_Compress (*get_compression)();
bool (*set_compression) (const RaptorQ_Compress);
size_t (*shared_cache_size) (const size_t);
size_t (*local_cache_size) (const size_t);
size_t (*get_shared_cache_size)();
size_t (*get_local_cache_size)();
// contructos
struct RaptorQ_ptr* (*Encoder_nodata) (RaptorQ_type type,
const uint16_t symbols,
const size_t symbol_size);
struct RaptorQ_ptr* (*Encoder) (RaptorQ_type type, const void* from,
const void* to,
const size_t symbol_size);
struct RaptorQ_ptr* (*Decoder) (RaptorQ_type type,
const uint16_t symbols,
const size_t symbol_size,
const RaptorQ_Compute report);
// common functions
uint16_t (*symbols) (const RaptorQ_ptr *ptr);
size_t (*symbol_size) (const RaptorQ_ptr *ptr);
RaptorQ_Error (*future_state) (struct RaptorQ_future *f);
RaptorQ_Error (*future_wait_for) (struct RaptorQ_future *f,
const uint64_t time,
const RaptorQ_Unit_Time unit);
void (*future_wait) (struct RaptorQ_future *f);
void (*future_free) (struct RaptorQ_future **f);
// encoder-specific
uint32_t (*max_repair) (const RaptorQ_ptr *enc);
size_t (*add_data) (const RaptorQ_ptr *enc, void *from, const void *to);
void (*clear_data) (const RaptorQ_ptr *enc);
size_t (*needed_bytes) (const RaptorQ_ptr *enc);
bool (*compute_sync) (const RaptorQ_ptr *enc);
RaptorQ_future_enc* (*compute) (const RaptorQ_ptr *enc);
RaptorQ_Error (*enc_future_get) (struct RaptorQ_future_enc *f);
size_t (*encode) (const RaptorQ_ptr *enc,
void *from, const void *to, const uint32_t);
// decoder-specific
RaptorQ_Error (*add_symbol) (const RaptorQ_ptr *dec, void *from,
const void *to,
const uint32_t esi);
bool (*can_decode) (const RaptorQ_ptr *dec);
void (*stop) (const RaptorQ_ptr *dec); //TODO: make common.
uint16_t (*needed_symbols) (const RaptorQ_ptr *dec);
RaptorQ_dec_result (*poll) (const RaptorQ_ptr *dec);
RaptorQ_dec_result (*wait_sync) (const RaptorQ_ptr *dec);
RaptorQ_future_dec* (*wait) (const RaptorQ_ptr *dec);
RaptorQ_dec_result (*dec_future_get) (struct RaptorQ_future_dec *f);
};
#ifdef __cplusplus
} // extern "C"
#endif