|
| 1 | +/* RQ Library - C API |
| 2 | + * Generated with cbindgen |
| 3 | + */ |
| 4 | + |
| 5 | + |
| 6 | +#ifndef RQ_LIB_H |
| 7 | +#define RQ_LIB_H |
| 8 | + |
| 9 | +/* Generated with cbindgen:0.28.0 */ |
| 10 | + |
| 11 | +#include <stdint.h> |
| 12 | +#include <stdbool.h> |
| 13 | + |
| 14 | +#ifdef __cplusplus |
| 15 | +namespace RQLibrary { |
| 16 | +#endif // __cplusplus |
| 17 | + |
| 18 | +#ifdef __cplusplus |
| 19 | +extern "C" { |
| 20 | +#endif // __cplusplus |
| 21 | + |
| 22 | +/** |
| 23 | + * Initializes a RaptorQ session with the given configuration |
| 24 | + * Returns a session ID on success, or 0 on failure |
| 25 | + */ |
| 26 | +uintptr_t raptorq_init_session(uint16_t symbol_size, |
| 27 | + uint8_t redundancy_factor, |
| 28 | + uint64_t max_memory_mb, |
| 29 | + uint64_t concurrency_limit); |
| 30 | + |
| 31 | +/** |
| 32 | + * Frees a RaptorQ session |
| 33 | + */ |
| 34 | +bool raptorq_free_session(uintptr_t session_id); |
| 35 | + |
| 36 | +/** |
| 37 | + * Encodes a file using RaptorQ - streaming implementation |
| 38 | + * |
| 39 | + * Arguments: |
| 40 | + * * `session_id` - Session ID returned from raptorq_init_session |
| 41 | + * * `input_path` - Path to the input file |
| 42 | + * * `output_dir` - Directory where symbols will be written |
| 43 | + * * `block_size` - Size of blocks to process at once (0 = auto) |
| 44 | + * * `result_buffer` - Buffer to store the result (JSON metadata) |
| 45 | + * * `result_buffer_len` - Length of the result buffer |
| 46 | + * |
| 47 | + * Returns: |
| 48 | + * * 0 on success |
| 49 | + * * -1 on generic error |
| 50 | + * * -2 on invalid parameters |
| 51 | + * * -3 on invalid response |
| 52 | + * * -4 on bad return buffer size |
| 53 | + * * -4 on encoding failure |
| 54 | + * * -5 on invalid session |
| 55 | + * * -11 on IO error |
| 56 | + * * -12 on File not found |
| 57 | + * * -13 on Encoding failed |
| 58 | + * * -15 on Memory limit exceeded |
| 59 | + * * -16 on Concurrency limit reached |
| 60 | + */ |
| 61 | +int32_t raptorq_create_metadata(uintptr_t session_id, |
| 62 | + const char *input_path, |
| 63 | + const char *output_dir, |
| 64 | + uintptr_t block_size, |
| 65 | + bool return_layout, |
| 66 | + char *result_buffer, |
| 67 | + uintptr_t result_buffer_len); |
| 68 | + |
| 69 | +/** |
| 70 | + * Encodes a file using RaptorQ - streaming implementation |
| 71 | + * |
| 72 | + * Arguments: |
| 73 | + * * `session_id` - Session ID returned from raptorq_init_session |
| 74 | + * * `input_path` - Path to the input file |
| 75 | + * * `output_dir` - Directory where symbols will be written |
| 76 | + * * `block_size` - Size of blocks to process at once (0 = auto) |
| 77 | + * * `result_buffer` - Buffer to store the result (JSON metadata) |
| 78 | + * * `result_buffer_len` - Length of the result buffer |
| 79 | + * |
| 80 | + * Returns: |
| 81 | + * * 0 on success |
| 82 | + * * -1 on generic error |
| 83 | + * * -2 on invalid parameters |
| 84 | + * * -3 on invalid response |
| 85 | + * * -4 on bad return buffer size |
| 86 | + * * -4 on encoding failure |
| 87 | + * * -5 on invalid session |
| 88 | + * * -11 on IO error |
| 89 | + * * -12 on File not found |
| 90 | + * * -13 on Encoding failed |
| 91 | + * * -15 on Memory limit exceeded |
| 92 | + * * -16 on Concurrency limit reached |
| 93 | + */ |
| 94 | +int32_t raptorq_encode_file(uintptr_t session_id, |
| 95 | + const char *input_path, |
| 96 | + const char *output_dir, |
| 97 | + uintptr_t block_size, |
| 98 | + char *result_buffer, |
| 99 | + uintptr_t result_buffer_len); |
| 100 | + |
| 101 | +/** |
| 102 | + * Gets the last error message from the processor |
| 103 | + * |
| 104 | + * Arguments: |
| 105 | + * * `session_id` - Session ID returned from raptorq_init_session |
| 106 | + * * `error_buffer` - Buffer to store the error message |
| 107 | + * * `error_buffer_len` - Length of the error buffer |
| 108 | + * |
| 109 | + * Returns: |
| 110 | + * * 0 on success |
| 111 | + * * -1 on error |
| 112 | + */ |
| 113 | +int32_t raptorq_get_last_error(uintptr_t session_id, |
| 114 | + char *error_buffer, |
| 115 | + uintptr_t error_buffer_len); |
| 116 | + |
| 117 | +/** |
| 118 | + * Decodes RaptorQ symbols back to the original file |
| 119 | + * |
| 120 | + * Arguments: |
| 121 | + * * `session_id` - Session ID returned from raptorq_init_session |
| 122 | + * * `symbols_dir` - Directory containing the symbols |
| 123 | + * * `output_path` - Path where the decoded file will be written |
| 124 | + * * `layout_path` - Path to the layout file (containing encoder parameters and block information) |
| 125 | + * |
| 126 | + * Returns: |
| 127 | + * * 0 on success |
| 128 | + * * -1 on generic error |
| 129 | + * * -2 on invalid parameters |
| 130 | + * * -3 on invalid response |
| 131 | + * * -4 on bad return buffer size |
| 132 | + * * -4 on encoding failure |
| 133 | + * * -5 on invalid session |
| 134 | + * * -11 on IO error |
| 135 | + * * -12 on File not found |
| 136 | + * * -14 on Decoding failed |
| 137 | + * * -15 on Memory limit exceeded |
| 138 | + * * -16 on Concurrency limit reached |
| 139 | + */ |
| 140 | +int32_t raptorq_decode_symbols(uintptr_t session_id, |
| 141 | + const char *symbols_dir, |
| 142 | + const char *output_path, |
| 143 | + const char *layout_path); |
| 144 | + |
| 145 | +/** |
| 146 | + * Gets a recommended block size based on file size and available memory |
| 147 | + * |
| 148 | + * Arguments: |
| 149 | + * * `session_id` - Session ID returned from raptorq_init_session |
| 150 | + * * `file_size` - Size of the file to process |
| 151 | + * |
| 152 | + * Returns: |
| 153 | + * * Recommended block size in bytes |
| 154 | + * * 0 if it should not block or on error |
| 155 | + */ |
| 156 | +uintptr_t raptorq_get_recommended_block_size(uintptr_t session_id, uint64_t file_size); |
| 157 | + |
| 158 | +/** |
| 159 | + * Version information |
| 160 | + */ |
| 161 | +int32_t raptorq_version(char *version_buffer, uintptr_t version_buffer_len); |
| 162 | + |
| 163 | +#ifdef __cplusplus |
| 164 | +} // extern "C" |
| 165 | +#endif // __cplusplus |
| 166 | + |
| 167 | +#ifdef __cplusplus |
| 168 | +} // namespace RQLibrary |
| 169 | +#endif // __cplusplus |
| 170 | + |
| 171 | +#endif /* RQ_LIB_H */ |
0 commit comments