ONVIF implementation on Linux devices 7: Write device capability Acquisition program __linux

Source: Internet
Author: User
Tags soap

1 Background notes

To communicate directly with the camera, the first step must obtain the webserver address, through this address to further obtain the equipment capacity, the provision of media frequency information and so on. The webserver address is in the probe answer package, specifically Xaddrs:http://192.168.15.240/onvif/device_service, and the next acquisition device capability function will use this address for communication.

2 getcapabilities Command Description

The actual name of the Getcapabilities function is not the same in different versions, my version is:

SOAP_FMAC5 int soap_fmac6 soap_call___ns2__getcapabilities (struct SOAP *soap, const char *soap_endpoint, const char *SOAP _action, struct _ns2__getcapabilities *ns2__getcapabilities, struct _ns2__getcapabilitiesresponse *ns2__ Getcapabilitiesresponse)

The function needs to provide a request pointer, an answer pointer. You can specify the full or partial capability of the requesting device:

Enum Ns3__capabilitycategory {ns3__capabilitycategory__all = 0, Ns3__capabilitycategory__analytics = 1, ns3__ Capabilitycategory__device = 2, ns3__capabilitycategory__events = 3, ns3__capabilitycategory__imaging = 4, ns3__ Capabilitycategory__media = 5, NS3__CAPABILITYCATEGORY__PTZ = 6};

The query Ns3__capabilitycategory__media ability is specified in the following instance. General can select the query all ability.

Finally, the media information Uri:http://192.168.15.240/onvif/media is extracted from the message, which will be used to query the specific video source and encoder configuration parameters.

If the device has user name, password, then query equipment capabilities may require authentication process, this article does not study ONVIF authentication mechanism, the default camera does not need to enter a username password. If a authentication response occurs, then the answer getcapresponse.capabilities is a null pointer. The Soap_call___ns2__getcapabilities function returns a value of 501.

The specific application examples are as follows:

/******************************************************************************
* Name:mygetcapabilities
*
* Desc: Ability to acquire specified device nodes
* Param:
struct SOAP *soap,
int index, device serial number

* Return:bool, True:success, False:fail
* Global:
* Note:
* Author:tom-hongtao.gao
* -------------------------------------
* LOG:2013/07/24, Create this function by Tom-hongtao.gao
******************************************************************************/
BOOL mygetcapabilities (struct soap *soap, int index)
{
BOOL Bret=false;
int result = 0;

Devicenode * Deviceode = dlfindbyindex (index);
if (!deviceode)
{
printf ("--error:dlfindbyindex (%d) return null! \ n ", index);
return FALSE;
}
if (Deviceode->webserver==null | | strlen (deviceode->webserver) ==0)
{
printf ("--error:deviceode->webserver is null! \ n ");
return FALSE;
}

struct _ns2__getcapabilities getcapreq={0};
struct _ns2__getcapabilitiesresponse getcapresponse={0};
Enum Ns3__capabilitycategory temp_category = Ns3__capabilitycategory__media;
Getcapreq.__sizecategory=1;
getcapreq.category=&temp_category;

result = soap_call___ns2__getcapabilities (soap, Deviceode->webserver, NULL, &getcapreq, &getcapresponse);
if (result==-1)
{
printf ("Soap Error:%d,%s,%s\n", Soap->error, *soap_faultcode (soap), *soap_faultstring (soap));
result = soap->error;
bret = FALSE;
}
Else
{
if (getcapresponse.capabilities==null)
{
printf ("Getcapabilities failed! result=%d \ n ", result);
bret = FALSE;
}
Else
{
printf ("Getcapabilities ok! result=%d \ n ", result);
printf ("media->xaddr=%s \", getcapresponse.capabilities->media->xaddr);
Dlsetmediauri (index, GETCAPRESPONSE.CAPABILITIES->MEDIA->XADDR);
Printfnodebyindex (index);
bret = TRUE;
}
}

Soap_end (SOAP);
return Bret;

}

The actual data message is as follows: slightly

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.