Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seniorjoinu/wirehair-wrapper
Wirehair wrapper for Kotlin - O(N) Fountain Code for Large Data
https://github.com/seniorjoinu/wirehair-wrapper
fast fec fountain-codes kotlin
Last synced: about 5 hours ago
JSON representation
Wirehair wrapper for Kotlin - O(N) Fountain Code for Large Data
- Host: GitHub
- URL: https://github.com/seniorjoinu/wirehair-wrapper
- Owner: seniorjoinu
- Created: 2019-04-05T15:26:57.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-01-15T15:30:21.000Z (almost 3 years ago)
- Last Synced: 2023-03-11T15:03:46.152Z (over 1 year ago)
- Topics: fast, fec, fountain-codes, kotlin
- Language: Kotlin
- Homepage:
- Size: 366 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Wirehair Kotlin Wrapper
Kotlin wrapper for amazing [catid/wirehair](https://github.com/catid/wirehair)
Works under:
* `linux-x86-64`
* `win32-x86-64`### Example
```kotlin
// initializing wirehair
Wirehair.init()// setting sizes
val kPacketSize = 1400
val kMessageBytes = 1000 * 1000 + 333// creating the message
val message = ByteBuffer.allocateDirect(kMessageBytes) as DirectBuffer// creating encoder and decoder and releasing them after all stuff is done
Wirehair.Encoder(message, kMessageBytes, kPacketSize).use { encoder ->
Wirehair.Decoder(kMessageBytes, kPacketSize).use { decoder ->
var blockId = 0while (true) {
// generating unique blockId
blockId++// generating repair block
val block = ByteArray(kPacketSize)
val writeLen = encoder.encode(blockId, block, kPacketSize)// imitating 10 percent packet drop
if (blockId % 10 == 0) continue// accumulating repair blocks
val enough = decoder.decode(blockId, block, writeLen)if (enough) break
}// decoding message from accumulated repair blocks
val decoded = ByteArray(kMessageBytes)
decoder.recover(decoded, kMessageBytes)
}
}
```### Install
Use [Jitpack](https://jitpack.io/)### Help
Feel free to open an issue or suggest a PR### TODO
* Bundle `jar` with binaries for major platforms
* Add other functions to the high level wrapper