From 132996c32a45889caad86c6d6e6a44a037cd4655 Mon Sep 17 00:00:00 2001 From: Bartosz Firyn Date: Fri, 29 Aug 2014 16:54:34 +0200 Subject: [PATCH] Add examples for PULL/PUSH foscam demo, refs #255 --- .../examples/java/FoscamMjpegPullExample.java | 37 +++++++++++++++++++ .../examples/java/FoscamMjpegPushExample.java | 37 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 webcam-capture-drivers/driver-ipcam/src/examples/java/FoscamMjpegPullExample.java create mode 100644 webcam-capture-drivers/driver-ipcam/src/examples/java/FoscamMjpegPushExample.java diff --git a/webcam-capture-drivers/driver-ipcam/src/examples/java/FoscamMjpegPullExample.java b/webcam-capture-drivers/driver-ipcam/src/examples/java/FoscamMjpegPullExample.java new file mode 100644 index 00000000..fcceb505 --- /dev/null +++ b/webcam-capture-drivers/driver-ipcam/src/examples/java/FoscamMjpegPullExample.java @@ -0,0 +1,37 @@ +import java.net.MalformedURLException; + +import javax.swing.JFrame; + +import com.github.sarxos.webcam.Webcam; +import com.github.sarxos.webcam.WebcamPanel; +import com.github.sarxos.webcam.ds.ipcam.IpCamAuth; +import com.github.sarxos.webcam.ds.ipcam.IpCamDeviceRegistry; +import com.github.sarxos.webcam.ds.ipcam.IpCamDriver; +import com.github.sarxos.webcam.ds.ipcam.IpCamMode; + + +public class FoscamMjpegPullExample { + + static { + Webcam.setDriver(new IpCamDriver()); + } + + public static void main(String[] args) throws MalformedURLException { + + String name = "Test #255"; + String url = "http://ce3014.myfoscam.org:20054/snapshot.cgi"; + IpCamMode mode = IpCamMode.PULL; + IpCamAuth auth = new IpCamAuth("user", "user"); + + IpCamDeviceRegistry.register(name, url, mode, auth); + + WebcamPanel panel = new WebcamPanel(Webcam.getWebcams().get(0)); + panel.setFPSLimit(1); + + JFrame f = new JFrame("Test #255 PULL"); + f.add(panel); + f.pack(); + f.setVisible(true); + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } +} diff --git a/webcam-capture-drivers/driver-ipcam/src/examples/java/FoscamMjpegPushExample.java b/webcam-capture-drivers/driver-ipcam/src/examples/java/FoscamMjpegPushExample.java new file mode 100644 index 00000000..e34f58f1 --- /dev/null +++ b/webcam-capture-drivers/driver-ipcam/src/examples/java/FoscamMjpegPushExample.java @@ -0,0 +1,37 @@ +import java.net.MalformedURLException; + +import javax.swing.JFrame; + +import com.github.sarxos.webcam.Webcam; +import com.github.sarxos.webcam.WebcamPanel; +import com.github.sarxos.webcam.ds.ipcam.IpCamAuth; +import com.github.sarxos.webcam.ds.ipcam.IpCamDeviceRegistry; +import com.github.sarxos.webcam.ds.ipcam.IpCamDriver; +import com.github.sarxos.webcam.ds.ipcam.IpCamMode; + + +public class FoscamMjpegPushExample { + + static { + Webcam.setDriver(new IpCamDriver()); + } + + public static void main(String[] args) throws MalformedURLException { + + String name = "Test #255"; + String url = "http://ce3014.myfoscam.org:20054/videostream.cgi"; + IpCamMode mode = IpCamMode.PUSH; + IpCamAuth auth = new IpCamAuth("user", "user"); + + IpCamDeviceRegistry.register(name, url, mode, auth); + + WebcamPanel panel = new WebcamPanel(Webcam.getWebcams().get(0)); + panel.setFPSLimit(1); + + JFrame f = new JFrame("Test #255 PUSH"); + f.add(panel); + f.pack(); + f.setVisible(true); + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } +}