Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Automation of deploy and testing, scaffold overhaul, Kotlin Coroutines wrappers and Kotlin Gradle DSL #3

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
out/
build/
.gradle/
.idea/
Binary file removed .gradle/4.8/fileChanges/last-build.bin
Binary file not shown.
Binary file removed .gradle/4.8/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed .gradle/4.8/fileHashes/fileHashes.lock
Binary file not shown.
Binary file removed .gradle/4.8/taskHistory/taskHistory.bin
Binary file not shown.
Binary file removed .gradle/4.8/taskHistory/taskHistory.lock
Binary file not shown.
Binary file removed .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 0 additions & 2 deletions .gradle/buildOutputCleanup/cache.properties

This file was deleted.

Binary file removed .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Empty file.
9 changes: 0 additions & 9 deletions .idea/libraries/gradle_wrapper.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

118 changes: 0 additions & 118 deletions .idea/workspace.xml

This file was deleted.

21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: java

before_install: chmod +x gradlew

script: ./gradlew build --console=plain

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

deploy:
provider: script
script: ./gradlew bintrayUpload --console=plain
skip_cleanup: true
on:
branch: master
tags: true
60 changes: 60 additions & 0 deletions KOTLIN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# ONVIF-Java
---
[ ![Download](https://api.bintray.com/packages/tomasverhelst/ONVIF-Java/ONVIF-Java/images/download.svg) ](https://bintray.com/tomasverhelst/ONVIF-Java/ONVIF-Java/_latestVersion)

<p align="center">
<img src="https://botw-pd.s3.amazonaws.com/styles/logo-thumbnail/s3/112012/onvif-converted.png?itok=yqR6_a6G">
</p>

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<Devices> = 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()
```
File renamed without changes.
Loading