Change log format
authorJaeyun <jy1210.jung@samsung.com>
Wed, 21 Nov 2018 12:53:11 +0000 (21:53 +0900)
committerMyungJoo Ham <myungjoo.ham@gmail.com>
Fri, 23 Nov 2018 06:20:00 +0000 (06:20 +0000)
Use common gst macros to print debug logs.

TODO: remove log macro in common header

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
gst/nnstreamer/tensor_common.c
gst/tensor_converter/tensor_converter.c
gst/tensor_decoder/tensordec.c
gst/tensor_filter/tensor_filter.c
gst/tensor_filter/tensor_filter_custom.c
gst/tensor_merge/gsttensormerge.c
gst/tensor_mux/gsttensormux.c
gst/tensor_transform/tensor_transform.c
tests/nnstreamer_tensors/tensors_test/gsttensorscheck.c

index 56c689c..60419f8 100644 (file)
@@ -323,7 +323,7 @@ gst_tensor_config_from_tensor_structure (GstTensorConfig * config,
   g_return_val_if_fail (structure != NULL, FALSE);
 
   if (!gst_structure_has_name (structure, "other/tensor")) {
-    err_print ("caps is not tensor %s\n", gst_structure_get_name (structure));
+    GST_WARNING ("caps is not tensor %s\n", gst_structure_get_name (structure));
     return FALSE;
   }
 
@@ -401,7 +401,8 @@ gst_tensor_config_from_video_info (GstTensorConfig * config,
       break;
     default:
       /** unsupported format */
-      err_print ("Unsupported format = %d\n", format);
+      GST_WARNING ("Unsupported format = %s\n",
+          format_string ? format_string : "Unknown");
       break;
   }
 
@@ -484,7 +485,8 @@ gst_tensor_config_from_audio_info (GstTensorConfig * config,
       break;
     default:
       /** unsupported format */
-      err_print ("Unsupported format = %d\n", format);
+      GST_WARNING ("Unsupported format = %s\n",
+          format_string ? format_string : "Unknown");
       break;
   }
 
@@ -532,7 +534,7 @@ gst_tensor_config_from_text_info (GstTensorConfig * config,
       config->info.type = _NNS_UINT8;
     } else {
       /** unsupported format */
-      err_print ("Unsupported format\n");
+      GST_WARNING ("Unsupported format = %s\n", format_string);
     }
   }
 
@@ -631,7 +633,7 @@ gst_tensor_config_from_structure (GstTensorConfig * config,
       gst_tensor_config_from_octet_stream_info (config, structure);
       break;
     default:
-      err_print ("Unsupported type %d\n", m_type);
+      GST_WARNING ("Unsupported type %d\n", m_type);
       return FALSE;
   }
 
@@ -777,7 +779,7 @@ gst_tensors_config_from_structure (GstTensorsConfig * config,
         &config->rate_d);
 
     if (config->info.num_tensors > NNS_TENSOR_SIZE_LIMIT) {
-      err_print ("Invalid param, max size is %d", NNS_TENSOR_SIZE_LIMIT);
+      GST_WARNING ("Invalid param, max size is %d", NNS_TENSOR_SIZE_LIMIT);
       config->info.num_tensors = NNS_TENSOR_SIZE_LIMIT;
     }
 
@@ -791,7 +793,7 @@ gst_tensors_config_from_structure (GstTensorsConfig * config,
       num_dims = g_strv_length (str_dims);
 
       if (config->info.num_tensors != num_dims) {
-        err_print ("Invalid param, dimensions (%d) tensors (%d)\n",
+        GST_WARNING ("Invalid param, dimensions (%d) tensors (%d)\n",
             num_dims, config->info.num_tensors);
 
         if (num_dims > config->info.num_tensors) {
@@ -816,7 +818,7 @@ gst_tensors_config_from_structure (GstTensorsConfig * config,
       num_types = g_strv_length (str_types);
 
       if (config->info.num_tensors != num_types) {
-        err_print ("Invalid param, types (%d) tensors (%d)\n",
+        GST_WARNING ("Invalid param, types (%d) tensors (%d)\n",
             num_types, config->info.num_tensors);
 
         if (num_types > config->info.num_tensors) {
@@ -831,7 +833,7 @@ gst_tensors_config_from_structure (GstTensorsConfig * config,
       g_strfreev (str_types);
     }
   } else {
-    err_print ("Unsupported type = %s\n", name);
+    GST_WARNING ("Unsupported type = %s\n", name ? name : "Unknown");
     return FALSE;
   }
 
index f557211..f2f6dce 100644 (file)
 /**
  * @brief Macro for debug message.
  */
-#define silent_debug(...) \
-    debug_print (DBG, __VA_ARGS__)
+#define silent_debug(...) do { \
+    if (DBG) { \
+      GST_DEBUG_OBJECT (self, __VA_ARGS__); \
+    } \
+  } while (0)
 
 #define silent_debug_caps(caps,msg) do { \
   if (DBG) { \
@@ -87,7 +90,7 @@
       for (caps_idx = 0; caps_idx < caps_size; caps_idx++) { \
         caps_s = gst_caps_get_structure (caps, caps_idx); \
         caps_s_string = gst_structure_to_string (caps_s); \
-        debug_print (TRUE, msg " = %s\n", caps_s_string); \
+        GST_DEBUG_OBJECT (self, msg " = %s\n", caps_s_string); \
         g_free (caps_s_string); \
       } \
     } \
@@ -96,9 +99,9 @@
 
 #define silent_debug_timestamp(buf) do { \
   if (DBG) { \
-    debug_print (TRUE, "pts = %" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_PTS (buf))); \
-    debug_print (TRUE, "dts = %" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DTS (buf))); \
-    debug_print (TRUE, "duration = %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (GST_BUFFER_DURATION (buf))); \
+    GST_DEBUG_OBJECT (self, "pts = %" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_PTS (buf))); \
+    GST_DEBUG_OBJECT (self, "dts = %" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DTS (buf))); \
+    GST_DEBUG_OBJECT (self, "duration = %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (GST_BUFFER_DURATION (buf))); \
   } \
 } while (0)
 
@@ -410,7 +413,7 @@ gst_tensor_converter_sink_event (GstPad * pad, GstObject * parent,
 
   self = GST_TENSOR_CONVERTER (parent);
 
-  GST_LOG_OBJECT (self, "Received %s event: %" GST_PTR_FORMAT,
+  GST_DEBUG_OBJECT (self, "Received %s event: %" GST_PTR_FORMAT,
       GST_EVENT_TYPE_NAME (event), event);
 
   switch (GST_EVENT_TYPE (event)) {
@@ -460,7 +463,8 @@ gst_tensor_converter_sink_event (GstPad * pad, GstObject * parent,
         return TRUE;
       }
 
-      err_print ("Unsupported format = %s\n", gst_format_get_name (seg.format));
+      GST_ERROR_OBJECT (self, "Unsupported format = %s\n",
+          gst_format_get_name (seg.format));
       gst_event_unref (event);
       return FALSE;
     }
@@ -482,7 +486,7 @@ gst_tensor_converter_sink_query (GstPad * pad, GstObject * parent,
 
   self = GST_TENSOR_CONVERTER (parent);
 
-  GST_LOG_OBJECT (self, "Received %s query: %" GST_PTR_FORMAT,
+  GST_DEBUG_OBJECT (self, "Received %s query: %" GST_PTR_FORMAT,
       GST_QUERY_TYPE_NAME (query), query);
 
   switch (GST_QUERY_TYPE (query)) {
@@ -535,7 +539,7 @@ gst_tensor_converter_src_query (GstPad * pad, GstObject * parent,
 
   self = GST_TENSOR_CONVERTER (parent);
 
-  GST_LOG_OBJECT (self, "Received %s query: %" GST_PTR_FORMAT,
+  GST_DEBUG_OBJECT (self, "Received %s query: %" GST_PTR_FORMAT,
       GST_QUERY_TYPE_NAME (query), query);
 
   switch (GST_QUERY_TYPE (query)) {
@@ -684,7 +688,7 @@ gst_tensor_converter_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
       break;
 
     default:
-      err_print ("Unsupported type %d\n", self->in_media_type);
+      GST_ERROR_OBJECT (self, "Unsupported type %d\n", self->in_media_type);
       g_assert (0);
       return GST_FLOW_ERROR;
   }
@@ -935,7 +939,7 @@ gst_tensor_converter_parse_caps (GstTensorConverter * self,
 
       gst_video_info_init (&info);
       if (!gst_video_info_from_caps (&info, caps)) {
-        err_print ("Failed to get video info from caps.\n");
+        GST_ERROR_OBJECT (self, "Failed to get video info from caps.\n");
         return FALSE;
       }
 
@@ -963,7 +967,7 @@ gst_tensor_converter_parse_caps (GstTensorConverter * self,
 
       gst_audio_info_init (&info);
       if (!gst_audio_info_from_caps (&info, caps)) {
-        err_print ("Failed to get audio info from caps.\n");
+        GST_ERROR_OBJECT (self, "Failed to get audio info from caps.\n");
         return FALSE;
       }
 
@@ -979,14 +983,15 @@ gst_tensor_converter_parse_caps (GstTensorConverter * self,
        * update tensor info from properties
        */
       if (!gst_tensor_info_validate (&self->tensor_info)) {
-        err_print ("Failed to get tensor info, update dimension and type.\n");
+        GST_ERROR_OBJECT (self,
+            "Failed to get tensor info, update dimension and type.\n");
         return FALSE;
       }
 
       config.info = self->tensor_info;
       break;
     default:
-      err_print ("Unsupported type %d\n", in_type);
+      GST_ERROR_OBJECT (self, "Unsupported type %d\n", in_type);
       return FALSE;
   }
 
@@ -997,14 +1002,14 @@ gst_tensor_converter_parse_caps (GstTensorConverter * self,
 
   if (!gst_tensor_config_validate (&config)) {
     /** not fully configured */
-    err_print ("Failed to configure tensor info.\n");
+    GST_ERROR_OBJECT (self, "Failed to configure tensor info.\n");
     return FALSE;
   }
 
   if (gst_tensor_info_validate (&self->tensor_info)) {
     /** compare tensor info */
     if (!gst_tensor_info_is_equal (&self->tensor_info, &config.info)) {
-      err_print ("Failed, mismatched tensor info.\n");
+      GST_ERROR_OBJECT (self, "Failed, mismatched tensor info.\n");
       return FALSE;
     }
   }
index aeb5ee7..6e5d891 100644 (file)
 #define DBG (!self->silent)
 #endif
 
-#define silent_debug(...) \
-    debug_print (DBG, __VA_ARGS__)
+#define silent_debug(...) do { \
+    if (DBG) { \
+      GST_DEBUG_OBJECT (self, __VA_ARGS__); \
+    } \
+  } while (0)
 
 #define silent_debug_caps(caps,msg) do {\
   if (DBG) { \
@@ -74,7 +77,7 @@
       for (caps_idx = 0; caps_idx < caps_size; caps_idx++) { \
         caps_s = gst_caps_get_structure (caps, caps_idx); \
         caps_s_string = gst_structure_to_string (caps_s); \
-        debug_print (TRUE, msg " = %s\n", caps_s_string); \
+        GST_DEBUG_OBJECT (self, msg " = %s\n", caps_s_string); \
         g_free (caps_s_string); \
       } \
     } \
@@ -168,7 +171,7 @@ gst_tensordec_media_caps_from_tensor (GstTensorDec * self,
     return self->decoder->getOutputDim (self, config);
   }
 
-  GST_ERROR ("Decoder plugin not yet configured.");
+  GST_ERROR_OBJECT (self, "Decoder plugin not yet configured.");
   return NULL;
 }
 
@@ -400,7 +403,8 @@ gst_tensordec_set_property (GObject * object, guint prop_id,
       if (NULL != decoder) {
         if (decoder == self->decoder) {
           /* Already configured??? */
-          GST_WARNING ("nnstreamer tensor_decoder %s is already confgured.\n",
+          GST_WARNING_OBJECT (self,
+              "nnstreamer tensor_decoder %s is already confgured.\n",
               temp_string);
         } else {
           /* Changing decoder. Deallocate the previous */
@@ -424,7 +428,8 @@ gst_tensordec_set_property (GObject * object, guint prop_id,
         self->mode = DECODE_MODE_PLUGIN;
         self->output_type = self->decoder->type;
       } else {
-        GST_ERROR ("The given mode for tensor_decoder, %s, is unrecognized.\n",
+        GST_ERROR_OBJECT (self,
+            "The given mode for tensor_decoder, %s, is unrecognized.\n",
             temp_string);
         if (NULL != self->decoder) {
           if (self->cleanup_plugin_data) {
@@ -512,17 +517,17 @@ gst_tensordec_configure (GstTensorDec * self, const GstCaps * caps)
   structure = gst_caps_get_structure (caps, 0);
 
   if (!gst_tensors_config_from_structure (&config, structure)) {
-    err_print ("Cannot configure tensor from structure");
+    GST_ERROR_OBJECT (self, "Cannot configure tensor from structure");
     return FALSE;
   }
 
   if (!gst_tensors_config_validate (&config)) {
-    err_print ("Not configured yet");
+    GST_ERROR_OBJECT (self, "Not configured yet");
     return FALSE;
   }
 
   if (self->configured && !gst_tensordec_check_consistency (self, &config)) {
-    err_print ("Mismatched to old metadata");
+    GST_ERROR_OBJECT (self, "Mismatched to old metadata");
     return FALSE;
   }
 
@@ -541,7 +546,7 @@ gst_tensordec_configure (GstTensorDec * self, const GstCaps * caps)
     return TRUE;
   }
 
-  GST_WARNING ("Decoder plugin is not yet configured.");
+  GST_WARNING_OBJECT (self, "Decoder plugin is not yet configured.");
   return FALSE;
 }
 
@@ -585,18 +590,18 @@ gst_tensordec_transform (GstBaseTransform * trans,
     for (i = 0; i < num_tensors; i++)
       gst_memory_unmap (in_mem[i], &in_info[i]);
   } else {
-    GST_ERROR ("Decoder plugin not yet configured.");
+    GST_ERROR_OBJECT (self, "Decoder plugin not yet configured.");
     goto unknown_type;
   }
 
   return res;
 
 unknown_format:
-  err_print ("Hit unknown_format");
+  GST_ERROR_OBJECT (self, "Hit unknown_format");
   GST_ELEMENT_ERROR (self, CORE, NOT_IMPLEMENTED, (NULL), ("unknown format"));
   return GST_FLOW_NOT_NEGOTIATED;
 unknown_tensor:
-  err_print ("Hit unknown_tensor");
+  GST_ERROR_OBJECT (self, "Hit unknown_tensor");
   GST_ELEMENT_ERROR (self, CORE, NOT_IMPLEMENTED, (NULL),
       ("unknown format for tensor"));
   return GST_FLOW_NOT_NEGOTIATED;
@@ -657,7 +662,7 @@ gst_tensordec_transform_caps (GstBaseTransform * trans,
 
   silent_debug_caps (result, "to");
 
-  GST_DEBUG_OBJECT (trans, "Direction[%d] transformed %" GST_PTR_FORMAT
+  GST_DEBUG_OBJECT (self, "Direction[%d] transformed %" GST_PTR_FORMAT
       " into %" GST_PTR_FORMAT, direction, caps, result);
   return result;
 }
@@ -678,7 +683,7 @@ gst_tensordec_fixate_caps (GstBaseTransform * trans,
   silent_debug_caps (caps, "from caps");
   silent_debug_caps (othercaps, "from othercaps");
 
-  GST_DEBUG_OBJECT (trans, "trying to fixate othercaps %" GST_PTR_FORMAT
+  GST_DEBUG_OBJECT (self, "trying to fixate othercaps %" GST_PTR_FORMAT
       " based on caps %" GST_PTR_FORMAT, othercaps, caps);
 
   /** @todo The code below assumes that direction is GST_PAD_SINK */
@@ -702,7 +707,7 @@ gst_tensordec_fixate_caps (GstBaseTransform * trans,
     gst_caps_unref (othercaps);
   }
 
-  GST_DEBUG_OBJECT (trans, "now fixating %" GST_PTR_FORMAT, result);
+  GST_DEBUG_OBJECT (self, "now fixating %" GST_PTR_FORMAT, result);
 
   result = gst_caps_make_writable (result);
   result = gst_caps_fixate (result);
@@ -736,7 +741,8 @@ gst_tensordec_set_caps (GstBaseTransform * trans,
 
     /** Check if outcaps ==equivalent== supposed */
     if (!gst_caps_is_always_compatible (outcaps, supposed)) {
-      GST_ERROR ("This is not compatible with the supposed output pad cap");
+      GST_ERROR_OBJECT (self,
+          "This is not compatible with the supposed output pad cap");
       gst_caps_unref (supposed);
       return FALSE;
     }
@@ -775,10 +781,10 @@ gst_tensordec_transform_size (GstBaseTransform * trans,
       *othersize = 0;
 
     return TRUE;
-  } else {
-    GST_ERROR ("Decoder plugin not yet configured.");
-    return FALSE;
   }
+
+  GST_ERROR_OBJECT (self, "Decoder plugin not yet configured.");
+  return FALSE;
 }
 
 /**
index 7c1ff30..ee3de9d 100644 (file)
 /**
  * @brief Macro for debug message.
  */
-#define silent_debug(...) \
-    debug_print (DBG, __VA_ARGS__)
+#define silent_debug(...) do { \
+    if (DBG) { \
+      GST_DEBUG_OBJECT (self, __VA_ARGS__); \
+    } \
+  } while (0)
 
 #define silent_debug_caps(caps,msg) do { \
   if (DBG) { \
@@ -82,7 +85,7 @@
       for (caps_idx = 0; caps_idx < caps_size; caps_idx++) { \
         caps_s = gst_caps_get_structure (caps, caps_idx); \
         caps_s_string = gst_structure_to_string (caps_s); \
-        debug_print (TRUE, msg " = %s\n", caps_s_string); \
+        GST_DEBUG_OBJECT (self, msg " = %s\n", caps_s_string); \
         g_free (caps_s_string); \
       } \
     } \
   if (DBG) { \
     guint info_idx; \
     gchar *dim_str; \
-    debug_print (TRUE, msg " total %d", (i)->num_tensors); \
+    GST_DEBUG_OBJECT (self, msg " total %d", (i)->num_tensors); \
     for (info_idx = 0; info_idx < (i)->num_tensors; info_idx++) { \
       dim_str = get_tensor_dimension_string ((i)->info[info_idx].dimension); \
-      debug_print (TRUE, "[%d] type=%d dim=%s", info_idx, (i)->info[info_idx].type, dim_str); \
+      GST_DEBUG_OBJECT (self, "[%d] type=%d dim=%s", info_idx, (i)->info[info_idx].type, dim_str); \
       g_free (dim_str); \
     } \
   } \
@@ -925,7 +928,7 @@ gst_tensor_filter_configure_tensor (GstTensorFilter * self,
       }
 
       if (!prop->output_configured) {
-        err_print ("Failed to get output tensor info.\n");
+        GST_ERROR_OBJECT (self, "Failed to get output tensor info.\n");
         g_assert (0);
         return FALSE;
       }
@@ -1048,7 +1051,7 @@ gst_tensor_filter_transform_caps (GstBaseTransform * trans,
         if (res == 0) {
           result = gst_tensor_filter_caps_from_config (self, &config);
         } else {
-          err_print ("Cannot get the output tensor info.");
+          GST_ERROR_OBJECT (self, "Cannot get the output tensor info.");
           g_assert (0);
           result = gst_caps_from_string (CAPS_STRING);
         }
@@ -1135,17 +1138,17 @@ gst_tensor_filter_set_caps (GstBaseTransform * trans,
   silent_debug_caps (outcaps, "outcaps");
 
   if (!gst_tensor_filter_configure_tensor (self, incaps)) {
-    silent_debug ("Failed to configure tensor.");
+    GST_ERROR_OBJECT (self, "Failed to configure tensor.");
     return FALSE;
   }
 
   if (!gst_tensors_config_validate (&self->in_config)) {
-    silent_debug ("Failed to validate input tensor.");
+    GST_ERROR_OBJECT (self, "Failed to validate input tensor.");
     return FALSE;
   }
 
   if (!gst_tensors_config_validate (&self->out_config)) {
-    silent_debug ("Failed to validate output tensor.");
+    GST_ERROR_OBJECT (self, "Failed to validate output tensor.");
     return FALSE;
   }
 
@@ -1154,7 +1157,7 @@ gst_tensor_filter_set_caps (GstBaseTransform * trans,
   gst_tensors_config_from_structure (&config, structure);
 
   if (!gst_tensors_config_is_equal (&self->out_config, &config)) {
-    silent_debug ("Invalid outcaps.");
+    GST_ERROR_OBJECT (self, "Invalid outcaps.");
     return FALSE;
   }
 
index cb10efe..11c7701 100644 (file)
@@ -83,7 +83,7 @@ custom_loadlib (const GstTensorFilter * filter, void **private_data)
       *((NNStreamer_custom_class **) dlsym (ptr->handle, "NNStreamer_custom"));
   dlsym_error = dlerror ();
   if (dlsym_error) {
-    err_print ("tensor_filter_custom:loadlib error: %s\n", dlsym_error);
+    GST_ERROR ("tensor_filter_custom:loadlib error: %s\n", dlsym_error);
     dlclose (ptr->handle);
     g_free (ptr);
     *private_data = NULL;
index d602ed2..dee0c23 100644 (file)
@@ -75,8 +75,11 @@ GST_DEBUG_CATEGORY_STATIC (gst_tensor_merge_debug);
 /**
  * @brief Macro for debug message.
  */
-#define silent_debug(...) \
-    debug_print (DBG, __VA_ARGS__)
+#define silent_debug(...) do { \
+    if (DBG) { \
+      GST_DEBUG_OBJECT (filter, __VA_ARGS__); \
+    } \
+  } while (0)
 
 enum
 {
@@ -292,7 +295,8 @@ gst_tensor_merge_request_new_pad (GstElement * element, GstPadTemplate * templ,
   tensor_merge = GST_TENSOR_MERGE (element);
 
   if (tensor_merge->tensors_config.info.num_tensors >= NNS_TENSOR_SIZE_LIMIT) {
-    err_print ("supposed max size is " NNS_TENSOR_SIZE_LIMIT_STR);
+    GST_ERROR_OBJECT (tensor_merge,
+        "supposed max size is " NNS_TENSOR_SIZE_LIMIT_STR);
     g_assert (0);
     return NULL;
   }
@@ -759,8 +763,9 @@ gst_tensor_merge_set_option_data (GstTensorMerge * filter)
     }
       break;
     default:
-      g_printerr ("Cannot identify mode\n");
+      GST_ERROR_OBJECT (filter, "Cannot identify mode\n");
       g_assert (0);
+      break;
   }
 }
 
index 1811569..222d678 100644 (file)
@@ -82,8 +82,11 @@ static const gchar *gst_tensor_time_sync_mode_string[] = {
 /**
  * @brief Macro for debug message.
  */
-#define silent_debug(...) \
-    debug_print (DBG, __VA_ARGS__)
+#define silent_debug(...) do { \
+    if (DBG) { \
+      GST_DEBUG_OBJECT (filter, __VA_ARGS__); \
+    } \
+  } while (0)
 
 enum
 {
@@ -247,7 +250,8 @@ gst_tensor_mux_request_new_pad (GstElement * element, GstPadTemplate * templ,
   tensor_mux = GST_TENSOR_MUX (element);
 
   if (tensor_mux->tensors_config.info.num_tensors >= NNS_TENSOR_SIZE_LIMIT) {
-    err_print ("supposed max size is " NNS_TENSOR_SIZE_LIMIT_STR);
+    GST_ERROR_OBJECT (tensor_mux,
+        "supposed max size is " NNS_TENSOR_SIZE_LIMIT_STR);
     g_assert (0);
     return NULL;
   }
index 72f27d8..53eac31 100644 (file)
 /**
  * @brief Macro for debug message.
  */
-#define silent_debug(...) \
-    debug_print (DBG, __VA_ARGS__)
+#define silent_debug(...) do { \
+    if (DBG) { \
+      GST_DEBUG_OBJECT (filter, __VA_ARGS__); \
+    } \
+  } while (0)
 
 #define silent_debug_caps(caps,msg) do { \
   if (DBG) { \
@@ -74,7 +77,7 @@
       for (caps_idx = 0; caps_idx < caps_size; caps_idx++) { \
         caps_s = gst_caps_get_structure (caps, caps_idx); \
         caps_s_string = gst_structure_to_string (caps_s); \
-        debug_print (TRUE, msg " = %s\n", caps_s_string); \
+        GST_DEBUG_OBJECT (filter, msg " = %s\n", caps_s_string); \
         g_free (caps_s_string); \
       } \
     } \
@@ -751,7 +754,7 @@ gst_tensor_transform_set_option_data (GstTensorTransform * filter)
       break;
     }
     default:
-      g_printerr ("Cannot identify mode\n");
+      GST_ERROR_OBJECT (filter, "Cannot identify mode\n");
       g_assert (0);
       break;
   }
@@ -863,8 +866,8 @@ gst_tensor_transform_dimchg (GstTensorTransform * filter,
   if (from == to) {
     /** Useless memcpy. Do not call this or @todo do "IP" operation */
     memcpy (outptr, inptr, gst_tensor_info_get_size (&filter->in_config.info));
-    g_printerr
-        ("Calling tensor_transform with high memcpy overhead WITHOUT any effects! Check your stream wheter you really need tensor_transform.\n");
+    GST_WARNING_OBJECT (filter,
+        "Calling tensor_transform with high memcpy overhead WITHOUT any effects! Check your stream wheter you really need tensor_transform.\n");
     return GST_FLOW_OK;
   }
 
@@ -1062,8 +1065,8 @@ gst_tensor_transform_transpose (GstTensorTransform * filter,
 
   if (!checkdim) {
     memcpy (outptr, inptr, gst_tensor_info_get_size (&filter->in_config.info));
-    g_printerr
-        ("Calling tensor_transform with high memcpy overhead WITHOUT any effects!");
+    GST_WARNING_OBJECT (filter,
+        "Calling tensor_transform with high memcpy overhead WITHOUT any effects!");
     return GST_FLOW_OK;
   }
 
@@ -1144,7 +1147,7 @@ gst_tensor_transform_stand (GstTensorTransform * filter,
       break;
     }
     default:
-      g_printerr ("Cannot identify mode\n");
+      GST_ERROR_OBJECT (filter, "Cannot identify mode\n");
       g_assert (0);
       return GST_FLOW_ERROR;
   }
@@ -1205,12 +1208,14 @@ gst_tensor_transform_transform (GstBaseTransform * trans,
 
 /**
  * @brief Read cap, parse tensor configuration (dim/type) from the cap.
+ * @param[in] filter "this" pointer
  * @param[in] caps The input caps to be read
  * @param[out] config configured tensor info
  * @return TRUE if successful (both dim/type read). FALSE if not.
  */
 static gboolean
-gst_tensor_transform_read_caps (const GstCaps * caps, GstTensorConfig * config)
+gst_tensor_transform_read_caps (GstTensorTransform * filter,
+    const GstCaps * caps, GstTensorConfig * config)
 {
   GstStructure *structure;
 
@@ -1219,7 +1224,8 @@ gst_tensor_transform_read_caps (const GstCaps * caps, GstTensorConfig * config)
   structure = gst_caps_get_structure (caps, 0);
 
   if (!gst_structure_has_name (structure, "other/tensor")) {
-    err_print ("caps is not tensor %s\n", gst_structure_get_name (structure));
+    GST_WARNING_OBJECT (filter, "caps is not tensor %s\n",
+        gst_structure_get_name (structure));
     return FALSE;
   }
 
@@ -1393,7 +1399,7 @@ gst_tensor_transform_transform_caps (GstBaseTransform * trans,
   gst_tensor_config_init (&in_config);
   gst_tensor_config_init (&out_config);
 
-  if (gst_tensor_transform_read_caps (caps, &in_config)) {
+  if (gst_tensor_transform_read_caps (filter, caps, &in_config)) {
     gst_tensor_transform_convert_dimension (filter, direction,
         &in_config.info, &out_config.info);
   }
@@ -1464,22 +1470,22 @@ gst_tensor_transform_set_caps (GstBaseTransform * trans,
   silent_debug_caps (incaps, "incaps");
   silent_debug_caps (outcaps, "outcaps");
 
-  if (!gst_tensor_transform_read_caps (incaps, &in_config) ||
+  if (!gst_tensor_transform_read_caps (filter, incaps, &in_config) ||
       !gst_tensor_config_validate (&in_config)) {
-    silent_debug ("Cannot read cap of incaps\n");
+    GST_ERROR_OBJECT (filter, "Cannot read cap of incaps\n");
     goto error;
   }
 
-  if (!gst_tensor_transform_read_caps (outcaps, &out_config) ||
+  if (!gst_tensor_transform_read_caps (filter, outcaps, &out_config) ||
       !gst_tensor_config_validate (&out_config)) {
-    silent_debug ("Cannot read cap of outcaps\n");
+    GST_ERROR_OBJECT (filter, "Cannot read cap of outcaps\n");
     goto error;
   }
 
   /* check framerate */
   if (in_config.rate_n != out_config.rate_n
       || in_config.rate_d != out_config.rate_d) {
-    silent_debug ("Framerate is not matched\n");
+    GST_ERROR_OBJECT (filter, "Framerate is not matched\n");
     goto error;
   }
 
@@ -1487,7 +1493,8 @@ gst_tensor_transform_set_caps (GstBaseTransform * trans,
   if (!gst_tensor_transform_convert_dimension (filter, GST_PAD_SINK,
           &in_config.info, &config.info) ||
       !gst_tensor_info_is_equal (&out_config.info, &config.info)) {
-    silent_debug ("Tensor info is not matched with given properties.\n");
+    GST_ERROR_OBJECT (filter,
+        "Tensor info is not matched with given properties.\n");
     goto error;
   }
 
@@ -1497,7 +1504,7 @@ gst_tensor_transform_set_caps (GstBaseTransform * trans,
 
   return TRUE;
 error:
-  silent_debug ("Set Caps Failed!\n");
+  GST_ERROR_OBJECT (filter, "Set Caps Failed!\n");
   return FALSE;
 }
 
index 10cbb49..a2fbba6 100644 (file)
@@ -254,7 +254,7 @@ gst_tensors_check (Gsttensorscheck * filter, GstBuffer * inbuf)
 
   /** Get number of tensors */
   num_tensors = filter->in_config.info.num_tensors;
-  debug_print (!filter->silent, "Number of Tensors : %d\n", num_tensors);
+  GST_DEBUG_OBJECT (filter, "Number of Tensors : %d\n", num_tensors);
 
   for (i = 0; i < num_tensors; i++) {
     GstMemory *mem;
@@ -291,7 +291,7 @@ gst_tensorscheck_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
 
   filter = GST_TENSORSCHECK (parent);
 
-  GST_LOG_OBJECT (filter, "Received %s event: %" GST_PTR_FORMAT,
+  GST_DEBUG_OBJECT (filter, "Received %s event: %" GST_PTR_FORMAT,
       GST_EVENT_TYPE_NAME (event), event);
 
   switch (GST_EVENT_TYPE (event)) {