Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
praxis / praxis.video.* - add JNA Platform library, extract GStreamer…
Browse files Browse the repository at this point in the history
… settings, add support for platform-specific library paths.
  • Loading branch information
neilcsmith-net committed Sep 15, 2016
1 parent 5979227 commit c25f568
Show file tree
Hide file tree
Showing 21 changed files with 338 additions and 157 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,5 @@
/lib.darcula/build/
/lib.nanohttpd/build/
/praxis.data/build/
/praxis.data/nbproject/private/
/praxis.data/nbproject/private/
/lib.jna.platform/build/
8 changes: 8 additions & 0 deletions lib.jna.platform/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
<!-- for some information on what you could do (e.g. targets to override). -->
<!-- If you delete this file and reopen the project it will be recreated. -->
<project name="com.sun.jna.platform" default="netbeans" basedir=".">
<description>Builds, tests, and runs the project com.sun.jna.platform.</description>
<import file="nbproject/build-impl.xml"/>
</project>
6 changes: 6 additions & 0 deletions lib.jna.platform/manifest.mf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: com.sun.jna.platform
OpenIDE-Module-Localizing-Bundle: com/sun/jna/platform/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0

45 changes: 45 additions & 0 deletions lib.jna.platform/nbproject/build-impl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
*** GENERATED FROM project.xml - DO NOT EDIT ***
*** EDIT ../build.xml INSTEAD ***
-->
<project name="com.sun.jna.platform-impl" basedir="..">
<fail message="Please build using Ant 1.7.1 or higher.">
<condition>
<not>
<antversion atleast="1.7.1"/>
</not>
</condition>
</fail>
<property file="nbproject/private/suite-private.properties"/>
<property file="nbproject/suite.properties"/>
<fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
<property file="${suite.dir}/nbproject/private/platform-private.properties"/>
<property file="${suite.dir}/nbproject/platform.properties"/>
<macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
<attribute name="name"/>
<attribute name="value"/>
<sequential>
<property name="@{name}" value="${@{value}}"/>
</sequential>
</macrodef>
<macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
<attribute name="property"/>
<attribute name="value"/>
<sequential>
<property name="@{property}" value="@{value}"/>
</sequential>
</macrodef>
<property file="${user.properties.file}"/>
<nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
<condition>
<not>
<contains string="${cluster.path.evaluated}" substring="platform"/>
</not>
</condition>
</fail>
<import file="${harness.dir}/build.xml"/>
</project>
8 changes: 8 additions & 0 deletions lib.jna.platform/nbproject/genfiles.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build.xml.data.CRC32=5dd71efe
build.xml.script.CRC32=c08ae6e9
build.xml.stylesheet.CRC32=[email protected]
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=5dd71efe
nbproject/build-impl.xml.script.CRC32=a5bb51d6
nbproject/build-impl.xml.stylesheet.CRC32=[email protected]
3 changes: 3 additions & 0 deletions lib.jna.platform/nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
is.autoload=true
javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.8
37 changes: 37 additions & 0 deletions lib.jna.platform/nbproject/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>com.sun.jna.platform</code-name-base>
<suite-component/>
<module-dependencies>
<dependency>
<code-name-base>com.sun.jna</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>3.5.1</specification-version>
</run-dependency>
</dependency>
</module-dependencies>
<public-packages>
<package>com.sun.jna.platform</package>
<package>com.sun.jna.platform.dnd</package>
<package>com.sun.jna.platform.mac</package>
<package>com.sun.jna.platform.unix</package>
<package>com.sun.jna.platform.win32</package>
<package>com.sun.jna.platform.win32.COM</package>
<package>com.sun.jna.platform.win32.COM.tlb</package>
<package>com.sun.jna.platform.win32.COM.tlb.imp</package>
<package>com.sun.jna.platform.win32.COM.util</package>
<package>com.sun.jna.platform.win32.COM.util.annotation</package>
<package>com.sun.jna.platform.wince</package>
</public-packages>
<class-path-extension>
<runtime-relative-path>ext/jna-platform-4.2.2.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jna-platform-4.2.2.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
</project>
1 change: 1 addition & 0 deletions lib.jna.platform/nbproject/suite.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
suite.dir=${basedir}/..
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OpenIDE-Module-Name=lib.jna.platform
4 changes: 3 additions & 1 deletion nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ modules=\
${project.net.neilcsmith.praxis.code.services}:\
${project.com.bulenkov.darcula}:\
${project.fi.iki.elonen}:\
${project.net.neilcsmith.praxis.data}
${project.net.neilcsmith.praxis.data}:\
${project.com.sun.jna.platform}
project.com.bulenkov.darcula=lib.darcula
project.com.sun.jna=lib.jna
project.com.sun.jna.platform=lib.jna.platform
project.com.tinkerforge=lib.tinkerforge
project.de.sciss.net=lib.netutil
project.fi.iki.elonen=lib.nanohttpd
Expand Down
8 changes: 4 additions & 4 deletions praxis.video.gst1/nbproject/genfiles.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
build.xml.data.CRC32=0c087fce
build.xml.data.CRC32=5f78fa18
build.xml.script.CRC32=c35d8958
build.xml.stylesheet.CRC32=a56c6a5b@2.67.1
build.xml.stylesheet.CRC32=a56c6a5b@2.71.1
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=0c087fce
nbproject/build-impl.xml.data.CRC32=5f78fa18
nbproject/build-impl.xml.script.CRC32=fb5821b9
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.67.1
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.71.1
28 changes: 27 additions & 1 deletion praxis.video.gst1/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
<code-name-base>net.neilcsmith.praxis.video.gst1</code-name-base>
<suite-component/>
<module-dependencies>
<dependency>
<code-name-base>com.sun.jna</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>3.5.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>com.sun.jna.platform</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>net.neilcsmith.praxis.core</code-name-base>
<build-prerequisite/>
Expand All @@ -22,6 +38,14 @@
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>net.neilcsmith.praxis.settings</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>net.neilcsmith.praxis.video</code-name-base>
<build-prerequisite/>
Expand Down Expand Up @@ -55,7 +79,9 @@
</run-dependency>
</dependency>
</module-dependencies>
<public-packages/>
<public-packages>
<package>net.neilcsmith.praxis.video.gst1</package>
</public-packages>
</data>
</configuration>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2016 Neil C Smith.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 3 for more details.
*
* You should have received a copy of the GNU General Public License version 3
* along with this work; if not, see http://www.gnu.org/licenses/
*
*
* Please visit http://neilcsmith.net if you need additional information or
* have any questions.
*/
package net.neilcsmith.praxis.video.gst1;

import com.sun.jna.Platform;
import net.neilcsmith.praxis.settings.Settings;

/**
*
* @author Neil C Smith (http://neilcsmith.net)
*/
public class GStreamerSettings {

private final static String KEY_CAPTURE_PREFIX = "video.gstreamer.capture";
private final static String KEY_LIBRARY_PATH = "video.gstreamer.path";

private final static String DEFAULT_CAPTURE_PREFIX;
private final static String DEFAULT_LIBRARY_PATH;

static {
if (Platform.isWindows()) {
DEFAULT_CAPTURE_PREFIX = "ksvideosrc device-index=";
if (Platform.is64Bit()) {
DEFAULT_LIBRARY_PATH = "C:\\gstreamer\\1.0\\x86_64\\bin\\";
} else {
DEFAULT_LIBRARY_PATH = "C:\\gstreamer\\1.0\\x86\\bin\\";
}
} else if (Platform.isMac()) {
DEFAULT_CAPTURE_PREFIX = "qtkitvideosrc device-index=";
DEFAULT_LIBRARY_PATH = "/Library/Frameworks/GStreamer.framework/Libraries/";
} else {
DEFAULT_CAPTURE_PREFIX = "v4l2src device=/dev/video";
DEFAULT_LIBRARY_PATH = "";
}
}

public static String getDefaultCaptureDevice(int idx) {
if (idx < 1) {
throw new IllegalArgumentException();
}
return DEFAULT_CAPTURE_PREFIX + (idx - 1);
}

public static void resetCaptureDevice(int idx) {
setCaptureDevice(idx, null);
}

public static String getCaptureDevice(int idx) {
if (idx < 1) {
throw new IllegalArgumentException();
}
return Settings.get(KEY_CAPTURE_PREFIX + idx, getDefaultCaptureDevice(idx));
}

public static void setCaptureDevice(int idx, String device) {
if (idx < 1) {
throw new IllegalArgumentException();
}
Settings.put(KEY_CAPTURE_PREFIX + idx, device);
}

public static String getDefaultLibraryPath() {
return DEFAULT_LIBRARY_PATH;
}

public static void resetLibraryPath() {
setLibraryPath(null);
}

public static String getLibraryPath() {
return Settings.get(KEY_LIBRARY_PATH, getDefaultLibraryPath());
}

public static void setLibraryPath(String libPath) {
Settings.put(KEY_LIBRARY_PATH, libPath);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2015 Neil C Smith.
* Copyright 2016 Neil C Smith.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 only, as
Expand Down Expand Up @@ -74,7 +74,7 @@ public abstract class AbstractGstDelegate extends VideoDelegate {
private volatile boolean looping;

protected AbstractGstDelegate() {
Gst.init();
GStreamerLibrary.getInstance().init();
state = new AtomicReference<>(State.New);
surfaceLock = new ReentrantLock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class BinDelegate extends AbstractGstDelegate {
private int requestHeight;
private int requestRate;

private BinDelegate(String binDescription) {
public BinDelegate(String binDescription) {
this.binDescription = binDescription;
}

Expand Down Expand Up @@ -128,7 +128,7 @@ private String buildCapsString() {
}



@Deprecated
public static BinDelegate create(String binDescription) {
return new BinDelegate(binDescription);
}
Expand Down
Loading

0 comments on commit c25f568

Please sign in to comment.