#define DBG FALSE
#endif
-#define _print_log(...) if (DBG) g_message(__VA_ARGS__)
-
/**
* @brief tensor repo global variable with init.
*/
gst_tensor_repo_get_repodata (guint nth)
{
GstTensorRepoData *data;
- gpointer *p = g_hash_table_lookup (_repo.hash, GINT_TO_POINTER (nth));
+ gpointer p = g_hash_table_lookup (_repo.hash, GINT_TO_POINTER (nth));
data = (GstTensorRepoData *) p;
- g_return_val_if_fail (data != NULL, NULL);
return data;
}
GstTensorRepoData *new;
GST_REPO_LOCK ();
- gpointer *check = g_hash_table_lookup (_repo.hash, GINT_TO_POINTER (nth));
+ gpointer check = g_hash_table_lookup (_repo.hash, GINT_TO_POINTER (nth));
if (check != NULL) {
return TRUE;
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]", nth);
+ if (DBG)
+ GST_DEBUG ("Successfully added in hash table with key[%d]", nth);
_repo.num_data++;
GST_REPO_UNLOCK ();
g_return_val_if_fail (data != NULL, FALSE);
data->buffer = buffer;
- _print_log ("Pushed [%d] (size : %lu)\n", nth,
- gst_buffer_get_size (data->buffer));
+ if (DBG) {
+ unsigned long size = gst_buffer_get_size (data->buffer);
+ GST_DEBUG ("Pushed [%d] (size : %lu)\n", nth, size);
+ }
GST_TENSOR_REPO_SIGNAL (nth);
GST_TENSOR_REPO_UNLOCK (nth);
gst_tensor_repo_check_eos (guint nth)
{
GstTensorRepoData *data = gst_tensor_repo_get_repodata (nth);
- if (data == NULL || data->eos) {
- _print_log ("check eos done [%s]\n", data->eos ? "TRUE" : "FALSE");
+ if (data->eos) {
+ if (DBG)
+ GST_DEBUG ("check eos done [%s]\n", data->eos ? "TRUE" : "FALSE");
}
return data->eos;
}
GST_TENSOR_REPO_LOCK (nth);
GstTensorRepoData *data = gst_tensor_repo_get_repodata (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;
GST_TENSOR_REPO_WAIT (nth);
}
if (eos) {
- _print_log ("Get EOS Signal while waiting\n");
+ if (DBG)
+ GST_DEBUG ("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));
+ if (DBG) {
+ unsigned long size = gst_buffer_get_size (buf);
+ GST_DEBUG ("Popped [ %d ] (size: %lu)\n", nth, size);
+ }
}
current_data->buffer = NULL;
GST_TENSOR_REPO_UNLOCK (nth);
gst_tensor_repo_remove_repodata (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));
if (ret) {
_repo.num_data--;
- _print_log ("key[%d] is removed\n", nth);
+ if (DBG)
+ GST_DEBUG ("key[%d] is removed\n", nth);
+ }
+
+ if (!_repo.num_data) {
+ g_hash_table_destroy (_repo.hash);
}
GST_REPO_UNLOCK ();
*/
extern GstTensorRepo _repo;
-
GST_DEBUG_CATEGORY_STATIC (gst_tensor_reposink_debug);
#define GST_CAT_DEFAULT gst_tensor_reposink_debug
gst_tensor_repo_init ();
- silent_debug ("GstTensorRepo is sucessfully initailzed");
+ GST_DEBUG_OBJECT (self, "GstTensorRepo is sucessfully initailzed");
self->silent = DEFAULT_SILENT;
self->signal_rate = DEFAULT_SIGNAL_RATE;
self = GST_TENSOR_REPOSINK (sink);
type = GST_EVENT_TYPE (event);
- silent_debug ("received event %s", GST_EVENT_TYPE_NAME (event));
+ GST_DEBUG_OBJECT (self, "received event %s", GST_EVENT_TYPE_NAME (event));
switch (type) {
case GST_EVENT_EOS:
self = GST_TENSOR_REPOSINK (sink);
type = GST_QUERY_TYPE (query);
+ GST_DEBUG_OBJECT (self, "received query %s", GST_QUERY_TYPE_NAME (query));
switch (type) {
case GST_QUERY_SEEKING:
gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
self = GST_TENSOR_REPOSINK (sink);
gst_caps_replace (&self->in_caps, caps);
+ if (!self->silent) {
+ guint caps_size, i;
+
+ caps_size = gst_caps_get_size (caps);
+ GST_DEBUG_OBJECT (self, "set caps, size is %d", caps_size);
+
+ for (i = 0; i < caps_size; i++) {
+ GstStructure *structure = gst_caps_get_structure (caps, i);
+ gchar *str = gst_structure_to_string (structure);
+
+ GST_DEBUG_OBJECT (self, "[%d] %s", i, str);
+ g_free (str);
+ }
+ }
+
return TRUE;
}
#include <config.h>
#endif
+#include <string.h>
#include "tensor_reposrc.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_reposrc_debug);
#define GST_CAT_DEFAULT gst_tensor_reposrc_debug
int i;
guint num_tensors = self->config.info.num_tensors;
gsize size = 0;
- for (i = 0; i < num_tensors; i++)
- size += gst_tensor_info_get_size (&self->config.info.info[i]);
- buf = gst_buffer_new_and_alloc (size);
- gst_buffer_memset (buf, 0, 0, size);
+ buf = gst_buffer_new ();
+ for (i = 0; i < num_tensors; i++) {
+ GstMemory *mem;
+ GstMapInfo info;
+ size = gst_tensor_info_get_size (&self->config.info.info[i]);
+ mem = gst_allocator_alloc (NULL, size, NULL);
+ gst_memory_map (mem, &info, GST_MAP_WRITE);
+ memset (info.data, 0, size);
+ gst_memory_unmap (mem, &info);
+ gst_buffer_append_memory (buf, mem);
+ }
self->ini = TRUE;
} else {
buf = gst_tensor_repo_get_buffer (self->myid);
/**
* @brief GstTensorRepoSrc data structure.
*
- * GstTensorRepoSrc inherits GstBaseSink.
+ * GstTensorRepoSrc inherits GstPushSrc
*/
struct _GstTensorRepoSrc
{
GstPushSrc parent;
- GstBaseSink element;
GstTensorsConfig config;
gboolean silent;
guint myid;
/**
* @brief GstTensorRepoSrcClass data structure.
*
- * GstTensorRepoSrc inherits GstBaseSink.
+ * GstTensorRepoSrc inherits GstPushSrc
*/
struct _GstTensorRepoSrcClass
{