Newer
Older
* 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/>.
*/
#include "RaptorQ/v1/wrapper/C_RFC_API.h"
#include "RaptorQ/v1/wrapper/CPP_RFC_API.hpp"
#include "RaptorQ/v1/caches.hpp"
RaptorQ_ptr (const RaptorQ_type _type) : ptr (nullptr), type (_type) {}
struct RAPTORQ_LOCAL RaptorQ_future
{
void RAPTORQ_LOCAL RFC6330_test_del (struct RaptorQ_ptr **ptr);
void RAPTORQ_LOCAL RFC6330_test_del (struct RaptorQ_ptr **ptr)
{
if (ptr == nullptr || *ptr == nullptr ||
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
112
113
114
115
116
117
118
|| (*ptr)->ptr == nullptr) {
if (ptr != nullptr) {
delete *ptr;
*ptr = nullptr;
return;
}
return;
}
switch ((*ptr)->type) {
case RaptorQ_type::RQ_ENC_8:
if(!(reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_ENC_16:
if(!(reinterpret_cast<RFC6330__v1::Encoder<uint16_t, uint16_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_ENC_32:
if(!(reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_ENC_64:
if(!(reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_DEC_8:
if(!(reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_DEC_16:
if(!(reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_DEC_32:
if(!(reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_DEC_64:
if(!(reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_NONE:
assert(false && "RaptorQ: C Wrapper: should not have gotten here");
break;
}
return;
}
struct RaptorQ_ptr *RaptorQ_Enc (const RaptorQ_type type, void *data,
const uint64_t size,
const uint16_t min_subsymbol_size,
const uint16_t symbol_size,
const size_t max_memory)
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
switch (type) {
case RaptorQ_type::RQ_ENC_8:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Encoder<uint8_t*, uint8_t*> (
reinterpret_cast<uint8_t*> (data),
reinterpret_cast<uint8_t*> (data) + size,
min_subsymbol_size,
symbol_size,
max_memory));
break;
case RaptorQ_type::RQ_ENC_16:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Encoder<uint16_t*, uint16_t*> (
reinterpret_cast<uint16_t*> (data),
reinterpret_cast<uint16_t*> (data) + size,
min_subsymbol_size,
symbol_size,
max_memory));
break;
case RaptorQ_type::RQ_ENC_32:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Encoder<uint32_t*, uint32_t*> (
reinterpret_cast<uint32_t*> (data),
reinterpret_cast<uint32_t*> (data) + size,
min_subsymbol_size,
symbol_size,
max_memory));
break;
case RaptorQ_type::RQ_ENC_64:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Encoder<uint64_t*, uint64_t*> (
reinterpret_cast<uint64_t*> (data),
reinterpret_cast<uint64_t*> (data) + size,
min_subsymbol_size,
symbol_size,
max_memory));
break;
case RaptorQ_type::RQ_DEC_8:
case RaptorQ_type::RQ_DEC_16:
case RaptorQ_type::RQ_DEC_32:
case RaptorQ_type::RQ_DEC_64:
case RaptorQ_type::RQ_NONE:
return new RaptorQ_ptr (RaptorQ_type::RQ_NONE);
}
auto raw_ptr = ret.release();
RFC6330_test_del (&raw_ptr);
return raw_ptr;
const RaptorQ_OTI_Common_Data common,
const RaptorQ_OTI_Scheme_Specific_Data scheme)
switch (type) {
case RaptorQ_type::RQ_DEC_8:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Decoder<uint8_t*, uint8_t*> (common, scheme));
break;
case RaptorQ_type::RQ_DEC_16:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Decoder<uint16_t*, uint16_t*> (common,scheme));
break;
case RaptorQ_type::RQ_DEC_32:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Decoder<uint32_t*, uint32_t*> (common,scheme));
break;
case RaptorQ_type::RQ_DEC_64:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Decoder<uint64_t*, uint64_t*> (common,scheme));
break;
case RaptorQ_type::RQ_ENC_8:
Loading full blame...