Coder Social home page Coder Social logo

onvif's Introduction

onvif protocol

Simple management of onvif IP-devices cameras. onvif is an implementation of ONVIF protocol for managing onvif IP devices. The purpose of this library is convenient and easy management of IP cameras and other devices that support ONVIF standard.

Installation

To install the library, use go get:

go get github.com/use-go/onvif

Supported services

The following services are implemented:

  • Device
  • Media
  • PTZ
  • Imaging
  • Event
  • Discovery
  • Auth(More Options)
  • Soap

Using

General concept

  1. Connecting to the device
  2. Authentication (if necessary)
  3. Defining Data Types
  4. Carrying out the required method

Connecting to the device

If there is a device on the network at the address 192.168.13.42, and its ONVIF services use the 1234 port, then you can connect to the device in the following way:

dev, err := onvif.NewDevice(onvif.DeviceParams{Xaddr: "192.168.13.42:1234"})

The ONVIF port may differ depending on the device , to find out which port to use, you can go to the web interface of the device. Usually this is 80 port.

Authentication

If any function of the ONVIF services requires authentication, you must use the Authenticate method.

device := onvif.NewDevice(onvif.DeviceParams{Xaddr: "192.168.13.42:1234", Username: "username", Password: password})

Defining Data Types

Each ONVIF service in this library has its own package, in which all data types of this service are defined, and the package name is identical to the service name and begins with a capital letter. onvif defines the structures for each function of each ONVIF service supported by this library. Define the data type of the GetCapabilities function of the Device service. This is done as follows:

capabilities := device.GetCapabilities{Category:"All"}

Why does the GetCapabilities structure have the Category field and why is the value of this field All?

The figure below shows the documentation for the GetCapabilities. It can be seen that the function takes one Category parameter and its value should be one of the following: 'All', 'Analytics',' Device ',' Events', 'Imaging', 'Media' or 'PTZ'`.

Device GetCapabilities

An example of defining the data type of GetServiceCapabilities function in PTZ:

ptzCapabilities := ptz.GetServiceCapabilities{}

The figure below shows that GetServiceCapabilities does not accept any arguments.

PTZ GetServiceCapabilities

Common data types are in the xsd/onvif package. The types of data (structures) that can be shared by all services are defined in the onvif package.

An example of how to define the data type of the CreateUsers function in Devicemgmt:

createUsers := device.CreateUsers{User: onvif.User{Username:"admin", Password:"qwerty", UserLevel:"User"}}

The figure below shows that ,in this example, the CreateUsers structure field must be a User whose data type is the User structure containing the Username, Password, UserLevel, and optional Extension fields. The User structure is in the onvif package.

Device CreateUsers

Carrying out the required method

To perform any function of one of the ONVIF services whose structure has been defined, you must use the CallMethod of the device object.

createUsers := device.CreateUsers{User: onvif.User{Username:"admin", Password:"qwerty", UserLevel:"User"}}
device := onvif.NewDevice(onvif.DeviceParams{Xaddr: "192.168.13.42:1234", Username: "username", Password: password})
device.Authenticate("username", "password")
resp, err := dev.CallMethod(createUsers)

Great Thanks

Enhanced and Improved from: goonvif

onvif's People

Contributors

crazybber avatar dependabot[bot] avatar greenlightning avatar jfsmig avatar kikimor avatar palanjyan avatar stefan-kiss avatar sunjirui avatar tarancss avatar yakovlevdmv avatar yjkhtddx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onvif's Issues

GetProfile is not working in some cameras.

IP Camera Company Named Syntel All other endpoints are working fine: but profile request is asking for authentication but dahua cameras are working fine.

Here is request :-
<?xml version="1.0" encoding="UTF-8"?><soap-env:Envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope" xmlns:soap-enc="http://www.w3.org/2003/05/soap-encoding" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:onvif="http://www.onvif.org/ver10/schema" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"><soap-env:Header><Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <UsernameToken xmlns=""> <Username>admin</Username> <Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">tmD70TuteOMdpVIqXhSzkx1/w+M=</Password> <Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">n1115yhlqt6di7bme8ea54xq6mqun47h</Nonce> <Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2023-11-24T07:54:33.429776418Z</Created> </UsernameToken> </Security></soap-env:Header><soap-env:Body><tds:GetCapabilities> <tds:Category>All</tds:Category> </tds:GetCapabilities></soap-env:Body></soap-env:Envelope>

Response Provided By the camera :-
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:saml1="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:ttr="http://www.onvif.org/ver20/analytics/radiometry" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tand="http://www.onvif.org/ver10/analyticsdevice/wsdl" xmlns:tdisp="http://www.onvif.org/ver10/display/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:timg20="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tptz20="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:trt20="http://www.onvif.org/ver20/media/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tnshik="http://www.hikvision.com/2011/event/topics" xmlns:ter="http://www.onvif.org/ver10/error"><SOAP-ENV:Header><wsse:Security SOAP-ENV:mustUnderstand="true"></wsse:Security></SOAP-ENV:Header><SOAP-ENV:Body><SOAP-ENV:Fault><SOAP-ENV:Code><SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value><SOAP-ENV:Subcode><SOAP-ENV:Value>ter:NotAuthorized</SOAP-ENV:Value></SOAP-ENV:Subcode></SOAP-ENV:Code><SOAP-ENV:Reason><SOAP-ENV:Text xml:lang="en">Sender not Authorized</SOAP-ENV:Text></SOAP-ENV:Reason><SOAP-ENV:Detail>The action requested requires authorization and the sender is not authorized.</SOAP-ENV:Detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

I'am trying to fetch snapshot url here. so i need to fetch all profiles.

Same Request Gives Success with Dahua Camera:-
<?xml version="1.0" encoding="utf-8" standalone="yes" ?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:sc="http://www.w3.org/2003/05/soap-encoding" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema"><s:Body><trt:GetProfilesResponse><trt:Profiles token="Profile000" fixed="true"><tt:Name>Profile000</tt:Name><tt:VideoSourceConfiguration token="VideoSource000"><tt:Name>VideoSource000</tt:Name><tt:UseCount>2</tt:UseCount><tt:SourceToken>VideoSource000</tt:SourceToken><tt:Bounds x="0" y="0" width="1920" height="1080"></tt:Bounds></tt:VideoSourceConfiguration><tt:VideoEncoderConfiguration token="VideoEncoder000"><tt:Name>VideoEncoder000</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>H265</tt:Encoding><tt:Resolution><tt:Width>1920</tt:Width><tt:Height>1080</tt:Height></tt:Resolution><tt:Quality>4.000000</tt:Quality><tt:RateControl><tt:FrameRateLimit>1</tt:FrameRateLimit><tt:EncodingInterval>1</tt:EncodingInterval><tt:BitrateLimit>1536</tt:BitrateLimit></tt:RateControl><tt:H265><tt:GovLength>2</tt:GovLength><tt:H265Profile>Main</tt:H265Profile></tt:H265><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.2.4</tt:IPv4Address></tt:Address><tt:Port>40000</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:VideoEncoderConfiguration><tt:VideoAnalyticsConfiguration token="Analytics000"><tt:Name>Analytics000</tt:Name><tt:UseCount>2</tt:UseCount><tt:AnalyticsEngineConfiguration><tt:AnalyticsModule Name="MyCellMotionEngine" Type="tt:CellMotionEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="60"></tt:SimpleItem><tt:ElementItem Name="Layout"><tt:CellLayout Columns="22" Rows="18"><tt:Transformation><tt:Translate x="-1.000000" y="1.000000"></tt:Translate><tt:Scale x="0.000244" y="0.000244"></tt:Scale></tt:Transformation></tt:CellLayout></tt:ElementItem></tt:Parameters></tt:AnalyticsModule><tt:AnalyticsModule Name="MyCellMotionEngine" Type="tt:CellMotionEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="60"></tt:SimpleItem><tt:ElementItem Name="Layout"><tt:CellLayout Columns="22" Rows="18"><tt:Transformation><tt:Translate x="-1.000000" y="1.000000"></tt:Translate><tt:Scale x="0.000244" y="0.000244"></tt:Scale></tt:Transformation></tt:CellLayout></tt:ElementItem></tt:Parameters></tt:AnalyticsModule><tt:AnalyticsModule Name="MyCellMotionEngine" Type="tt:CellMotionEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="60"></tt:SimpleItem><tt:ElementItem Name="Layout"><tt:CellLayout Columns="22" Rows="18"><tt:Transformation><tt:Translate x="-1.000000" y="1.000000"></tt:Translate><tt:Scale x="0.000244" y="0.000244"></tt:Scale></tt:Transformation></tt:CellLayout></tt:ElementItem></tt:Parameters></tt:AnalyticsModule><tt:AnalyticsModule Name="MyCellMotionEngine" Type="tt:CellMotionEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="60"></tt:SimpleItem><tt:ElementItem Name="Layout"><tt:CellLayout Columns="22" Rows="18"><tt:Transformation><tt:Translate x="-1.000000" y="1.000000"></tt:Translate><tt:Scale x="0.000244" y="0.000244"></tt:Scale></tt:Transformation></tt:CellLayout></tt:ElementItem></tt:Parameters></tt:AnalyticsModule></tt:AnalyticsEngineConfiguration><tt:RuleEngineConfiguration><tt:Rule Name="Region1" Type="tt:CellMotionDetector"><tt:Parameters><tt:SimpleItem Name="MinCount" Value="20"></tt:SimpleItem><tt:SimpleItem Name="AlarmOnDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="AlarmOffDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="ActiveCells" Value="0P8A8A=="></tt:SimpleItem></tt:Parameters></tt:Rule><tt:Rule Name="Region2" Type="tt:CellMotionDetector"><tt:Parameters><tt:SimpleItem Name="MinCount" Value="20"></tt:SimpleItem><tt:SimpleItem Name="AlarmOnDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="AlarmOffDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="ActiveCells" Value="zwA="></tt:SimpleItem></tt:Parameters></tt:Rule><tt:Rule Name="Region3" Type="tt:CellMotionDetector"><tt:Parameters><tt:SimpleItem Name="MinCount" Value="20"></tt:SimpleItem><tt:SimpleItem Name="AlarmOnDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="AlarmOffDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="ActiveCells" Value="zwA="></tt:SimpleItem></tt:Parameters></tt:Rule><tt:Rule Name="Region4" Type="tt:CellMotionDetector"><tt:Parameters><tt:SimpleItem Name="MinCount" Value="20"></tt:SimpleItem><tt:SimpleItem Name="AlarmOnDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="AlarmOffDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="ActiveCells" Value="zwA="></tt:SimpleItem></tt:Parameters></tt:Rule></tt:RuleEngineConfiguration></tt:VideoAnalyticsConfiguration><tt:PTZConfiguration token="PTZ000" MoveRamp="0" PresetRamp="0" PresetTourRamp="0"><tt:Name>PTZ000</tt:Name><tt:UseCount>2</tt:UseCount><tt:NodeToken>PTZ000</tt:NodeToken><tt:DefaultRelativeZoomTranslationSpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace</tt:DefaultRelativeZoomTranslationSpace><tt:DefaultContinuousZoomVelocitySpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace</tt:DefaultContinuousZoomVelocitySpace><tt:DefaultPTZSpeed><tt:Zoom space="http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace" x="0.800000"></tt:Zoom></tt:DefaultPTZSpeed><tt:DefaultPTZTimeout>PT10S</tt:DefaultPTZTimeout></tt:PTZConfiguration><tt:MetadataConfiguration token="Metadata000" CompressionType="None" GeoLocation="false"><tt:Name>Metadata000</tt:Name><tt:UseCount>1</tt:UseCount><tt:PTZStatus><tt:Status>false</tt:Status><tt:Position>false</tt:Position></tt:PTZStatus><tt:Events><tt:Filter><wsnt:TopicExpression Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tns1="http://www.onvif.org/ver10/topics">tns1:Media/ConfigurationChanged</wsnt:TopicExpression></tt:Filter></tt:Events><tt:Analytics>true</tt:Analytics><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.2.4</tt:IPv4Address></tt:Address><tt:Port>40000</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:MetadataConfiguration></trt:Profiles><trt:Profiles token="Profile001" fixed="true"><tt:Name>Profile001</tt:Name><tt:VideoSourceConfiguration token="VideoSource000"><tt:Name>VideoSource000</tt:Name><tt:UseCount>2</tt:UseCount><tt:SourceToken>VideoSource000</tt:SourceToken><tt:Bounds x="0" y="0" width="1920" height="1080"></tt:Bounds></tt:VideoSourceConfiguration><tt:VideoEncoderConfiguration token="VideoEncoder001"><tt:Name>VideoEncoder001</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>H264</tt:Encoding><tt:Resolution><tt:Width>704</tt:Width><tt:Height>576</tt:Height></tt:Resolution><tt:Quality>4.000000</tt:Quality><tt:RateControl><tt:FrameRateLimit>1</tt:FrameRateLimit><tt:EncodingInterval>1</tt:EncodingInterval><tt:BitrateLimit>256</tt:BitrateLimit></tt:RateControl><tt:H264><tt:GovLength>2</tt:GovLength><tt:H264Profile>Main</tt:H264Profile></tt:H264><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.2.4</tt:IPv4Address></tt:Address><tt:Port>40016</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:VideoEncoderConfiguration><tt:VideoAnalyticsConfiguration token="Analytics000"><tt:Name>Analytics000</tt:Name><tt:UseCount>2</tt:UseCount><tt:AnalyticsEngineConfiguration><tt:AnalyticsModule Name="MyCellMotionEngine" Type="tt:CellMotionEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="60"></tt:SimpleItem><tt:ElementItem Name="Layout"><tt:CellLayout Columns="22" Rows="18"><tt:Transformation><tt:Translate x="-1.000000" y="1.000000"></tt:Translate><tt:Scale x="0.000244" y="0.000244"></tt:Scale></tt:Transformation></tt:CellLayout></tt:ElementItem></tt:Parameters></tt:AnalyticsModule><tt:AnalyticsModule Name="MyCellMotionEngine" Type="tt:CellMotionEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="60"></tt:SimpleItem><tt:ElementItem Name="Layout"><tt:CellLayout Columns="22" Rows="18"><tt:Transformation><tt:Translate x="-1.000000" y="1.000000"></tt:Translate><tt:Scale x="0.000244" y="0.000244"></tt:Scale></tt:Transformation></tt:CellLayout></tt:ElementItem></tt:Parameters></tt:AnalyticsModule><tt:AnalyticsModule Name="MyCellMotionEngine" Type="tt:CellMotionEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="60"></tt:SimpleItem><tt:ElementItem Name="Layout"><tt:CellLayout Columns="22" Rows="18"><tt:Transformation><tt:Translate x="-1.000000" y="1.000000"></tt:Translate><tt:Scale x="0.000244" y="0.000244"></tt:Scale></tt:Transformation></tt:CellLayout></tt:ElementItem></tt:Parameters></tt:AnalyticsModule><tt:AnalyticsModule Name="MyCellMotionEngine" Type="tt:CellMotionEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="60"></tt:SimpleItem><tt:ElementItem Name="Layout"><tt:CellLayout Columns="22" Rows="18"><tt:Transformation><tt:Translate x="-1.000000" y="1.000000"></tt:Translate><tt:Scale x="0.000244" y="0.000244"></tt:Scale></tt:Transformation></tt:CellLayout></tt:ElementItem></tt:Parameters></tt:AnalyticsModule></tt:AnalyticsEngineConfiguration><tt:RuleEngineConfiguration><tt:Rule Name="Region1" Type="tt:CellMotionDetector"><tt:Parameters><tt:SimpleItem Name="MinCount" Value="20"></tt:SimpleItem><tt:SimpleItem Name="AlarmOnDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="AlarmOffDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="ActiveCells" Value="0P8A8A=="></tt:SimpleItem></tt:Parameters></tt:Rule><tt:Rule Name="Region2" Type="tt:CellMotionDetector"><tt:Parameters><tt:SimpleItem Name="MinCount" Value="20"></tt:SimpleItem><tt:SimpleItem Name="AlarmOnDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="AlarmOffDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="ActiveCells" Value="zwA="></tt:SimpleItem></tt:Parameters></tt:Rule><tt:Rule Name="Region3" Type="tt:CellMotionDetector"><tt:Parameters><tt:SimpleItem Name="MinCount" Value="20"></tt:SimpleItem><tt:SimpleItem Name="AlarmOnDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="AlarmOffDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="ActiveCells" Value="zwA="></tt:SimpleItem></tt:Parameters></tt:Rule><tt:Rule Name="Region4" Type="tt:CellMotionDetector"><tt:Parameters><tt:SimpleItem Name="MinCount" Value="20"></tt:SimpleItem><tt:SimpleItem Name="AlarmOnDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="AlarmOffDelay" Value="1000"></tt:SimpleItem><tt:SimpleItem Name="ActiveCells" Value="zwA="></tt:SimpleItem></tt:Parameters></tt:Rule></tt:RuleEngineConfiguration></tt:VideoAnalyticsConfiguration><tt:PTZConfiguration token="PTZ000" MoveRamp="0" PresetRamp="0" PresetTourRamp="0"><tt:Name>PTZ000</tt:Name><tt:UseCount>2</tt:UseCount><tt:NodeToken>PTZ000</tt:NodeToken><tt:DefaultRelativeZoomTranslationSpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace</tt:DefaultRelativeZoomTranslationSpace><tt:DefaultContinuousZoomVelocitySpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace</tt:DefaultContinuousZoomVelocitySpace><tt:DefaultPTZSpeed><tt:Zoom space="http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace" x="0.800000"></tt:Zoom></tt:DefaultPTZSpeed><tt:DefaultPTZTimeout>PT10S</tt:DefaultPTZTimeout></tt:PTZConfiguration><tt:MetadataConfiguration token="Metadata001" CompressionType="None" GeoLocation="false"><tt:Name>Metadata001</tt:Name><tt:UseCount>1</tt:UseCount><tt:PTZStatus><tt:Status>false</tt:Status><tt:Position>false</tt:Position></tt:PTZStatus><tt:Events><tt:Filter><wsnt:TopicExpression Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tns1="http://www.onvif.org/ver10/topics">tns1:Media/ConfigurationChanged</wsnt:TopicExpression></tt:Filter></tt:Events><tt:Analytics>true</tt:Analytics><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.2.4</tt:IPv4Address></tt:Address><tt:Port>40016</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:MetadataConfiguration></trt:Profiles></trt:GetProfilesResponse></s:Body></s:Envelope>

Please Help Me out Here.

Code consistency

Code does not match what is received when issuing go get and when cloning via git

Device.go differs seems DeviceParams has been added but this does not reflect in downloaded package from go get.

Media structs are prefixed with onvif:

So I noticed when trying to use the media queries (sdk/media/*), that some of the structs are prefixed by onvif: for the xml parsing tags (example https://github.com/use-go/onvif/blob/master/xsd/onvif/onvif.go#L361).

image

When getting an actual response from a camera, I noticed the structs did not unmarshal properly because of this prefix. From my understanding, the prefixes should be different according to the ONVIF media spec.

image

Regardless, I have forked the repo and dropped the prefix for my uses, but was curious if you would like a PR and the tests I wrote, or if I am headed in the wrong direction

time.RFC3339Nano Precision is high ONLY in linux and its causing 401 unauthorised, when forming Digest Auth Security xml

In gosoap/ws-security.go
In func NewSecurity

created := time.Now().UTC().Format(time.RFC3339Nano)

Output in mac
2024-08-08T10:05:42.785935Z

Output in linux
2024-08-08T10:06:17.763359929Z

In the Linux output, the time is formatted using a higher level of precision, including 9 digits after the decimal point, representing nanoseconds.

Because of this, when I try connecting to my Hikvision Camera/DVR, it is throwing 401 unauthorised error.
When I changed the code to
created := time.Now().UTC().Format(time.RFC3339) // removed Nano
It started working fine.

Please fix this issue, so that it works everywhere.

Thank you.

Call_GetStatus无法绑定数据到结构体

使用Call_GetStatus时,使用:
type PTZVector struct {
PanTilt Vector2D xml:"onvif:PanTilt"
Zoom Vector1D xml:"onvif:Zoom"
} 无法绑定xml数据,
在我修改为:
type PTZVector struct {
PanTilt Vector2D xml:"PanTilt"
Zoom Vector1D xml:"Zoom"
}后正常绑定数据

NewDevice succeeds on non camera devices

If I provide NewDevice() with an IPaddr and port that reference a web server, it will return success as long as the website hosted on that server does not return an http error. The issue is in "func (dev *Device) getSupportedServices(resp *http.Response)" This function does not check that the response is a valid SOAP response.

deviceIO package missing

I'm trying to read out the relay outputs and digital input, but looks like missing from the library. Any plans to add this functionality? Looks like it's currently added to the device pkg, but that won't work.

why Authenticate function has been deleted?

why Authenticate function has been deleted?

if GetAvailableDevicesAtSpecificEthernetInterface return devices, if the device need user/passwd, i can't use that device

i must need to use the device probed to newDevice

devices, err := goonvif.GetAvailableDevicesAtSpecificEthernetInterface("en7")
if err != nil {
log.Println(err)
return nil
}

for _, dev := range devices {
newDev := onvif.NewDevice(onvif.DeviceParams{Xaddr: dev.params.Xaddr, Username: "username", Password: password})
}

Event Example

Hi everyone,

Can someone please provide an Event example ?

TIA

unmarshal support for onvif soap response

currently there is soap xml marshaling tags only for the request structs.
for response structs there are no xml unmarshal capabilities.
planning to add that support? there is any technical limitation to have that implemented or its only a matter of mapping each struct?

onvif version

Hello,Is onvif2.02 supported?

ONVIF Device Test Tool 19.06:

Error in desenalizing body of reply message for operation GetService

Can this act as an onvif server?

As I known, this package can act as an ONVIF CLIENT to find and interact with other onvif devices (like IPC ect.). It works like ONVIF Device Manager.

However, I wonder if it can act as an ONVIF SERVER which can answer probe message from others or provide WS-Discovery service. I want to make my device act as an onvif IPC to be found by others.

thanks

Subscribe response isn't correct when status code is 500

When try call Subscribe with wrong InitialTerminationTime parameter value server return error response with status code 500:

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tst="http://www.onvif.org/ver10/storage/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12" xmlns:http="http://schemas.xmlsoap.org/wsdl/http" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2" xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tnshik="http://www.hikvision.com/2011/event/topics" xmlns:hikwsd="http://www.onvifext.com/onvif/ext/ver10/wsdl" xmlns:hikxsd="http://www.onvifext.com/onvif/ext/ver10/schema" xmlns:tas="http://www.onvif.org/ver10/advancedsecurity/wsdl" xmlns:tr2="http://www.onvif.org/ver20/media/wsdl" xmlns:axt="http://www.onvif.org/ver20/analytics"><env:Header><wsa:Action>http://docs.oasis-open.org/wsrf/fault</wsa:Action>
</env:Header>
<env:Body><env:Fault><env:Code><env:Value>env:Receiver</env:Value>
  </env:Code>
     <env:Reason><env:Text xml:lang="en">wsnt:UnacceptableInitialTerminationTimeFault</env:Text>
     </env:Reason>
     <env:Detail><wsnt:UnacceptableInitialTerminationTimeFault><wsrf-bf:Timestamp>2023-11-24T08:17:18Z</wsrf-bf:Timestamp>
        </wsnt:UnacceptableInitialTerminationTimeFault>
      </env:Detail>
    </env:Fault>
  </env:Body>
</env:Envelope>

In this Call_Subscribe doesn't check status code of response and try parse (unmarshaling) a corresponding response type. But if http status code not equal 200 response has <env:Fault> type.

I think this relevant (http status code checking is missing) for all methods, not only for Call_Subscribe.

Unable to set IP Address

Id just like to prefix this with the fact that Im using a cheap ONVIF camera.
But wondering whether Im doing something wrong, response returns "false" however I cant connect to the camera on the new IP address.

Ive have managed to do other Get calls, but unable to perform this Set call.

dev, err := onvif.NewDevice(onvif.DeviceParams{
	Xaddr:      "192.168.1.10:8899",
	Username:   "admin",
	Password:   "",
	HttpClient: new(http.Client),
})
if err != nil {
	panic(err)
}


prefxedIpv4Address := xsdonvif.PrefixedIPv4Address{Address: "192.168.1.2", PrefixLength: 24}

ipv4NetworkInterfaceSetConfiguration := xsdonvif.IPv4NetworkInterfaceSetConfiguration{Enabled: true, Manual: prefxedIpv4Address, DHCP: true}

networkInterfaceSetConfiguration := xsdonvif.NetworkInterfaceSetConfiguration{Enabled: true, IPv4: ipv4NetworkInterfaceSetConfiguration}

setNetworkInterfaces := device.SetNetworkInterfaces{InterfaceToken: "eth0", NetworkInterface: networkInterfaceSetConfiguration}

setNetworkInterfaceResponse, err := sdk.Call_SetNetworkInterfaces(ctx, dev, setNetworkInterfaces)
if err != nil {
	log.Println(err)
} else {
	fmt.Println(setNetworkInterfaceResponse)
}

onvif PlayBack

i need to see the playback , is there any way to help me and give an example

RTSP Uri Cant‘t Play

The video address I got from this library is “rtsp://192.168.123.211 :554/user=admin_ password=tlJwpbo6_ channel=1_ stream=0.sdp?real_ Stream”, using VLC playback, as long as the sound has no image, the image is black, but the address obtained by another dart library is “rtsp://192.168.123.211 :554/user=admin_ password=tlJwpbo6_ channel=1_ stream=1.sdp?real_ stream” has sound and video. I don't know the difference between them. Is there an example of getting video address.
my test Code:

	s := onvif.GetAvailableDevicesAtSpecificEthernetInterface("en7")

	log.Printf("%s", s)
	for _, d := range s {
		d.Authenticate("admin", "")
		log.Println(d.GetServices())
		log.Println(d.GetEndpoint("media"))
		resp, err := d.CallMethod(media.GetProfilesResponse{})
		if err != nil {
			log.Fatal(err)
		}
		bytes, _ := ioutil.ReadAll(resp.Body)
		log.Println(string(bytes))
		resp, err = d.CallMethod(media.GetStreamUri{
			StreamSetup:onvif2.StreamSetup{
				Stream:    "RTP-Unicast",
				Transport: onvif2.Transport{Protocol:"HTTP",Tunnel:nil},
			},
			ProfileToken: "000",
		})
		if err != nil {
			log.Fatal(err)
		}
		bytes, _ = ioutil.ReadAll(resp.Body)
		log.Println(string(bytes))
	}

output Uri:
rtsp://192.168.123.211:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream :
截屏2021-01-27 下午9 25 50

dart Code get Uri:
rtsp://192.168.123.211:554/user=admin_password=tlJwpbo6_channel=1_stream=1.sdp?real_stream

截屏2021-01-27 下午9 27 52

I don't known the difference between 1.sdp and 0.sdp,Is there an example of getting video address?

memery leak many socket not close

memery leak many socket not close for latest version

	dev, err := goonvif.NewDevice(addr)
	if err != nil {
		log.Errorf(this.tag, "[ONVIF]:sync time to addr:%s error: %s", addr, err.Error())
		return
	}
	dev.Authenticate(userName, password)
	res, err := dev.CallMethod(device.SetSystemDateAndTime{
		XMLName:         "",
		DateTimeType:    "Manual",
		DaylightSavings: false,
		TimeZone: onvif.TimeZone{
			TZ: "CST-8:00:00",
		},
		UTCDateTime: onvif.DateTime{
			Time: onvif.Time{
				Hour:   (xsd.Int)(time.Now().UTC().Hour()),
				Minute: (xsd.Int)(time.Now().UTC().Minute()),
				Second: (xsd.Int)(time.Now().UTC().Second()),
			},
			Date: onvif.Date{
				Year:  (xsd.Int)(time.Now().UTC().Year()),
				Month: (xsd.Int)(time.Now().UTC().Month()),
				Day:   (xsd.Int)(time.Now().UTC().Day()),
			},
		},
	})

How do I set the connection password for the discovered device

After I searched for the device through onvif.GetAvailableDevicesAtSpecificEthernetInterface("eth0"), I cannot fill in the account and password for the returned device, which prevents me from operating the device through the CallMethod method. Is there any good method to solve this problem?

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.