Skip to content

Commit

Permalink
Start working on experimental GStreamer driver, refs #57
Browse files Browse the repository at this point in the history
  • Loading branch information
sarxos committed Apr 27, 2013
1 parent a7ba4d4 commit 82cd706
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 1 deletion.
3 changes: 2 additions & 1 deletion webcam-capture-drivers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@

<modules>
<module>webcam-capture-driver-ffmpeg-cli</module>
<module>webcam-capture-driver-lti-civil</module>
<module>webcam-capture-driver-gstreamer</module>
<module>webcam-capture-driver-ipcam</module>
<module>webcam-capture-driver-javacv</module>
<module>webcam-capture-driver-jmf</module>
<module>webcam-capture-driver-lti-civil</module>
<module>webcam-capture-driver-openimaj</module>
<module>webcam-capture-driver-vlcj</module>
</modules>
Expand Down
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 webcam-capture-drivers/webcam-capture-driver-gstreamer/.project
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 webcam-capture-drivers/webcam-capture-driver-gstreamer/pom.xml
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>
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();
}
}

0 comments on commit 82cd706

Please sign in to comment.