From 35a85de7b7495878ae4dcb73449f18c28131496c Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期五, 03 二月 2023 17:17:16 +0800
Subject: [PATCH] add go test,complete

---
 shmparser/shmparser.c |   57 ++++++++++++++++++++++++++++++---------------------------
 1 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/shmparser/shmparser.c b/shmparser/shmparser.c
index 1ad70dc..49aceb7 100644
--- a/shmparser/shmparser.c
+++ b/shmparser/shmparser.c
@@ -113,26 +113,25 @@
     ptr[7] = (uint8_t) (u);
 }
 
-struct stimg make_image_ref(const uint64_t id, const unsigned char* data, const uint32_t size,
+struct stimg* make_image_ref(const uint64_t id, const unsigned char* data, const uint32_t size,
                             const uint32_t width, const uint32_t height,
                             const char* timestamp, const uint32_t ts_size,
                             const char* camera_id, const uint32_t cid_size,
                             const char* camera_name,const uint32_t cname_size)
 {
-    struct stimg img;
-    memset(&img, 0, sizeof(img));
+    struct stimg* img = (struct stimg*)calloc(1, sizeof(struct stimg));
 
-    img.data = (unsigned char*)data;
-    img.data_size = size;
-    img.width = width;
-    img.height = height;
-    img.id = id;
-    img.timestamp = (char*)timestamp;
-    img.timestamp_size = ts_size;
-    img.camera_id = (char*)camera_id;
-    img.camera_id_size = cid_size;
-    img.camera_name = (char*)camera_name;
-    img.camera_name_size = cname_size;
+    img->data = (unsigned char*)data;
+    img->data_size = size;
+    img->width = width;
+    img->height = height;
+    img->id = id;
+    img->timestamp = (char*)timestamp;
+    img->timestamp_size = ts_size;
+    img->camera_id = (char*)camera_id;
+    img->camera_id_size = cid_size;
+    img->camera_name = (char*)camera_name;
+    img->camera_name_size = cname_size;
 
     return img;
 }
@@ -551,12 +550,12 @@
 ///////////////////////////////////////////////////////////////
 // go need function
 
-void goimage2shm(void* shm, void* img){
+void goImage2Shm(void* shm, void* img){
     struct stimg* cimg = (struct stimg*)img;
     image2shm(shm, cimg);
 }
 
-void goimageinfo(void* img, void** data, uint64_t* size,
+void goImageGet(void* img, void** data, uint64_t* size,
                 void** ts, uint32_t* tss,
                 void** cid, uint32_t* cids,
                 void** cname, uint32_t* cnames,
@@ -580,19 +579,19 @@
     *h = cimg->height;
 }
 
-void gotargetsdel(void* tgts){
+void goTargetsDel(void* tgts){
     if (tgts) {
         struct sttgt* t = (struct sttgt*)tgts;
         free(t);
     }
 }
 
-void* gotargetsnew(const uint32_t size){
+void* goTargetsNew(const uint32_t size){
     struct sttgt* t = (struct sttgt*)calloc(size, sizeof(struct sttgt));
     return t;
 }
 
-void gotargetsadd(void* tgts, int idx, uint64_t id, char* type, uint32_t tsize, int32_t confidence,
+void goTargetAdd(void* tgts, int idx, uint64_t id, char* type, uint32_t tsize, int32_t confidence,
                     int left, int top, int right, int bottom,
                     unsigned char* feat, uint32_t featsize,
                     unsigned char* attr, uint32_t attrsize)
@@ -617,7 +616,7 @@
     ts[idx] = t;
 }
 
-void goruleaddsdk(void* shm, void* tgts, uint32_t tgtcnt,
+void goSdkPut(void* shm, void* tgts, uint32_t tgtcnt,
                     char* type, uint32_t tsize,
                     char* timestamp, uint32_t tmsize)
 {
@@ -649,29 +648,31 @@
 
 //////////////////// unserialize
 
-void gorulehandletrack(void* rule, void** data, uint32_t* size){
+void goHandletrackGet(void* rule, void** data, uint32_t* size){
     struct strule* r = (struct strule*)rule;
     *data = r->handletrack;
     *size = r->handletrack_size;
 }
 
-void goruledatatype(void* rule, void** data, uint32_t* size){
+void goDatatypeGet(void* rule, void** data, uint32_t* size){
     struct strule* r = (struct strule*)rule;
     *data = r->datatype;
     *size = r->datatype_size;
 }
 
-void gorulesdk(void* rule, void** data, uint32_t* size){
+void goSdkArrayGet(void* rule, void** data, uint32_t* size){
     struct strule* r = (struct strule*)rule;
     *data = r->sdk;
     *size = r->sdk_count;
 }
 
-void gorulesdkinfo(void* sdk, int idx, void** t, uint32_t* ts,
+void goSdkGet(void* sdk, int idx, void** t, uint32_t* ts,
                     void** i, uint32_t* is, void** n, uint32_t* ns,
                     void** tm, uint32_t* tms, void** data, uint32_t* size)
 {
-    struct stsdk* s = (struct stsdk*)sdk;
+    struct stsdk* ss = (struct stsdk*)sdk;
+    struct stsdk* s = &ss[idx];
+
     *t = s->sdktype;
     *ts = s->sdktype_size;
 
@@ -687,12 +688,14 @@
     *size = s->tgt_count;
 }
 
-void gorulesdktargetinfo(void* tgt, int idx, uint64_t* id, int32_t* c,
+void goTargetGet(void* tgt, int idx, uint64_t* id, int32_t* c,
                         int32_t* l,int32_t* t,int32_t* r,int32_t* b,
                         void** tp, uint32_t* tps,
                         void** feat, uint32_t* fs, void** attr, uint32_t* attrs)
 {
-    struct sttgt* tt = (struct sttgt*)tgt;
+    struct sttgt* ta = (struct sttgt*)tgt;
+    struct sttgt* tt = &ta[idx];
+
     *id = tt->id;
     *c = tt->confidence;
     *l = tt->rect.left;

--
Gitblit v1.8.0