ONVIF Cameras Discovery
The ONVIF cameras can be discovered in multicast mode, by scanning a range of IP addresses, or both, by invoking both functions consecutively. Both discoveries can run at the same time: the cameras found are accumulated in the same list, which is cleared when a discovery starts while no other discovery is running.
The discovery is performed in the background.
Starting the discovery
- To discover the ONVIF cameras through a multicast request, invoke ONVIFDiscoverCameras_Multicast (timeout_seconds_or_0_for_default).
- To discover the ONVIF cameras through a range of IP addresses, invoke ONVIFDiscoverCameras_IPRange (First_IP, Last_IP, timeout_seconds_or_0_for_default).
Note
timeout_seconds_or_0_for_default is the total duration of the discovery; 0 selects the default duration (4 seconds). 2 to 5 seconds are usually sufficient.
Stopping the discovery before its completion
If needed, invoke ONVIFCancelDiscovery () to stop the current background process.
Results of the discovery
- Each camera discovered is notified by an OnONVIFDiscoveryCompleted event (dcs_CameraFound, int CameraCount).
- The end of the multicast discovery is notified by an OnONVIFDiscoveryCompleted event (dcs_MulticastCompleted, int CameraCount).
- The end of the IP range scanning is notified by an OnONVIFDiscoveryCompleted event (dcs_IPRangeCompleted, int CameraCount).
From any of these events, ONVIFEnumCamerasDiscovered can be invoked for each camera, whose index is specified by the CameraIndex parameter. When CameraIndex >= the number of cameras, the function returns false.
The sample code is included in the Delphi and C# MainDemo projects.