How to subscribe for camera events in C#
This article demonstrates how to subscribe Onvif camera events in C# This is useful if you would like to be informed about what events are happening on the camera side.
The ONVIF specification includes three different types of event notifications:
- Real-time Pull-Point Notification Interface
- Basic Notification Interface (WS-BaseNotification)
- Notification Streaming Interface (metadata streaming)
The next parts describe the GetEventProperties action, which will inform you about which notifications a device supports and what information they contain. We will learn how to set up the subscriptions for the methods above, and how the Notification Message is processed.
The WS-BaseNotification specification defines a set of optional WS-ResouceProperties.
This specification does not require the implementation of the WS-ResourceProperty interface.
Instead, the subsequent direct interface shall be implemented by an ONVIF compliant device
in order to provide information about the FilterDialects, Schema files and topics supported
by the device.
The GetEventProperties action returns the various event topics that the device supports. The prerequisites are a device must be discovered and the service URIs must be known.
This method returns a PullPointSubscription that can be polled using PullMessages. This message
contains the same elements as the SubscriptionRequest of the WS-BaseNotification without the ConsumerReference.
PullPoint subscription is used when a client wants to fetch event notifications from a service. This is an ONVIF extension to the standard WS-BaseNotification mechanisms. First, a subscription is created and a subscriptionReference is returned, which is used in PullMessages requests to fetch the actual event notifications. If no notifications are available, the response is delayed. The prerequisites are the following: a device that must be discovered and the service URIs must be known.
A subscription is set up and the notification handling service connects to the specified URL and sends the Notification message. The producer initiates the connection where the Notification is sent through. The consumer and the entity which sets up the subscription don't have to be the same. This process requires a device that must be discovered and the service URIs that are must be known.
Below you can find the answers for the most frequently asked questions related to this topic:
How can I get the URL of the camera?
You can get the URL from the producer of the camera. (In the 10th tutorial you can find information on how to create an own IP camera discoverer program.)
I moved my hand and it has not been detected. Why?
The pixel intensity (sensitivity of movement) has a default value, but in the next chapter we will learn how to change it.
- How to use camera side motion detection in C#
- How to setup viewer side motion detection in C#
- How to set motion detection sensitivity in C#
- How to mask certain areas of the video image in C#
- C# alarm snapshot sending in e-mail
- C# camera snapshot picture upload to FTP
- C# video alarm sending in e-mail
- C# recording alarm video upload to ftp
- Make a VoIP phone alarm call with text to speech in C#
- C# Contact ID alarm message
- Detect if a camera goes offline using alarm phone call