The jitsi-sctp project creates a JNI wrapper around the usrsctp lib and provides a set of Java classes to further flesh out a convenient Java SCTP API.
Because JNI has a complex build process, this project has multiple submodules to try and separate each of the phases necessary from start to finish. The maven modules are laid out as follows:
`-- jitsi-sctp |-- jniwrapper | |-- java | |-- jnilib | `-- native |-- sctp `-- usrsctp
usrsctpsubmodule handles the compilation of the usrsctp source into a library. Once the usrsctp source has been cloned to the proper place (into the src/native/usrsctp directory of this submodule), the
compilelifecycle can be used to bootstrap, configure and make the source into a library.
packagewill create a jar that will include the native library and the necessary include headers.
jniwrappersubmodule has 3 nested submodules:
jniwrapper-javasubmodule includes the Java portion of the JNI API and interacts with the native code.
jniwrapper-nativesubmodule contains the C portion of the JNI API that bridges the Java and the usrsctp native lib. It depends on both the
usrsctpmodule (because it needs the built library and include headers) and the
jniwrapper-javamodule (to generate the header file to match the C implementation from the Java file). The
compilelifecycle will create a new jni lib in target/. The
packagelifecycle will create a jar that includes the java code and the native libraries. NOTE: The
packagelifecycle does NOT use the created JNI lib from the target directory. It is intended that the JNI libs are built for each platform ahead of time, and are placed in the
src/main/resourcesdirectory. This directory is where the
packagelifecycle will include libraries from.
jnilibsubmodule combines the
jniwrapper-nativesubmodules into a fat jar which includes the Java API and the native JNI libraries that will need to be loaded at runtime.
sctpsubmodule contains the library on top of the JNI code. The jar built by this is what is intended to be used by other code.
Building the jar files
- Clone the project
mvn installto install locally)
This will install all the jars built by the project. Depend on the
sctp module to use jitsi-sctp in your code.
(Re)Building a new JNI lib
The JNI lib will need to be rebuilt if there is a change in the usrsctp version or a change in the JNI wrapper C file.
- Clone the project
- Clone the usrsctp src:
jitsi-sctp/usrsctp> git clone https://github.com/sctplab/usrsctp (check out whatever hash/version you want)
- Package everything and denote what should be rebuilt and redeployed. Here we rebuild the usrsctp libs, rebuild the native wrapper and deploy the newly-built jnilib to the prebuilt libs directory
jitsi-sctp> mvn package -DbuildSctp -DbuildNativeWrapper -DdeployNewJnilib
- Compile and install
jitsi-sctp> mvn install -DbuildSctp -DbuildNativeWrapper -DdeployNewJnilib
- Note: The above commands must be run separately right now due to a bug in the maven-native-plugin. Once a new release is done which includes this fix we'll be able to just run
mvn package install -DbuildSctp -DbuildNativeWrapper -DdeployNewJnilib.