Skip to content

Commit

Permalink
Printing Gstreamer location and version info at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
stammit committed Aug 8, 2019
1 parent 6e45453 commit 0345bf5
Showing 1 changed file with 45 additions and 5 deletions.
50 changes: 45 additions & 5 deletions src/processing/video/Video.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public class Video implements PConstants {

protected static boolean defaultGLibContext = false;

protected static boolean useGstreamerSystemInstall = false;

protected static long INSTANCES_COUNT = 0;

protected static int bitsJVM;
Expand Down Expand Up @@ -142,15 +144,52 @@ static protected void initImpl() {
String[] args = { "" };
Gst.setUseDefaultContext(defaultGLibContext);
Gst.init("Processing core video", args);

// instead of setting the plugin path via scanPath(), we could alternatively
// also set the GST_PLUGIN_PATH_1_0 environment variable
addPlugins();
addPlugins();


// output GStreamer version, lib path, plugin path
// and whether a system install is being used
printGStreamerInfo();
}

static protected void printGStreamerInfo() {

String output = "";
System.out.println("Gstreamer Version: " + Gst.getVersionString());

if(useGstreamerSystemInstall) {
output = "Using System Install Gstreamer: ";

// get x64-bit root of GStreamer install
if(System.getenv("GSTREAMER_1_0_ROOT_X86_64") != null && bitsJVM == 64) {
output += System.getenv("GSTREAMER_1_0_ROOT_X86_64");
}

// get x32-bit root of GStreamer install
else if(System.getenv("GSTREAMER_1_0_ROOT_X86") != null && bitsJVM == 32) {
output += System.getenv("GSTREAMER_1_0_ROOT_X86");
}

else {
output += "Unknown location, please set GSTREAMER_1_0_ROOT_X86(_64) to where GStreamer is installed";
}

System.out.println(output);
}

// simply output gstreamerLibPath and gstreamerPluginPath when using bundled GStreamer
else {
System.out.println("Gstreamer Library Path: " + gstreamerLibPath);
System.out.println("Gstreamer Plugin Path: " + gstreamerPluginPath);
}

}

static protected void addPlugins() {
if (!gstreamerPluginPath.equals("")) {
if (!gstreamerPluginPath.equals("") && !useGstreamerSystemInstall) {
Registry reg = Registry.get();
boolean res;
res = reg.scanPath(gstreamerPluginPath);
Expand Down Expand Up @@ -199,8 +238,9 @@ static protected String buildGStreamerLibPath(String base, String os) {
File path = new File(base + os);
if (path.exists()) {
return base + os;
} else {
return base;
} else {
useGstreamerSystemInstall = true;
return base;
}
}

Expand Down

0 comments on commit 0345bf5

Please sign in to comment.