-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start working on experimental GStreamer driver, refs #57
- Loading branch information
Showing
5 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
webcam-capture-drivers/webcam-capture-driver-gstreamer/.classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
23 changes: 23 additions & 0 deletions
23
webcam-capture-drivers/webcam-capture-driver-gstreamer/.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>webcam-capture-driver-gstreamer</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
46 changes: 46 additions & 0 deletions
46
webcam-capture-drivers/webcam-capture-driver-gstreamer/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.github.sarxos</groupId> | ||
<artifactId>webcam-capture-drivers</artifactId> | ||
<version>0.3.10-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>webcam-capture-driver-gstreamer</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Webcam Capture - GStreamer Driver</name> | ||
<description>Webcam Capture driver using GStreamer framework to grab frames from camera devices</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.github.sarxos</groupId> | ||
<artifactId>webcam-capture</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.googlecode.gstreamer-java</groupId> | ||
<artifactId>gstreamer-java</artifactId> | ||
<version>1.5</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
75 changes: 75 additions & 0 deletions
75
...driver-gstreamer/src/main/java/com/github/sarxos/webcam/ds/gstreamer/GStreamerDriver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.github.sarxos.webcam.ds.gstreamer; | ||
|
||
import java.util.List; | ||
|
||
import org.gstreamer.Element; | ||
import org.gstreamer.ElementFactory; | ||
import org.gstreamer.Gst; | ||
import org.gstreamer.Pipeline; | ||
import org.gstreamer.State; | ||
import org.gstreamer.interfaces.PropertyProbe; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.github.sarxos.webcam.WebcamDevice; | ||
import com.github.sarxos.webcam.WebcamDriver; | ||
import com.sun.jna.NativeLibrary; | ||
|
||
|
||
public class GStreamerDriver implements WebcamDriver { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(GStreamerDriver.class); | ||
|
||
private static final class GStreamerShutdownHook extends Thread { | ||
|
||
public GStreamerShutdownHook() { | ||
super("gstreamer-shutdown-hook"); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
Gst.deinit(); | ||
} | ||
} | ||
|
||
static { | ||
NativeLibrary.addSearchPath("gstreamer-0.10", "C:\\Program Files\\OSSBuild\\GStreamer\\v0.10.6\\bin"); | ||
Gst.init(GStreamerDriver.class.getSimpleName(), new String[0]); | ||
Runtime.getRuntime().addShutdownHook(new GStreamerShutdownHook()); | ||
} | ||
|
||
private static final Pipeline pipe = new Pipeline(GStreamerDriver.class.getSimpleName()); | ||
|
||
@Override | ||
public List<WebcamDevice> getDevices() { | ||
|
||
Element dshowsrc = ElementFactory.make("dshowvideosrc", "source"); | ||
dshowsrc.setState(State.READY); | ||
|
||
PropertyProbe probe = PropertyProbe.wrap(dshowsrc); | ||
for (Object device : probe.getValues("device-name")) { | ||
System.out.println(device); | ||
} | ||
|
||
dshowsrc.setState(State.NULL); | ||
|
||
// final Element videosrc = ElementFactory.make("videotestsrc", | ||
// "source"); | ||
// final Element videofilter = ElementFactory.make("capsfilter", | ||
// "filter"); | ||
// videofilter.setCaps(Caps.fromString("video/x-raw-yuv, width=720, height=576" | ||
// + ", bpp=32, depth=32, framerate=25/1")); | ||
|
||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isThreadSafe() { | ||
return false; | ||
} | ||
|
||
public static void main(String[] args) { | ||
new GStreamerDriver().getDevices(); | ||
} | ||
} |