40 #define GST_CAT_DEFAULT gst_tensor_reposink_debug
53 #define DEFAULT_SIGNAL_RATE 0
54 #define DEFAULT_SILENT TRUE
55 #define DEFAULT_QOS TRUE
56 #define DEFAULT_INDEX 0
59 const GValue * value, GParamSpec * pspec);
61 GValue * value, GParamSpec * pspec);
73 GstBufferList * buffer_list);
79 #define gst_tensor_reposink_parent_class parent_class
88 GObjectClass *gobject_class;
89 GstElementClass *element_class;
90 GstBaseSinkClass *basesink_class;
91 GstPadTemplate *pad_template;
94 GST_DEBUG_CATEGORY_INIT (gst_tensor_reposink_debug,
"tensor_reposink", 0,
95 "Sink element to handle tensor repository");
97 gobject_class = G_OBJECT_CLASS (klass);
98 element_class = GST_ELEMENT_CLASS (klass);
99 basesink_class = GST_BASE_SINK_CLASS (klass);
106 g_param_spec_uint (
"signal-rate",
"Signal rate",
107 "New data signals per second (0 for unlimited, max 500)", 0, 500,
110 g_object_class_install_property (gobject_class,
PROP_SLOT,
111 g_param_spec_uint (
"slot-index",
"Slot Index",
"repository slot index",
113 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
115 g_object_class_install_property (gobject_class,
PROP_SILENT,
116 g_param_spec_boolean (
"silent",
"Silent",
"Produce verbose output",
119 gst_element_class_set_static_metadata (element_class,
121 "Sink/Tensor/Repository",
122 "Set element to handle tensor repository",
123 "Samsung Electronics Co., Ltd.");
128 pad_template = gst_pad_template_new (
"sink", GST_PAD_SINK, GST_PAD_ALWAYS,
130 gst_element_class_add_pad_template (element_class, pad_template);
131 gst_caps_unref (pad_caps);
138 basesink_class->render_list =
150 GstBaseSink *basesink;
152 basesink = GST_BASE_SINK (
self);
156 GST_DEBUG_OBJECT (
self,
"GstTensorRepo is successfully initialized");
160 self->last_render_time = GST_CLOCK_TIME_NONE;
161 self->set_startid =
FALSE;
162 self->in_caps = NULL;
164 gst_base_sink_set_qos_enabled (basesink,
DEFAULT_QOS);
167 gst_base_sink_set_sync (basesink,
FALSE);
168 gst_base_sink_set_async_enabled (basesink,
FALSE);
176 const GValue * value, GParamSpec * pspec)
184 self->signal_rate = g_value_get_uint (value);
187 self->silent = g_value_get_boolean (value);
190 self->o_myid =
self->myid;
191 self->myid = g_value_get_uint (value);
195 if (!self->set_startid) {
196 self->o_myid =
self->myid;
197 self->set_startid =
TRUE;
200 if (self->o_myid != self->myid)
204 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
214 GValue * value, GParamSpec * pspec)
222 g_value_set_uint (value, self->signal_rate);
225 g_value_set_boolean (value, self->silent);
228 g_value_set_uint (value, self->myid);
231 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
247 gst_caps_unref (self->in_caps);
249 G_OBJECT_CLASS (parent_class)->dispose (
object);
284 type = GST_EVENT_TYPE (event);
286 GST_DEBUG_OBJECT (
self,
"received event %s", GST_EVENT_TYPE_NAME (event));
296 return GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
310 type = GST_QUERY_TYPE (query);
312 GST_DEBUG_OBJECT (
self,
"received query %s", GST_QUERY_TYPE_NAME (query));
315 case GST_QUERY_SEEKING:
316 gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
317 gst_query_set_seeking (query, format,
FALSE, 0, -1);
323 return GST_BASE_SINK_CLASS (parent_class)->query (sink, query);
332 GstClockTime now = GST_CLOCK_TIME_NONE;
334 gboolean notify =
FALSE;
337 signal_rate =
self->signal_rate;
341 GstClockTime render_time;
343 clock = gst_element_get_clock (GST_ELEMENT (
self));
346 now = gst_clock_get_time (clock);
347 render_time = (1000 / signal_rate) * GST_MSECOND + self->last_render_time;
349 if (!GST_CLOCK_TIME_IS_VALID (self->last_render_time) ||
350 GST_CLOCK_DIFF (now, render_time) <= 0) {
354 gst_object_unref (clock);
361 self->last_render_time = now;
364 GST_ELEMENT_ERROR (
self, RESOURCE, WRITE,
365 (
"Cannot Set buffer into repo [key: %d]", self->myid), NULL);
384 return GST_FLOW_ERROR;
393 GstBufferList * buffer_list)
401 num_buffers = gst_buffer_list_length (buffer_list);
403 for (i = 0; i < num_buffers; i++) {
404 buffer = gst_buffer_list_get (buffer_list, i);
406 return GST_FLOW_ERROR;
421 gst_caps_replace (&self->in_caps, caps);
425 GstStructure *structure;
429 caps_size = gst_caps_get_size (caps);
430 GST_DEBUG_OBJECT (
self,
"set caps, size is %d", caps_size);
432 for (i = 0; i < caps_size; i++) {
433 structure = gst_caps_get_structure (caps, i);
434 str = gst_structure_to_string (structure);
436 GST_DEBUG_OBJECT (
self,
"[%d] %s", i, str);
455 caps =
self->in_caps;
459 caps = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);