+
+ONVIF is an open industry forum that provides and promotes standardized interfaces for effective interoperability of IP-based physical security products. ONVIF was created to make a standard way of how IP products within CCTV and other security areas can communicate with each other.
+
+## Kotlin coroutines
+
+All the Kotlin functions provided are `suspend` functions. All the examples below assumes that you are inside a coroutine context. If not wrap your code inside a `suspend` function or `runBlocking{}`.
+I highly recommend to run those functions inside the [`IO`](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-i-o.html) dispatcher since these calls are thread blocking.
+
+### Discovery
+Straight forward solution:
+
+```kotlin
+val devices: List = discoverDevices()
+```
+
+If you need to create and customize a a one-shot `DiscoveryManager`:
+```kotlin
+val devices = discoverDevices {
+ discoveryTimeout = 10000
+}
+```
+
+If using a custom `DiscoveryManager`:
+```kotlin
+ val myDM = DiscoveryManager().apply { discoveryTimeout = 10000 }
+ val devices = awaitDeviceDiscovery { myDM.discover(it) }
+```
+
+### Information, Profiles and URIs
+
+Once you obtained the device host and you know username and password, create the `OnvifDevice` and get its data async using:
+
+```kotlin
+val om = OnvifManager()
+val device = OnvifDevice(host, user, pswd)
+
+val infos = awaitDeviceInformations { om.getDeviceInformation(device, it) }
+val profiles = awaitDeviceMediaProfiles { om.getMediaProfiles(device, it) }
+val streamUri = awaitDeviceMediaStreamUri { om.getMediaStreamURI(device, profiles.first(), it) }
+val snapshotUri = awaitDeviceMediaSnapshotUri { om.getMediaSnapshotURI(device, profiles.first(), it) }
+```
+
+Or even more easy:
+```kotlin
+val device = OnvifDevice(host, user, pswd)
+val info = device.getInformations()
+val mediaProfiles = device.getMediaProfiles()
+val aStreamUri = device.getMediaStreamUri(mediaProfiles.first())
+val aSnapshotUri = device.getMediaSnapshotUri(mediaProfiles.first())
+
+val allStreamUris = device.getAllMediaStreamUris()
+val allSnapshotUris = device.getAllMediaSsnapshotUris()
+```
diff --git a/LICENSE.txt b/LICENSE
similarity index 100%
rename from LICENSE.txt
rename to LICENSE
diff --git a/README.md b/README.md
index 0d05b26..06ed920 100644
--- a/README.md
+++ b/README.md
@@ -1,216 +1,227 @@
-# ONVIF-Java
----
-[  ](https://bintray.com/tomasverhelst/ONVIF-Java/ONVIF-Java/_latestVersion)
-
-
-
-
-
-ONVIF is an open industry forum that provides and promotes standardized interfaces for effective interoperability of IP-based physical security products. ONVIF was created to make a standard way of how IP products within CCTV and other security areas can communicate with each other.
-
-
-## Features
-
- - **ONVIF & UPnP discovery**
- - ONVIF device management (Services, device information, media profiles, raw media stream uri)
- - UPnP device information
- - Easily extendable with your own requests
- - **Android supported!**
-
-## Discovery
----
-The OnvifDiscovery class uses the **Web Services Dynamic Discovery (WS-Discovery)**. This is a technical specification that defines a multicast discovery protocol to locate services on a local network. It operates over TCP and UDP port ```3702``` and uses IP multicast address ```239.255.255.250```. As the name suggests, the actual communication between nodes is done using web services standards, notably **SOAP-over-UDP**.
-
-With WS-Discovery, the discovery tool puts SSDP queries on the network from its unicast address to ```239.255.255.250``` multicast address, sending them to the well-known UDP port 3702. The device receives the query, and answers to the discovery tool's unicast IP address from its unicast IP address. The reply contains information about the Web Services (WS) available on the device.
-
-**UPnP** works in a very similar way, but on a different UDP port (```1900```).
-Compared to the WS-Discovery, the UPnP is intended for a general use (data sharing, communication, entertainment).
-
-```java
-DiscoveryManager manager = new DiscoveryManager();
-manager.setDiscoveryTimeout(10000);
-manager.discover(new DiscoveryListener() {
- @Override
- public void onDiscoveryStarted() {
- System.out.println("Discovery started");
- }
-
- @Override
- public void onDevicesFound(List devices) {
- for (Device device : devices)
- System.out.println("Devices found: " + device.getHostName());
- }
-});
-```
-
-## ONVIF
----
-
-With the ```OnvifManager``` class it is possible to send requests to an ONVIF-supported device. All requests are sent asynchronously and you can use the ```OnvifResponseListener``` for errors and custom response handling. It is possible to create your own ```OnvifDevice``` or retrieve a list from the ```discover``` method in the ```DiscoveryManager```
-
-```java
-onvifManager = new OnvifManager();
-onvifManager.setOnvifResponseListener(this);
-OnvifDevice device = new OnvifDevice("192.168.0.131", "username", "password");
-```
-
-### Services
-Returns information about services on the device.
-
-```java
-onvifManager.getServices(device, new OnvifServicesListener() {
- @Override
- public void onServicesReceived(@Nonnull OnvifDevice onvifDevice, OnvifServices services) {
-
- }
-});
-```
-
-### Device information
-Returns basic device information from the device. This includes the manufacturer, serial number, hardwareId, ...
-
-```java
-onvifManager.getDeviceInformation(device, new OnvifDeviceInformationListener() {
- @Override
- public void onDeviceInformationReceived(@Nonnull OnvifDevice device,
- @Nonnull OnvifDeviceInformation deviceInformation) {
-
- }
-});
-```
-
-### Media Profiles
-Returns pre-configured or dynamically configured profiles. This command lists all configured profiles in a device. The client does not need to know the media profile in order to use the command.
-
-```java
-onvifManager.getMediaProfiles(device, new OnvifMediaProfilesListener() {
- @Override
- public void onMediaProfilesReceived(@Nonnull OnvifDevice device,
- @Nonnull List mediaProfiles) {
-
- }
-});
-```
-
-### Media Stream URI
-Returns a raw media stream URI that remains valid indefinitely even if the profile is changed.
-
-```java
-onvifManager.getMediaStreamURI(device, mediaProfiles.get(0), new OnvifMediaStreamURIListener() {
- @Override
- public void onMediaStreamURIReceived(@Nonnull OnvifDevice device,
- @Nonnull OnvifMediaProfile profile, @Nonnull String uri) {
-
- }
-});
-```
-
-## UPnP
----
-
-With the ```UPnPManager``` it is possible to retrieve device information from a locally connected UPnP device. A ```UPnPDevice``` can be created manually or discovered from the ```DiscoveryManager``` using ```discovery.discover(DiscoveryMode.UPNP)```
-
-```java
-UPnPDevice device = new UPnPDevice("192.168.0.160");
-device.setLocation("http://192.168.0.160:49152/rootdesc1.xml");
-UPnPManager uPnPManager = new UPnPManager();
-uPnPManager.getDeviceInformation(device, new UPnPDeviceInformationListener() {
- @Override
- public void onDeviceInformationReceived(@Nonnull UPnPDevice device,
- @Nonnull UPnPDeviceInformation information) {
- Log.i(TAG, device.getHostName() + ": " + information.getFriendlyName());
- }
- @Override
- public void onError(@Nonnull UPnPDevice onvifDevice, int errorCode, String errorMessage) {
- Log.e(TAG, "Error: " + errorMessage);
- }
-});
-```
-
-## Custom requests
----
-
-It is possible to implement your custom ONVIF request by creating a new class and implementing the ```OnvifRequest``` interface and overriding the ```getXml()``` and ```getType()``` methods.
-
-```java
-public class PTZRequest implements OnvifRequest {
- @Override
- public String getXml() {
- return "" +
- "false" +
- "";
- }
- @Override
- public OnvifType getType() {
- return OnvifType.CUSTOM;
- }
-}
-```
-
-and send it to the appropriate ```OnvifDevice```:
-
-```java
-onvifManager.sendOnvifRequest(device, new PTZRequest());
-```
-
-Use the ```OnvifResponseListener``` to receive responses from your custom requests.
-
-## Android
----
-In order to receive multicasts packets on your Android device, you'll have to acquire a lock on your WifiManager before making a discovery. Make sure to release the lock once the discovery is completed. More information can be found here: https://developer.android.com/reference/android/net/wifi/WifiManager.MulticastLock
-
-```java
-private void lockMulticast() {
- WifiManager wifi = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
- if (wifi == null)
- return;
-
- WifiManager.MulticastLock lock = wifi.createMulticastLock("ONVIF");
- lock.acquire();
-}
-```
-
-Download
---------
-
-Download [the latest JAR][2] or grab via Maven:
-```xml
-
- be.teletask.onvif
- onvif
- 1.0.0
-
-```
-or Gradle:
-```groovy
-compile 'be.teletask.onvif:onvif:1.0.0'
-```
-
-## Todos
-
- - Implementation ONVIF version management
- - Implementation PTZ
-
-## Pull Requests
----
-Feel free to send pull requests.
-
-License
-=======
-
- Copyright 2018 TELETASK BVBA.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-[2]: https://bintray.com/tomasverhelst/ONVIF-Java/ONVIF-Java/1.0.0#files/be/teletask/onvif/onvif/1.0.0
-
+# ONVIF-Java
+
+[](https://travis-ci.org/lamba92/ONVIF-Java)
+[  ](https://bintray.com/lamba92/com.github.lamba92/ONVIF-Java/_latestVersion)
+
+
+
+
+
+
+ONVIF is an open industry forum that provides and promotes standardized interfaces for effective interoperability of IP-based physical security products. ONVIF was created to make a standard way of how IP products within CCTV and other security areas can communicate with each other.
+
+
+## Features
+
+ - **ONVIF & UPnP discovery**
+ - ONVIF device management (Services, device information, media profiles, raw media stream uri)
+ - UPnP device information
+ - Easily extendable with your own requests
+ - **Android supported!**
+ - [**Kotlin Coroutines support**](KOTLIN.md)
+
+## Discovery
+---
+The OnvifDiscovery class uses the **Web Services Dynamic Discovery (WS-Discovery)**. This is a technical specification that defines a multicast discovery protocol to locate services on a local network. It operates over TCP and UDP port ```3702``` and uses IP multicast address ```239.255.255.250```. As the name suggests, the actual communication between nodes is done using web services standards, notably **SOAP-over-UDP**.
+
+With WS-Discovery, the discovery tool puts SSDP queries on the network from its unicast address to ```239.255.255.250``` multicast address, sending them to the well-known UDP port 3702. The device receives the query, and answers to the discovery tool's unicast IP address from its unicast IP address. The reply contains information about the Web Services (WS) available on the device.
+
+**UPnP** works in a very similar way, but on a different UDP port (```1900```).
+Compared to the WS-Discovery, the UPnP is intended for a general use (data sharing, communication, entertainment).
+
+```java
+DiscoveryManager manager = new DiscoveryManager();
+manager.setDiscoveryTimeout(10000);
+manager.discover(new DiscoveryListener() {
+ @Override
+ public void onDiscoveryStarted() {
+ System.out.println("Discovery started");
+ }
+
+ @Override
+ public void onDevicesFound(List devices) {
+ for (Device device : devices)
+ System.out.println("Devices found: " + device.getHostName());
+ }
+});
+```
+
+## ONVIF
+---
+
+With the ```OnvifManager``` class it is possible to send requests to an ONVIF-supported device. All requests are sent asynchronously and you can use the ```OnvifResponseListener``` for errors and custom response handling. It is possible to create your own ```OnvifDevice``` or retrieve a list from the ```discover``` method in the ```DiscoveryManager```
+
+```java
+onvifManager = new OnvifManager();
+onvifManager.setOnvifResponseListener(this);
+OnvifDevice device = new OnvifDevice("192.168.0.131", "username", "password");
+```
+
+### Services
+Returns information about services on the device.
+
+```java
+onvifManager.getServices(device, new OnvifServicesListener() {
+ @Override
+ public void onServicesReceived(@Nonnull OnvifDevice onvifDevice, OnvifServices services) {
+
+ }
+});
+```
+
+### Device information
+Returns basic device information from the device. This includes the manufacturer, serial number, hardwareId, ...
+
+```java
+onvifManager.getDeviceInformation(device, new OnvifDeviceInformationListener() {
+ @Override
+ public void onDeviceInformationReceived(@Nonnull OnvifDevice device,
+ @Nonnull OnvifDeviceInformation deviceInformation) {
+
+ }
+});
+```
+
+### Media Profiles
+Returns pre-configured or dynamically configured profiles. This command lists all configured profiles in a device. The client does not need to know the media profile in order to use the command.
+
+```java
+onvifManager.getMediaProfiles(device, new OnvifMediaProfilesListener() {
+ @Override
+ public void onMediaProfilesReceived(@Nonnull OnvifDevice device,
+ @Nonnull List mediaProfiles) {
+
+ }
+});
+```
+
+### Media Stream URI
+Returns a raw media stream URI that remains valid indefinitely even if the profile is changed.
+
+```java
+onvifManager.getMediaStreamURI(device, mediaProfiles.get(0), new OnvifMediaStreamURIListener() {
+ @Override
+ public void onMediaStreamURIReceived(@Nonnull OnvifDevice device,
+ @Nonnull OnvifMediaProfile profile, @Nonnull String uri) {
+
+ }
+});
+```
+
+### Media Snapshot URI
+Returns a raw media snapshot URI that remains valid indefinitely even if the profile is changed.
+
+```java
+onvifManager.getMediaSnapshotURI(device, mediaProfiles.get(0), new OnvifMediaStreamURIListener() {
+ @Override
+ public void onMediaSnapshotURIReceived(@Nonnull OnvifDevice device,
+ @Nonnull OnvifMediaProfile profile, @Nonnull String uri) {
+
+ }
+});
+```
+
+## UPnP
+---
+
+With the ```UPnPManager``` it is possible to retrieve device information from a locally connected UPnP device. A ```UPnPDevice``` can be created manually or discovered from the ```DiscoveryManager``` using ```discovery.discover(DiscoveryMode.UPNP)```
+
+```java
+UPnPDevice device = new UPnPDevice("192.168.0.160");
+device.setLocation("http://192.168.0.160:49152/rootdesc1.xml");
+UPnPManager uPnPManager = new UPnPManager();
+uPnPManager.getDeviceInformation(device, new UPnPDeviceInformationListener() {
+ @Override
+ public void onDeviceInformationReceived(@Nonnull UPnPDevice device,
+ @Nonnull UPnPDeviceInformation information) {
+ Log.i(TAG, device.getHostName() + ": " + information.getFriendlyName());
+ }
+ @Override
+ public void onError(@Nonnull UPnPDevice onvifDevice, int errorCode, String errorMessage) {
+ Log.e(TAG, "Error: " + errorMessage);
+ }
+});
+```
+
+## Custom requests
+---
+
+It is possible to implement your custom ONVIF request by creating a new class and implementing the ```OnvifRequest``` interface and overriding the ```getXml()``` and ```getType()``` methods.
+
+```java
+public class PTZRequest implements OnvifRequest {
+ @Override
+ public String getXml() {
+ return "" +
+ "false" +
+ "";
+ }
+ @Override
+ public OnvifType getType() {
+ return OnvifType.CUSTOM;
+ }
+}
+```
+
+and send it to the appropriate ```OnvifDevice```:
+
+```java
+onvifManager.sendOnvifRequest(device, new PTZRequest());
+```
+
+Use the ```OnvifResponseListener``` to receive responses from your custom requests.
+
+## Android
+---
+In order to receive multicasts packets on your Android device, you'll have to acquire a lock on your WifiManager before making a discovery. Make sure to release the lock once the discovery is completed. More information can be found here: https://developer.android.com/reference/android/net/wifi/WifiManager.MulticastLock
+
+```java
+private void lockMulticast() {
+ WifiManager wifi = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+ if (wifi == null)
+ return;
+
+ WifiManager.MulticastLock lock = wifi.createMulticastLock("ONVIF");
+ lock.acquire();
+}
+```
+
+## Download [](https://jitpack.io/#lamba92/ONVIF-Java)
+
+```kotlin
+repositories {
+ maven("https://dl.bintray.com/lamba92/com.github.lamba92")
+}
+
+dependencies {
+ implementation("com.github.lamba92:ONVIF-Java:{LATEST_TAG}")
+}
+```
+
+## Todos
+
+ - Implementation ONVIF version management
+
+## Pull Requests
+---
+Feel free to send pull requests.
+
+License
+=======
+
+ Copyright 2018 TELETASK BVBA.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+[2]: https://bintray.com/tomasverhelst/ONVIF-Java/ONVIF-Java/1.0.0#files/be/teletask/onvif/onvif/1.0.0
+
diff --git a/build.gradle.kts b/build.gradle.kts
new file mode 100644
index 0000000..24b6d60
--- /dev/null
+++ b/build.gradle.kts
@@ -0,0 +1,46 @@
+import com.github.lamba92.gradle.utils.*
+
+buildscript {
+ repositories {
+ maven("https://dl.bintray.com/lamba92/com.github.lamba92")
+ google()
+ }
+ dependencies {
+ classpath("com.github.lamba92", "lamba-gradle-utils", "1.0.6")
+ }
+}
+
+plugins {
+ kotlin("jvm") version "1.3.72"
+ id("com.jfrog.bintray") version "1.8.5"
+ `maven-publish`
+}
+
+repositories {
+ mavenCentral()
+ jcenter()
+}
+
+group = "com.github.lamba92"
+version = TRAVIS_TAG ?: "1.1.5"
+
+dependencies {
+ implementation(kotlin("stdlib-jdk8"))
+ implementation("org.jetbrains", "annotations", "15.0")
+ implementation("net.sf.kxml", "kxml2", "2.3.0")
+ implementation("com.squareup.okhttp3", "okhttp", "3.11.0")
+ implementation("com.burgstaller", "okhttp-digest", "1.18")
+ implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-core", "1.3.4")
+}
+
+val sourcesJar by tasks.creating(Jar::class) {
+ archiveClassifier.set("sources")
+ from(sourceSets["main"].allSource)
+}
+
+publishing.publications.register("mavenJava") {
+ from(components["java"])
+ artifact(sourcesJar)
+}
+
+prepareForPublication()
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..91ca28c
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/lib/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
similarity index 80%
rename from lib/gradle/wrapper/gradle-wrapper.properties
rename to gradle/wrapper/gradle-wrapper.properties
index 8d1e1cb..6623300 100644
--- a/lib/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Fri Sep 07 13:33:20 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip
diff --git a/lib/gradlew b/gradlew
similarity index 100%
rename from lib/gradlew
rename to gradlew
diff --git a/lib/gradlew.bat b/gradlew.bat
similarity index 96%
rename from lib/gradlew.bat
rename to gradlew.bat
index e95643d..f955316 100644
--- a/lib/gradlew.bat
+++ b/gradlew.bat
@@ -1,84 +1,84 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/lib/.gitignore b/lib/.gitignore
deleted file mode 100644
index deee1b6..0000000
--- a/lib/.gitignore
+++ /dev/null
@@ -1,174 +0,0 @@
-
-# Created by https://www.gitignore.io/api/java,android,intellij
-
-### Android ###
-# Built application files
-*.apk
-*.ap_
-
-# Files for the ART/Dalvik VM
-*.dex
-
-# Java class files
-*.class
-
-# Generated files
-bin/
-gen/
-out/
-
-# Gradle files
-.gradle/
-build/
-
-# Local configuration file (sdk path, etc)
-local.properties
-
-# Proguard folder generated by Eclipse
-proguard/
-
-# Log Files
-*.log
-
-# Android Studio Navigation editor temp files
-.navigation/
-
-# Android Studio captures folder
-captures/
-
-# IntelliJ
-*.iml
-.idea
-.idea/workspace.xml
-.idea/tasks.xml
-.idea/gradle.xml
-.idea/assetWizardSettings.xml
-.idea/dictionaries
-.idea/libraries
-.idea/caches
-
-# Keystore files
-# Uncomment the following line if you do not want to check your keystore files in.
-#*.jks
-
-# External native build folder generated in Android Studio 2.2 and later
-.externalNativeBuild
-
-# Google Services (e.g. APIs or Firebase)
-google-services.json
-
-# Freeline
-freeline.py
-freeline/
-freeline_project_description.json
-
-# fastlane
-fastlane/report.xml
-fastlane/Preview.html
-fastlane/screenshots
-fastlane/test_output
-fastlane/readme.md
-
-### Android Patch ###
-gen-external-apklibs
-
-### Intellij ###
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
-# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
-
-# User-specific stuff
-.idea/**/workspace.xml
-.idea/**/tasks.xml
-.idea/**/usage.statistics.xml
-.idea/**/dictionaries
-.idea/**/shelf
-
-# Generated files
-.idea/**/contentModel.xml
-
-# Sensitive or high-churn files
-.idea/**/dataSources/
-.idea/**/dataSources.ids
-.idea/**/dataSources.local.xml
-.idea/**/sqlDataSources.xml
-.idea/**/dynamic.xml
-.idea/**/uiDesigner.xml
-.idea/**/dbnavigator.xml
-
-# Gradle
-.idea/**/gradle.xml
-.idea/**/libraries
-
-# Gradle and Maven with auto-import
-# When using Gradle or Maven with auto-import, you should exclude module files,
-# since they will be recreated, and may cause churn. Uncomment if using
-# auto-import.
-# .idea/modules.xml
-# .idea/*.iml
-# .idea/modules
-
-# CMake
-cmake-build-*/
-
-# Mongo Explorer plugin
-.idea/**/mongoSettings.xml
-
-# File-based project format
-*.iws
-
-# IntelliJ
-
-# mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# JIRA plugin
-atlassian-ide-plugin.xml
-
-# Cursive Clojure plugin
-.idea/replstate.xml
-
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-fabric.properties
-
-# Editor-based Rest Client
-.idea/httpRequests
-
-### Intellij Patch ###
-# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
-
-# *.iml
-# modules.xml
-# .idea/misc.xml
-# *.ipr
-
-# Sonarlint plugin
-.idea/sonarlint
-
-### Java ###
-# Compiled class file
-
-# Log file
-
-# BlueJ files
-*.ctxt
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.jar
-*.war
-*.nar
-*.ear
-*.zip
-*.tar.gz
-*.rar
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-
-
-# End of https://www.gitignore.io/api/java,android,intellij
\ No newline at end of file
diff --git a/lib/build.gradle b/lib/build.gradle
deleted file mode 100644
index 1a2d811..0000000
--- a/lib/build.gradle
+++ /dev/null
@@ -1,150 +0,0 @@
-buildscript {
- repositories {
- jcenter()
- }
- dependencies {
- classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
- }
-}
-
-plugins {
- id 'java'
-}
-
-group 'be.teletask.onvif'
-version '1.0.0'
-
-sourceCompatibility = 1.8
-
-if (JavaVersion.current().isJava8Compatible()) {
- allprojects {
- tasks.withType(Javadoc) {
- options.addStringOption('Xdoclint:none', '-quiet')
- }
- }
-}
-
-repositories {
- mavenCentral()
- jcenter()
-}
-
-dependencies {
- testCompile group: 'junit', name: 'junit', version: '4.12'
-
- //Annotations
- compile group: 'org.jetbrains', name: 'annotations', version: '15.0'
-
- //XML parser
- compile group: 'net.sf.kxml', name: 'kxml2', version: '2.3.0'
-
- //OkHttp
- compile 'com.squareup.okhttp3:okhttp:3.11.0'
-
- //OkHttp Digest
- compile 'com.burgstaller:okhttp-digest:1.18'
-}
-
-ext {
- bintrayRepo = 'ONVIF-Java'
- bintrayName = 'ONVIF-Java'
-
- publishedGroupId = 'be.teletask.onvif'
- libraryName = 'ONVIF-Java'
- artifact = 'onvif'
-
- libraryDescription = 'A Java client library to discover, control and manage ONVIF-supported devices.'
-
- siteUrl = 'https://github.com/RootSoft/ONVIF-Java'
- gitUrl = 'https://github.com/RootSoft/ONVIF-Java.git'
-
- libraryVersion = '1.0.2'
-
- developerId = 'tomasverhelst'
- developerName = 'Tomas Verhelst'
- developerEmail = 'tve@teletask.be'
-
- licenseName = 'The Apache Software License, Version 2.0'
- licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- allLicenses = ["Apache-2.0"]
-}
-
-apply plugin: 'com.github.dcendents.android-maven'
-apply plugin: 'com.jfrog.bintray'
-
-group = publishedGroupId
-version = libraryVersion
-
-install {
- repositories.mavenInstaller {
- pom.project {
- packaging 'jar'
- groupId publishedGroupId
- artifactId artifact
-
- name libraryName
- description libraryDescription
- url siteUrl
-
- licenses {
- license {
- name licenseName
- url licenseUrl
- }
- }
- developers {
- developer {
- id developerId
- name developerName
- email developerEmail
- }
- }
- scm {
- connection gitUrl
- developerConnection gitUrl
- url siteUrl
- }
- }
- }
-}
-
-task sourcesJar(type: Jar) {
- classifier = 'sources'
- from sourceSets.main.java.srcDirs
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-
-artifacts {
- archives javadocJar
- archives sourcesJar
-}
-
-Properties properties = new Properties()
-properties.load(project.rootProject.file('local.properties').newDataInputStream())
-
-bintray {
- user = properties.getProperty("bintray.user")
- key = properties.getProperty("bintray.apikey")
-
- configurations = ['archives']
- pkg {
- repo = bintrayRepo
- name = bintrayName
- desc = libraryDescription
- websiteUrl = siteUrl
- vcsUrl = gitUrl
- licenses = allLicenses
- dryRun = false
- publish = true
- override = false
- publicDownloadNumbers = true
- version {
- desc = libraryDescription
- }
- }
-}
diff --git a/lib/settings.gradle b/lib/settings.gradle
deleted file mode 100644
index bab79fc..0000000
--- a/lib/settings.gradle
+++ /dev/null
@@ -1,2 +0,0 @@
-rootProject.name = 'onvif'
-
diff --git a/lib/src/main/java/be/teletask/onvif/OnvifManager.java b/lib/src/main/java/be/teletask/onvif/OnvifManager.java
deleted file mode 100644
index 45b4e0a..0000000
--- a/lib/src/main/java/be/teletask/onvif/OnvifManager.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package be.teletask.onvif;
-
-import be.teletask.onvif.listeners.*;
-import be.teletask.onvif.models.OnvifDevice;
-import be.teletask.onvif.models.OnvifMediaProfile;
-import be.teletask.onvif.requests.*;
-import be.teletask.onvif.responses.OnvifResponse;
-
-
-/**
- * Created by Tomas Verhelst on 03/09/2018.
- * Copyright (c) 2018 TELETASK BVBA. All rights reserved.
- */
-public class OnvifManager implements OnvifResponseListener {
-
- //Constants
- public final static String TAG = OnvifManager.class.getSimpleName();
-
- //Attributes
- private OnvifExecutor executor;
- private OnvifResponseListener onvifResponseListener;
-
- //Constructors
- public OnvifManager() {
- this(null);
- }
-
- private OnvifManager(OnvifResponseListener onvifResponseListener) {
- this.onvifResponseListener = onvifResponseListener;
- executor = new OnvifExecutor(this);
- }
-
- //Methods
- public void getServices(OnvifDevice device, OnvifServicesListener listener) {
- OnvifRequest request = new GetServicesRequest(listener);
- executor.sendRequest(device, request);
- }
-
- public void getDeviceInformation(OnvifDevice device, OnvifDeviceInformationListener listener) {
- OnvifRequest request = new GetDeviceInformationRequest(listener);
- executor.sendRequest(device, request);
- }
-
- public void getMediaProfiles(OnvifDevice device, OnvifMediaProfilesListener listener) {
- OnvifRequest request = new GetMediaProfilesRequest(listener);
- executor.sendRequest(device, request);
- }
-
- public void getMediaStreamURI(OnvifDevice device, OnvifMediaProfile profile, OnvifMediaStreamURIListener listener) {
- OnvifRequest request = new GetMediaStreamRequest(profile, listener);
- executor.sendRequest(device, request);
- }
-
- public void sendOnvifRequest(OnvifDevice device, OnvifRequest request) {
- executor.sendRequest(device, request);
- }
-
- public void setOnvifResponseListener(OnvifResponseListener onvifResponseListener) {
- this.onvifResponseListener = onvifResponseListener;
- }
-
- /**
- * Clear up the resources.
- */
- public void destroy() {
- onvifResponseListener = null;
- executor.clear();
- }
-
- @Override
- public void onResponse(OnvifDevice onvifDevice, OnvifResponse response) {
- if (onvifResponseListener != null)
- onvifResponseListener.onResponse(onvifDevice, response);
- }
-
- @Override
- public void onError(OnvifDevice onvifDevice, int errorCode, String errorMessage) {
- if (onvifResponseListener != null)
- onvifResponseListener.onError(onvifDevice, errorCode, errorMessage);
- }
-
-}
diff --git a/lib/src/main/java/be/teletask/onvif/OnvifXMLBuilder.java b/lib/src/main/java/be/teletask/onvif/OnvifXMLBuilder.java
deleted file mode 100644
index b6da2c3..0000000
--- a/lib/src/main/java/be/teletask/onvif/OnvifXMLBuilder.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package be.teletask.onvif;
-
-/**
- * Created by Tomas Verhelst on 03/09/2018.
- * Copyright (c) 2018 TELETASK BVBA. All rights reserved.
- */
-public class OnvifXMLBuilder {
-
- //Constants
- public static final String TAG = OnvifXMLBuilder.class.getSimpleName();
-
- //Attributes
-
- public static String getSoapHeader() {
- return "" +
- "" +
- "";
- }
-
- public static String getEnvelopeEnd() {
- return "";
- }
-
- public static String getDiscoverySoapHeader() {
- return "" +
- "" +
- "" +
- "http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe" +
- "urn:uuid:%s\n" +
- "urn:schemas-xmlsoap-org:ws:2005:04:discovery\n" +
- "" +
- "";
- }
-
- public static String getDiscoverySoapBody() {
- return "";
- }
-
-}
diff --git a/lib/src/main/java/be/teletask/onvif/listeners/OnvifDeviceInformationListener.java b/lib/src/main/java/be/teletask/onvif/listeners/OnvifDeviceInformationListener.java
deleted file mode 100644
index e98c770..0000000
--- a/lib/src/main/java/be/teletask/onvif/listeners/OnvifDeviceInformationListener.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package be.teletask.onvif.listeners;
-
-import be.teletask.onvif.models.OnvifDevice;
-import be.teletask.onvif.models.OnvifDeviceInformation;
-
-
-/**
- * Created by Tomas Verhelst on 03/09/2018.
- * Copyright (c) 2018 TELETASK BVBA. All rights reserved.
- */
-public interface OnvifDeviceInformationListener {
-
- void onDeviceInformationReceived(OnvifDevice device, OnvifDeviceInformation deviceInformation);
-
-}
diff --git a/lib/src/main/java/be/teletask/onvif/listeners/OnvifMediaProfilesListener.java b/lib/src/main/java/be/teletask/onvif/listeners/OnvifMediaProfilesListener.java
deleted file mode 100644
index 1ebf891..0000000
--- a/lib/src/main/java/be/teletask/onvif/listeners/OnvifMediaProfilesListener.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package be.teletask.onvif.listeners;
-
-import be.teletask.onvif.models.OnvifDevice;
-import be.teletask.onvif.models.OnvifMediaProfile;
-
-
-import java.util.List;
-
-/**
- * Created by Tomas Verhelst on 03/09/2018.
- * Copyright (c) 2018 TELETASK BVBA. All rights reserved.
- */
-public interface OnvifMediaProfilesListener {
-
- void onMediaProfilesReceived(OnvifDevice device, List mediaProfiles);
-
-}
diff --git a/lib/src/main/java/be/teletask/onvif/listeners/OnvifMediaStreamURIListener.java b/lib/src/main/java/be/teletask/onvif/listeners/OnvifMediaStreamURIListener.java
deleted file mode 100644
index e275398..0000000
--- a/lib/src/main/java/be/teletask/onvif/listeners/OnvifMediaStreamURIListener.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package be.teletask.onvif.listeners;
-
-import be.teletask.onvif.models.OnvifDevice;
-import be.teletask.onvif.models.OnvifMediaProfile;
-
-
-/**
- * Created by Tomas Verhelst on 03/09/2018.
- * Copyright (c) 2018 TELETASK BVBA. All rights reserved.
- */
-public interface OnvifMediaStreamURIListener {
-
- void onMediaStreamURIReceived(OnvifDevice device, OnvifMediaProfile profile, String uri);
-
-}
diff --git a/lib/src/main/java/be/teletask/onvif/listeners/OnvifServicesListener.java b/lib/src/main/java/be/teletask/onvif/listeners/OnvifServicesListener.java
deleted file mode 100644
index 55ed8c1..0000000
--- a/lib/src/main/java/be/teletask/onvif/listeners/OnvifServicesListener.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package be.teletask.onvif.listeners;
-
-import be.teletask.onvif.models.OnvifDevice;
-import be.teletask.onvif.models.OnvifServices;
-
-
-/**
- * Created by Tomas Verhelst on 03/09/2018.
- * Copyright (c) 2018 TELETASK BVBA. All rights reserved.
- */
-public interface OnvifServicesListener {
-
- void onServicesReceived(OnvifDevice onvifDevice, OnvifServices paths);
-
-}
diff --git a/lib/src/main/java/be/teletask/onvif/requests/OnvifRequest.java b/lib/src/main/java/be/teletask/onvif/requests/OnvifRequest.java
deleted file mode 100644
index b5518b8..0000000
--- a/lib/src/main/java/be/teletask/onvif/requests/OnvifRequest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package be.teletask.onvif.requests;
-
-import be.teletask.onvif.models.OnvifType;
-
-/**
- * Created by Tomas Verhelst on 03/09/2018.
- * Copyright (c) 2018 TELETASK BVBA. All rights reserved.
- */
-public interface OnvifRequest {
-
- String getXml();
-
- OnvifType getType();
-
-}
diff --git a/lib/src/main/java/be/teletask/onvif/DiscoveryManager.java b/src/main/java/be/teletask/onvif/DiscoveryManager.java
similarity index 100%
rename from lib/src/main/java/be/teletask/onvif/DiscoveryManager.java
rename to src/main/java/be/teletask/onvif/DiscoveryManager.java
diff --git a/lib/src/main/java/be/teletask/onvif/DiscoveryMode.java b/src/main/java/be/teletask/onvif/DiscoveryMode.java
similarity index 100%
rename from lib/src/main/java/be/teletask/onvif/DiscoveryMode.java
rename to src/main/java/be/teletask/onvif/DiscoveryMode.java
diff --git a/lib/src/main/java/be/teletask/onvif/DiscoveryThread.java b/src/main/java/be/teletask/onvif/DiscoveryThread.java
similarity index 100%
rename from lib/src/main/java/be/teletask/onvif/DiscoveryThread.java
rename to src/main/java/be/teletask/onvif/DiscoveryThread.java
diff --git a/lib/src/main/java/be/teletask/onvif/OnvifDiscovery.java b/src/main/java/be/teletask/onvif/OnvifDiscovery.java
similarity index 100%
rename from lib/src/main/java/be/teletask/onvif/OnvifDiscovery.java
rename to src/main/java/be/teletask/onvif/OnvifDiscovery.java
diff --git a/lib/src/main/java/be/teletask/onvif/OnvifExecutor.java b/src/main/java/be/teletask/onvif/OnvifExecutor.java
similarity index 80%
rename from lib/src/main/java/be/teletask/onvif/OnvifExecutor.java
rename to src/main/java/be/teletask/onvif/OnvifExecutor.java
index ef75ad8..6ab51c1 100644
--- a/lib/src/main/java/be/teletask/onvif/OnvifExecutor.java
+++ b/src/main/java/be/teletask/onvif/OnvifExecutor.java
@@ -7,7 +7,7 @@
import be.teletask.onvif.parsers.GetMediaProfilesParser;
import be.teletask.onvif.parsers.GetMediaStreamParser;
import be.teletask.onvif.parsers.GetServicesParser;
-import be.teletask.onvif.requests.*;
+import be.teletask.onvif.requests.OnvifRequest;
import be.teletask.onvif.responses.OnvifResponse;
import com.burgstaller.okhttp.AuthenticationCacheInterceptor;
import com.burgstaller.okhttp.CachingAuthenticatorDecorator;
@@ -17,7 +17,6 @@
import okhttp3.*;
import okio.Buffer;
-
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -67,7 +66,7 @@ public class OnvifExecutor {
* @param device
* @param request
*/
- void sendRequest(OnvifDevice device, OnvifRequest request) {
+ void sendRequest(OnvifDevice device, OnvifRequest> request) {
credentials.setUserName(device.getUsername());
credentials.setPassword(device.getPassword());
reqBody = RequestBody.create(reqBodyType, OnvifXMLBuilder.getSoapHeader() + request.getXml() + OnvifXMLBuilder.getEnvelopeEnd());
@@ -87,17 +86,15 @@ public void setOnvifResponseListener(OnvifResponseListener onvifResponseListener
this.onvifResponseListener = onvifResponseListener;
}
- private void performXmlRequest(OnvifDevice device, OnvifRequest request, Request xmlRequest) {
- if (xmlRequest == null)
- return;
+ private void performXmlRequest(OnvifDevice device, OnvifRequest> request, Request xmlRequest) {
+ if (xmlRequest == null) return;
client.newCall(xmlRequest)
.enqueue(new Callback() {
@Override
public void onResponse(Call call, Response xmlResponse) throws IOException {
-
- OnvifResponse response = new OnvifResponse(request);
+ OnvifResponse