-
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.
Add dedicated class for D-Link DSC-933L IP camera, refs #511
- Loading branch information
Showing
5 changed files
with
96 additions
and
14 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
webcam-capture-drivers/driver-ipcam/src/examples/java/DLinkDsc933LExample.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,36 @@ | ||
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.IpCamDeviceRegistry; | ||
import com.github.sarxos.webcam.ds.ipcam.IpCamDriver; | ||
import com.github.sarxos.webcam.ds.ipcam.device.dlink.DSC933L; | ||
|
||
|
||
public class DLinkDsc933LExample { | ||
|
||
static { | ||
Webcam.setDriver(new IpCamDriver()); | ||
} | ||
|
||
public static void main(String[] args) throws MalformedURLException { | ||
|
||
final String name = "D-Link 993L Camera"; | ||
final String user = "{username}"; // change to your own username | ||
final String pass = "{password}"; // change to your own password | ||
final String url = "http://{ip-address-or-domain-name}"; // camera's IP address or domain | ||
|
||
IpCamDeviceRegistry.register(new DSC933L(name, url, user, pass)); | ||
|
||
final Webcam webcam = Webcam.getDefault(); | ||
final WebcamPanel panel = new WebcamPanel(webcam); | ||
|
||
JFrame f = new JFrame(name); | ||
f.add(panel); | ||
f.pack(); | ||
f.setVisible(true); | ||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
} | ||
} |
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
51 changes: 51 additions & 0 deletions
51
...rs/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/device/dlink/DSC933L.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,51 @@ | ||
package com.github.sarxos.webcam.ds.ipcam.device.dlink; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
import com.github.sarxos.webcam.WebcamException; | ||
import com.github.sarxos.webcam.ds.ipcam.IpCamAuth; | ||
import com.github.sarxos.webcam.ds.ipcam.IpCamDevice; | ||
import com.github.sarxos.webcam.ds.ipcam.IpCamMode; | ||
|
||
|
||
/** | ||
* This is webcam device abstraction to handle MJPEG video stream from D-Link DSC-933L IP camera. | ||
* | ||
* @author Bartosz Firyn (sarxos) | ||
*/ | ||
public class DSC933L extends IpCamDevice { | ||
|
||
/** | ||
* Path used by this camera model to expose MJPEG video feed. | ||
*/ | ||
private static final String MJPEG_PATH = "video/mjpg.cgi"; | ||
|
||
/** | ||
* @param name the camera name, e.g. 'Bedroom Camera' | ||
* @param url the camera address, e.g. 'http://192.168.0.12' | ||
* @param user the user name configured in camera | ||
* @param password the password for the user | ||
* @throws MalformedURLException if camera address is invalid | ||
*/ | ||
public DSC933L(String name, String url, String user, String password) throws MalformedURLException { | ||
this(name, url, IpCamMode.PUSH, new IpCamAuth(user, password)); | ||
} | ||
|
||
private DSC933L(String name, String url, IpCamMode mode, IpCamAuth auth) throws MalformedURLException { | ||
super(name, url, mode, auth); | ||
} | ||
|
||
@Override | ||
public URL getURL() { | ||
|
||
final String base = super.getURL().toString(); | ||
final String address = base + (base.endsWith("/") ? MJPEG_PATH : ("/" + MJPEG_PATH)); | ||
|
||
try { | ||
return new URL(address); | ||
} catch (MalformedURLException e) { | ||
throw new WebcamException("Invalid URL " + base); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -30,5 +30,4 @@ public URL getURL() { | |
throw new WebcamException(String.format("Incorrect URL %s", url), e); | ||
} | ||
} | ||
|
||
} |
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