diff --git a/intellij-style.xml b/intellij-style.xml
index f3a6743..cf29951 100644
--- a/intellij-style.xml
+++ b/intellij-style.xml
@@ -2,222 +2,222 @@
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
@@ -226,7 +226,7 @@
xmlns:android
-
+
^$
@@ -237,7 +237,7 @@
xmlns:.*
-
+
^$
@@ -249,7 +249,7 @@
.*:id
-
+
http://schemas.android.com/apk/res/android
@@ -260,7 +260,7 @@
style
-
+
^$
@@ -271,7 +271,7 @@
.*
-
+
^$
@@ -283,7 +283,7 @@
.*:.*Style
-
+
http://schemas.android.com/apk/res/android
@@ -295,7 +295,7 @@
.*:layout_width
-
+
http://schemas.android.com/apk/res/android
@@ -306,7 +306,7 @@
.*:layout_height
-
+
http://schemas.android.com/apk/res/android
@@ -317,7 +317,7 @@
.*:layout_weight
-
+
http://schemas.android.com/apk/res/android
@@ -328,7 +328,7 @@
.*:layout_margin
-
+
http://schemas.android.com/apk/res/android
@@ -339,7 +339,7 @@
.*:layout_marginTop
-
+
http://schemas.android.com/apk/res/android
@@ -350,7 +350,7 @@
.*:layout_marginBottom
-
+
http://schemas.android.com/apk/res/android
@@ -361,7 +361,7 @@
.*:layout_marginStart
-
+
http://schemas.android.com/apk/res/android
@@ -372,7 +372,7 @@
.*:layout_marginEnd
-
+
http://schemas.android.com/apk/res/android
@@ -383,7 +383,7 @@
.*:layout_marginLeft
-
+
http://schemas.android.com/apk/res/android
@@ -394,7 +394,7 @@
.*:layout_marginRight
-
+
http://schemas.android.com/apk/res/android
@@ -405,7 +405,7 @@
.*:layout_.*
-
+
http://schemas.android.com/apk/res/android
@@ -417,7 +417,7 @@
.*:padding
-
+
http://schemas.android.com/apk/res/android
@@ -428,7 +428,7 @@
.*:paddingTop
-
+
http://schemas.android.com/apk/res/android
@@ -439,7 +439,7 @@
.*:paddingBottom
-
+
http://schemas.android.com/apk/res/android
@@ -450,7 +450,7 @@
.*:paddingStart
-
+
http://schemas.android.com/apk/res/android
@@ -461,7 +461,7 @@
.*:paddingEnd
-
+
http://schemas.android.com/apk/res/android
@@ -472,7 +472,7 @@
.*:paddingLeft
-
+
http://schemas.android.com/apk/res/android
@@ -483,7 +483,7 @@
.*:paddingRight
-
+
http://schemas.android.com/apk/res/android
@@ -537,62 +537,62 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
diff --git a/onvif-java/pom.xml b/onvif-java/pom.xml
index ef4cda7..ec3cdf9 100644
--- a/onvif-java/pom.xml
+++ b/onvif-java/pom.xml
@@ -1,129 +1,129 @@
-
- 4.0.0
-
- org.onvif
- onvif
- 1.0-SNAPSHOT
-
- onvif-java
+
+ 4.0.0
+
+ org.onvif
+ onvif
+ 1.0-SNAPSHOT
+
+ onvif-java
-
-
- org.apache.cxf
- cxf-rt-ws-security
- ${cxf.version}
-
-
- org.apache.cxf
- cxf-rt-transports-http
- ${cxf.version}
-
-
-
-
-
-
-
-
-
-
-
+
+
+ org.apache.cxf
+ cxf-rt-ws-security
+ ${cxf.version}
+
+
+ org.apache.cxf
+ cxf-rt-transports-http
+ ${cxf.version}
+
+
+
+
+
+
+
+
+
+
+
-
- org.onvif
- onvif-ws-client
- ${project.version}
-
-
- commons-io
- commons-io
- 2.4
-
-
- commons-codec
- commons-codec
- 1.10
-
-
- org.apache.commons
- commons-lang3
- 3.4
-
+
+ org.onvif
+ onvif-ws-client
+ ${project.version}
+
+
+ commons-io
+ commons-io
+ 2.4
+
+
+ commons-codec
+ commons-codec
+ 1.10
+
+
+ org.apache.commons
+ commons-lang3
+ 3.4
+
-
-
-
- com.sun.xml.messaging.saaj
- saaj-impl
- 1.5.1
-
+
+
+
+ com.sun.xml.messaging.saaj
+ saaj-impl
+ 1.5.1
+
-
-
-
+
+
+
-
-
- com.sun.activation
- javax.activation
- ${javax.activation.version}
-
+
+
+ com.sun.activation
+ javax.activation
+ ${javax.activation.version}
+
-
- javax.xml.bind
- jaxb-api
- ${jaxb.api.version}
-
+
+ javax.xml.bind
+ jaxb-api
+ ${jaxb.api.version}
+
-
- com.sun.xml.bind
- jaxb-core
- 2.3.0.1
-
+
+ com.sun.xml.bind
+ jaxb-core
+ 2.3.0.1
+
-
- com.sun.xml.bind
- jaxb-impl
- ${jaxb.api.version}
-
-
+
+ com.sun.xml.bind
+ jaxb-impl
+ ${jaxb.api.version}
+
+
-
+
-
-
- org.slf4j
- slf4j-simple
- 1.7.26
- test
-
+
+
+ org.slf4j
+ slf4j-simple
+ 1.7.26
+ test
+
+
-
-
-
+
\ No newline at end of file
diff --git a/onvif-java/src/main/java/de/onvif/soap/NaiveSSLHelper.java b/onvif-java/src/main/java/de/onvif/soap/NaiveSSLHelper.java
index 47a5062..ad946e1 100644
--- a/onvif-java/src/main/java/de/onvif/soap/NaiveSSLHelper.java
+++ b/onvif-java/src/main/java/de/onvif/soap/NaiveSSLHelper.java
@@ -1,99 +1,92 @@
package de.onvif.soap;
-import org.apache.cxf.configuration.jsse.TLSClientParameters;
-import org.apache.cxf.transport.http.HTTPConduit;
-
-import javax.net.ssl.*;
-import javax.xml.ws.BindingProvider;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Map;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import javax.xml.ws.BindingProvider;
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.transport.http.HTTPConduit;
public class NaiveSSLHelper {
- public static void makeWebServiceClientTrustEveryone(
- Object webServicePort) {
- if (webServicePort instanceof BindingProvider) {
- BindingProvider bp = (BindingProvider) webServicePort;
- Map requestContext = bp.getRequestContext();
- requestContext.put(JAXWS_SSL_SOCKET_FACTORY, getTrustingSSLSocketFactory());
- requestContext.put(JAXWS_HOSTNAME_VERIFIER,
- new NaiveHostnameVerifier());
- } else {
- throw new IllegalArgumentException(
- "Web service port "
- + webServicePort.getClass().getName()
- + " does not implement "
- + BindingProvider.class.getName());
- }
- }
+ public static void makeWebServiceClientTrustEveryone(Object webServicePort) {
+ if (webServicePort instanceof BindingProvider) {
+ BindingProvider bp = (BindingProvider) webServicePort;
+ Map requestContext = bp.getRequestContext();
+ requestContext.put(JAXWS_SSL_SOCKET_FACTORY, getTrustingSSLSocketFactory());
+ requestContext.put(JAXWS_HOSTNAME_VERIFIER, new NaiveHostnameVerifier());
+ } else {
+ throw new IllegalArgumentException(
+ "Web service port "
+ + webServicePort.getClass().getName()
+ + " does not implement "
+ + BindingProvider.class.getName());
+ }
+ }
- public static SSLSocketFactory getTrustingSSLSocketFactory() {
- return SSLSocketFactoryHolder.INSTANCE;
- }
+ public static SSLSocketFactory getTrustingSSLSocketFactory() {
+ return SSLSocketFactoryHolder.INSTANCE;
+ }
- private static SSLSocketFactory createSSLSocketFactory() {
- TrustManager[] trustManagers = new TrustManager[] {
- new NaiveTrustManager()
- };
- SSLContext sslContext;
- try {
- sslContext = SSLContext.getInstance("TLS");
- sslContext.init(new KeyManager[0], trustManagers,
- new SecureRandom());
- return sslContext.getSocketFactory();
- } catch (GeneralSecurityException e) {
- return null;
- }
- }
+ private static SSLSocketFactory createSSLSocketFactory() {
+ TrustManager[] trustManagers = new TrustManager[] {new NaiveTrustManager()};
+ SSLContext sslContext;
+ try {
+ sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(new KeyManager[0], trustManagers, new SecureRandom());
+ return sslContext.getSocketFactory();
+ } catch (GeneralSecurityException e) {
+ return null;
+ }
+ }
- public static void makeCxfWebServiceClientTrustEveryone(HTTPConduit http) {
- TrustManager[] trustManagers = new TrustManager[]{
- new NaiveTrustManager()
- };
- TLSClientParameters tlsParams = new TLSClientParameters();
- tlsParams.setSecureSocketProtocol("TLS");
- tlsParams.setKeyManagers(new KeyManager[0]);
- tlsParams.setTrustManagers(trustManagers);
- tlsParams.setDisableCNCheck(true);
- http.setTlsClientParameters(tlsParams);
- }
+ public static void makeCxfWebServiceClientTrustEveryone(HTTPConduit http) {
+ TrustManager[] trustManagers = new TrustManager[] {new NaiveTrustManager()};
+ TLSClientParameters tlsParams = new TLSClientParameters();
+ tlsParams.setSecureSocketProtocol("TLS");
+ tlsParams.setKeyManagers(new KeyManager[0]);
+ tlsParams.setTrustManagers(trustManagers);
+ tlsParams.setDisableCNCheck(true);
+ http.setTlsClientParameters(tlsParams);
+ }
- private interface SSLSocketFactoryHolder {
- SSLSocketFactory INSTANCE = createSSLSocketFactory();
- }
+ private interface SSLSocketFactoryHolder {
+ SSLSocketFactory INSTANCE = createSSLSocketFactory();
+ }
- private static class NaiveHostnameVerifier implements
- HostnameVerifier {
- @Override
- public boolean verify(String hostName,
- SSLSession session) {
- return true;
- }
- }
+ private static class NaiveHostnameVerifier implements HostnameVerifier {
+ @Override
+ public boolean verify(String hostName, SSLSession session) {
+ return true;
+ }
+ }
- private static class NaiveTrustManager implements
- X509TrustManager {
+ private static class NaiveTrustManager implements X509TrustManager {
- @Override
- public void checkClientTrusted(X509Certificate[] certs,
- String authType) throws CertificateException {
- }
+ @Override
+ public void checkClientTrusted(X509Certificate[] certs, String authType)
+ throws CertificateException {}
- @Override
- public void checkServerTrusted(X509Certificate[] certs,
- String authType) throws CertificateException {
- }
+ @Override
+ public void checkServerTrusted(X509Certificate[] certs, String authType)
+ throws CertificateException {}
- @Override
- public X509Certificate[] getAcceptedIssuers() {
- return new X509Certificate[0];
- }
- }
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return new X509Certificate[0];
+ }
+ }
- private static final java.lang.String JAXWS_HOSTNAME_VERIFIER =
- "com.sun.xml.internal.ws.transport.https.client.hostname.verifier";
- private static final java.lang.String JAXWS_SSL_SOCKET_FACTORY =
- "com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory";
+ private static final java.lang.String JAXWS_HOSTNAME_VERIFIER =
+ "com.sun.xml.internal.ws.transport.https.client.hostname.verifier";
+ private static final java.lang.String JAXWS_SSL_SOCKET_FACTORY =
+ "com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory";
}
diff --git a/onvif-java/src/main/java/de/onvif/soap/OnvifDevice.java b/onvif-java/src/main/java/de/onvif/soap/OnvifDevice.java
index c30cab4..f637b4d 100644
--- a/onvif-java/src/main/java/de/onvif/soap/OnvifDevice.java
+++ b/onvif-java/src/main/java/de/onvif/soap/OnvifDevice.java
@@ -62,16 +62,27 @@ public class OnvifDevice {
private static boolean verbose = false; // enable/disable logging of SOAP messages
final SimpleSecurityHandler securityHandler;
+ private static URL cleanURL(URL u) throws ConnectException {
+ if (u == null) throw new ConnectException("null url not allowed");
+ String f = u.getFile();
+ if (!f.isEmpty()) {
+ String out = u.toString().replace(f, "");
+ try {
+ return new URL(out);
+ } catch (MalformedURLException e) {
+ throw new ConnectException("MalformedURLException " + u);
+ }
+ }
+
+ return u;
+ }
/*
* @param url is http://host or http://host:port or https://host or https://host:port
* @param user Username you need to login, or "" for none
* @param password User's password to login, or "" for none
*/
- public OnvifDevice(URL url, String user, String password)
- throws ConnectException, SOAPException, MalformedURLException {
- this.url = url;
- String f = url.getFile();
- if (!f.isEmpty()) throw new MalformedURLException("Expected empty file in URL, not:" + f);
+ public OnvifDevice(URL url, String user, String password) throws ConnectException, SOAPException {
+ this.url = cleanURL(url);
securityHandler =
!user.isEmpty() && !password.isEmpty() ? new SimpleSecurityHandler(user, password) : null;
init();
@@ -289,8 +300,8 @@ public class OnvifDevice {
return getSnapshotUri(0);
}
- public String getRTSPUri() {
- return getRTSPUri(0);
+ public String getStreamUri() {
+ return getStreamUri(0);
}
// Get snapshot uri for profile with index
@@ -300,12 +311,12 @@ public class OnvifDevice {
return "";
}
- public String getRTSPUri(int index) {
- return getRTSPUri(media.getProfiles().get(index).getToken());
+ public String getStreamUri(int index) {
+ return getStreamUri(media.getProfiles().get(index).getToken());
}
// returns rtsp://host[:port]/path_for_rtsp
- public String getRTSPUri(String profileToken) {
+ public String getStreamUri(String profileToken) {
StreamSetup streamSetup = new StreamSetup();
Transport t = new Transport();
t.setProtocol(TransportProtocol.RTSP);
diff --git a/onvif-java/src/main/java/de/onvif/soap/SimpleSecurityHandler.java b/onvif-java/src/main/java/de/onvif/soap/SimpleSecurityHandler.java
index b969dae..10801d6 100644
--- a/onvif-java/src/main/java/de/onvif/soap/SimpleSecurityHandler.java
+++ b/onvif-java/src/main/java/de/onvif/soap/SimpleSecurityHandler.java
@@ -36,8 +36,8 @@ import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.MessageDigestAlgorithms;
/*
- Utility class to add user/password onvif credentials to SOAP communications
- */
+ Utility class to add user/password onvif credentials to SOAP communications
+*/
public class SimpleSecurityHandler implements SOAPHandler {
private final String username;
diff --git a/onvif-java/src/main/resources/log4j.properties b/onvif-java/src/main/resources/log4j.properties
index 393e087..bbefa38 100644
--- a/onvif-java/src/main/resources/log4j.properties
+++ b/onvif-java/src/main/resources/log4j.properties
@@ -1,6 +1,5 @@
# Root logger option
log4j.rootLogger=INFO, stdout
-
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
diff --git a/onvif-java/src/main/resources/probe-template.xml b/onvif-java/src/main/resources/probe-template.xml
deleted file mode 100644
index 7769d6c..0000000
--- a/onvif-java/src/main/resources/probe-template.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
- http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe
- urn:uuid:c032cfdd-c3ca-49dc-820e-ee6696ad63e2
- urn:schemas-xmlsoap-org:ws:2005:04:discovery
-
-
-
-
-
\ No newline at end of file
diff --git a/onvif-java/src/test/java/org/onvif/client/DiscoverAndTest.java b/onvif-java/src/test/java/org/onvif/client/DiscoverAndTest.java
index a2e5b34..fbe61fb 100644
--- a/onvif-java/src/test/java/org/onvif/client/DiscoverAndTest.java
+++ b/onvif-java/src/test/java/org/onvif/client/DiscoverAndTest.java
@@ -6,16 +6,17 @@ import java.io.StringWriter;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.logging.Logger;
-import org.apache.cxf.common.logging.LogUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
- * Class calls OnvifDiscovery and for each device URL found, calls TestDevice
- * This assumes all onvif devices on your network use the same username and password.
+ * Class calls OnvifDiscovery and for each device URL found, calls TestDevice This assumes all onvif
+ * devices on your network use the same username and password.
+ *
* @author Brad Lowe
*/
public class DiscoverAndTest {
- private static final Logger LOG = LogUtils.getL7dLogger(TestDevice.class);
+ private static final Logger LOG = LoggerFactory.getLogger(TestDevice.class);
public static String discoverAndTest(String user, String password) {
String sep = "\n";
@@ -38,10 +39,10 @@ public class DiscoverAndTest {
results.add(u.toString() + ":" + result);
} catch (Throwable e) {
bad++;
- LOG.severe("error:" + u + " " + e.toString());
+ LOG.error("error:" + u, e);
// This is a bit of a hack. When a camera is password protected (it should be!)
// and the password is not provided or wrong, a "Unable to Send Message" exception
- // is thrown. This is not clear-- buried in the stack track is the real cause.
+ // may be thrown. This is not clear-- buried in the stack track is the real cause.
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
@@ -58,8 +59,16 @@ public class DiscoverAndTest {
public static void main(String[] args) {
// get user and password.. we will ignore device host
- OnvifCredentials creds = GetTestDevice.getOnvifCredentials(args);
- if (creds.getPassword().isEmpty()) LOG.info("Warning: No password for discover and test...");
- LOG.info(discoverAndTest(creds.getUser(), creds.getPassword()));
+ String user = "";
+ String password = "";
+ if (args.length > 0) user = args[0];
+ if (args.length > 1) password = args[1];
+
+ if (password.isEmpty()) {
+ LOG.info(
+ "Warning: No password for discover and test... run with common user password as arguments");
+ }
+ // OnvifDevice.setVerbose(true);
+ LOG.info(discoverAndTest(user, password));
}
}
diff --git a/onvif-java/src/test/java/org/onvif/client/DiscoveryTest.java b/onvif-java/src/test/java/org/onvif/client/DiscoveryTest.java
index e43263c..13fc326 100644
--- a/onvif-java/src/test/java/org/onvif/client/DiscoveryTest.java
+++ b/onvif-java/src/test/java/org/onvif/client/DiscoveryTest.java
@@ -1,22 +1,18 @@
package org.onvif.client;
-
import de.onvif.discovery.OnvifDiscovery;
-import org.apache.cxf.common.logging.LogUtils;
-
import java.net.URL;
import java.util.Collection;
-import java.util.logging.Logger;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DiscoveryTest {
- private static final Logger LOG = LogUtils.getL7dLogger(DiscoveryTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DiscoveryTest.class);
- public static void main(String[] args) {
- Collection urls = OnvifDiscovery.discoverOnvifURLs();
- for (URL u : urls) {
- LOG.info(u.toString());
- }
- }
+ public static void main(String[] args) {
+ Collection urls = OnvifDiscovery.discoverOnvifURLs();
+ for (URL u : urls) {
+ LOG.info(u.toString());
+ }
+ }
}
-
diff --git a/onvif-java/src/test/java/org/onvif/client/GetTestDevice.java b/onvif-java/src/test/java/org/onvif/client/GetTestDevice.java
index 821f5f3..18b5ecf 100644
--- a/onvif-java/src/test/java/org/onvif/client/GetTestDevice.java
+++ b/onvif-java/src/test/java/org/onvif/client/GetTestDevice.java
@@ -1,119 +1,116 @@
package org.onvif.client;
-import org.apache.cxf.common.logging.LogUtils;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
import java.util.Scanner;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class GetTestDevice {
- static String PROPERTY_NAME="ONVIF_HOST";
- private static final Logger LOG = LogUtils.getL7dLogger(GetTestDevice.class);
+ static String PROPERTY_NAME = "ONVIF_HOST";
+ private static final Logger LOG = LoggerFactory.getLogger(GetTestDevice.class);
- // Get a camera host, user name, and password for tests.
- // Add an environment variable or java Property called "TEST_CAM" and set to host,user,password,profile
- // or modify resource/onvif.properties
+ // Get a camera host, user name, and password for tests.
+ // Add an environment variable or java Property called "TEST_CAM" and set to
+ // host,user,password,profile
+ // or modify resource/onvif.properties
- public static OnvifCredentials getOnvifCredentials(String args[]) {
+ public static OnvifCredentials getOnvifCredentials(String[] args) {
- OnvifCredentials creds = getFromArgs(args);
- if (creds!=null) return creds;
+ OnvifCredentials creds = getFromArgs(args);
+ if (creds != null) return creds;
- creds = getFromProperties();
- if (creds!=null) return creds;
- try {
- creds = getFirstFromResource("/onvif.properties");
- if (creds != null) return creds;
- }catch(IOException ioe)
- {
- LOG.log(Level.WARNING, "Error", ioe);
- }
- try {
- creds = getFromStandardInput();
- if (creds != null) return creds;
- }catch(IOException ioe)
- {
- LOG.log(Level.WARNING, "Error", ioe);
- }
+ creds = getFromProperties();
+ if (creds != null) return creds;
+ try {
+ creds = getFirstFromResource("/onvif.properties");
+ if (creds != null) return creds;
+ } catch (IOException ioe) {
+ LOG.error("Error", ioe);
+ }
+ try {
+ creds = getFromStandardInput();
+ if (creds != null) return creds;
+ } catch (IOException ioe) {
+ LOG.error("Error", ioe);
+ }
- LOG.info("Unable to get default test onvif credentials");
- return new OnvifCredentials("","","","");
- }
+ LOG.info("Unable to get default test onvif credentials");
+ return new OnvifCredentials("", "", "", "");
+ }
- // arguments to any test app can be host user password profilename
- // if no arguments passed, returns null.
- // All arguments optional.
- public static OnvifCredentials getFromArgs(String[] args) {
- if (args==null||args.length==0) return null;
- String host="",user="",password="",profile="";
- host = args[0];
- if (args.length > 1) user = args[1];
- if (args.length > 2) password = args[2];
- if (args.length > 3) profile = args[3];
- return new OnvifCredentials(host,user,password,profile);
- }
+ // arguments to any test app can be host user password profilename
+ // if no arguments passed, returns null.
+ // All arguments optional.
+ public static OnvifCredentials getFromArgs(String[] args) {
+ if (args == null || args.length == 0) return null;
+ String host = "", user = "", password = "", profile = "";
+ host = args[0];
+ if (args.length > 1) user = args[1];
+ if (args.length > 2) password = args[2];
+ if (args.length > 3) profile = args[3];
+ return new OnvifCredentials(host, user, password, profile);
+ }
- public static OnvifCredentials getFromProperties() {
- String test = null;
- if (test == null) test = System.getProperty(PROPERTY_NAME);
- if (test == null) test = System.getenv(PROPERTY_NAME);
+ public static OnvifCredentials getFromProperties() {
+ String test = null;
+ if (test == null) test = System.getProperty(PROPERTY_NAME);
+ if (test == null) test = System.getenv(PROPERTY_NAME);
- if (test != null) {
- return parse(test);
- }
- return null;
- }
+ if (test != null) {
+ return parse(test);
+ }
+ return null;
+ }
- private static OnvifCredentials getFromStandardInput() throws IOException {
+ private static OnvifCredentials getFromStandardInput() throws IOException {
- System.out.println("Getting camera credentials from standard input");
- InputStreamReader inputStream = new InputStreamReader(System.in, "utf-8");
- BufferedReader keyboardInput = new BufferedReader(inputStream);
- System.out.println("Please enter camera IP (with port if not 80):");
- String cameraAddress = keyboardInput.readLine();
- System.out.println("Please enter camera username:");
- String user = keyboardInput.readLine();
- System.out.println("Please enter camera password:");
- String password = keyboardInput.readLine();
- System.out.println("Please enter camera profile [or enter to use first]:");
- String profile = keyboardInput.readLine();
- OnvifCredentials creds = new OnvifCredentials(cameraAddress, user, password, profile);
- return creds;
- }
- private static OnvifCredentials getFirstFromResource(String resource) throws IOException {
+ System.out.println("Getting camera credentials from standard input");
+ InputStreamReader inputStream = new InputStreamReader(System.in, StandardCharsets.UTF_8);
+ BufferedReader keyboardInput = new BufferedReader(inputStream);
+ System.out.println("Please enter camera IP (with port if not 80):");
+ String cameraAddress = keyboardInput.readLine();
+ System.out.println("Please enter camera username:");
+ String user = keyboardInput.readLine();
+ System.out.println("Please enter camera password:");
+ String password = keyboardInput.readLine();
+ System.out.println("Please enter camera profile [or enter to use first]:");
+ String profile = keyboardInput.readLine();
+ OnvifCredentials creds = new OnvifCredentials(cameraAddress, user, password, profile);
+ return creds;
+ }
- InputStream res = GetTestDevice.class.getResourceAsStream(resource);
- if (res != null) {
- Scanner s = new Scanner(res, "UTF-8").useDelimiter("\\A");
- while (s.hasNextLine()) {
- String line = s.nextLine();
- if (!line.isEmpty() && !line.startsWith("#"))
- return parse(line.substring(line.indexOf("=")+1));
- }
- }
- return null;
- }
+ private static OnvifCredentials getFirstFromResource(String resource) throws IOException {
- // warning, this breaks if password contains a comma.
- public static OnvifCredentials parse(String i) {
- String host = "", user = "", password = "", profile = "";
- if (i != null) {
- if (i.contains(",")) {
- String sp[] = i.split(",");
- if (sp.length > 0) host = sp[0];
- if (sp.length > 1) user = sp[1];
- if (sp.length > 2) password = sp[2];
- if (sp.length > 3) profile = sp[3];
+ InputStream res = GetTestDevice.class.getResourceAsStream(resource);
+ if (res != null) {
+ Scanner s = new Scanner(res, StandardCharsets.UTF_8).useDelimiter("\\A");
+ while (s.hasNextLine()) {
+ String line = s.nextLine();
+ if (!line.isEmpty() && !line.startsWith("#"))
+ return parse(line.substring(line.indexOf("=") + 1));
+ }
+ }
+ return null;
+ }
- } else host = i;
- }
- return new OnvifCredentials(host, user, password, profile);
- }
+ // warning, this breaks if password contains a comma.
+ public static OnvifCredentials parse(String i) {
+ String host = "", user = "", password = "", profile = "";
+ if (i != null) {
+ if (i.contains(",")) {
+ String[] sp = i.split(",");
+ if (sp.length > 0) host = sp[0];
+ if (sp.length > 1) user = sp[1];
+ if (sp.length > 2) password = sp[2];
+ if (sp.length > 3) profile = sp[3];
+ } else host = i;
+ }
+ return new OnvifCredentials(host, user, password, profile);
+ }
}
-
diff --git a/onvif-java/src/test/java/org/onvif/client/OnvifCredentials.java b/onvif-java/src/test/java/org/onvif/client/OnvifCredentials.java
index 6e415f0..0708ce6 100644
--- a/onvif-java/src/test/java/org/onvif/client/OnvifCredentials.java
+++ b/onvif-java/src/test/java/org/onvif/client/OnvifCredentials.java
@@ -1,55 +1,55 @@
package org.onvif.client;
public class OnvifCredentials {
- private String host; // 92.168.xx.yy, or http://host[:port]
- private String user; // admin
- private String password; // secret
- private String profile; // "MediaProfile000" If empty, will use first profile.
+ private String host; // 92.168.xx.yy, or http://host[:port]
+ private String user; // admin
+ private String password; // secret
+ private String profile; // "MediaProfile000" If empty, will use first profile.
- public OnvifCredentials(String host, String user, String password, String profile) {
- this.host = host;
- this.user = user;
- this.password = password;
- this.profile = profile;
- }
+ public OnvifCredentials(String host, String user, String password, String profile) {
+ this.host = host;
+ this.user = user;
+ this.password = password;
+ this.profile = profile;
+ }
- public String getHost() {
- return host;
- }
+ public String getHost() {
+ return host;
+ }
- public void setHost(String host) {
- this.host = host;
- }
+ public void setHost(String host) {
+ this.host = host;
+ }
- public String getUser() {
- return user;
- }
+ public String getUser() {
+ return user;
+ }
- public void setUser(String user) {
- this.user = user;
- }
+ public void setUser(String user) {
+ this.user = user;
+ }
- public String getPassword() {
- return password;
- }
+ public String getPassword() {
+ return password;
+ }
- public void setPassword(String password) {
- this.password = password;
- }
+ public void setPassword(String password) {
+ this.password = password;
+ }
- public String getProfile() {
- return profile;
- }
+ public String getProfile() {
+ return profile;
+ }
- public void setProfile(String profile) {
- this.profile = profile;
- }
+ public void setProfile(String profile) {
+ this.profile = profile;
+ }
- public String toString() {
- return host; // + "," + user+ "," + "****,"++ "#" + profile;
- }
+ public String toString() {
+ return host; // + "," + user+ "," + "****,"++ "#" + profile;
+ }
- public String details() {
- return host + "," + user + "," + password + "," + profile;
- }
+ public String details() {
+ return host + "," + user + "," + password + "," + profile;
+ }
}
diff --git a/onvif-java/src/test/java/org/onvif/client/ReadCommandsFromStdInput.java b/onvif-java/src/test/java/org/onvif/client/ReadCommandsFromStdInput.java
index 2c3e680..3d4fe35 100644
--- a/onvif-java/src/test/java/org/onvif/client/ReadCommandsFromStdInput.java
+++ b/onvif-java/src/test/java/org/onvif/client/ReadCommandsFromStdInput.java
@@ -1,90 +1,96 @@
package org.onvif.client;
import de.onvif.soap.OnvifDevice;
-import org.onvif.ver10.schema.Profile;
-
-import javax.xml.soap.SOAPException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ConnectException;
import java.net.MalformedURLException;
import java.util.List;
+import javax.xml.soap.SOAPException;
+import org.onvif.ver10.schema.Profile;
public class ReadCommandsFromStdInput {
- private static final String INFO = "Commands:\n \n url: Get snapshort URL.\n info: Get information about each valid command.\n profiles: Get all profiles.\n inspect: Get device details.\n exit: Exit this application.";
+ private static final String INFO =
+ "Commands:\n \n url: Get snapshort URL.\n info: Get information about each valid command.\n profiles: Get all profiles.\n inspect: Get device details.\n exit: Exit this application.";
- public static void main(String args[]) {
- InputStreamReader inputStream = new InputStreamReader(System.in);
- BufferedReader keyboardInput = new BufferedReader(inputStream);
- String input, cameraAddress, user, password;
+ public static void main(String[] args) {
+ InputStreamReader inputStream = new InputStreamReader(System.in);
+ BufferedReader keyboardInput = new BufferedReader(inputStream);
+ String input, cameraAddress, user, password;
- try {
- System.out.println("Please enter camera IP (with port if not 80):");
- cameraAddress = keyboardInput.readLine();
- System.out.println("Please enter camera username:");
- user = keyboardInput.readLine();
- System.out.println("Please enter camera password:");
- password = keyboardInput.readLine();
- if (cameraAddress==null||user==null||password==null) throw new IOException("No input");
- } catch (IOException e1) {
- e1.printStackTrace();
- return;
- }
+ try {
+ System.out.println("Please enter camera IP (with port if not 80):");
+ cameraAddress = keyboardInput.readLine();
+ System.out.println("Please enter camera username:");
+ user = keyboardInput.readLine();
+ System.out.println("Please enter camera password:");
+ password = keyboardInput.readLine();
+ if (cameraAddress == null || user == null || password == null)
+ throw new IOException("No input");
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ return;
+ }
- System.out.println("Connect to camera, please wait ...");
- OnvifDevice cam;
- try {
- cam = new OnvifDevice(cameraAddress, user, password);
- } catch (MalformedURLException | ConnectException | SOAPException e1) {
- System.err.println("No connection to camera, please try again.");
- return;
- }
+ System.out.println("Connect to camera, please wait ...");
+ OnvifDevice cam;
+ try {
+ cam = new OnvifDevice(cameraAddress, user, password);
+ } catch (MalformedURLException | ConnectException | SOAPException e1) {
+ System.err.println("No connection to camera, please try again.");
+ return;
+ }
- System.out.println("Connection to camera successful!");
+ System.out.println("Connection to camera successful!");
- while (true) {
- try {
- System.out.println();
- System.out.println("Enter a command (type \"info\" to get commands):");
- input = keyboardInput.readLine();
- if (input==null) break;
- switch (input) {
- case "url": {
- List profiles = cam.getMedia().getProfiles();
- for (Profile p : profiles) {
- System.out.println("URL from Profile \'" + p.getName() + "\': " + cam.getMedia().getSnapshotUri(p.getToken()));
- }
- break;
- }
- case "profiles":
- List profiles = cam.getMedia().getProfiles();
- System.out.println("Number of profiles: " + profiles.size());
- for (Profile p : profiles) {
- System.out.println(" Profile " + p.getName() + " token is: " + p.getToken());
- }
- break;
- case "info":
- System.out.println(INFO);
- break;
- case "inspect":
- System.out.println(TestDevice.inspect(cam));
- break;
+ while (true) {
+ try {
+ System.out.println();
+ System.out.println("Enter a command (type \"info\" to get commands):");
+ input = keyboardInput.readLine();
+ if (input == null) break;
+ switch (input) {
+ case "url":
+ {
+ List profiles = cam.getMedia().getProfiles();
+ for (Profile p : profiles) {
+ System.out.println(
+ "URL from Profile \'"
+ + p.getName()
+ + "\': "
+ + cam.getMedia().getSnapshotUri(p.getToken()));
+ }
+ break;
+ }
+ case "profiles":
+ List profiles = cam.getMedia().getProfiles();
+ System.out.println("Number of profiles: " + profiles.size());
+ for (Profile p : profiles) {
+ System.out.println(" Profile " + p.getName() + " token is: " + p.getToken());
+ }
+ break;
+ case "info":
+ System.out.println(INFO);
+ break;
+ case "inspect":
+ System.out.println(TestDevice.inspect(cam));
+ break;
- case "quit":
- case "exit":
- case "end":
- return;
- default:
- System.out.println("Unknown command!");
- System.out.println();
- System.out.println(INFO);
- break;
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-}
\ No newline at end of file
+ case "quit":
+ case "exit":
+ case "end":
+ return;
+ default:
+ System.out.println("Unknown command!");
+ System.out.println();
+ System.out.println(INFO);
+ break;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/onvif-java/src/test/java/org/onvif/client/SimpleTest.java b/onvif-java/src/test/java/org/onvif/client/SimpleTest.java
index c61e8f9..7440988 100644
--- a/onvif-java/src/test/java/org/onvif/client/SimpleTest.java
+++ b/onvif-java/src/test/java/org/onvif/client/SimpleTest.java
@@ -1,72 +1,56 @@
package org.onvif.client;
import de.onvif.soap.OnvifDevice;
-import de.onvif.utils.OnvifUtils;
-import org.apache.commons.io.FileUtils;
-import org.onvif.ver10.media.wsdl.Media;
-import org.onvif.ver10.schema.*;
-import org.onvif.ver20.ptz.wsdl.PTZ;
-
-import javax.xml.soap.SOAPException;
import java.io.File;
import java.io.FileInputStream;
-import java.lang.Object;
-import java.net.ConnectException;
import java.net.URL;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Properties;
-
+import org.apache.commons.io.FileUtils;
public class SimpleTest {
- // This test reads connection params from a properties file and take a
- // screenshot
- public static void main(String[] args) throws Exception {
+ // This test reads connection params from a properties file and take a
+ // screenshot
+ public static void main(String[] args) throws Exception {
+ final Map onvifCameras = new HashMap<>();
+ final Map credentialsMap = new HashMap<>();
+ final String propFileRelativePath = "src/test/resources/onvif.properties";
+ final Properties config = new Properties();
+ final File f = new File(propFileRelativePath);
+ if (!f.exists()) throw new Exception("fnf: " + f.getAbsolutePath());
+ config.load(new FileInputStream(f));
- final Map onvifCameras = new HashMap<>();
- final Map credentialsMap = new HashMap<>();
- final String propFileRelativePath = "src/test/resources/onvif.properties";
- final Properties config = new Properties();
- final File f = new File(propFileRelativePath);
- if (!f.exists()) throw new Exception("fnf: " + f.getAbsolutePath());
- config.load(new FileInputStream(f));
+ for (Object k : config.keySet()) {
+ String line = config.get(k.toString()).toString();
+ OnvifCredentials credentials = GetTestDevice.parse(line);
+ if (credentials != null) {
+ try {
+ System.out.println("Connect to camera, please wait ...");
+ OnvifDevice cam =
+ new OnvifDevice(
+ credentials.getHost(), credentials.getUser(), credentials.getPassword());
+ System.out.printf("Connected to device %s (%s)%n", cam.getDeviceInfo(), k.toString());
+ System.out.println(TestDevice.inspect(cam));
- for (Object k:config.keySet())
- {
- String line = config.get(k.toString()).toString();
- OnvifCredentials credentials = GetTestDevice.parse(line);
- if (credentials!=null)
- {
- try {
- System.out.println("Connect to camera, please wait ...");
- OnvifDevice cam = new OnvifDevice(credentials.getHost(), credentials.getUser(), credentials.getPassword());
- System.out.printf("Connected to device %s (%s)%n", cam.getDeviceInfo(), k.toString());
- System.out.println(TestDevice.inspect(cam));
+ String snapshotUri = cam.getSnapshotUri();
+ if (!snapshotUri.isEmpty()) {
+ File tempFile = File.createTempFile("tmp", ".jpg");
- String snapshotUri = cam.getSnapshotUri();
- if (!snapshotUri.isEmpty()) {
- File tempFile = File.createTempFile("tmp", ".jpg");
+ // Note: This will likely fail if the camera/device is password protected.
+ // embedding the user:password@ into the URL will not work with FileUtils.copyURLToFile
+ FileUtils.copyURLToFile(new URL(snapshotUri), tempFile);
+ System.out.println(
+ "snapshot: " + tempFile.getAbsolutePath() + " length:" + tempFile.length());
+ }
- // Note: This will likely fail if the camera/device is password protected.
- // embedding the user:password@ into the URL will not work with FileUtils.copyURLToFile
- FileUtils.copyURLToFile(new URL(snapshotUri), tempFile);
- System.out.println("snapshot: " + tempFile.getAbsolutePath() + " length:" + tempFile.length());
- }
-
-
- }catch(Throwable th)
- {
- System.err.println("Error on device: "+k);
- th.printStackTrace();
- }
- }
- }
-
-
- }
-
-}
\ No newline at end of file
+ } catch (Throwable th) {
+ System.err.println("Error on device: " + k);
+ th.printStackTrace();
+ }
+ }
+ }
+ }
+}
diff --git a/onvif-java/src/test/java/org/onvif/client/TestDevice.java b/onvif-java/src/test/java/org/onvif/client/TestDevice.java
index 0229071..cdf0a53 100644
--- a/onvif-java/src/test/java/org/onvif/client/TestDevice.java
+++ b/onvif-java/src/test/java/org/onvif/client/TestDevice.java
@@ -3,176 +3,194 @@ package org.onvif.client;
import de.onvif.beans.DeviceInfo;
import de.onvif.soap.OnvifDevice;
import de.onvif.utils.OnvifUtils;
-import org.apache.cxf.common.logging.LogUtils;
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+import javax.xml.soap.SOAPException;
import org.onvif.ver10.device.wsdl.DeviceServiceCapabilities;
import org.onvif.ver10.events.wsdl.EventPortType;
import org.onvif.ver10.events.wsdl.GetEventProperties;
import org.onvif.ver10.events.wsdl.GetEventPropertiesResponse;
import org.onvif.ver10.media.wsdl.Media;
-import org.onvif.ver10.schema.*;
+import org.onvif.ver10.schema.AudioSource;
+import org.onvif.ver10.schema.PTZPreset;
+import org.onvif.ver10.schema.PTZStatus;
+import org.onvif.ver10.schema.Profile;
+import org.onvif.ver10.schema.VideoSource;
import org.onvif.ver20.imaging.wsdl.ImagingPort;
import org.onvif.ver20.ptz.wsdl.Capabilities;
import org.onvif.ver20.ptz.wsdl.PTZ;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import javax.xml.soap.SOAPException;
-import java.io.IOException;
-import java.lang.Object;
-import java.net.URL;
-import java.util.List;
-import java.util.logging.Logger;
-
-/**
- * @author Brad Lowe
- */
+/** @author Brad Lowe */
public class TestDevice {
- private static final Logger LOG = LogUtils.getL7dLogger(TestDevice.class);
+ private static final Logger LOG = LoggerFactory.getLogger(TestDevice.class);
- public static String testCamera(OnvifCredentials creds) throws SOAPException, IOException {
- URL u = creds.getHost().startsWith("http") ? new URL(creds.getHost()) : new URL("http://" + creds.getHost());
- return testCamera(u, creds.getUser(), creds.getPassword());
- }
+ public static String testCamera(OnvifCredentials creds) throws SOAPException, IOException {
+ URL u =
+ creds.getHost().startsWith("http")
+ ? new URL(creds.getHost())
+ : new URL("http://" + creds.getHost());
+ return testCamera(u, creds.getUser(), creds.getPassword());
+ }
- static String sep = "\n";
+ static String sep = "\n";
- // This method returns information about an initialized OnvifDevice.
- // This could throw an uncaught SOAP or other error on some cameras...
- // Would accept Pull Requests on printing out additional information about devices.
- public static String inspect(OnvifDevice device) {
- String out = "";
- DeviceInfo info = device.getDeviceInfo();
- out += "DeviceInfo:" +sep + "\t" + info + sep;
- DeviceServiceCapabilities caps = device.getDevice().getServiceCapabilities();
- out += "\tgetServiceCapabilities: " + OnvifUtils.format(caps) + sep;
- out += "\tgetServiceCapabilities.getSystem: " + OnvifUtils.format(caps.getSystem()) + sep;
+ // This method returns information about an initialized OnvifDevice.
+ // This could throw an uncaught SOAP or other error on some cameras...
+ // Would accept Pull Requests on printing out additional information about devices.
+ public static String inspect(OnvifDevice device) {
+ String out = "";
+ DeviceInfo info = device.getDeviceInfo();
+ out += "DeviceInfo:" + sep + "\t" + info + sep;
+ DeviceServiceCapabilities caps = device.getDevice().getServiceCapabilities();
+ String sysCaps = OnvifUtils.format(caps);
+ sysCaps = sysCaps.replace("],", "],\t\n");
+ out += "\tgetServiceCapabilities: " + sysCaps + sep;
+ // out += "\tgetServiceCapabilities.getSystem: " + OnvifUtils.format(caps.getSystem()) + sep;
- Media media = device.getMedia();
- media.getVideoSources();
- List profiles = media.getProfiles();
- out += "Media Profiles: " + profiles.size() + sep;
- for (Profile profile : profiles) {
- String profileToken = profile.getToken();
- String rtsp = device.getRTSPUri(profileToken);
- out += "\tProfile: " + profile.getName() + " token=" + profile.getToken() + sep;
- out += "\t\trtsp: " + rtsp + sep;
- out += "\t\tsnapshot: " + device.getSnapshotUri(profileToken) + sep;
- out += "\t\tdetails:" + OnvifUtils.format(profile) + sep;
- }
+ Media media = device.getMedia();
- List videoSources = media.getVideoSources();
- out += "VideoSources: " + videoSources.size() + sep;
- for (VideoSource v : videoSources)
- out += "\t" + OnvifUtils.format(v) + sep;
+ media.getVideoSources();
+ List profiles = media.getProfiles();
+ out += "Media Profiles: " + profiles.size() + sep;
+ for (Profile profile : profiles) {
+ String profileToken = profile.getToken();
+ String rtsp = device.getStreamUri(profileToken);
+ out += "\tProfile: " + profile.getName() + " token=" + profile.getToken() + sep;
+ out += "\t\tstream: " + rtsp + sep;
+ out += "\t\tsnapshot: " + device.getSnapshotUri(profileToken) + sep;
+ out += "\t\tdetails:" + OnvifUtils.format(profile) + sep;
+ }
- List audioSources = media.getAudioSources();
- out += "AudioSources: " + audioSources.size() + sep;
- for (AudioSource a : audioSources)
- out += "\t" + OnvifUtils.format(a) + sep;
+ try {
+ List videoSources = media.getVideoSources();
+ out += "VideoSources: " + videoSources.size() + sep;
+ for (VideoSource v : videoSources) out += "\t" + OnvifUtils.format(v) + sep;
+ ImagingPort imaging = device.getImaging();
+ if (imaging != null && videoSources.size() > 0) {
+ String token = videoSources.get(0).getToken();
- ImagingPort imaging = device.getImaging();
- if (imaging != null && videoSources.size() > 0) {
- String token = videoSources.get(0).getToken();
+ out += "Imaging:" + token + sep;
+ try {
+ org.onvif.ver20.imaging.wsdl.Capabilities image_caps = imaging.getServiceCapabilities();
+ out += "\tgetServiceCapabilities=" + OnvifUtils.format(image_caps) + sep;
- out += "Imaging:" + token + sep;
- try {
- org.onvif.ver20.imaging.wsdl.Capabilities image_caps = imaging.getServiceCapabilities();
- out += "\tgetServiceCapabilities=" + OnvifUtils.format(image_caps) + sep;
+ if (token != null) {
+ out +=
+ "\tgetImagingSettings="
+ + OnvifUtils.format(imaging.getImagingSettings(token))
+ + sep;
+ out += "\tgetMoveOptions=" + OnvifUtils.format(imaging.getMoveOptions(token)) + sep;
+ out += "\tgetStatus=" + OnvifUtils.format(imaging.getStatus(token)) + sep;
+ out += "\tgetOptions=" + OnvifUtils.format(imaging.getOptions(token)) + sep;
+ }
+ } catch (Throwable th) {
+ out += "Imaging unavailable:" + th.getMessage() + sep;
+ }
+ }
+ } catch (Throwable th) {
+ // this can fail if the device doesn't support video sources.
+ out += "VideoSources: " + th.getMessage() + sep;
+ }
+ try {
+ // This may throw a SoapFaultException with the message "This device does not support audio"
+ List audioSources = media.getAudioSources();
+ out += "AudioSources: " + audioSources.size() + sep;
+ for (AudioSource a : audioSources) out += "\t" + OnvifUtils.format(a) + sep;
+ } catch (Throwable th) {
+ out += "AudioSources Unavailable: " + th.getMessage() + sep;
+ }
- if (token != null) {
- out += "\tgetImagingSettings=" + OnvifUtils.format(imaging.getImagingSettings(token)) + sep;
- out += "\tgetMoveOptions=" + OnvifUtils.format(imaging.getMoveOptions(token)) + sep;
- out += "\tgetStatus=" + OnvifUtils.format(imaging.getStatus(token)) + sep;
- out += "\tgetOptions=" + OnvifUtils.format(imaging.getOptions(token)) + sep;
- }
- } catch (Throwable th) {
- out += "error=" + th.getMessage() + sep;
- }
- }
+ try {
+ EventPortType events = device.getEvents();
+ if (events != null) {
+ out += "Events:" + sep;
+ out +=
+ "\tgetServiceCapabilities=" + OnvifUtils.format(events.getServiceCapabilities()) + sep;
+ GetEventProperties getEventProperties = new GetEventProperties();
+ GetEventPropertiesResponse getEventPropertiesResp =
+ events.getEventProperties(getEventProperties);
+ out += "\tMessageContentFilterDialects:" + sep;
+ for (String f : getEventPropertiesResp.getMessageContentFilterDialect())
+ out += ("\t\t" + f + sep);
+ out += "\tTopicExpressionDialects:" + sep;
+ for (String f : getEventPropertiesResp.getTopicExpressionDialect())
+ out += ("\t\t" + f + sep);
- EventPortType events = device.getEvents();
- if (events != null) {
- out += "Events:" + sep;
- out += "\tgetServiceCapabilities=" + OnvifUtils.format(events.getServiceCapabilities()) + sep;
+ out += "\tTopics:" + sep;
+ StringBuffer tree = new StringBuffer();
+ for (Object object : getEventPropertiesResp.getTopicSet().getAny()) {
+ Element e = (Element) object;
+ printTree(e, e.getNodeName(), tree);
+ // WsNotificationTest.printTree(e, e.getNodeName());
+ }
+ out += tree;
+ }
+ } catch (Throwable th) {
+ out += "Events Unavailable: " + th.getMessage() + sep;
+ }
+ PTZ ptz = device.getPtz();
+ if (ptz != null) {
+ String profileToken = profiles.get(0).getToken();
+ try {
+ Capabilities ptz_caps = ptz.getServiceCapabilities();
+ out += "PTZ:" + sep;
+ out += "\tgetServiceCapabilities=" + OnvifUtils.format(ptz_caps) + sep;
+ PTZStatus s = ptz.getStatus(profileToken);
+ out += "\tgetStatus=" + OnvifUtils.format(s) + sep;
+ // out += "ptz.getConfiguration=" + ptz.getConfiguration(profileToken) + sep;
+ List presets = ptz.getPresets(profileToken);
+ if (presets != null && !presets.isEmpty()) {
+ out += "\tPresets:" + presets.size() + sep;
+ for (PTZPreset p : presets) out += "\t\t" + OnvifUtils.format(p) + sep;
+ }
+ } catch (Throwable th) {
+ out += "PTZ: Unavailable" + th.getMessage() + sep;
+ }
+ }
- GetEventProperties getEventProperties = new GetEventProperties();
- GetEventPropertiesResponse getEventPropertiesResp = events.getEventProperties(getEventProperties);
- out += "\tMessageContentFilterDialects:" + sep;
- for (String f : getEventPropertiesResp.getMessageContentFilterDialect())
- out += ("\t\t" + f + sep);
- out += "\tTopicExpressionDialects:" + sep;
- for (String f : getEventPropertiesResp.getTopicExpressionDialect())
- out += ("\t\t" + f + sep);
+ return out;
+ }
- out += "\tTopics:" + sep;
- StringBuffer tree = new StringBuffer();
- for (Object object : getEventPropertiesResp.getTopicSet().getAny()) {
- Element e = (Element) object;
- printTree(e, e.getNodeName(), tree);
- // WsNotificationTest.printTree(e, e.getNodeName());
- }
- out += tree;
+ public static void printTree(Node node, String name, StringBuffer buffer) {
- }
+ if (node.hasChildNodes()) {
+ NodeList nodes = node.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node n = nodes.item(i);
+ printTree(n, name + " - " + n.getNodeName(), buffer);
+ }
+ } else {
+ buffer.append("\t\t" + name + " - " + node.getNodeName() + "\n");
+ }
+ }
+ public static String testCamera(URL url, String user, String password)
+ throws SOAPException, IOException {
+ LOG.info("Testing camera:" + url);
+ OnvifDevice device = new OnvifDevice(url, user, password);
+ return inspect(device);
+ }
- PTZ ptz = device.getPtz();
- if (ptz != null) {
-
- out += "PTZ:" + sep;
- String profileToken = profiles.get(0).getToken();
-
- Capabilities ptz_caps = ptz.getServiceCapabilities();
- out += "\tgetServiceCapabilities=" + OnvifUtils.format(ptz_caps) + sep;
- PTZStatus s = ptz.getStatus(profileToken);
- out += "\tgetStatus=" + OnvifUtils.format(s) + sep;
- // out += "ptz.getConfiguration=" + ptz.getConfiguration(profileToken) + sep;
- List presets = ptz.getPresets(profileToken);
- if (presets != null && !presets.isEmpty()) {
- out += "\tPresets:" + presets.size() + sep;
- for (PTZPreset p : presets)
- out += "\t\t" + OnvifUtils.format(p) + sep;
- }
- }
-
-
- return out;
- }
-
- public static void printTree(Node node, String name, StringBuffer buffer) {
-
- if (node.hasChildNodes()) {
- NodeList nodes = node.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- Node n = nodes.item(i);
- printTree(n, name + " - " + n.getNodeName(), buffer);
- }
- } else {
- buffer.append("\t\t"+ name + " - " + node.getNodeName() + "\n");
- }
-
- }
-
- public static String testCamera(URL url, String user, String password) throws SOAPException, IOException {
- OnvifDevice device = new OnvifDevice(url, user, password);
- return inspect(device);
- }
-
-
- public static void main(String[] args) {
- try {
- OnvifCredentials creds = GetTestDevice.getOnvifCredentials(args);
- String out = testCamera(creds);
- LOG.info("\n" + out + "\n");
- } catch (Throwable th) {
- LOG.warning("Error "+th);
- th.printStackTrace();
- }
- }
+ public static void main(String[] args) {
+ OnvifCredentials creds = GetTestDevice.getOnvifCredentials(args);
+ try {
+ // OnvifDevice.setVerbose(true);
+ String out = testCamera(creds);
+ LOG.info("\n" + out + "\n");
+ } catch (Throwable th) {
+ LOG.error("Failed for " + creds, th);
+ th.printStackTrace();
+ }
+ }
}
diff --git a/onvif-java/src/test/java/org/onvif/client/WsNotificationTest.java b/onvif-java/src/test/java/org/onvif/client/WsNotificationTest.java
index d671d82..3414b7b 100644
--- a/onvif-java/src/test/java/org/onvif/client/WsNotificationTest.java
+++ b/onvif-java/src/test/java/org/onvif/client/WsNotificationTest.java
@@ -1,6 +1,15 @@
package org.onvif.client;
import de.onvif.soap.OnvifDevice;
+import java.io.File;
+import java.io.IOException;
+import java.net.ConnectException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import javax.xml.bind.JAXBElement;
+import javax.xml.soap.SOAPException;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.commons.io.FileUtils;
import org.apache.cxf.wsn.client.Consumer;
@@ -11,10 +20,24 @@ import org.apache.cxf.wsn.services.JaxwsNotificationBroker;
import org.oasis_open.docs.wsn.b_2.FilterType;
import org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType;
import org.oasis_open.docs.wsn.b_2.TopicExpressionType;
-import org.oasis_open.docs.wsn.bw_2.*;
+import org.oasis_open.docs.wsn.bw_2.InvalidFilterFault;
+import org.oasis_open.docs.wsn.bw_2.InvalidMessageContentExpressionFault;
+import org.oasis_open.docs.wsn.bw_2.InvalidProducerPropertiesExpressionFault;
+import org.oasis_open.docs.wsn.bw_2.InvalidTopicExpressionFault;
+import org.oasis_open.docs.wsn.bw_2.NotifyMessageNotSupportedFault;
+import org.oasis_open.docs.wsn.bw_2.SubscribeCreationFailedFault;
+import org.oasis_open.docs.wsn.bw_2.TopicExpressionDialectUnknownFault;
+import org.oasis_open.docs.wsn.bw_2.TopicNotSupportedFault;
+import org.oasis_open.docs.wsn.bw_2.UnacceptableInitialTerminationTimeFault;
+import org.oasis_open.docs.wsn.bw_2.UnrecognizedPolicyRequestFault;
+import org.oasis_open.docs.wsn.bw_2.UnsupportedPolicyRequestFault;
import org.oasis_open.docs.wsrf.rw_2.ResourceUnknownFault;
-import org.onvif.ver10.events.wsdl.*;
+import org.onvif.ver10.events.wsdl.CreatePullPointSubscription;
import org.onvif.ver10.events.wsdl.CreatePullPointSubscription.SubscriptionPolicy;
+import org.onvif.ver10.events.wsdl.CreatePullPointSubscriptionResponse;
+import org.onvif.ver10.events.wsdl.EventPortType;
+import org.onvif.ver10.events.wsdl.GetEventProperties;
+import org.onvif.ver10.events.wsdl.GetEventPropertiesResponse;
import org.onvif.ver10.schema.Capabilities;
import org.onvif.ver10.schema.CapabilityCategory;
import org.onvif.ver10.schema.MediaUri;
@@ -23,220 +46,226 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import javax.xml.bind.JAXBElement;
-import javax.xml.soap.SOAPException;
-import java.io.File;
-import java.io.IOException;
-import java.net.ConnectException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
public class WsNotificationTest {
- // This is a work in progress class...any help is welcome ;)
- // A good idea could be to follow this guide:
- // https://access.redhat.com/documentation/en-us/red_hat_jboss_a-mq/6.1/html-single/ws-notification_guide/index#WSNTutorial
+ // This is a work in progress class...any help is welcome ;)
+ // A good idea could be to follow this guide:
+ // https://access.redhat.com/documentation/en-us/red_hat_jboss_a-mq/6.1/html-single/ws-notification_guide/index#WSNTutorial
- public static void main(String args[]) throws IOException {
- OnvifCredentials creds = GetTestDevice.getOnvifCredentials(args);
- System.out.println("Connect to camera, please wait ...");
+ public static void main(String[] args) throws IOException {
+ OnvifCredentials creds = GetTestDevice.getOnvifCredentials(args);
+ System.out.println("Connect to camera, please wait ...");
- OnvifDevice cam = null;
- try {
- cam = new OnvifDevice(creds.getHost(), creds.getUser(), creds.getPassword());
- } catch (ConnectException | SOAPException e1) {
- System.err.println("No connection to device with ip " + creds + ", please try again.");
- System.exit(0);
- }
- System.out.println("Connected to device " + cam.getDeviceInfo());
+ OnvifDevice cam = null;
+ try {
+ cam = new OnvifDevice(creds.getHost(), creds.getUser(), creds.getPassword());
+ } catch (ConnectException | SOAPException e1) {
+ System.err.println("No connection to device with ip " + creds + ", please try again.");
+ System.exit(0);
+ }
+ System.out.println("Connected to device " + cam.getDeviceInfo());
- // get device capabilities
- Capabilities cap = cam.getDevice().getCapabilities(Arrays.asList(CapabilityCategory.ALL));
- System.out.println(cap.getDevice().toString());
- // print profiles
- printProfiles(cam);
- // takeScreenShot(profileToken, cam);
- // presets
- // List presets = cam.getPtz().getPresets(profileToken);
- // presets.forEach(x->System.out.println(x.getName()));
+ // get device capabilities
+ Capabilities cap = cam.getDevice().getCapabilities(Arrays.asList(CapabilityCategory.ALL));
+ System.out.println(cap.getDevice().toString());
+ // print profiles
+ printProfiles(cam);
+ // takeScreenShot(profileToken, cam);
+ // presets
+ // List presets = cam.getPtz().getPresets(profileToken);
+ // presets.forEach(x->System.out.println(x.getName()));
- EventPortType eventWs = cam.getEvents();
- GetEventProperties getEventProperties = new GetEventProperties();
- GetEventPropertiesResponse getEventPropertiesResp = eventWs.getEventProperties(getEventProperties);
- getEventPropertiesResp.getMessageContentFilterDialect().forEach(x -> System.out.println(x));
- getEventPropertiesResp.getTopicExpressionDialect().forEach(x -> System.out.println(x));
- for (Object object : getEventPropertiesResp.getTopicSet().getAny()) {
- Element e = (Element) object;
- printTree(e, e.getNodeName());
- }
+ EventPortType eventWs = cam.getEvents();
+ GetEventProperties getEventProperties = new GetEventProperties();
+ GetEventPropertiesResponse getEventPropertiesResp =
+ eventWs.getEventProperties(getEventProperties);
+ getEventPropertiesResp.getMessageContentFilterDialect().forEach(x -> System.out.println(x));
+ getEventPropertiesResp.getTopicExpressionDialect().forEach(x -> System.out.println(x));
+ for (Object object : getEventPropertiesResp.getTopicSet().getAny()) {
+ Element e = (Element) object;
+ printTree(e, e.getNodeName());
+ }
- org.oasis_open.docs.wsn.b_2.ObjectFactory objectFactory = new org.oasis_open.docs.wsn.b_2.ObjectFactory();
- CreatePullPointSubscription pullPointSubscription = new CreatePullPointSubscription();
- FilterType filter = new FilterType();
- TopicExpressionType topicExp = new TopicExpressionType();
- topicExp.getContent().add("tns1:RuleEngine//.");// every event in that
- // topic
- topicExp.setDialect("http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet");
- JAXBElement> topicExpElem = objectFactory.createTopicExpression(topicExp);
- filter.getAny().add(topicExpElem);
- pullPointSubscription.setFilter(filter);
- org.onvif.ver10.events.wsdl.ObjectFactory eventObjFactory = new org.onvif.ver10.events.wsdl.ObjectFactory();
- SubscriptionPolicy subcriptionPolicy = eventObjFactory.createCreatePullPointSubscriptionSubscriptionPolicy();
- pullPointSubscription.setSubscriptionPolicy(subcriptionPolicy);
- String timespan = "PT10S";// every 10 seconds
- // String timespan = "PT1M";//every 1 minute
- pullPointSubscription.setInitialTerminationTime(objectFactory.createSubscribeInitialTerminationTime(timespan));
+ org.oasis_open.docs.wsn.b_2.ObjectFactory objectFactory =
+ new org.oasis_open.docs.wsn.b_2.ObjectFactory();
+ CreatePullPointSubscription pullPointSubscription = new CreatePullPointSubscription();
+ FilterType filter = new FilterType();
+ TopicExpressionType topicExp = new TopicExpressionType();
+ topicExp.getContent().add("tns1:RuleEngine//."); // every event in that
+ // topic
+ topicExp.setDialect("http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet");
+ JAXBElement> topicExpElem = objectFactory.createTopicExpression(topicExp);
+ filter.getAny().add(topicExpElem);
+ pullPointSubscription.setFilter(filter);
+ org.onvif.ver10.events.wsdl.ObjectFactory eventObjFactory =
+ new org.onvif.ver10.events.wsdl.ObjectFactory();
+ SubscriptionPolicy subcriptionPolicy =
+ eventObjFactory.createCreatePullPointSubscriptionSubscriptionPolicy();
+ pullPointSubscription.setSubscriptionPolicy(subcriptionPolicy);
+ String timespan = "PT10S"; // every 10 seconds
+ // String timespan = "PT1M";//every 1 minute
+ pullPointSubscription.setInitialTerminationTime(
+ objectFactory.createSubscribeInitialTerminationTime(timespan));
- try {
- CreatePullPointSubscriptionResponse resp = eventWs.createPullPointSubscription(pullPointSubscription);
+ try {
+ CreatePullPointSubscriptionResponse resp =
+ eventWs.createPullPointSubscription(pullPointSubscription);
- // Start a consumer that will listen for notification messages
- // We'll just print the text content out for now.
- String eventConsumerAddress = "http://localhost:9001/MyConsumer";
- Consumer consumer = new Consumer(new Consumer.Callback() {
- public void notify(NotificationMessageHolderType message) {
- Object o = message.getMessage().getAny();
- System.out.println(message.getMessage().getAny());
- if (o instanceof Element) {
- System.out.println(((Element) o).getTextContent());
- }
- }
- }, eventConsumerAddress);
+ // Start a consumer that will listen for notification messages
+ // We'll just print the text content out for now.
+ String eventConsumerAddress = "http://localhost:9001/MyConsumer";
+ Consumer consumer =
+ new Consumer(
+ new Consumer.Callback() {
+ public void notify(NotificationMessageHolderType message) {
+ Object o = message.getMessage().getAny();
+ System.out.println(message.getMessage().getAny());
+ if (o instanceof Element) {
+ System.out.println(((Element) o).getTextContent());
+ }
+ }
+ },
+ eventConsumerAddress);
- String queuePort = "8182";
- String brokerPort = "8181";
- String brokerAddress = "http://localhost:" + brokerPort + "/wsn/NotificationBroker";
- ActiveMQConnectionFactory activemq = new ActiveMQConnectionFactory(
- "vm:(broker:(tcp://localhost:" + queuePort + ")?persistent=false)");
- JaxwsNotificationBroker notificationBrokerServer = new JaxwsNotificationBroker("WSNotificationBroker",
- activemq);
- notificationBrokerServer.setAddress(brokerAddress);
- notificationBrokerServer.init();
+ String queuePort = "8182";
+ String brokerPort = "8181";
+ String brokerAddress = "http://localhost:" + brokerPort + "/wsn/NotificationBroker";
+ ActiveMQConnectionFactory activemq =
+ new ActiveMQConnectionFactory(
+ "vm:(broker:(tcp://localhost:" + queuePort + ")?persistent=false)");
+ JaxwsNotificationBroker notificationBrokerServer =
+ new JaxwsNotificationBroker("WSNotificationBroker", activemq);
+ notificationBrokerServer.setAddress(brokerAddress);
+ notificationBrokerServer.init();
- // Create a subscription for a Topic on the broker
- NotificationBroker notificationBroker = new NotificationBroker(brokerAddress);
- // PublisherCallback publisherCallback = new PublisherCallback();
- // Publisher publisher = new Publisher(publisherCallback,
- // "http://localhost:" + port2 + "/test/publisher");
- Subscription subscription = notificationBroker.subscribe(consumer, "tns1:RuleEngine");
+ // Create a subscription for a Topic on the broker
+ NotificationBroker notificationBroker = new NotificationBroker(brokerAddress);
+ // PublisherCallback publisherCallback = new PublisherCallback();
+ // Publisher publisher = new Publisher(publisherCallback,
+ // "http://localhost:" + port2 + "/test/publisher");
+ Subscription subscription = notificationBroker.subscribe(consumer, "tns1:RuleEngine");
- // Device
- // Trigger/Relay
- // OperationMode/ShutdownInitiated
- // OperationMode/UploadInitiated
- // HardwareFailure/FanFailure
- // HardwareFailure/PowerSupplyFailure
- // HardwareFailure/StorageFailure
- // HardwareFailure/TemperatureCritical
- // VideoSource
- // tns1:VideoSource/CameraRedirected
- // tns1:VideoSource/SignalLoss
- // tns1:VideoSource/MotionAlarm
- // VideoEncoder
- // VideoAnalytics
- // RuleEngine
- // LineDetector/Crossed
- // FieldDetector/ObjectsInside
- // PTZController
- // PTZPresets/Invoked
- // PTZPresets/Reached
- // PTZPresets/Aborted
- // PTZPresets/Left
- // AudioSource
- // AudioEncoder
- // UserAlarm
- // MediaControl
- // RecordingConfig
- // RecordingHistory
- // VideoOutput
- // AudioOutput
- // VideoDecoder
- // AudioDecoder
- // Receiver
- // MediaConfiguration
- // VideoSourceConfiguration
- // AudioSourceConfiguration
- // VideoEncoderConfiguration
- // AudioEncoderConfiguration
- // VideoAnalyticsConfiguration
- // PTZConfiguration
- // MetaDataConfiguration
+ // Device
+ // Trigger/Relay
+ // OperationMode/ShutdownInitiated
+ // OperationMode/UploadInitiated
+ // HardwareFailure/FanFailure
+ // HardwareFailure/PowerSupplyFailure
+ // HardwareFailure/StorageFailure
+ // HardwareFailure/TemperatureCritical
+ // VideoSource
+ // tns1:VideoSource/CameraRedirected
+ // tns1:VideoSource/SignalLoss
+ // tns1:VideoSource/MotionAlarm
+ // VideoEncoder
+ // VideoAnalytics
+ // RuleEngine
+ // LineDetector/Crossed
+ // FieldDetector/ObjectsInside
+ // PTZController
+ // PTZPresets/Invoked
+ // PTZPresets/Reached
+ // PTZPresets/Aborted
+ // PTZPresets/Left
+ // AudioSource
+ // AudioEncoder
+ // UserAlarm
+ // MediaControl
+ // RecordingConfig
+ // RecordingHistory
+ // VideoOutput
+ // AudioOutput
+ // VideoDecoder
+ // AudioDecoder
+ // Receiver
+ // MediaConfiguration
+ // VideoSourceConfiguration
+ // AudioSourceConfiguration
+ // VideoEncoderConfiguration
+ // AudioEncoderConfiguration
+ // VideoAnalyticsConfiguration
+ // PTZConfiguration
+ // MetaDataConfiguration
- // Wait for some messages to accumulate in the pull point
- Thread.sleep(50_000);
+ // Wait for some messages to accumulate in the pull point
+ Thread.sleep(50_000);
- // Cleanup and exit
- subscription.unsubscribe();
- consumer.stop();
+ // Cleanup and exit
+ subscription.unsubscribe();
+ consumer.stop();
- } catch (TopicNotSupportedFault | TopicExpressionDialectUnknownFault | InvalidTopicExpressionFault
- | InvalidMessageContentExpressionFault | InvalidProducerPropertiesExpressionFault
- | UnacceptableInitialTerminationTimeFault | NotifyMessageNotSupportedFault | ResourceUnknownFault
- | UnsupportedPolicyRequestFault | InvalidFilterFault | SubscribeCreationFailedFault
- | UnrecognizedPolicyRequestFault e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ } catch (TopicNotSupportedFault
+ | TopicExpressionDialectUnknownFault
+ | InvalidTopicExpressionFault
+ | InvalidMessageContentExpressionFault
+ | InvalidProducerPropertiesExpressionFault
+ | UnacceptableInitialTerminationTimeFault
+ | NotifyMessageNotSupportedFault
+ | ResourceUnknownFault
+ | UnsupportedPolicyRequestFault
+ | InvalidFilterFault
+ | SubscribeCreationFailedFault
+ | UnrecognizedPolicyRequestFault e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
- }
+ public static void printTree(Node node, String name) {
+ if (node.hasChildNodes()) {
+ NodeList nodes = node.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node n = nodes.item(i);
+ printTree(n, name + " - " + n.getNodeName());
+ }
+ } else System.out.println(name + " - " + node.getNodeName());
+ }
- public static void printTree(Node node, String name) {
- if (node.hasChildNodes()) {
- NodeList nodes = node.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- Node n = nodes.item(i);
- printTree(n, name + " - " + n.getNodeName());
- }
- } else
- System.out.println(name + " - " + node.getNodeName());
- }
+ private static void takeScreenShot(String profileToken, OnvifDevice cam) {
+ try {
+ MediaUri sceenshotUri = cam.getMedia().getSnapshotUri(profileToken);
+ File tempFile = File.createTempFile("bosc", ".jpg");
+ // tempFile.deleteOnExit();
+ FileUtils.copyURLToFile(new URL(sceenshotUri.getUri()), tempFile);
+ Runtime.getRuntime().exec("nautilus " + tempFile.getAbsolutePath());
+ Thread.sleep(10000);
+ } catch (ConnectException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
- private static void takeScreenShot(String profileToken, OnvifDevice cam) {
- try {
- MediaUri sceenshotUri = cam.getMedia().getSnapshotUri(profileToken);
- File tempFile = File.createTempFile("bosc", ".jpg");
- // tempFile.deleteOnExit();
- FileUtils.copyURLToFile(new URL(sceenshotUri.getUri()), tempFile);
- Runtime.getRuntime().exec("nautilus " + tempFile.getAbsolutePath());
- Thread.sleep(10000);
- } catch (ConnectException e) {
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ private static void printProfiles(OnvifDevice cam) {
- private static void printProfiles(OnvifDevice cam) {
+ List profiles = cam.getMedia().getProfiles();
+ for (Profile p : profiles) {
+ System.out.printf(
+ "Profile: [token=%s,name=%s,snapshotUri=%s]%n",
+ p.getToken(), p.getName(), cam.getMedia().getSnapshotUri(p.getToken()).getUri());
+ }
+ }
- List profiles = cam.getMedia().getProfiles();
- for (Profile p : profiles) {
- System.out.printf("Profile: [token=%s,name=%s,snapshotUri=%s]%n", p.getToken(), p.getName(),
- cam.getMedia().getSnapshotUri(p.getToken()).getUri());
- }
- }
+ public static class PublisherCallback implements Publisher.Callback {
+ final CountDownLatch subscribed = new CountDownLatch(1);
+ final CountDownLatch unsubscribed = new CountDownLatch(1);
- public static class PublisherCallback implements Publisher.Callback {
- final CountDownLatch subscribed = new CountDownLatch(1);
- final CountDownLatch unsubscribed = new CountDownLatch(1);
+ public void subscribe(TopicExpressionType topic) {
+ subscribed.countDown();
+ }
- public void subscribe(TopicExpressionType topic) {
- subscribed.countDown();
- }
-
- public void unsubscribe(TopicExpressionType topic) {
- unsubscribed.countDown();
- }
- }
-}
\ No newline at end of file
+ public void unsubscribe(TopicExpressionType topic) {
+ unsubscribed.countDown();
+ }
+ }
+}
diff --git a/onvif-ws-client/pom.xml b/onvif-ws-client/pom.xml
index 0ccab20..63bba10 100644
--- a/onvif-ws-client/pom.xml
+++ b/onvif-ws-client/pom.xml
@@ -1,189 +1,189 @@
-
- 4.0.0
-
- org.onvif
- onvif
- 1.0-SNAPSHOT
-
- onvif-ws-client
+
+ 4.0.0
+
+ org.onvif
+ onvif
+ 1.0-SNAPSHOT
+
+ onvif-ws-client
-
-
- org.apache.cxf
- cxf-rt-frontend-jaxws
- ${cxf.version}
-
-
-
-
-
-
-
- org.apache.cxf
- cxf-rt-transports-http-jetty
- ${cxf.version}
-
+
+
+ org.apache.cxf
+ cxf-rt-frontend-jaxws
+ ${cxf.version}
+
+
+
+
+
+
+
+ org.apache.cxf
+ cxf-rt-transports-http-jetty
+ ${cxf.version}
+
-
-
- javax.xml.ws
- jaxws-api
- 2.3.1
-
+
+
+ javax.xml.ws
+ jaxws-api
+ 2.3.1
+
-
- javax.jws
- javax.jws-api
- 1.1
-
-
-
- org.apache.cxf.services.wsn
- cxf-services-wsn-core
- ${cxf.version}
-
+
+ javax.jws
+ javax.jws-api
+ 1.1
+
+
+
+ org.apache.cxf.services.wsn
+ cxf-services-wsn-core
+ ${cxf.version}
+
-
-
- org.apache.commons
- commons-lang3
- 3.8.1
- compile
-
+
+
+ org.apache.commons
+ commons-lang3
+ 3.8.1
+ compile
+
-
- org.apache.cxf.xjc-utils
- cxf-xjc-runtime
- 3.3.0
-
+
+ org.apache.cxf.xjc-utils
+ cxf-xjc-runtime
+ 3.3.0
+
-
- org.apache.maven
- maven-model-builder
- 3.6.1
-
+
+ org.apache.maven
+ maven-model-builder
+ 3.6.1
+
-
-
-
-
- org.apache.cxf
- cxf-codegen-plugin
- 3.3.2
-
-
- generate-ws-stubs
- generate-sources
-
- wsdl2java
-
-
- ${basedir}/src/main/resources/wsdl
- ${basedir}/src/main/java
-
-
- *.wsdl
-
-
-
-
- -xjc-Xbg
- -xjc-Xts
- -verbose
- -suppress-generated-date
- -wsdlLocation
- null
+
+
+
+
+ org.apache.cxf
+ cxf-codegen-plugin
+ 3.3.2
+
+
+ generate-ws-stubs
+ generate-sources
+
+ wsdl2java
+
+
+ ${basedir}/src/main/resources/wsdl
+ ${basedir}/src/main/java
+
+
+ *.wsdl
+
+
+
+
+ -xjc-Xbg
+ -xjc-Xts
+ -verbose
+ -suppress-generated-date
+ -wsdlLocation
+ null
- -catalog
- ${basedir}/src/main/resources/wsdl/jax-ws-catalog.xml
+ -catalog
+ ${basedir}/src/main/resources/wsdl/jax-ws-catalog.xml
-
-
-
-
-
-
-
- org.apache.cxf
- cxf-rt-bindings-soap
- 3.1.0
-
-
-
- org.apache.cxf.xjcplugins
- cxf-xjc-boolean
- 3.1.0
-
-
-
- org.apache.cxf.xjcplugins
- cxf-xjc-ts
- 3.1.0
-
-
- org.apache.cxf.xjc-utils
- cxf-xjc-runtime
- 3.3.0
-
+
+
+
+
+
+
+
+ org.apache.cxf
+ cxf-rt-bindings-soap
+ 3.1.0
+
+
+
+ org.apache.cxf.xjcplugins
+ cxf-xjc-boolean
+ 3.1.0
+
+
+
+ org.apache.cxf.xjcplugins
+ cxf-xjc-ts
+ 3.1.0
+
+
+ org.apache.cxf.xjc-utils
+ cxf-xjc-runtime
+ 3.3.0
+
-
- org.apache.maven
- maven-model-builder
- 3.6.1
-
+
+ org.apache.maven
+ maven-model-builder
+ 3.6.1
+
-
-
- com.sun.activation
- javax.activation
- ${javax.activation.version}
-
+
+
+ com.sun.activation
+ javax.activation
+ ${javax.activation.version}
+
-
- javax.xml.bind
- jaxb-api
- ${jaxb.api.version}
-
+
+ javax.xml.bind
+ jaxb-api
+ ${jaxb.api.version}
+
-
- com.sun.xml.bind
- jaxb-core
- 2.3.0.1
-
+
+ com.sun.xml.bind
+ jaxb-core
+ 2.3.0.1
+
-
- com.sun.xml.bind
- jaxb-impl
- ${jaxb.api.version}
-
+
+ com.sun.xml.bind
+ jaxb-impl
+ ${jaxb.api.version}
+
-
- javax.annotation
- javax.annotation-api
- 1.3.1
-
-
- javax.xml.ws
- jaxws-api
- 2.3.0
-
-
- javax.activation
- activation
- 1.1.1
-
+
+ javax.annotation
+ javax.annotation-api
+ 1.3.1
+
+
+ javax.xml.ws
+ jaxws-api
+ 2.3.0
+
+
+ javax.activation
+ activation
+ 1.1.1
+
-
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 1960531..36d9e09 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,81 +1,82 @@
-
- 4.0.0
- org.onvif
- onvif
- 1.0-SNAPSHOT
- pom
+
+ 4.0.0
+ org.onvif
+ onvif
+ 1.0-SNAPSHOT
+ pom
-
- 1.8
- 3.3.2
- 3.0.0
- 1.2.0
- 2.3.1
- 8
-
- 3.8.1
- UTF-8
-
+
+ 1.8
+ 3.3.2
+ 3.0.0
+ 1.2.0
+ 2.3.1
+ 8
+
+ 3.8.1
+ UTF-8
+
-
- onvif-ws-client
- onvif-java
-
+
+ onvif-ws-client
+ onvif-java
+
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
-
- ${java.release}
-
-
- ${java.version}
- ${java.version}
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+
+ ${java.release}
+
+
+ ${java.version}
+ ${java.version}
+
+
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
- ${checkstyle-maven-plugin.version}
-
- google_checks.xml
-
-
-
-
- check
-
-
-
-
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ ${checkstyle-maven-plugin.version}
+
+ google_checks.xml
+
+
+
+
+ check
+
+
+
+
-
-
+
+
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
- ${checkstyle-maven-plugin.version}
-
- google_checks.xml
-
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ ${checkstyle-maven-plugin.version}
+
+ google_checks.xml
+
+
+
+
-
-
- internal
- file://${project.build.directory}/mvn-repo
-
-
+
+
+ internal
+ file://${project.build.directory}/mvn-repo
+
+
\ No newline at end of file