Use common gst macros to print debug logs.
TODO: remove log macro in common header
Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
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;
}
break;
default:
/** unsupported format */
- err_print ("Unsupported format = %d\n", format);
+ GST_WARNING ("Unsupported format = %s\n",
+ format_string ? format_string : "Unknown");
break;
}
break;
default:
/** unsupported format */
- err_print ("Unsupported format = %d\n", format);
+ GST_WARNING ("Unsupported format = %s\n",
+ format_string ? format_string : "Unknown");
break;
}
config->info.type = _NNS_UINT8;
} else {
/** unsupported format */
- err_print ("Unsupported format\n");
+ GST_WARNING ("Unsupported format = %s\n", format_string);
}
}
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;
}
&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;
}
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) {
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) {
g_strfreev (str_types);
}
} else {
- err_print ("Unsupported type = %s\n", name);
+ GST_WARNING ("Unsupported type = %s\n", name ? name : "Unknown");
return FALSE;
}
/**
* @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) { \
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); \
} \
} \
#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)
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)) {
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;
}
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)) {
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)) {
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;
}
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;
}
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;
}
* 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;
}
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;
}
}
#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) { \
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); \
} \
} \
return self->decoder->getOutputDim (self, config);
}
- GST_ERROR ("Decoder plugin not yet configured.");
+ GST_ERROR_OBJECT (self, "Decoder plugin not yet configured.");
return NULL;
}
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 */
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) {
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;
}
return TRUE;
}
- GST_WARNING ("Decoder plugin is not yet configured.");
+ GST_WARNING_OBJECT (self, "Decoder plugin is not yet configured.");
return FALSE;
}
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;
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;
}
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 */
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);
/** 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;
}
*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;
}
/**
/**
* @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) { \
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); \
} \
} \
}
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;
}
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);
}
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;
}
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;
}
*((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;
/**
* @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
{
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;
}
}
break;
default:
- g_printerr ("Cannot identify mode\n");
+ GST_ERROR_OBJECT (filter, "Cannot identify mode\n");
g_assert (0);
+ break;
}
}
/**
* @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
{
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;
}
/**
* @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) { \
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); \
} \
} \
break;
}
default:
- g_printerr ("Cannot identify mode\n");
+ GST_ERROR_OBJECT (filter, "Cannot identify mode\n");
g_assert (0);
break;
}
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;
}
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;
}
break;
}
default:
- g_printerr ("Cannot identify mode\n");
+ GST_ERROR_OBJECT (filter, "Cannot identify mode\n");
g_assert (0);
return GST_FLOW_ERROR;
}
/**
* @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;
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;
}
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);
}
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;
}
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;
}
return TRUE;
error:
- silent_debug ("Set Caps Failed!\n");
+ GST_ERROR_OBJECT (filter, "Set Caps Failed!\n");
return FALSE;
}
/** 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;
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)) {