查看: 995|回复: 1

[RTMP] 树莓派 Onenet 视频服务 出现 “段错误”

[复制链接]

1

主题

9

帖子

26

积分

新手上路

Rank: 1

积分
26
发表于 2021-10-18 13:20:01 | 显示全部楼层 |阅读模式
树莓派 Onenet 视频服务 出现 “段错误”软硬平台
硬件平台:树莓派
软件版本:2020-02-13-raspbian-buster.img
问题描述
在运行编译完成的Onenet视频推流程序时,出现如下情况:
  1. pi@raspberrypi:~/Desktop/onenet_sdk/bin $ ./sample_video_s
  2. INFO: [info]:url=http://192.168.137.***:8081/onvif/device_service has profiles-------------------------------------------------------:
  3. INFO: profile [0: level=1 bitrate=10000 framterate=10]
  4. 段错误
复制代码
问题解决
出现“段错误”主要是因为指针没有初始化,造成了树莓派内存访问问题,我们需要将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;

   ***********************************省略***********************************
}
***********************************省略***********************************
***********************************省略***********************************


回复

举报

95

主题

578

帖子

2212

积分

金牌会员

Rank: 5Rank: 5

积分
2212
发表于 2021-10-25 15:47:30 | 显示全部楼层
感谢分享
1、OneNET交流群6:887624121
该群目前非常活跃,欢迎大家参与进来,交流,讨论,答疑,解惑~~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表