From: jijoong.moon Date: Fri, 23 Nov 2018 00:33:44 +0000 (+0900) Subject: [Repo] Change Element Name & Fix Sync Bug when EOS X-Git-Tag: v0.0.3~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4051eb23387572e14db02bc572576fc1fc8dccab;p=platform%2Fupstream%2Fnnstreamer.git [Repo] Change Element Name & Fix Sync Bug when EOS - Element Name is changed. . tensor_repopush -> tensor_reposink . tensor_repopop -> tensor_reposrc - There is hanging bug when reposrc is tryig to get buffer and reposink set eos signal meanwhile. It is fixed by double check eos signal during cond wait. **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: jijoong.moon --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bf6ef0..0acc938 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,8 @@ SET(PROJECTS tensor_split tensor_transform tensor_filter - tensor_repopush - tensor_repopop + tensor_reposink + tensor_reposrc ) ADD_SUBDIRECTORY(nnstreamer_example) diff --git a/gst/nnstreamer/nnstreamer.c b/gst/nnstreamer/nnstreamer.c index 20fa59b..90ad087 100644 --- a/gst/nnstreamer/nnstreamer.c +++ b/gst/nnstreamer/nnstreamer.c @@ -40,8 +40,8 @@ NNSTREAMER_PLUGIN (tensor_sink); NNSTREAMER_PLUGIN (tensor_split); NNSTREAMER_PLUGIN (tensor_transform); NNSTREAMER_PLUGIN (tensor_filter); -NNSTREAMER_PLUGIN (tensor_repopush); -NNSTREAMER_PLUGIN (tensor_repopop); +NNSTREAMER_PLUGIN (tensor_reposink); +NNSTREAMER_PLUGIN (tensor_reposrc); #define NNSTREAMER_INIT(name, plugin) \ do { \ @@ -67,8 +67,8 @@ gst_nnstreamer_init (GstPlugin * plugin) NNSTREAMER_INIT (tensor_split, plugin); NNSTREAMER_INIT (tensor_transform, plugin); NNSTREAMER_INIT (tensor_filter, plugin); - NNSTREAMER_INIT (tensor_repopush, plugin); - NNSTREAMER_INIT (tensor_repopop, plugin); + NNSTREAMER_INIT (tensor_reposink, plugin); + NNSTREAMER_INIT (tensor_reposrc, plugin); return TRUE; } diff --git a/gst/nnstreamer/tensor_repo.c b/gst/nnstreamer/tensor_repo.c index 422119e..55e020f 100644 --- a/gst/nnstreamer/tensor_repo.c +++ b/gst/nnstreamer/tensor_repo.c @@ -27,7 +27,7 @@ #include #ifndef DBG -#define DBG FALSE +#define DBG TRUE #endif #define _print_log(...) if (DBG) g_message(__VA_ARGS__) @@ -54,13 +54,13 @@ gst_tensor_repo_get_tensor (guint nth) * @brief add GstTensorData into repo */ gboolean -gst_tensor_repo_add_data (guint myid) +gst_tensor_repo_add_data (guint nth) { gboolean ret = FALSE; GstTensorData *new; GST_REPO_LOCK (); - gpointer *check = g_hash_table_lookup (_repo.hash, GINT_TO_POINTER (myid)); + gpointer *check = g_hash_table_lookup (_repo.hash, GINT_TO_POINTER (nth)); if (check != NULL) { return TRUE; @@ -72,10 +72,10 @@ gst_tensor_repo_add_data (guint myid) g_cond_init (&new->cond); g_mutex_init (&new->lock); - ret = g_hash_table_insert (_repo.hash, GINT_TO_POINTER (myid), new); + ret = g_hash_table_insert (_repo.hash, GINT_TO_POINTER (nth), new); g_assert (ret); - _print_log ("Successfully added in hash table with key[%d]", myid); + _print_log ("Successfully added in hash table with key[%d]", nth); _repo.num_data++; GST_REPO_UNLOCK (); @@ -86,7 +86,7 @@ gst_tensor_repo_add_data (guint myid) * @brief push GstBuffer into repo */ gboolean -gst_tensor_repo_push_buffer (guint nth, GstBuffer * buffer) +gst_tensor_repo_set_buffer (guint nth, GstBuffer * buffer) { GST_TENSOR_REPO_LOCK (nth); @@ -108,9 +108,10 @@ gst_tensor_repo_push_buffer (guint nth, GstBuffer * buffer) gboolean gst_tensor_repo_check_eos (guint nth) { - GST_TENSOR_REPO_LOCK (nth); GstTensorData *data = gst_tensor_repo_get_tensor (nth); - GST_TENSOR_REPO_UNLOCK (nth); + if (data == NULL || data->eos) { + _print_log ("check eos done [%s]\n", data->eos ? "TRUE" : "FALSE"); + } return data->eos; } @@ -123,30 +124,43 @@ gst_tensor_repo_set_eos (guint nth) GST_TENSOR_REPO_LOCK (nth); GstTensorData *data = gst_tensor_repo_get_tensor (nth); data->eos = TRUE; + if (data->buffer) + gst_buffer_unref (data->buffer); + + GST_TENSOR_REPO_SIGNAL (nth); GST_TENSOR_REPO_UNLOCK (nth); return data->eos; } /** - * @brief pop GstTensorData from repo + * @brief get GstTensorData from repo */ GstBuffer * -gst_tensor_repopop_buffer (guint nth) +gst_tensor_repo_get_buffer (guint nth) { GstTensorData *current_data; GstBuffer *buf; + gboolean eos = FALSE; current_data = gst_tensor_repo_get_tensor (nth); - GST_TENSOR_REPO_LOCK (nth); - while (!current_data->buffer) + while (!current_data->buffer) { + if (gst_tensor_repo_check_eos (nth)) { + eos = TRUE; + break; + } GST_TENSOR_REPO_WAIT (nth); - buf = gst_buffer_copy_deep (current_data->buffer); - _print_log ("Popped [ %d ] (size: %lu)\n", nth, gst_buffer_get_size (buf)); + } + if (eos) { + _print_log ("Get EOS Signal while waiting\n"); + buf = NULL; + } else { + buf = gst_buffer_copy_deep (current_data->buffer); + _print_log ("Popped [ %d ] (size: %lu)\n", nth, gst_buffer_get_size (buf)); + } current_data->buffer = NULL; GST_TENSOR_REPO_UNLOCK (nth); - return buf; } @@ -157,6 +171,7 @@ gboolean gst_tensor_repo_remove_data (guint nth) { gboolean ret; + printf ("removeing .... \n"); GST_REPO_LOCK (); g_mutex_clear (GST_TENSOR_REPO_GET_LOCK (nth)); g_cond_clear (GST_TENSOR_REPO_GET_COND (nth)); diff --git a/gst/nnstreamer/tensor_repo.h b/gst/nnstreamer/tensor_repo.h index 82f6d41..3f9ed08 100644 --- a/gst/nnstreamer/tensor_repo.h +++ b/gst/nnstreamer/tensor_repo.h @@ -77,7 +77,7 @@ gst_tensor_repo_add_data (guint myid); * @brief push GstBuffer into repo */ gboolean -gst_tensor_repo_push_buffer (guint nth, GstBuffer * buffer); +gst_tensor_repo_set_buffer (guint nth, GstBuffer * buffer); /** * @brief get EOS @@ -92,10 +92,10 @@ gboolean gst_tensor_repo_set_eos(guint nth); /** - * @brief pop GstTensorData from repo + * @brief Get GstTensorData from repo */ GstBuffer * -gst_tensor_repopop_buffer (guint nth); +gst_tensor_repo_get_buffer (guint nth); /** * @brief remove nth GstTensorData from GstTensorRepo diff --git a/gst/tensor_repopop/CMakeLists.txt b/gst/tensor_repopop/CMakeLists.txt deleted file mode 100644 index 571546a..0000000 --- a/gst/tensor_repopop/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -ADD_LIBRARY(tensor_repopopOBJ OBJECT tensor_repopop.c ) diff --git a/gst/tensor_repopush/CMakeLists.txt b/gst/tensor_repopush/CMakeLists.txt deleted file mode 100644 index b687b6d..0000000 --- a/gst/tensor_repopush/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -ADD_LIBRARY(tensor_repopushOBJ OBJECT tensor_repopush.c) diff --git a/gst/tensor_reposink/CMakeLists.txt b/gst/tensor_reposink/CMakeLists.txt new file mode 100644 index 0000000..e6cbab8 --- /dev/null +++ b/gst/tensor_reposink/CMakeLists.txt @@ -0,0 +1 @@ +ADD_LIBRARY(tensor_reposinkOBJ OBJECT tensor_reposink.c) diff --git a/gst/tensor_repopush/tensor_repopush.c b/gst/tensor_reposink/tensor_reposink.c similarity index 64% rename from gst/tensor_repopush/tensor_repopush.c rename to gst/tensor_reposink/tensor_reposink.c index 0a2748e..4fad1fd 100644 --- a/gst/tensor_repopush/tensor_repopush.c +++ b/gst/tensor_reposink/tensor_reposink.c @@ -16,11 +16,11 @@ */ /** - * SECTION: element-tensor_repopush + * SECTION: element-tensor_reposink * - * Push elemnt to handle tensor repo + * Set elemnt to handle tensor repo * - * @file tensor_repopush.c + * @file tensor_reposink.c * @date 19 Nov 2018 * @brief GStreamer plugin to handle tensor repository * @see https://github.com/nnsuite/nnstreamer @@ -32,7 +32,7 @@ #include #endif -#include "tensor_repopush.h" +#include "tensor_reposink.h" /** * @brief tensor repository @@ -40,11 +40,11 @@ extern GstTensorRepo _repo; -GST_DEBUG_CATEGORY_STATIC (gst_tensor_repopush_debug); -#define GST_CAT_DEFAULT gst_tensor_repopush_debug +GST_DEBUG_CATEGORY_STATIC (gst_tensor_reposink_debug); +#define GST_CAT_DEFAULT gst_tensor_reposink_debug /** - * @brief tensor_repopush properties + * @brief tensor_reposink properties */ enum { @@ -60,43 +60,43 @@ enum #define DEFAULT_INDEX 0 /** - * @brief tensor_repopush sink template + * @brief tensor_reposink sink template */ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT "; " GST_TENSORS_CAP_DEFAULT)); -static void gst_tensor_repopush_set_property (GObject * object, guint prop_id, +static void gst_tensor_reposink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); -static void gst_tensor_repopush_get_property (GObject * object, guint prop_id, +static void gst_tensor_reposink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static void gst_tensor_repopush_dispose (GObject * object); +static void gst_tensor_reposink_dispose (GObject * object); -static gboolean gst_tensor_repopush_start (GstBaseSink * sink); -static gboolean gst_tensor_repopush_stop (GstBaseSink * sink); -static gboolean gst_tensor_repopush_event (GstBaseSink * sink, +static gboolean gst_tensor_reposink_start (GstBaseSink * sink); +static gboolean gst_tensor_reposink_stop (GstBaseSink * sink); +static gboolean gst_tensor_reposink_event (GstBaseSink * sink, GstEvent * event); -static gboolean gst_tensor_repopush_query (GstBaseSink * sink, +static gboolean gst_tensor_reposink_query (GstBaseSink * sink, GstQuery * query); -static GstFlowReturn gst_tensor_repopush_render (GstBaseSink * sink, +static GstFlowReturn gst_tensor_reposink_render (GstBaseSink * sink, GstBuffer * buffer); -static GstFlowReturn gst_tensor_repopush_render_list (GstBaseSink * sink, +static GstFlowReturn gst_tensor_reposink_render_list (GstBaseSink * sink, GstBufferList * buffer_list); -static gboolean gst_tensor_repopush_set_caps (GstBaseSink * sink, +static gboolean gst_tensor_reposink_set_caps (GstBaseSink * sink, GstCaps * caps); -static GstCaps *gst_tensor_repopush_get_caps (GstBaseSink * sink, +static GstCaps *gst_tensor_reposink_get_caps (GstBaseSink * sink, GstCaps * filter); -#define gst_tensor_repopush_parent_class parent_class -G_DEFINE_TYPE (GstTensorRepoPush, gst_tensor_repopush, GST_TYPE_BASE_SINK); +#define gst_tensor_reposink_parent_class parent_class +G_DEFINE_TYPE (GstTensorRepoSink, gst_tensor_reposink, GST_TYPE_BASE_SINK); /** - * @brief class initialization of tensor_repopush + * @brief class initialization of tensor_reposink */ static void -gst_tensor_repopush_class_init (GstTensorRepoPushClass * klass) +gst_tensor_reposink_class_init (GstTensorRepoSinkClass * klass) { GObjectClass *gobject_class; GstElementClass *element_class; @@ -105,9 +105,9 @@ gst_tensor_repopush_class_init (GstTensorRepoPushClass * klass) element_class = GST_ELEMENT_CLASS (klass); basesink_class = GST_BASE_SINK_CLASS (klass); - gobject_class->set_property = gst_tensor_repopush_set_property; - gobject_class->get_property = gst_tensor_repopush_get_property; - gobject_class->dispose = gst_tensor_repopush_dispose; + gobject_class->set_property = gst_tensor_reposink_set_property; + gobject_class->get_property = gst_tensor_reposink_get_property; + gobject_class->dispose = gst_tensor_reposink_dispose; g_object_class_install_property (gobject_class, PROP_SIGNAL_RATE, g_param_spec_uint ("signal-rate", "Signal rate", @@ -124,29 +124,29 @@ gst_tensor_repopush_class_init (GstTensorRepoPushClass * klass) DEFAULT_SILENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); gst_element_class_set_static_metadata (element_class, - "TensorRepoPush", - "Push/TensorRepo", - "Push element to handle tensor repository", + "TensorRepoSink", + "Set/TensorRepo", + "Set element to handle tensor repository", "Samsung Electronics Co., Ltd."); gst_element_class_add_static_pad_template (element_class, &sink_template); - basesink_class->start = GST_DEBUG_FUNCPTR (gst_tensor_repopush_start); - basesink_class->stop = GST_DEBUG_FUNCPTR (gst_tensor_repopush_stop); - basesink_class->event = GST_DEBUG_FUNCPTR (gst_tensor_repopush_event); - basesink_class->query = GST_DEBUG_FUNCPTR (gst_tensor_repopush_query); - basesink_class->render = GST_DEBUG_FUNCPTR (gst_tensor_repopush_render); + basesink_class->start = GST_DEBUG_FUNCPTR (gst_tensor_reposink_start); + basesink_class->stop = GST_DEBUG_FUNCPTR (gst_tensor_reposink_stop); + basesink_class->event = GST_DEBUG_FUNCPTR (gst_tensor_reposink_event); + basesink_class->query = GST_DEBUG_FUNCPTR (gst_tensor_reposink_query); + basesink_class->render = GST_DEBUG_FUNCPTR (gst_tensor_reposink_render); basesink_class->render_list = - GST_DEBUG_FUNCPTR (gst_tensor_repopush_render_list); - basesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_tensor_repopush_set_caps); - basesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_tensor_repopush_get_caps); + GST_DEBUG_FUNCPTR (gst_tensor_reposink_render_list); + basesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_tensor_reposink_set_caps); + basesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_tensor_reposink_get_caps); } /** - * @brief initialization of tensor_repopush + * @brief initialization of tensor_reposink */ static void -gst_tensor_repopush_init (GstTensorRepoPush * self) +gst_tensor_reposink_init (GstTensorRepoSink * self) { GstBaseSink *basesink; basesink = GST_BASE_SINK (self); @@ -167,11 +167,11 @@ gst_tensor_repopush_init (GstTensorRepoPush * self) * @brief set property vmethod */ static void -gst_tensor_repopush_set_property (GObject * object, guint prop_id, +gst_tensor_reposink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { - GstTensorRepoPush *self; - self = GST_TENSOR_REPOPUSH (object); + GstTensorRepoSink *self; + self = GST_TENSOR_REPOSINK (object); switch (prop_id) { case PROP_SIGNAL_RATE: @@ -194,11 +194,11 @@ gst_tensor_repopush_set_property (GObject * object, guint prop_id, * @brief get property vmethod */ static void -gst_tensor_repopush_get_property (GObject * object, guint prop_id, +gst_tensor_reposink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { - GstTensorRepoPush *self; - self = GST_TENSOR_REPOPUSH (object); + GstTensorRepoSink *self; + self = GST_TENSOR_REPOSINK (object); switch (prop_id) { case PROP_SIGNAL_RATE: g_value_set_uint (value, self->signal_rate); @@ -219,10 +219,10 @@ gst_tensor_repopush_get_property (GObject * object, guint prop_id, * @brief dispose vmethod implementation */ static void -gst_tensor_repopush_dispose (GObject * object) +gst_tensor_reposink_dispose (GObject * object) { - GstTensorRepoPush *self; - self = GST_TENSOR_REPOPUSH (object); + GstTensorRepoSink *self; + self = GST_TENSOR_REPOSINK (object); if (self->in_caps) gst_caps_unref (self->in_caps); @@ -233,7 +233,7 @@ gst_tensor_repopush_dispose (GObject * object) * @brief start vmethod implementation */ static gboolean -gst_tensor_repopush_start (GstBaseSink * sink) +gst_tensor_reposink_start (GstBaseSink * sink) { return TRUE; } @@ -242,7 +242,7 @@ gst_tensor_repopush_start (GstBaseSink * sink) * @brief stop vmethod implementation */ static gboolean -gst_tensor_repopush_stop (GstBaseSink * sink) +gst_tensor_reposink_stop (GstBaseSink * sink) { return TRUE; } @@ -253,12 +253,12 @@ gst_tensor_repopush_stop (GstBaseSink * sink) * GstBaseSink method implementation. */ static gboolean -gst_tensor_repopush_event (GstBaseSink * sink, GstEvent * event) +gst_tensor_reposink_event (GstBaseSink * sink, GstEvent * event) { - GstTensorRepoPush *self; + GstTensorRepoSink *self; GstEventType type; - self = GST_TENSOR_REPOPUSH (sink); + self = GST_TENSOR_REPOSINK (sink); type = GST_EVENT_TYPE (event); silent_debug ("received event %s", GST_EVENT_TYPE_NAME (event)); @@ -271,7 +271,6 @@ gst_tensor_repopush_event (GstBaseSink * sink, GstEvent * event) default: break; } - return GST_BASE_SINK_CLASS (parent_class)->event (sink, event); } @@ -279,16 +278,17 @@ gst_tensor_repopush_event (GstBaseSink * sink, GstEvent * event) * @brief query vmethod implementation */ static gboolean -gst_tensor_repopush_query (GstBaseSink * sink, GstQuery * query) +gst_tensor_reposink_query (GstBaseSink * sink, GstQuery * query) { + GstTensorRepoSink *self; GstQueryType type; GstFormat format; + self = GST_TENSOR_REPOSINK (sink); type = GST_QUERY_TYPE (query); switch (type) { case GST_QUERY_SEEKING: - /** tensor sink does not support seeking */ gst_query_parse_seeking (query, &format, NULL, NULL, NULL); gst_query_set_seeking (query, format, FALSE, 0, -1); return TRUE; @@ -302,15 +302,15 @@ gst_tensor_repopush_query (GstBaseSink * sink, GstQuery * query) /** - * @brief push GstBuffer + * @brief Push GstBuffer */ static void -gst_tensor_repopush_render_buffer (GstTensorRepoPush * self, GstBuffer * buffer) +gst_tensor_reposink_render_buffer (GstTensorRepoSink * self, GstBuffer * buffer) { GstClockTime now = GST_CLOCK_TIME_NONE; guint signal_rate; gboolean notify = FALSE; - g_return_if_fail (GST_IS_TENSOR_REPOPUSH (self)); + g_return_if_fail (GST_IS_TENSOR_REPOSINK (self)); signal_rate = self->signal_rate; @@ -334,10 +334,10 @@ gst_tensor_repopush_render_buffer (GstTensorRepoPush * self, GstBuffer * buffer) if (notify) { gboolean ret = FALSE; self->last_render_time = now; - ret = gst_tensor_repo_push_buffer (self->myid, buffer); + ret = gst_tensor_repo_set_buffer (self->myid, buffer); if (!ret) GST_ELEMENT_ERROR (self, RESOURCE, WRITE, - ("Cannot push buffer into repo [key: %d]", self->myid), NULL); + ("Cannot Set buffer into repo [key: %d]", self->myid), NULL); } } @@ -345,13 +345,13 @@ gst_tensor_repopush_render_buffer (GstTensorRepoPush * self, GstBuffer * buffer) * @brief render vmethod implementation */ static GstFlowReturn -gst_tensor_repopush_render (GstBaseSink * sink, GstBuffer * buffer) +gst_tensor_reposink_render (GstBaseSink * sink, GstBuffer * buffer) { - GstTensorRepoPush *self; - self = GST_TENSOR_REPOPUSH (sink); + GstTensorRepoSink *self; + self = GST_TENSOR_REPOSINK (sink); - gst_tensor_repopush_render_buffer (self, buffer); + gst_tensor_reposink_render_buffer (self, buffer); return GST_FLOW_OK; } @@ -359,20 +359,20 @@ gst_tensor_repopush_render (GstBaseSink * sink, GstBuffer * buffer) * @brief render list vmethod implementation */ static GstFlowReturn -gst_tensor_repopush_render_list (GstBaseSink * sink, +gst_tensor_reposink_render_list (GstBaseSink * sink, GstBufferList * buffer_list) { - GstTensorRepoPush *self; + GstTensorRepoSink *self; GstBuffer *buffer; guint i; guint num_buffers; - self = GST_TENSOR_REPOPUSH (sink); + self = GST_TENSOR_REPOSINK (sink); num_buffers = gst_buffer_list_length (buffer_list); for (i = 0; i < num_buffers; i++) { buffer = gst_buffer_list_get (buffer_list, i); - gst_tensor_repopush_render_buffer (self, buffer); + gst_tensor_reposink_render_buffer (self, buffer); } return GST_FLOW_OK; @@ -382,11 +382,11 @@ gst_tensor_repopush_render_list (GstBaseSink * sink, * @brief set_caps vmethod implementation */ static gboolean -gst_tensor_repopush_set_caps (GstBaseSink * sink, GstCaps * caps) +gst_tensor_reposink_set_caps (GstBaseSink * sink, GstCaps * caps) { - GstTensorRepoPush *self; + GstTensorRepoSink *self; - self = GST_TENSOR_REPOPUSH (sink); + self = GST_TENSOR_REPOSINK (sink); gst_caps_replace (&self->in_caps, caps); return TRUE; @@ -396,12 +396,12 @@ gst_tensor_repopush_set_caps (GstBaseSink * sink, GstCaps * caps) * @brief get_caps vmethod implementation */ static GstCaps * -gst_tensor_repopush_get_caps (GstBaseSink * sink, GstCaps * filter) +gst_tensor_reposink_get_caps (GstBaseSink * sink, GstCaps * filter) { - GstTensorRepoPush *self; + GstTensorRepoSink *self; GstCaps *caps; - self = GST_TENSOR_REPOPUSH (sink); + self = GST_TENSOR_REPOSINK (sink); caps = self->in_caps; @@ -422,11 +422,11 @@ gst_tensor_repopush_get_caps (GstBaseSink * sink, GstCaps * filter) * * See GstPluginInitFunc() for more details. */ -NNSTREAMER_PLUGIN_INIT (tensor_repopush) +NNSTREAMER_PLUGIN_INIT (tensor_reposink) { - GST_DEBUG_CATEGORY_INIT (gst_tensor_repopush_debug, "tensor_repopush", - 0, "tensor_repopush element"); + GST_DEBUG_CATEGORY_INIT (gst_tensor_reposink_debug, "tensor_reposink", + 0, "tensor_reposink element"); - return gst_element_register (plugin, "tensor_repopush", - GST_RANK_NONE, GST_TYPE_TENSOR_REPOPUSH); + return gst_element_register (plugin, "tensor_reposink", + GST_RANK_NONE, GST_TYPE_TENSOR_REPOSINK); } diff --git a/gst/tensor_repopush/tensor_repopush.h b/gst/tensor_reposink/tensor_reposink.h similarity index 53% rename from gst/tensor_repopush/tensor_repopush.h rename to gst/tensor_reposink/tensor_reposink.h index cb2a4a9..704f454 100644 --- a/gst/tensor_repopush/tensor_repopush.h +++ b/gst/tensor_reposink/tensor_reposink.h @@ -16,7 +16,7 @@ */ /** - * @file tensor_repopush.h + * @file tensor_reposink.h * @date 19 Nov 2018 * @brief GStreamer plugin to handle tensor repository * @see https://github.com/nnsuite/nnstreamer @@ -24,8 +24,8 @@ * @bug No known bugs except for NYI items */ -#ifndef __GST_TENSOR_REPOPUSH_H_ -#define __GST_TENSOR_REPOPUSH_H__ +#ifndef __GST_TENSOR_REPOSINK_H_ +#define __GST_TENSOR_REPOSINK_H__ #include #include @@ -33,25 +33,25 @@ G_BEGIN_DECLS -#define GST_TYPE_TENSOR_REPOPUSH \ - (gst_tensor_repopush_get_type()) -#define GST_TENSOR_REPOPUSH(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TENSOR_REPOPUSH,GstTensorRepoPush)) -#define GST_TENSOR_REPOPUSH_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TENSOR_REPOPUSH,GstTensorRepoPushClass)) -#define GST_IS_TENSOR_REPOPUSH(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TENSOR_REPOPUSH)) -#define GST_IS_TENSOR_REPOPUSH_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TENSOR_REPOPUSH)) -typedef struct _GstTensorRepoPush GstTensorRepoPush; -typedef struct _GstTensorRepoPushClass GstTensorRepoPushClass; +#define GST_TYPE_TENSOR_REPOSINK \ + (gst_tensor_reposink_get_type()) +#define GST_TENSOR_REPOSINK(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TENSOR_REPOSINK,GstTensorRepoSink)) +#define GST_TENSOR_REPOSINK_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TENSOR_REPOSINK,GstTensorRepoSinkClass)) +#define GST_IS_TENSOR_REPOSINK(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TENSOR_REPOSINK)) +#define GST_IS_TENSOR_REPOSINK_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TENSOR_REPOSINK)) +typedef struct _GstTensorRepoSink GstTensorRepoSink; +typedef struct _GstTensorRepoSinkClass GstTensorRepoSinkClass; /** - * @brief GstTensorRepoPush data structure. + * @brief GstTensorRepoSink data structure. * - * GstTensorRepoPush inherits GstBaseSink. + * GstTensorRepoSink inherits GstBaseSink. */ -struct _GstTensorRepoPush +struct _GstTensorRepoSink { GstBaseSink element; @@ -63,19 +63,19 @@ struct _GstTensorRepoPush }; /** - * @brief GstTensorRepoPushClass data structure. + * @brief GstTensorRepoSinkClass data structure. * - * GstTensorRepoPush inherits GstBaseSink. + * GstTensorRepoSink inherits GstBaseSink. */ -struct _GstTensorRepoPushClass +struct _GstTensorRepoSinkClass { GstBaseSinkClass parent_class; }; /** - * @brief Function to get type of tensor_repopush. + * @brief Function to get type of tensor_reposink. */ -GType gst_tensor_repopush_get_type (void); +GType gst_tensor_reposink_get_type (void); G_END_DECLS -#endif /** __GST_TENSOR_REPOPUSH_H__ */ +#endif /** __GST_TENSOR_REPOSINK_H__ */ diff --git a/gst/tensor_reposrc/CMakeLists.txt b/gst/tensor_reposrc/CMakeLists.txt new file mode 100644 index 0000000..fa6272b --- /dev/null +++ b/gst/tensor_reposrc/CMakeLists.txt @@ -0,0 +1 @@ +ADD_LIBRARY(tensor_reposrcOBJ OBJECT tensor_reposrc.c ) diff --git a/gst/tensor_repopop/tensor_repopop.c b/gst/tensor_reposrc/tensor_reposrc.c similarity index 71% rename from gst/tensor_repopop/tensor_repopop.c rename to gst/tensor_reposrc/tensor_reposrc.c index ed3c82c..c5c95ab 100644 --- a/gst/tensor_repopop/tensor_repopop.c +++ b/gst/tensor_reposrc/tensor_reposrc.c @@ -16,11 +16,11 @@ */ /** - * SECTION: element-tensor_repopop + * SECTION: element-tensor_reposrc * * Pop elemnt to handle tensor repo * - * @file tensor_repopop.c + * @file tensor_reposrc.c * @date 19 Nov 2018 * @brief GStreamer plugin to handle tensor repository * @see https://github.com/nnsuite/nnstreamer @@ -32,7 +32,7 @@ #include #endif -#include "tensor_repopop.h" +#include "tensor_reposrc.h" /** * @brief Macro for debug mode. @@ -47,11 +47,11 @@ #define silent_debug(...) \ debug_print (DBG, __VA_ARGS__) -GST_DEBUG_CATEGORY_STATIC (gst_tensor_repopop_debug); -#define GST_CAT_DEFAULT gst_tensor_repopop_debug +GST_DEBUG_CATEGORY_STATIC (gst_tensor_reposrc_debug); +#define GST_CAT_DEFAULT gst_tensor_reposrc_debug /** - * @brief tensor_repopop properties + * @brief tensor_reposrc properties */ enum { @@ -70,38 +70,38 @@ enum extern GstTensorRepo _repo; /** - * @brief tensor_repopop src template + * @brief tensor_reposrc 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, +static void gst_tensor_reposrc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); -static void gst_tensor_repopop_get_property (GObject * object, guint prop_id, +static void gst_tensor_reposrc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static void gst_tensor_repopop_dispose (GObject * object); -static GstCaps *gst_tensor_repopop_getcaps (GstBaseSrc * src, GstCaps * filter); -static GstFlowReturn gst_tensor_repopop_create (GstPushSrc * src, +static void gst_tensor_reposrc_dispose (GObject * object); +static GstCaps *gst_tensor_reposrc_getcaps (GstBaseSrc * src, GstCaps * filter); +static GstFlowReturn gst_tensor_reposrc_create (GstPushSrc * src, GstBuffer ** buffer); -#define gst_tensor_repopop_parent_class parent_class -G_DEFINE_TYPE (GstTensorRepoPop, gst_tensor_repopop, GST_TYPE_PUSH_SRC); +#define gst_tensor_reposrc_parent_class parent_class +G_DEFINE_TYPE (GstTensorRepoSrc, gst_tensor_reposrc, GST_TYPE_PUSH_SRC); /** - * @brief class initialization of tensor_repopop + * @brief class initialization of tensor_reposrc */ static void -gst_tensor_repopop_class_init (GstTensorRepoPopClass * klass) +gst_tensor_reposrc_class_init (GstTensorRepoSrcClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstPushSrcClass *pushsrc_class = GST_PUSH_SRC_CLASS (klass); GstBaseSrcClass *basesrc_class = GST_BASE_SRC_CLASS (klass); - gobject_class->set_property = gst_tensor_repopop_set_property; - gobject_class->get_property = gst_tensor_repopop_get_property; + gobject_class->set_property = gst_tensor_reposrc_set_property; + gobject_class->get_property = gst_tensor_reposrc_get_property; g_object_class_install_property (gobject_class, PROP_CAPS, g_param_spec_boxed ("caps", "Caps", @@ -117,13 +117,13 @@ gst_tensor_repopop_class_init (GstTensorRepoPopClass * klass) 0, UINT_MAX, DEFAULT_INDEX, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - gobject_class->dispose = gst_tensor_repopop_dispose; + gobject_class->dispose = gst_tensor_reposrc_dispose; - basesrc_class->get_caps = gst_tensor_repopop_getcaps; - pushsrc_class->create = gst_tensor_repopop_create; + basesrc_class->get_caps = gst_tensor_reposrc_getcaps; + pushsrc_class->create = gst_tensor_reposrc_create; gst_element_class_set_static_metadata (element_class, - "TensorRepoPop", + "TensorRepoSrc", "Pop/TensorRepo", "Pop element to handle tensor repository", "Samsung Electronics Co., Ltd."); @@ -132,10 +132,10 @@ gst_tensor_repopop_class_init (GstTensorRepoPopClass * klass) } /** - * @brief object initialization of tensor_repopop + * @brief object initialization of tensor_reposrc */ static void -gst_tensor_repopop_init (GstTensorRepoPop * self) +gst_tensor_reposrc_init (GstTensorRepoSrc * self) { self->silent = TRUE; self->ini = FALSE; @@ -144,13 +144,13 @@ gst_tensor_repopop_init (GstTensorRepoPop * self) } /** - * @brief object dispose of tensor_repopop + * @brief object dispose of tensor_reposrc */ static void -gst_tensor_repopop_dispose (GObject * object) +gst_tensor_reposrc_dispose (GObject * object) { gboolean ret; - GstTensorRepoPop *self = GST_TENSOR_REPOPOP (object); + GstTensorRepoSrc *self = GST_TENSOR_REPOSRC (object); ret = gst_tensor_repo_remove_data (self->myid); if (!ret) @@ -164,13 +164,13 @@ gst_tensor_repopop_dispose (GObject * object) } /** - * @brief get cap of tensor_repopop + * @brief get cap of tensor_reposrc */ static GstCaps * -gst_tensor_repopop_getcaps (GstBaseSrc * src, GstCaps * filter) +gst_tensor_reposrc_getcaps (GstBaseSrc * src, GstCaps * filter) { GstCaps *cap; - GstTensorRepoPop *self = GST_TENSOR_REPOPOP (src); + GstTensorRepoSrc *self = GST_TENSOR_REPOSRC (src); GST_DEBUG_OBJECT (self, "returning %" GST_PTR_FORMAT, self->caps); @@ -192,14 +192,14 @@ gst_tensor_repopop_getcaps (GstBaseSrc * src, GstCaps * filter) } /** - * @brief set property of tensor_repopop + * @brief set property of tensor_reposrc */ static void -gst_tensor_repopop_set_property (GObject * object, guint prop_id, +gst_tensor_reposrc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { - GstTensorRepoPop *self = GST_TENSOR_REPOPOP (object); + GstTensorRepoSrc *self = GST_TENSOR_REPOSRC (object); switch (prop_id) { case PROP_SILENT: @@ -243,13 +243,13 @@ gst_tensor_repopop_set_property (GObject * object, guint prop_id, } /** - * @brief get property of tensor_repopop + * @brief get property of tensor_reposrc */ static void -gst_tensor_repopop_get_property (GObject * object, guint prop_id, +gst_tensor_reposrc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { - GstTensorRepoPop *self = GST_TENSOR_REPOPOP (object); + GstTensorRepoSrc *self = GST_TENSOR_REPOSRC (object); switch (prop_id) { case PROP_SILENT: @@ -268,20 +268,19 @@ gst_tensor_repopop_get_property (GObject * object, guint prop_id, } /** - * @brief create func of tensor_repopop + * @brief create func of tensor_reposrc */ static GstFlowReturn -gst_tensor_repopop_create (GstPushSrc * src, GstBuffer ** buffer) +gst_tensor_reposrc_create (GstPushSrc * src, GstBuffer ** buffer) { - GstTensorRepoPop *self; - GstBuffer *buf; - - self = GST_TENSOR_REPOPOP (src); + GstTensorRepoSrc *self; + GstBuffer *buf = NULL; + self = GST_TENSOR_REPOSRC (src); gst_tensor_repo_wait (); - - if (gst_tensor_repo_check_eos (self->myid)) + if (gst_tensor_repo_check_eos (self->myid)) { return GST_FLOW_EOS; + } if (!self->ini) { int i; @@ -293,7 +292,9 @@ gst_tensor_repopop_create (GstPushSrc * src, GstBuffer ** buffer) gst_buffer_memset (buf, 0, 0, size); self->ini = TRUE; } else { - buf = gst_tensor_repopop_buffer (self->myid); + buf = gst_tensor_repo_get_buffer (self->myid); + if (buf == NULL) + return GST_FLOW_EOS; } *buffer = buf; @@ -306,11 +307,11 @@ gst_tensor_repopop_create (GstPushSrc * src, GstBuffer ** buffer) * * See GstPluginInitFunc() for more details. */ -NNSTREAMER_PLUGIN_INIT (tensor_repopop) +NNSTREAMER_PLUGIN_INIT (tensor_reposrc) { - GST_DEBUG_CATEGORY_INIT (gst_tensor_repopop_debug, "tensor_repopop", - 0, "tensor_repopop element"); + GST_DEBUG_CATEGORY_INIT (gst_tensor_reposrc_debug, "tensor_reposrc", + 0, "tensor_reposrc element"); - return gst_element_register (plugin, "tensor_repopop", - GST_RANK_NONE, GST_TYPE_TENSOR_REPOPOP); + return gst_element_register (plugin, "tensor_reposrc", + GST_RANK_NONE, GST_TYPE_TENSOR_REPOSRC); } diff --git a/gst/tensor_repopop/tensor_repopop.h b/gst/tensor_reposrc/tensor_reposrc.h similarity index 54% rename from gst/tensor_repopop/tensor_repopop.h rename to gst/tensor_reposrc/tensor_reposrc.h index 8464428..cdc9032 100644 --- a/gst/tensor_repopop/tensor_repopop.h +++ b/gst/tensor_reposrc/tensor_reposrc.h @@ -16,7 +16,7 @@ */ /** - * @file tensor_repopop.h + * @file tensor_reposrc.h * @date 19 Nov 2018 * @brief GStreamer plugin to handle tensor repository * @see https://github.com/nnsuite/nnstreamer @@ -24,33 +24,33 @@ * @bug No known bugs except for NYI items */ -#ifndef __GST_TENSOR_REPOPOP_H_ -#define __GST_TENSOR_REPOPOP_H__ +#ifndef __GST_TENSOR_REPOSRC_H_ +#define __GST_TENSOR_REPOSRC_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; +#define GST_TYPE_TENSOR_REPOSRC \ + (gst_tensor_reposrc_get_type()) +#define GST_TENSOR_REPOSRC(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TENSOR_REPOSRC,GstTensorRepoSrc)) +#define GST_TENSOR_REPOSRC_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TENSOR_REPOSRC,GstTensorRepoSrcClass)) +#define GST_IS_TENSOR_REPOSRC(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TENSOR_REPOSRC)) +#define GST_IS_TENSOR_REPOSRC_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TENSOR_REPOSRC)) +typedef struct _GstTensorRepoSrc GstTensorRepoSrc; +typedef struct _GstTensorRepoSrcClass GstTensorRepoSrcClass; /** - * @brief GstTensorRepoPop data structure. + * @brief GstTensorRepoSrc data structure. * - * GstTensorRepoPop inherits GstBaseSink. + * GstTensorRepoSrc inherits GstBaseSink. */ -struct _GstTensorRepoPop +struct _GstTensorRepoSrc { GstPushSrc parent; GstBaseSink element; @@ -63,19 +63,19 @@ struct _GstTensorRepoPop }; /** - * @brief GstTensorRepoPopClass data structure. + * @brief GstTensorRepoSrcClass data structure. * - * GstTensorRepoPop inherits GstBaseSink. + * GstTensorRepoSrc inherits GstBaseSink. */ -struct _GstTensorRepoPopClass +struct _GstTensorRepoSrcClass { GstPushSrcClass parent_class; }; /** - * @brief Function to get type of tensor_repopop. + * @brief Function to get type of tensor_reposrc. */ -GType gst_tensor_repopop_get_type (void); +GType gst_tensor_reposrc_get_type (void); G_END_DECLS -#endif /** __GST_TENSOR_REPOPOP_H__ */ +#endif /** __GST_TENSOR_REPOSRC_H__ */