High-performance native audio codec implementations for Lavaplayer, written in Rust with JNI bindings.
This project provides native implementations of audio codecs (AAC, MP3, Opus, Vorbis) and sample rate conversion for use with Lavaplayer. Built with Rust for memory safety and performance, it serves as a drop-in replacement for lavaplayer-natives.
- AAC Decoder: Using FDK-AAC library
- MP3 Decoder: Using mpg123 library
- Opus Codec: Full encoder and decoder support
- Vorbis Decoder: Ogg Vorbis decoding support
- Sample Rate Conversion: Using libsamplerate
Supported native platforms:
Linux x86_64:
Linux ARM64:
Windows x86_64:
macOS Universal (x86_64 + aarch64):
repositories {
maven {
url = uri("https://maven.pkg.github.com/NezuChan/connector-rs")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.token") ?: System.getenv("GITHUB_TOKEN")
}
}
}
dependencies {
implementation("org.nezu:connector-native-linux-x86-64:VERSION")
implementation("org.nezu:connector-native-linux-aarch64:VERSION")
implementation("org.nezu:connector-native-win-x86-64:VERSION")
implementation("org.nezu:connector-native-darwin:VERSION")
}- Rust toolchain (1.70+)
- Java Development Kit (JDK 8+)
- Gradle
- Native library dependencies (automatically handled by -sys crates)
The project supports multiple target platforms:
- Linux: x86_64 (glibc), aarch64 (ARM 64-bit)
- Windows: x86_64
- macOS: Universal binary (x86_64 + aarch64)
# Build for current platform
cargo build --release
# Build for specific target
cargo build --release --target x86_64-unknown-linux-gnu
# Build all targets via Gradle
./gradlew compileRustDarwin8664
./gradlew compileRustLinux8664
# ... etcThis library is designed to be a drop-in replacement for lavaplayer-natives. Simply include the compiled native libraries in your classpath, and Lavaplayer will automatically use them.
The codebase follows a clean, flat structure:
- macros.rs: JNI helper macros for safe pointer handling
- util.rs: Buffer access utilities
- aac.rs, mp3.rs, opus.rs, vorbis.rs, samplerate.rs: Individual codec implementations
All codecs share consistent patterns:
create(): Initialize codec instanceprocess/encode/decode(): Process audio datadestroy(): Clean up resources
This implementation prioritizes safety through:
- Rust's memory safety guarantees where applicable
- Careful handling of JNI boundaries
- Proper resource cleanup
- Explicit error handling
Licensed under Apache License 2.0