Atitit onvif protocol Get RTSP address play Java language ATTILX summary
1.1. Get the RTSP address algorithm and Flow 1
1.2.Onvif camera discovery, WS discovery Mechanism, using XCF class library 1
2. Call Getstreamuri get RTSP address, use class library onvif Java Library by Milgo2
2.1. The problem why use this get address can not play 4
1.1. algorithms and processes for obtaining RTSP addresses
Dynamic discovery of ONVIF equipment
Call Getprofiles to get the profile list,
Call Getstreamuri Get RTSP address (use profile parameter)
1.2. onvif camera discovery, WS discovery Mechanism, using XCF class library
The ONVIF protocol is based on the WebService protocol. His discovery mechanism is the discovery mechanism of WS.
Import java.util.List;
Import javax.xml.ws.EndpointReference;
Import org.apache.cxf.ws.discovery.WSDiscoveryClient;
public class Main
{
public static void Main (string[] args)
{
Wsdiscoveryclient client = new Wsdiscoveryclient ();
Client.setversion10 (); Use Ws-discovery 1.0
Client.setdefaultprobetimeout (1000); timeout 1s
System.out.println ("Probe:" + client.getaddress ());
list<endpointreference> references = Client.probe ();
System.out.println ("Nb answsers:" + references.size ());
for (EndpointReference ref:references)
{
System.out.println (Ref.tostring ());
}
}
}
Probe is:soap.udp://239.255.255.250:3702
Nb answsers:1
<?xml version= "1.0" encoding= "UTF-8" standalone= "yes"? ><endpointreference xmlns= "http://www.w3.org/2005/" 08/addressing "><Address>http://192.168.31.144:10080/onvif/device_service</Address>< Referenceparameters/></endpointreference>
The WS-Service address returned Http://192.168.31.144:10080/onvif/device_service
2. call Getstreamuri Get RTSP address, use class library onvif Java Library by Milgo
Extracts ip,port based on the WS-Service address obtained asynchronously. Call Getstreamuri to get RTSP address
The returned RTSP address Rtsp://192.168.31.144:10554/tcp/av0_0
package Com.attilax.video; /** *@author Attilax * December 21, 2016 10:38:11 */ import java.io.IOException; import java.net.ConnectException; import java.util.List; import javax.xml.soap.SOAPException; import Org.onvif.ver10.media.wsdl.GetStreamUri; import org.onvif.ver10.media.wsdl.GetStreamUriResponse; import org.onvif.ver10.schema.Profile; import Org.onvif.ver10.schema.StreamSetup; import Org.onvif.ver10.schema.Transport; import De.onvif.soap.OnvifDevice; Public class onviftest { Public Static void Main (String[] args) { Org.apache.commons.codec.binary.Base64 Org.apache.commons.codec.binary.Base64 Try { ONVIFDEVICENVT = new Onvifdevice ("192.168.0.20", "admin", "Password"); Onvifdevice NVT = new onvifdevice ("192.168.31.144:10080", "", ""); list<profile> Profiles = Nvt.getdevices (). Getprofiles (); for ( Profile profile: Profiles) { String Profiletoken = profiles.get (0). GetToken (); System. out. println (profile); } System.out.println ("Snapshot URI:" +nvt.getmedia (). Getsnapshoturi (Profiletoken)); String Profiletoken = profiles.get (0). GetToken (); profile_000 Streamsetup Streamsetup = new streamsetup (); String Getstreamuri = Nvt.getmedia (). Getstreamuri (Profiletoken, Streamsetup); System. out. println |