From 3316526689c58dd1cde7e3c1b0403ec5ae4f318c Mon Sep 17 00:00:00 2001 From: gichan-jang Date: Fri, 24 Jul 2020 11:23:34 +0900 Subject: [PATCH] [Protobuf] Fix protobuf util function header file Fix protobuf util function header file. Signed-off-by: gichan-jang --- ext/nnstreamer/extra/nnstreamer_protobuf.cc | 31 +++++++++-------------------- ext/nnstreamer/extra/nnstreamer_protobuf.h | 12 +++++------ gst/nnstreamer/include/tensor_typedef.h | 8 -------- 3 files changed, 15 insertions(+), 36 deletions(-) diff --git a/ext/nnstreamer/extra/nnstreamer_protobuf.cc b/ext/nnstreamer/extra/nnstreamer_protobuf.cc index 0ade6b7..2415085 100644 --- a/ext/nnstreamer/extra/nnstreamer_protobuf.cc +++ b/ext/nnstreamer/extra/nnstreamer_protobuf.cc @@ -22,17 +22,11 @@ * $ sudo apt install libprotobuf-dev libprotobuf-lite17 libprotobuf17 protobuf-compiler17 */ -#include #include +#include +#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 */ diff --git a/ext/nnstreamer/extra/nnstreamer_protobuf.h b/ext/nnstreamer/extra/nnstreamer_protobuf.h index 73aa077..2884098 100644 --- a/ext/nnstreamer/extra/nnstreamer_protobuf.h +++ b/ext/nnstreamer/extra/nnstreamer_protobuf.h @@ -12,9 +12,11 @@ * @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 /** * @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__ */ diff --git a/gst/nnstreamer/include/tensor_typedef.h b/gst/nnstreamer/include/tensor_typedef.h index e6f4452..bdee3d0 100644 --- a/gst/nnstreamer/include/tensor_typedef.h +++ b/gst/nnstreamer/include/tensor_typedef.h @@ -87,14 +87,6 @@ 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 -- 2.7.4