Summary of camera development based on ONVIF protocol

Posted by ViperG on Sat, 11 May 2019 17:19:16 +0200

Original: http://www.cnblogs.com/big-devil/p/7625752.html

Recently, while working on the onvif protocol, I read a good article about the onvif protocol and reloaded it for recording.

1 What is the ONVIF protocol

In May 2008, the AXIS Joint Expo (BOSCH) and Sony (SONY) Corporation The three parties announced that they will work together to form an international open model Web Video Product Standard Network Interface Development Forum, named ONVIF (Open Network Video Interface Forum), and jointly formulates open industry standards based on open and open principles.The ONVIF standard will be Web Video Information exchange between devices defines common protocols, including device search, real-time video, audio, metadata, and control information.

Interfaces defined in the Device Management and Control section of the ONVIF specification are as follows: Web Services The device is provided as a service provider as a service provider.The ONVIF specification covers a complete base XML and WSDL Definition.Each terminal device that supports the ONVIF specification must provide a Web Service corresponding to its functionality.The data interaction between the server and the client is based on the SOAP protocol.Other parts of the ONVIF, such as audio and video streams, are handled through RTP/RTSP.

2 web service

Web services are network-based, distributed, modular components that perform specific tasks.Web Service s make use of HTTP and SOAP protocols to transfer data over the Web.Web users can use SOAP and HTTP to invoke remote objects through Web-invoked methods.(

Web Service is a service based on XML and HTTPS, and its communication protocol is mainly based on SOAP.The server and client implement the request and response of the service by delivering XML-compliant SOAP messages.

Clients generate a SOAP request message based on the WSDL description document, which is embedded in an HTTP POST request and sent to the Web server on which the Web service resides.The Web Services Request Processor parses the received SOAP request and invokes the corresponding Web Services.Then generate the corresponding SOAP response.When the Web server receives a SOAP response, it sends the information back to the client via an HTTP response.

3 ONVIF Specification

The ONVIF specification introduces the concept of Web Service to video monitoring.The actual functions of the devices are abstracted as the services of Web Services. The control unit of the video monitoring system appears as a client and completes the control operation through a Web request.

A: What Web Services can monitor for video

a) The irrelevance of the device, any one of which is connected to the system will not affect other systems.

b) Independence of the device, each device is only responsible for providing feedback on received requests, and does not even need to be aware of the existence of the control side.

c) Centralization of management, all controls initiated by the client.

What can the B:ONVIF specification bring to video monitoring

  1. Interfaces that abstract functionality.Unified configuration and operation of the device.
  2. The control side is not concerned with the model of the device, but with the Web Service provided by the device.
  3. Specification of behavior outside the Web Service scope in video systems.
  4. ONVIF provides WSDL for each module and has a very efficient development method.

Contents of the C:ONVIF specification

  • Device Discovery
  • device management
  • Device Input and Output Services
  • Image Configuration
  • Media Configuration
  • Real-time streaming
  • Receiver Configuration
  • Display Services
  • event processing
  • PTZ control
  • Other

4 WSDL

WSDL is an abbreviation for Web Services Description Language.It is an XML-based description language for network services, an XML language for describing Web services and describing how to communicate with Web services, providing detailed interface instructions to users.

<span data-wiz-span="data-wiz-span" style="font-size: 1rem;"><?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name="HelloWorld"
    targetNamespace="http://server.cxf.webservice.web.apps.lucl.com/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://server.cxf.webservice.web.apps.lucl.com/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
    >
    <!-- Define data types -->
    <wsdl:types>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://server.cxf.webservice.web.apps.lucl.com/"
            elementFormDefault="unqualified"
            targetNamespace="http://server.cxf.webservice.web.apps.lucl.com/"
            version="1.0">
            <xs:element name="sayHi" type="tns:sayHi" />
            <xs:element name="sayHiResponse" type="tns:sayHiResponse" />
            <xs:complexType name="sayHi">
                <xs:sequence>
                    <xs:element minOccurs="0" name="arg0" type="xs:string" />
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="sayHiResponse">
                <xs:sequence>
                    <xs:element minOccurs="0" name="return" type="xs:string" />
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <!-- Define message grouping -->
    <wsdl:message name="sayHiResponse">
        <wsdl:part element="tns:sayHiResponse" name="parameters" />
    </wsdl:message>
    <wsdl:message name="sayHi">
        <wsdl:part element="tns:sayHi" name="parameters" />
    </wsdl:message>
    <!-- Definition port type -->
    <wsdl:portType name="HelloWorldPortType">
        <wsdl:operation name="sayHi">
            <wsdl:input message="tns:sayHi" name="sayHi" />
            <wsdl:output message="tns:sayHiResponse" name="sayHiResponse" />
            <!-- Specify when Web Any message-level exception that occurs when the service tries to respond to a client's request -->
            <!--
            <wsdl:fault name="" message=""></wsdl:fault> 
            -->
        </wsdl:operation>
    </wsdl:portType>
    <!-- binding Operate to a specific protocol, that is, an association portType To agreement, here is SOAP -->
    <!-- W3C Three are recommended Web Bindings for services:
            HTTP On SOAP(SOAP over HTTP)
            HTTP GET/POST
            SOAP/MIME
    -->
    <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorldPortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="sayHi">
            <soap:operation soapAction="" style="document" />
            <wsdl:input name="sayHi">
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="sayHiResponse">
                <soap:body use="literal" />
            </wsdl:output>
            <!-- application portType At fault -->
            <!--
            <wsdl:fault name="">
            <soap:fault name="" use="literal"/>
            </wsdl:fault> 
            -->
        </wsdl:operation>
    </wsdl:binding>
    <!--
        //Describes the connection information for bindings and handles requests based on the portType implemented by the binding.
        //For SOAP over HTTP, this is the URL to that process.
    -->
    <wsdl:service name="HelloWorld">
        <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldPort">
            <soap:address location="http://localhost:9000/helloWorld" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions></span>

5 SOAP

SOAP is the abbreviation of Simple Object Access Protocol.Is a protocol based on XML.A SOAP message is a common XML document that contains the following elements:

  • Required Envelope element to identify this XML document as a SOAP message
  • Optional Header element, containing header information
  • Required Body element, containing all call and response information
  • Optional Fault element that provides information about errors that occurred while processing this message

In the SOAP request sent to the Web Service, the field in the Body element needs to match the data type in the WSDL.This correspondence must be obtained and mapped from the WSDL file during the SOAP building process.However, such a corresponding process would be repetitive and mechanical, and a compilation tool called gSOAP was created to avoid unnecessary human errors and save development time.

gSOAP utilizes compiler technology to provide a transparent set of SOAP API s and hides from users the details of development-independent SOAP implementations.The development of Web Service s is minimized by serializing WSDL file parsing into C/C++ files.

 

 

Topics: xml network Web Server encoding