/*
* =====================================================================================
*
* Filename: main.c
* Description: 简单例程测试:客户端通过ONVIF协议搜索前端设备
* Compiler: gcc
* Author: miibotree
*
* =====================================================================================
*/
#include "wsdd.h"
#include "wsseapi.h"
#include <stdio.h>
#define ONVIF_USER "admin"
#define ONVIF_PASSWORD "19921203"
static struct soap* ONVIF_Initsoap(struct SOAP_ENV__Header *header, const char *was_To, const char *was_Action, int timeout);
int ONVIF_ClientDiscovery( );
int ONVIF_Capabilities(struct __wsdd__ProbeMatches *resp);
void UserGetProfiles(struct soap *soap, struct _tds__GetCapabilitiesResponse *capa_resp);
void UserGetUri(struct soap *soap, struct _trt__GetProfilesResponse *trt__GetProfilesResponse,struct _tds__GetCapabilitiesResponse *capa_resp);
int HasDev = 0;//the number of devices
int main(void )
{
//发现协议
if (ONVIF_ClientDiscovery() != 0 )
{
printf("discovery failed!\n");
return -1;
}
return 0;
}
//初始化soap函数
static struct soap* ONVIF_Initsoap(struct SOAP_ENV__Header *header, const char *was_To, const char *was_Action,
int timeout)
{
struct soap *soap = NULL;
unsigned char macaddr[6];
char _HwId[1024];
unsigned int Flagrand;
soap = soap_new();
if(soap == NULL)
{
printf("[%d]soap = NULL\n", __LINE__);
return NULL;
}
soap_set_namespaces( soap, namespaces);
//超过5秒钟没有数据就退出
if (timeout > 0)
{
soap->recv_timeout = timeout;
soap->send_timeout = timeout;
soap->connect_timeout = timeout;
}
else
{
//如果外部接口没有设备默认超时时间的话,我这里给了一个默认值10s
soap->recv_timeout = 10;
soap->send_timeout = 10;
soap->connect_timeout = 10;
}
soap_default_SOAP_ENV__Header(soap, header);
// 为了保证每次搜索的时候MessageID都是不相同的!因为简单,直接取了随机值
srand((int)time(0));
Flagrand = rand()%9000 + 1000; //保证四位整数
macaddr[0] = 0x1; macaddr[1] =
完整的Onvif的检索-鉴权-配置-得到rtstp过程
最新推荐文章于 2024-08-05 00:00:00 发布
该博客详细介绍了如何与ONVIF设备进行交互,包括完整的检索、鉴权、配置步骤,最终获取RTSP流的过程。通过GitHub上的开源工程提供实践代码,适合物联网行业开发者参考。
摘要由CSDN通过智能技术生成