Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Oct 5, 2021. It is now read-only.
/ONVIF-JavaPublic archive

A Java client library to discover, control and manage ONVIF-supported devices.

License

NotificationsYou must be signed in to change notification settings

RootSoft/ONVIF-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Download

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 theWeb 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 port3702 and uses IP multicast address239.255.255.250. As the name suggests, the actual communication between nodes is done using web services standards, notablySOAP-over-UDP.

With WS-Discovery, the discovery tool puts SSDP queries on the network from its unicast address to239.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).

DiscoveryManagermanager =newDiscoveryManager();manager.setDiscoveryTimeout(10000);manager.discover(newDiscoveryListener() {@OverridepublicvoidonDiscoveryStarted() {System.out.println("Discovery started");    }@OverridepublicvoidonDevicesFound(List<Device>devices) {for (Devicedevice :devices)System.out.println("Devices found: " +device.getHostName());    }});

ONVIF


With theOnvifManager class it is possible to send requests to an ONVIF-supported device. All requests are sent asynchronously and you can use theOnvifResponseListener for errors and custom response handling. It is possible to create your ownOnvifDevice or retrieve a list from thediscover method in theDiscoveryManager

onvifManager =newOnvifManager();onvifManager.setOnvifResponseListener(this);OnvifDevicedevice =newOnvifDevice("192.168.0.131","username","password");

Services

Returns information about services on the device.

onvifManager.getServices(device,newOnvifServicesListener() {@OverridepublicvoidonServicesReceived(@NonnullOnvifDeviceonvifDevice,OnvifServicesservices) {            }});

Device information

Returns basic device information from the device. This includes the manufacturer, serial number, hardwareId, ...

onvifManager.getDeviceInformation(device,newOnvifDeviceInformationListener() {@OverridepublicvoidonDeviceInformationReceived(@NonnullOnvifDevicedevice,@NonnullOnvifDeviceInformationdeviceInformation) {            }});

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.

onvifManager.getMediaProfiles(device,newOnvifMediaProfilesListener() {@OverridepublicvoidonMediaProfilesReceived(@NonnullOnvifDevicedevice,@NonnullList<OnvifMediaProfile>mediaProfiles) {            }});

Media Stream URI

Returns a raw media stream URI that remains valid indefinitely even if the profile is changed.

onvifManager.getMediaStreamURI(device,mediaProfiles.get(0),newOnvifMediaStreamURIListener() {@OverridepublicvoidonMediaStreamURIReceived(@NonnullOnvifDevicedevice,@NonnullOnvifMediaProfileprofile,@NonnullStringuri) {            }});

UPnP


With theUPnPManager it is possible to retrieve device information from a locally connected UPnP device. AUPnPDevice can be created manually or discovered from theDiscoveryManager usingdiscovery.discover(DiscoveryMode.UPNP)

UPnPDevicedevice =newUPnPDevice("192.168.0.160");device.setLocation("http://192.168.0.160:49152/rootdesc1.xml");UPnPManageruPnPManager =newUPnPManager();uPnPManager.getDeviceInformation(device,newUPnPDeviceInformationListener() {@OverridepublicvoidonDeviceInformationReceived(@NonnullUPnPDevicedevice,@NonnullUPnPDeviceInformationinformation) {Log.i(TAG,device.getHostName() +": " +information.getFriendlyName());    }@OverridepublicvoidonError(@NonnullUPnPDeviceonvifDevice,interrorCode,StringerrorMessage) {Log.e(TAG,"Error: " +errorMessage);    }});

Custom requests


It is possible to implement your custom ONVIF request by creating a new class and implementing theOnvifRequest interface and overriding thegetXml() andgetType() methods.

publicclassPTZRequestimplementsOnvifRequest {@OverridepublicStringgetXml() {return"<GetServices xmlns=\"http://www.onvif.org/ver10/device/wsdl\">" +"<IncludeCapability>false</IncludeCapability>" +"</GetServices>";    }@OverridepublicOnvifTypegetType() {returnOnvifType.CUSTOM;    }}

and send it to the appropriateOnvifDevice:

onvifManager.sendOnvifRequest(device,newPTZRequest());

Use theOnvifResponseListener 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

privatevoidlockMulticast() {WifiManagerwifi = (WifiManager)getApplicationContext().getSystemService(Context.WIFI_SERVICE);if (wifi ==null)return;WifiManager.MulticastLocklock =wifi.createMulticastLock("ONVIF");lock.acquire();}

Download

Downloadthe latest JAR or grab via Maven:

<dependency>  <groupId>be.teletask.onvif</groupId>  <artifactId>onvif</artifactId>  <version>1.0.0</version></dependency>

or Gradle:

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.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.

About

A Java client library to discover, control and manage ONVIF-supported devices.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp