Commit dd4d4e8f by Oliver Woodman

Add libopus/libvpx availability checks

parent 4422e8a0
......@@ -120,12 +120,19 @@ public final class LibopusAudioTrackRenderer extends SampleSourceTrackRenderer
}
/**
* Returns whether the underlying libopus library is available.
*/
public static boolean isLibopusAvailable() {
return OpusDecoder.isLibopusAvailable();
}
/**
* Get the version of underlying libopus library.
*
* @return version of the underlying libopus library.
*/
public static String getLibopusVersion() {
return OpusDecoder.getLibopusVersion();
return isLibopusAvailable() ? OpusDecoder.getLibopusVersion() : null;
}
@Override
......
......@@ -26,13 +26,21 @@ import java.nio.ByteBuffer;
*/
/* package */ class OpusDecoder {
private final long nativeDecoderContext;
private static final boolean IS_AVAILABLE;
static {
boolean isAvailable;
try {
System.loadLibrary("opus");
System.loadLibrary("opusJNI");
isAvailable = true;
} catch (UnsatisfiedLinkError exception) {
isAvailable = false;
}
IS_AVAILABLE = isAvailable;
}
private final long nativeDecoderContext;
/**
* Creates the Opus Decoder.
*
......@@ -82,6 +90,13 @@ import java.nio.ByteBuffer;
}
/**
* Returns whether the underlying libopus library is available.
*/
public static boolean isLibopusAvailable() {
return IS_AVAILABLE;
}
/**
* Returns the version string of the underlying libopus decoder.
*/
public static native String getLibopusVersion();
......
......@@ -151,12 +151,17 @@ public final class LibvpxVideoTrackRenderer extends SampleSourceTrackRenderer {
}
/**
* Get the version of underlying libvpx library.
*
* @return version of the underlying libvpx library.
* Returns whether the underlying libvpx library is available.
*/
public static boolean isLibvpxAvailable() {
return VpxDecoder.isLibvpxAvailable();
}
/**
* Returns the version of the underlying libvpx library if available, otherwise {@code null}.
*/
public static String getLibvpxVersion() {
return VpxDecoder.getLibvpxVersion();
return isLibvpxAvailable() ? VpxDecoder.getLibvpxVersion() : null;
}
@Override
......
......@@ -24,13 +24,21 @@ import java.nio.ByteBuffer;
*/
/* package */ class VpxDecoder {
private final long vpxDecContext;
private static final boolean IS_AVAILABLE;
static {
boolean isAvailable;
try {
System.loadLibrary("vpx");
System.loadLibrary("vpxJNI");
isAvailable = true;
} catch (UnsatisfiedLinkError exception) {
isAvailable = false;
}
IS_AVAILABLE = isAvailable;
}
private final long vpxDecContext;
/**
* Creates the VP9 Decoder.
*
......@@ -70,6 +78,13 @@ import java.nio.ByteBuffer;
}
/**
* Returns whether the underlying libvpx library is available.
*/
public static boolean isLibvpxAvailable() {
return IS_AVAILABLE;
}
/**
* Returns the version string of the underlying libvpx decoder.
*/
public static native String getLibvpxVersion();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment