Atitit java onvif 开源类库 getProfiles getStreamUri
1. ONVIF Java Library by Milgo1
1.1. https://github.com/milg0/onvif-java-lib4
1.2. getProfiles respones file4
1.3. getStreamUri:rtsp://192.168.31.144:10554/tcp/av0_04
1. ONVIF Java Library by Milgo
Non-Profit, Analytics, Security
The ONVIF Java library by Milgo aims to be the first library to interact with the API features related to standardize communication between IP-based security products. ONVIF stands for open network video interface forum. ONVIF API is targeted to installers, system integrators, architects, engineers, and end users.
nvifDevice nvt = new OnvifDevice("192.168.0.20", "admin", "password");
nvt.getDevices(); // Basic methods for configuration and information
nvt.getMedia(); // Methods to get media information like stream or screenshot URIs or to change your video encoder configuration
nvt.getImaging(); // A few functions to change your image settings, really just for your image settings!
nvt.getPtz(); // Functionality to move your camera (if supported!)
Our first goal is to get a snapshot URI of our camera (not every must support this, but most NVT should do). So we will work on with our media methods and there are some methods to achieve our goal. Don't get irritated by the fact that there are methods to get snapshot- and screenshot-URIs, they return the same and have just different names.
getDefaultSnapshotUri() : String
getSnapshotUri(profileToken : String) : String
You can get your device profiles with the initial devices.
OnvifDevice nvt = new OnvifDevice("192.168.0.20", "admin", "password");
List<Profile> profiles = nvt.getDevices().getProfiles();
snapshot URI.
import java.net.ConnectException;
import java.util.List;
import javax.xml.soap.SOAPException;
import org.onvif.ver10.schema.Profile;
import de.onvif.soap.OnvifDevice;
public class OnvifTest {
public static void main(String[] args) {
try {
OnvifDevice nvt = new OnvifDevice("192.168.0.20", "admin", "password");
List<Profile> profiles = nvt.getDevices().getProfiles();
String profileToken = profiles.get(0).getToken();
System.out.println("Snapshot URI: "+nvt.getMedia().getSnapshotUri(profileToken));
}
catch (ConnectException e) {
System.err.println("Could not connect to NVT.");
}
catch (SOAPException e) {
e.printStackTrace();
}
}
}