Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Commit

Permalink
Make library compatible with Raspbian release August 2017
Browse files Browse the repository at this point in the history
  • Loading branch information
gohai committed Aug 20, 2017
1 parent 218610b commit 5a63e2a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ paragraph = This uses GL textures and accelerated video decoding. Recommended fo
# compare different versions of the same library, and check if an update is
# available. You should think of it as a counter, counting the total number of
# releases you've had.
version = 7
version = 8

# The version as the user will see it. If blank, the version attribute will be
# used here. This should be a single word, with no spaces.
prettyVersion = 1.2.2
prettyVersion = 1.2.3

# The min and max revision of Processing compatible with your library.
# Note that these fields use the revision and not the version of Processing,
Expand Down
32 changes: 30 additions & 2 deletions src/gohai/glvideo/GLVideo.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
package gohai.glvideo;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import processing.core.*;
import processing.opengl.*;

Expand Down Expand Up @@ -88,7 +90,7 @@ public static void enableDebug() {
}

public static void enableDebug(int level) {
System.loadLibrary("glvideo");
loadNativeLibrary();
gstreamer_setEnvVar("GST_DEBUG_NO_COLOR", "1");
gstreamer_setEnvVar("GST_DEBUG", Integer.toString(level));
if (2 < level) {
Expand All @@ -106,7 +108,7 @@ protected static void loadGStreamer() {
boolean use_host_gstreamer = false;

if (!loaded) {
System.loadLibrary("glvideo");
loadNativeLibrary();
loaded = true;

String jar = GLVideo.class.getProtectionDomain().getCodeSource().getLocation().getPath();
Expand Down Expand Up @@ -150,6 +152,32 @@ protected static void loadGStreamer() {
}
}

protected static void loadNativeLibrary() {
// Raspbian August 2017 renamed libraries gstgl depends on
workaroundBrcm();
System.loadLibrary("glvideo");
}

protected static void workaroundBrcm() {
File new_lib = new File("/opt/vc/lib/libbrcmGLESv2.so");

String jar = GLVideo.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String nativeLib = jar.substring(0, jar.lastIndexOf(File.separatorChar));
File symlink = new File(nativeLib + "/linux-armv6hf/libGLESv2.so");

if (new_lib.isFile() && !symlink.isFile()) {
// attempt to create symlinks that make it compatible
// with earlier Raspbian releases
try {
Files.createSymbolicLink(Paths.get(nativeLib + "/linux-armv6hf/libGLESv2.so"), Paths.get("/opt/vc/lib/libbrcmGLESv2.so"));
Files.createSymbolicLink(Paths.get(nativeLib + "/linux-armv6hf/libEGL.so"), Paths.get("/opt/vc/lib/libbrcmEGL.so"));
System.out.println("GLVideo: Created compatibility symlinks");
} catch (Exception e) {
System.err.println("GLVideo: Error creating compatibility symlinks");
}
}
}

public void dispose() {
close();
}
Expand Down

0 comments on commit 5a63e2a

Please sign in to comment.