Skip to content

Commit

Permalink
Add github deploy option
Browse files Browse the repository at this point in the history
  • Loading branch information
sarxos committed May 29, 2012
1 parent 3031a4d commit 5a541ba
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .classpath
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" path="src/example/java"/>
<classpathentry kind="src" path="src/example/resources"/>
<classpathentry kind="src" path="src/main/assembly"/>
<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="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
145 changes: 144 additions & 1 deletion pom.xml
Expand Up @@ -23,6 +23,10 @@
<url>https://github.com/sarxos/webcam-capture/issues</url>
</issueManagement>

<properties>
<github.global.server>github</github.global.server>
</properties>

<distributionManagement>
<repository>
<id>sarxos-ftp-repo</id>
Expand All @@ -39,6 +43,131 @@
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/dist.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>downloads-maven-plugin</artifactId>
<version>0.5</version>
<configuration>
<description>${project.name} release ${project.version}</description>
<override>true</override>
<includes>
<include>${artifactId}-${version}-dist.zip</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>upload</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>

<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
Expand All @@ -48,4 +177,18 @@
</extensions>
</build>

</project>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<show>public</show>
<keywords>cam,webcam,camera,spycam</keywords>
</configuration>
</plugin>
</plugins>
</reporting>

</project>
50 changes: 50 additions & 0 deletions src/main/assembly/dist.xml
@@ -0,0 +1,50 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

<id>dist</id>
<formats>
<!-- <format>tar.gz</format> <format>tar.bz2</format> -->
<format>zip</format>
</formats>

<includeBaseDirectory>false</includeBaseDirectory>

<fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>README*</include>
<include>LICENSE*</include>
<include>NOTICE*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>${artifactId}-${version}.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/dependencies</directory>
<outputDirectory>libs</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/apidocs</directory>
<outputDirectory>docs</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/java</directory>
<outputDirectory>src</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/example/java</directory>
<outputDirectory>examples</outputDirectory>
</fileSet>
</fileSets>

</assembly>
50 changes: 46 additions & 4 deletions src/main/java/com/sarxos/webcam/Webcam.java
Expand Up @@ -36,7 +36,14 @@
*/
public class Webcam {

/**
* Control to control format.
*/
private final static String FORMAT_CTRL = "javax.media.control.FormatControl";

/**
* Control to grab frames.
*/
private final static String GRABBING_CTRL = "javax.media.control.FrameGrabbingControl";

/**
Expand Down Expand Up @@ -94,10 +101,24 @@ public void controllerUpdate(ControllerEvent ce) {
}
}

/**
* Webcam listeners.
*/
private List<WebcamListener> listeners = new ArrayList<WebcamListener>();

/**
* Is webcam open.
*/
private volatile boolean open = false;

/**
* Is player available.
*/
private volatile boolean available = false;

/**
* Is player started.
*/
private volatile boolean started = false;

private CaptureDeviceInfo device = null;
Expand Down Expand Up @@ -161,9 +182,9 @@ public synchronized void open() {
WebcamEvent we = new WebcamEvent(this);

synchronized (listeners) {
Iterator<WebcamListener> wli = listeners.iterator();
while (wli.hasNext()) {
WebcamListener l = wli.next();
Iterator<WebcamListener> li = listeners.iterator();
while (li.hasNext()) {
WebcamListener l = li.next();
try {
l.webcamOpen(we);
} catch (Exception e) {
Expand Down Expand Up @@ -218,6 +239,9 @@ private Control getControl(String name) {
return control;
}

/**
* @return Webcam view size (picture size) in pixels.
*/
public Dimension getViewSize() {
if (!isOpen()) {
throw new RuntimeException("Webcam has to be open to get video size");
Expand Down Expand Up @@ -326,6 +350,17 @@ public static List<Webcam> getWebcams() {
return webcams;
}

/**
* @return Default (first) webcam.
*/
public static Webcam getDefault() {
List<Webcam> webcams = getWebcams();
if (webcams.isEmpty()) {
return null;
}
return webcams.get(0);
}

/**
* Get webcam name (actually device name).
*
Expand All @@ -340,16 +375,23 @@ public String toString() {
return "webcam:" + getName();
}

/**
* Add webcam listener.
*
* @param l a listener to add
*/
public void addWebcamListener(WebcamListener l) {
synchronized (listeners) {
listeners.add(l);
}
}

/**
* @return All webcam listeners
*/
public WebcamListener[] getWebcamListeners() {
synchronized (listeners) {
return listeners.toArray(new WebcamListener[listeners.size()]);
}
}

}
10 changes: 10 additions & 0 deletions src/main/java/com/sarxos/webcam/WebcamEvent.java
Expand Up @@ -3,10 +3,20 @@
import java.util.EventObject;


/**
* Webcam event.
*
* @author Bartosz Firyn (SarXos)
*/
public class WebcamEvent extends EventObject {

private static final long serialVersionUID = 7701762815832038598L;

/**
* Webcam event.
*
* @param w - webcam object
*/
public WebcamEvent(Webcam w) {
super(w);
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/sarxos/webcam/WebcamListener.java
@@ -1,9 +1,24 @@
package com.sarxos.webcam;

/**
* Webcam listener.
*
* @author Bartosz Firyn (SarXos)
*/
public interface WebcamListener {

/**
* Webcam has been open.
*
* @param we a webcam event
*/
public void webcamOpen(WebcamEvent we);

/**
* Webcam has been closed
*
* @param we a webcam event
*/
public void webcamClosed(WebcamEvent we);

}
6 changes: 6 additions & 0 deletions src/main/java/com/sarxos/webcam/WebcamPanel.java
Expand Up @@ -6,6 +6,12 @@
import javax.swing.JPanel;


/**
* Simply implementation of JPanel allowing users to render pictures taken with
* webcam.
*
* @author Bartosz Firyn (SarXos)
*/
public class WebcamPanel extends JPanel implements WebcamListener {

private static final long serialVersionUID = 5792962512394656227L;
Expand Down

0 comments on commit 5a541ba

Please sign in to comment.