thephez / onvif-interface

An ONVIF interface for connecting to and controlling cameras
MIT License
35 stars 7 forks source link

could you explain how to get OnvifEvents #1

Open dotori1995-enu opened 2 years ago

dotori1995-enu commented 2 years ago

I don’t know what to say for your contribution! i learn about the onvif interface, and maked onvif PTZ function.

but i encounter the new big deal.

        public void pull(string ip, int port)
        {
             ....
             ....

            // 2. CreatePullPointSubscription
            FilterType filter = new FilterType();
            DateTime currentTime;
            XmlElement[] xml = null;
            DateTime? termTime;
            List<MessageHeader> lstHeaders = new List<MessageHeader>() { };

            EndpointReferenceType ert = eptc.CreatePullPointSubscription(
                filter,
                "PT15S",
                new CreatePullPointSubscriptionSubscriptionPolicy(),
                ref xml,
                out currentTime,
                out termTime
                );
            listBox1.Items.Add(ert.Address.Value);

            //PROBLEM HERE "ReferenceParameters" IS NULL
            if ((ert.ReferenceParameters != null) && (ert.ReferenceParameters.Any != null))
            {
                foreach (System.Xml.XmlElement oXml in ert.ReferenceParameters.Any)
                {
                    string strName = oXml.LocalName;
                    string strNS = oXml.NamespaceURI;
                    string strValue = oXml.InnerXml;

                    lstHeaders.Add(MessageHeader.CreateHeader(strName, strNS, strValue, true));
                }
            }

i always get that "ReferenceParameters" is null.

image

could you explain what happen in this code?


OS: window10 develop framework: dotnet framwork 4.8 IDE: visual studio 2022

Thanks for reading

thephez commented 2 years ago

Hi! Glad you've found some of this to be helpful. I haven't worked with this in 5+ years at this point and, unfortunately, don't have the ability to really investigate this. Probably unrelated to your issue, but maybe try 192.168.0.10 in the Camera IP field rather than 192, 168, 0, 10.

dotori1995-enu commented 1 year ago

Thank you for reply. that problem is almost solved! it's all thanks to you.