树莓派 Onenet 视频服务 出现 “段错误”
作者:互联网
树莓派 Onenet 视频服务 出现 “段错误”
软硬平台
硬件平台:树莓派
软件版本:2020-02-13-raspbian-buster.img
问题描述
在运行编译完成的Onenet视频推流程序时,出现如下情况:
pi@raspberrypi:~/Desktop/onenet_sdk/bin $ ./sample_video_s
INFO: [info]:url=http://192.168.137.***:8081/onvif/device_service has profiles-------------------------------------------------------:
INFO: profile [0: level=1 bitrate=10000 framterate=10]
段错误
问题解决
出现“段错误”主要是因为指针没有初始化,造成了树莓派内存访问问题,我们需要将sample/onvif/device_onvif.c
中所有的指针初始化为NULL,再次编译后的文件就可以放到树莓派平台愉快的玩耍了。
#include <stdint.h>
#include <log.h>
#include "namespace.h"
#include "soapH.h"
#include "device_onvif.h"
#include "wsseapi.h"
#include "getifaddrs.h"
#define DEBUG 1
#define M_ONVIFDEVICE_NUMBERS 30
#define M_ONVIFDEVICE_DISCOVERY_NUMS 30
int ont_onvifdevice_capablity(const char *url, device_onvif_t *devicePtr);
int ont_onvifdevice_getplayurl(device_onvif_t *devicePtr, int profileindex);
int ont_onvifdevice_getprofile(device_onvif_t *devicePtr);
int ont_onvifdevice_getconfigurations(device_onvif_t *devicePtr);
***********************************省略***********************************
}
int ont_onvifdevice_getprofile(device_onvif_t *devicePtr)
{
struct _trt__GetProfiles trt__GetProfile = { 0 };
struct _trt__GetProfilesResponse trt__Response = { 0 };
static struct soap *soap;
struct SOAP_ENV__Header header = { 0 };
int i = 0;
int result = 0;
soap = soap_new();
***********************************省略***********************************
}
int ont_onvifdevice_capablity( const char *url, device_onvif_t *devicePtr)
{
static struct soap *soap;
struct SOAP_ENV__Header header = { 0 };
const char* soap_endpoint = url;
int i = 0;
int result = 0;
struct _tds__GetCapabilities _Capabilities = { 0 };
struct tt__Capabilities *items = NULL;
struct _tds__GetCapabilitiesResponse __GetCapabilitiesResponse = { 0 };
enum tt__CapabilityCategory _eCapAll[1] = { tt__CapabilityCategory__All };
***********************************省略***********************************
}
int ont_onvifdevice_getplayurl(device_onvif_t *devicePtr, int profileindex)
{
struct _trt__GetStreamUri trt__GetStreamUri = { 0 };
struct _trt__GetStreamUriResponse trt__GetStreamUriResponse = { 0 };
struct tt__StreamSetup _tt__StreamSetup = { 0 };
struct tt__Transport tt__transport = { 0 };
int result = 0;
trt__GetStreamUri.StreamSetup = &_tt__StreamSetup;
trt__GetStreamUri.StreamSetup->Stream = 0;//stream type
trt__GetStreamUri.StreamSetup->Transport = &tt__transport;
trt__GetStreamUri.StreamSetup->Transport->Protocol = 2;
trt__GetStreamUri.StreamSetup->Transport->Tunnel = 0;
trt__GetStreamUri.ProfileToken = devicePtr->profiles[profileindex].strprofile;
struct soap *soap;
struct SOAP_ENV__Header header = { 0 };
soap = soap_new();
soap_set_namespaces(soap, namespaces);
soap_default_SOAP_ENV__Header(soap, &header);
soap_wsse_add_Security(soap);
soap_wsse_add_UsernameTokenDigest(soap, "Id", (const char*)devicePtr->strUser, (const char*)devicePtr->strPass);
soap->recv_timeout = 5;
***********************************省略***********************************
}
/*#include "namespace.h"*/
void ont_gen_uuid(char _HwId[1024])
{
unsigned char macaddr[6];
unsigned int Flagrand;
srand((int)time(0));
Flagrand = rand() % 9000 + 1000;
macaddr[0] = 0x1; macaddr[1] = 0x2; macaddr[2] = 0x3; macaddr[3] = 0x4; macaddr[4] = 0x5; macaddr[5] = 0x6;
sprintf(_HwId, "urn:uuid:%ud68b-1dd2-11b2-a105-%02X%02X%02X%02X%02X%02X",
Flagrand, macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]);
}
device_onvif_discovery_info_t* getDeviceOnvifDiscoveryPtr(device_onvif_discovery_list_t * dodlPtr, int* index)
{
int i = *index;
device_onvif_discovery_info_t *dodiPtr = NULL;
***********************************省略***********************************
}
static struct soap* ont_onvif_initsoap(struct SOAP_ENV__Header *header, const char *was_To, const char *was_Action, int timeout, const char* ip)
{
struct soap *soap = NULL;
unsigned char macaddr[6];
char _HwId[1024];
unsigned int Flagrand;
soap = soap_new();
***********************************省略***********************************
}
int ont_onvif_device_discovery( device_onvif_cluster_t *cluster )
{
device_onvif_discovery_list_t *_gOnvifDeviceDiscoveryPtr = &cluster->onvif_device_discovery_list;
int HasDev = 0;
int i = 0;
int retval = SOAP_OK;
wsdd__ProbeType req;
struct __wsdd__ProbeMatches resp;
wsdd__ScopesType sScope;
struct SOAP_ENV__Header header;
struct soap* soap;
***********************************省略***********************************
}
***********************************省略***********************************
***********************************省略***********************************
标签:__,视频,树莓,Onenet,struct,int,device,soap,onvif 来源: https://blog.csdn.net/qq_44857700/article/details/120824556