[Protobuf] Fix protobuf util function header file
authorgichan-jang <gichan2.jang@samsung.com>
Fri, 24 Jul 2020 02:23:34 +0000 (11:23 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 24 Jul 2020 09:42:52 +0000 (18:42 +0900)
Fix protobuf util function header file.

Signed-off-by: gichan-jang <gichan2.jang@samsung.com>
ext/nnstreamer/extra/nnstreamer_protobuf.cc
ext/nnstreamer/extra/nnstreamer_protobuf.h
gst/nnstreamer/include/tensor_typedef.h

index 0ade6b7..2415085 100644 (file)
  * $ sudo apt install libprotobuf-dev libprotobuf-lite17 libprotobuf17 protobuf-compiler17
  */
 
-#include <nnstreamer_plugin_api.h>
 #include <nnstreamer_log.h>
+#include <nnstreamer_plugin_api.h>
+#include "nnstreamer_protobuf.h"
 #include "nnstreamer.pb.h"      /* Generated by `protoc` */
 
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-namespace nnstreamer {
-namespace protobuf {
-
 /** @brief tensordec-plugin's GstTensorDecoderDef callback */
 GstFlowReturn
 gst_tensor_decoder_protobuf (const GstTensorsConfig * config,
@@ -41,8 +35,8 @@ gst_tensor_decoder_protobuf (const GstTensorsConfig * config,
   GstMapInfo out_info;
   GstMemory *out_mem;
   size_t size, outbuf_size;
-  Tensors tensors;
-  Tensors::frame_rate *fr = NULL;
+  nnstreamer::protobuf::Tensors tensors;
+  nnstreamer::protobuf::Tensors::frame_rate *fr = NULL;
   const unsigned int num_tensors = config->info.num_tensors;
 
   if (NULL == outbuf) {
@@ -68,7 +62,7 @@ gst_tensor_decoder_protobuf (const GstTensorsConfig * config,
   fr->set_rate_d (config->rate_d);
   
   for (unsigned int i = 0; i < num_tensors; ++i) {
-    Tensor *tensor = tensors.add_tensor ();
+    nnstreamer::protobuf::Tensor *tensor = tensors.add_tensor ();
     gchar *name = NULL;
 
     name = config->info.info[i].name;
@@ -78,7 +72,7 @@ gst_tensor_decoder_protobuf (const GstTensorsConfig * config,
       tensor->set_name (name);
     }
 
-    tensor->set_type ((Tensor::Tensor_type)
+    tensor->set_type ((nnstreamer::protobuf::Tensor::Tensor_type)
                           config->info.info[i].type);
 
     for (int j = 0; j < NNS_TENSOR_RANK_LIMIT; ++j) {
@@ -121,8 +115,8 @@ GstBuffer *
 gst_tensor_converter_protobuf (GstBuffer * in_buf, gsize * frame_size,
     guint * frames_in, GstTensorsConfig * config)
 {
-  Tensors tensors;
-  Tensors::frame_rate * fr = NULL;
+  nnstreamer::protobuf::Tensors tensors;
+  nnstreamer::protobuf::Tensors::frame_rate * fr = NULL;
   GstMemory *in_mem, *out_mem;
   GstMapInfo in_info;
   GstBuffer *out_buf;
@@ -147,7 +141,7 @@ gst_tensor_converter_protobuf (GstBuffer * in_buf, gsize * frame_size,
   out_buf = gst_buffer_new ();
 
   for (guint i = 0; i < config->info.num_tensors; i++) {
-    const Tensor *tensor = &tensors.tensor (i);
+    const nnstreamer::protobuf::Tensor *tensor = &tensors.tensor (i);
     config->info.info[i].name = g_strdup (tensor->name ().c_str ());
     config->info.info[i].type = (tensor_type) tensor->type ();
     for (guint j = 0; j < NNS_TENSOR_RANK_LIMIT; j++) {
@@ -171,10 +165,3 @@ gst_tensor_converter_protobuf (GstBuffer * in_buf, gsize * frame_size,
 
   return out_buf;
 }
-
-}; /* Namespace protobuf */
-}; /* Namespace nnstreamer */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
index 73aa077..2884098 100644 (file)
  * @bug         No known bugs except for NYI items
  *
  */
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+
+#ifndef __NNS_PROTOBUF_UTIL_H__
+#define __NNS_PROTOBUF_UTIL_H__
+
+#include <nnstreamer_plugin_api.h>
 
 /**
  * @brief Default static capability for Protocol Buffers
@@ -48,6 +50,4 @@ GstBuffer *
 gst_tensor_converter_protobuf (GstBuffer * in_buf, gsize * frame_size,
     guint * frames_in, GstTensorsConfig * config);
 
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+#endif /* __NNS_PROTOBUF_UTIL_H__ */
index e6f4452..bdee3d0 100644 (file)
     GST_TENSORS_CAP_WITH_NUM(GST_TENSOR_NUM_TENSORS_RANGE)
 
 /**
- * @brief Default static capability for Protocol Buffers
- * protobuf converter will convert this capability to other/tensor(s)
- * @todo Move this definition to proper header file
- */
-#define GST_PROTOBUF_TENSOR_CAP_DEFAULT \
-    "other/protobuf-tensor, " \
-    "framerate = " GST_TENSOR_RATE_RANGE
-/**
  * @brief Default static capability for flatbuffers
  * Flatbuf converter will convert this capability to other/tensor(s)
  * @todo Move this definition to proper header file