From: jijoong.moon Date: Tue, 20 Nov 2018 10:03:29 +0000 (+0900) Subject: [Repo/Pop] Tensor_RepoPop Draft X-Git-Tag: v0.0.3~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55c68d52cb257311a41fdcc78f387878ed0191ea;p=platform%2Fupstream%2Fnnstreamer.git [Repo/Pop] Tensor_RepoPop Draft This is the the anthor part to complete the tensor repo. tensor_repopop get the tensor repo data. **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: jijoong.moon --- diff --git a/gst/tensor_repopop/CMakeLists.txt b/gst/tensor_repopop/CMakeLists.txt new file mode 100644 index 0000000..571546a --- /dev/null +++ b/gst/tensor_repopop/CMakeLists.txt @@ -0,0 +1 @@ +ADD_LIBRARY(tensor_repopopOBJ OBJECT tensor_repopop.c ) diff --git a/gst/tensor_repopop/tensor_repopop.c b/gst/tensor_repopop/tensor_repopop.c new file mode 100644 index 0000000..9bf13a6 --- /dev/null +++ b/gst/tensor_repopop/tensor_repopop.c @@ -0,0 +1,191 @@ +/** + * GStreamer + * Copyright (C) 2005 Thomas Vander Stichele + * Copyright (C) 2005 Ronald S. Bultje + * Copyright (C) 2018 Samsung Electronics Co., Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + */ + +/** + * SECTION: element-tensor_repopop + * + * Pop elemnt to handle tensor repo + * + * @file tensor_repopop.c + * @date 19 Nov 2018 + * @brief GStreamer plugin to handle tensor repository + * @see https://github.com/nnsuite/nnstreamer + * @author Jijoong Moon + * @bug No known bugs except for NYI items + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "tensor_repopop.h" + +/** + * @brief Macro for debug mode. + */ +#ifndef DBG +#define DBG (!self->silent) +#endif + +/** + * @brief Macro for debug message. + */ +#define silent_debug(...) \ + debug_print (DBG, __VA_ARGS__) + +GST_DEBUG_CATEGORY_STATIC (gst_tensor_repopop_debug); +#define GST_CAT_DEFAULT gst_tensor_repopop_debug + +/** + * @brief tensor_repopop properties + */ +enum +{ + PROP_0, + PROP_CAPS, + PROP_SILENT +}; + +#define DEFAULT_SILENT TRUE + +extern GstTensorRepo _repo; + +/** + * @brief tensor_repopop src template + */ +static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT "; " GST_TENSORS_CAP_DEFAULT)); + +static void gst_tensor_repopop_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_tensor_repopop_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static void gst_tensor_repopop_dispose (GObject * object); +static gboolean gst_tensor_repopop_query (GstBaseSrc * src, GstQuery * query); +static GstCaps *gst_tensor_repopop_getcaps (GstBaseSrc * src, GstCaps * filter); + +#define gst_tensor_repopop_parent_class parent_class +G_DEFINE_TYPE (GstTensorRepoPop, gst_tensor_repopop, GST_TYPE_PUSH_SRC); + +static void +gst_tensor_repopop_class_init (GstTensorRepoPopClass * klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (kalss); + GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + GstPushSrcClass *pushsrc_class = GST_PUSH_SRC_CLASS (klass); + GstBaseSrcClass *basesrc_class = GST_BASE_SRC_CLASS (kalss); + + gobject_class->set_property = gst_tensor_repopop_set_property; + gobject_class->get_property = gst_tensor_repopop_get_property; + + g_object_class_install_property (gobject_class, PROP_CAPS, + g_param_spec_boxed ("caps", "Caps", + "Caps describing the format of the data.", + GST_TYPE_CAPS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, PROP_SILENT, + g_param_spec_boolean ("silent", "Silent", "Produce verbose output", + DEFAULT_SILENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + + gobject_class->dispose = gst_tensor_repopop_dispose; + + basesrc_class->get_caps = gst_tensor_repopop_getcaps; + basesrc_class->query = gst_tensor_repopop_query; + + pushsrc_class->create = gst_tensor_repopop_create; + + gst_element_class_set_static_metadata (element_class, + "TensorRepoPop", + "Pop/TensorRepo", + "Pop element to handle tensor repository", + "Samsung Electronics Co., Ltd."); + + gst_element_class_add_static_pad_template (element_class, &src_template); +} + +static void +gst_tensor_repopop_init (GstTensorRepoPop * self) +{ + self->silent = TRUE; + +} + + + + + + + + + + + + + + + + + + + + + + + + + + +/** + * @brief Function to initialize the plugin. + * + * See GstPluginInitFunc() for more details. + */ +NNSTREAMER_PLUGIN_INIT (tensor_repopop) +{ + GST_DEBUG_CATEGORY_INIT (gst_tensor_repopop_debug, "tensor_repopop", + 0, "tensor_repopop element"); + + return gst_element_register (plugin, "tensor_repopop", + GST_RANK_NONE, GST_TYPE_TENSOR_REPOPOP); +} + +#ifndef SINGLE_BINARY +/** + * @brief Definition for identifying tensor_repopop plugin. + * + * PACKAGE: this is usually set by autotools depending on some _INIT macro + * in configure.ac and then written into and defined in config.h, but we can + * just set it ourselves here in case someone doesn't use autotools to + * compile this code. GST_PLUGIN_DEFINE needs PACKAGE to be defined. + */ +#ifndef PACKAGE +#define PACKAGE "nnstreamer" +#endif + +/** + * @brief Macro to define the entry point of the plugin. + */ +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + tensor_repopop, + "Pop element to handle tensor repository", + gst_tensor_repopop_plugin_init, VERSION, "LGPL", "nnstreamer", + "https://github.com/nnsuite/nnstreamer"); +#endif diff --git a/gst/tensor_repopop/tensor_repopop.h b/gst/tensor_repopop/tensor_repopop.h new file mode 100644 index 0000000..7d4960f --- /dev/null +++ b/gst/tensor_repopop/tensor_repopop.h @@ -0,0 +1,79 @@ +/** + * GStreamer + * Copyright (C) 2005 Thomas Vander Stichele + * Copyright (C) 2005 Ronald S. Bultje + * Copyright (C) 2018 Samsung Electronics Co., Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + */ + +/** + * @file tensor_repopop.h + * @date 19 Nov 2018 + * @brief GStreamer plugin to handle tensor repository + * @see https://github.com/nnsuite/nnstreamer + * @author Jijoong Moon + * @bug No known bugs except for NYI items + */ + +#ifndef __GST_TENSOR_REPOPOP_H_ +#define __GST_TENSOR_REPOPOP_H__ + +#include +#include +#include + +G_BEGIN_DECLS +#define GST_TYPE_TENSOR_REPOPOP \ + (gst_tensor_repopop_get_type()) +#define GST_TENSOR_REPOPOP(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TENSOR_REPOPOP,GstTensorRepoPop)) +#define GST_TENSOR_REPOPOP_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TENSOR_REPOPOP,GstTensorRepoPopClass)) +#define GST_IS_TENSOR_REPOPOP(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TENSOR_REPOPOP)) +#define GST_IS_TENSOR_REPOPOP_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TENSOR_REPOPOP)) +typedef struct _GstTensorRepoPop GstTensorRepoPop; +typedef struct _GstTensorRepoPopClass GstTensorRepoPopClass; + +/** + * @brief GstTensorRepoPop data structure. + * + * GstTensorRepoPop inherits GstBaseSink. + */ +struct _GstTensorRepoPop +{ + GstBaseSink element; + + gboolean silent; + GstCaps *caps; + GstTensorData data; + guint myid; +}; + +/** + * @brief GstTensorRepoPopClass data structure. + * + * GstTensorRepoPop inherits GstBaseSink. + */ +struct _GstTensorRepoPopClass +{ + GstBaseSinkClass parent_class; +}; + +/** + * @brief Function to get type of tensor_repopop. + */ +GType gst_tensor_repopop_get_type (void); + +G_END_DECLS +#endif /** __GST_TENSOR_REPOPOP_H__ */