#define DLOG_TAG "nnstreamer-capi-pipeline"
+#define dlogi(...) \
+ dlog_print (DLOG_INFO, DLOG_TAG, __VA_ARGS__)
+
+#define dlogw(...) \
+ dlog_print (DLOG_WARN, DLOG_TAG, __VA_ARGS__)
+
+#define dloge(...) \
+ dlog_print (DLOG_ERROR, DLOG_TAG, __VA_ARGS__)
+
#define handle_init(type, name, h) \
nns_##type *name= (h); \
nns_pipeline *p; \
element *elem; \
int ret = NNS_ERROR_NONE; \
if (h == NULL) { \
- dlog_print (DLOG_ERROR, DLOG_TAG, \
- "The given handle is invalid"); \
+ dloge ("The given handle is invalid"); \
return NNS_ERROR_INVALID_PARAMETER; \
} \
\
p = name->pipe; \
elem = name->element; \
if (p == NULL || elem == NULL || p != elem->pipe) { \
- dlog_print (DLOG_ERROR, DLOG_TAG, \
- "The handle appears to be broken."); \
+ dloge ("The handle appears to be broken."); \
return NNS_ERROR_INVALID_PARAMETER; \
} \
\
g_mutex_lock (&elem->lock); \
\
if (NULL == g_list_find (elem->handles, name)) { \
- dlog_print (DLOG_ERROR, DLOG_TAG, \
- "The handle does not exists."); \
+ dloge ("The handle does not exists."); \
ret = NNS_ERROR_INVALID_PARAMETER; \
goto unlock_return; \
}
nns_tensors_info_s * tensors_info)
{
if (!gst_tensorsinfo) {
- dlog_print (DLOG_ERROR, DLOG_TAG, "GstTensorsInfo should not be NULL!");
+ dloge ("GstTensorsInfo should not be NULL!");
return NNS_ERROR_INVALID_PARAMETER;
}
num_mems = gst_buffer_n_memory (b);
if (num_mems > NNS_TENSOR_SIZE_LIMIT) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "Number of memory chunks in a GstBuffer exceed the limit: %u > %u",
+ dloge ("Number of memory chunks in a GstBuffer exceed the limit: %u > %u",
num_mems, NNS_TENSOR_SIZE_LIMIT);
return;
}
elem->size = 0;
if (elem->tensorsinfo.num_tensors != num_mems) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The sink event of [%s] cannot be handled because the tensor type mismatches.",
+ dloge
+ ("The sink event of [%s] cannot be handled because the tensor type mismatches.",
elem->name);
gst_caps_unref (caps);
elem->sink = NULL;
size_t sz = gst_tensor_info_get_size (&elem->tensorsinfo.info[i]);
if (sz != size[i]) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The sink event of [%s] cannot be handled because the tensor dimension mismatches.",
+ dloge
+ ("The sink event of [%s] cannot be handled because the tensor dimension mismatches.",
elem->name);
gst_caps_unref (caps);
elem->sink = NULL;
/* Get the data! */
if (gst_buffer_get_size (b) != total_size ||
(elem->size > 0 && total_size != elem->size)) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The buffersize mismatches. All the three values must be the same: %zu, %zu, %zu",
+ dloge
+ ("The buffersize mismatches. All the three values must be the same: %zu, %zu, %zu",
total_size, elem->size, gst_buffer_get_size (b));
g_mutex_unlock (&elem->lock);
return;
if (FALSE == gst_init_check (NULL, NULL, &err)) {
if (err) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "GStreamer has the following error: %s", err->message);
+ dloge ("GStreamer has the following error: %s", err->message);
g_error_free (err);
} else {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "Cannot initialize GStreamer. Unknown reason.");
+ dloge ("Cannot initialize GStreamer. Unknown reason.");
}
return NNS_ERROR_STREAMS_PIPE;
}
pipeline = gst_parse_launch (pipeline_description, &err);
if (pipeline == NULL || err) {
if (err) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "Cannot parse and launch the given pipeline = [%s], %s",
+ dloge ("Cannot parse and launch the given pipeline = [%s], %s",
pipeline_description, err->message);
g_error_free (err);
} else {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "Cannot parse and launch the given pipeline = [%s], unknown reason",
+ dloge
+ ("Cannot parse and launch the given pipeline = [%s], unknown reason",
pipeline_description);
}
return NNS_ERROR_STREAMS_PIPE;
break;
case GST_ITERATOR_RESYNC:
case GST_ITERATOR_ERROR:
- dlog_print (DLOG_WARN, DLOG_TAG,
- "There is an error or a resync-event while inspecting a pipeline. However, we can still execute the pipeline.");
+ dlogw
+ ("There is an error or a resync-event while inspecting a pipeline. However, we can still execute the pipeline.");
case GST_ITERATOR_DONE:
done = TRUE;
}
int ret = NNS_ERROR_NONE;
if (pipe == NULL) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The first argument, pipeline handle is not valid.");
+ dloge ("The first argument, pipeline handle is not valid.");
return NNS_ERROR_INVALID_PARAMETER;
}
if (cb == NULL) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The callback argument, cb, is not valid.");
+ dloge ("The callback argument, cb, is not valid.");
return NNS_ERROR_INVALID_PARAMETER;
}
elem = g_hash_table_lookup (p->namednodes, sinkname);
if (elem == NULL) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "There is no element named [%s] in the pipeline.", sinkname);
+ dloge ("There is no element named [%s] in the pipeline.", sinkname);
ret = NNS_ERROR_INVALID_PARAMETER;
goto unlock_return;
}
if (elem->type != NNSAPI_SINK) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The element [%s] in the pipeline is not a tensor_sink.", sinkname);
+ dloge ("The element [%s] in the pipeline is not a tensor_sink.", sinkname);
ret = NNS_ERROR_INVALID_PARAMETER;
goto unlock_return;
}
int ret = NNS_ERROR_NONE, i;
if (pipe == NULL) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The first argument, pipeline handle is not valid.");
+ dloge ("The first argument, pipeline handle is not valid.");
return NNS_ERROR_INVALID_PARAMETER;
}
elem = g_hash_table_lookup (p->namednodes, srcname);
if (elem == NULL) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "There is no element named [%s] in the pipeline.", srcname);
+ dloge ("There is no element named [%s] in the pipeline.", srcname);
ret = NNS_ERROR_INVALID_PARAMETER;
goto unlock_return;
}
if (elem->type != NNSAPI_SRC) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The element [%s] in the pipeline is not a tensor_src.", srcname);
+ dloge ("The element [%s] in the pipeline is not a tensor_src.", srcname);
ret = NNS_ERROR_INVALID_PARAMETER;
goto unlock_return;
}
/** @todo caps may be NULL for prerolling */
if (caps == NULL) {
- dlog_print (DLOG_WARN, DLOG_TAG,
- "Cannot find caps. The pipeline is not yet negotiated for tensor_src, [%s].",
+ dlogw
+ ("Cannot find caps. The pipeline is not yet negotiated for tensor_src, [%s].",
srcname);
} else {
guint n_caps = gst_caps_get_size (caps);
handle_init (src, src, h);
if (num_tensors < 1 || num_tensors > NNS_TENSOR_SIZE_LIMIT) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The tensor size if invalid. It should be 1 ~ %u; where it is %u",
+ dloge ("The tensor size if invalid. It should be 1 ~ %u; where it is %u",
NNS_TENSOR_SIZE_LIMIT, num_tensors);
ret = NNS_ERROR_INVALID_PARAMETER;
goto unlock_return;
elem->size = 0;
if (elem->tensorsinfo.num_tensors != num_tensors) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The src push of [%s] cannot be handled because the number of tensors in a frame mismatches. %u != %u",
+ dloge
+ ("The src push of [%s] cannot be handled because the number of tensors in a frame mismatches. %u != %u",
elem->name, elem->tensorsinfo.num_tensors, num_tensors);
gst_caps_unref (caps);
elem->sink = NULL;
size_t sz = gst_tensor_info_get_size (&elem->tensorsinfo.info[i]);
if (sz != size[i]) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The sink event of [%s] cannot be handled because the tensor dimension mismatches.",
+ dloge
+ ("The sink event of [%s] cannot be handled because the tensor dimension mismatches.",
elem->name);
gst_caps_unref (caps);
elem->sink = NULL;
elem->size += sz;
if (sz != size[i]) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The given input tensor size (%d'th, %zu bytes) mismatches the source pad (%zu bytes)",
+ dloge
+ ("The given input tensor size (%d'th, %zu bytes) mismatches the source pad (%zu bytes)",
i, size[i], sz);
gst_caps_unref (caps);
elem->sink = NULL;
}
if (elem->size == 0) {
- dlog_print (DLOG_WARN, DLOG_TAG,
- "The pipeline is not ready to accept inputs. The input is ignored.");
+ dlogw ("The pipeline is not ready to accept inputs. The input is ignored.");
ret = NNS_ERROR_TRY_AGAIN;
goto unlock_return;
}
gret = gst_app_src_push_buffer (GST_APP_SRC (elem->element), buffer);
if (gret == GST_FLOW_FLUSHING) {
- dlog_print (DLOG_WARN, DLOG_TAG,
- "The pipeline is not in PAUSED/PLAYING. The input may be ignored.");
+ dlogw ("The pipeline is not in PAUSED/PLAYING. The input may be ignored.");
ret = NNS_ERROR_TRY_AGAIN;
} else if (gret == GST_FLOW_EOS) {
- dlog_print (DLOG_WARN, DLOG_TAG,
- "THe pipeline is in EOS state. The input is ignored.");
+ dlogw ("THe pipeline is in EOS state. The input is ignored.");
ret = NNS_ERROR_STREAMS_PIPE;
}
int ret = NNS_ERROR_NONE;
if (pipe == NULL) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The first argument, pipeline handle, is not valid.");
+ dloge ("The first argument, pipeline handle, is not valid.");
return NNS_ERROR_INVALID_PARAMETER;
}
if (switchname == NULL) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The second argument, switchname, is not valid.");
+ dloge ("The second argument, switchname, is not valid.");
return NNS_ERROR_INVALID_PARAMETER;
}
elem = g_hash_table_lookup (p->namednodes, switchname);
if (elem == NULL) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "There is no switch element named [%s] in the pipeline.", switchname);
+ dloge ("There is no switch element named [%s] in the pipeline.",
+ switchname);
ret = NNS_ERROR_INVALID_PARAMETER;
goto unlock_return;
}
if (elem->type != NNSAPI_SWITCH_INPUT && elem->type != NNSAPI_SWITCH_OUTPUT) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "There is an element named [%s] in the pipeline, but it is not an input/output switch",
+ dloge
+ ("There is an element named [%s] in the pipeline, but it is not an input/output switch",
switchname);
ret = NNS_ERROR_INVALID_PARAMETER;
goto unlock_return;
else if (elem->type == NNSAPI_SWITCH_OUTPUT)
*type = NNS_SWITCH_OUTPUTSELECTOR;
else {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "Internal data of switch-handle [%s] is broken. It is fatal.",
+ dloge ("Internal data of switch-handle [%s] is broken. It is fatal.",
elem->name);
ret = NNS_ERROR_INVALID_PARAMETER;
goto unlock_return;
active_name = gst_pad_get_name (active_pad);
if (!g_strcmp0 (padname, active_name)) {
- dlog_print (DLOG_INFO, DLOG_TAG,
- "Switch is called, but there is no effective changes: %s->%s.",
+ dlogi ("Switch is called, but there is no effective changes: %s->%s.",
active_name, padname);
g_free (active_name);
gst_object_unref (active_pad);
new_pad = gst_element_get_static_pad (elem->element, padname);
if (new_pad == NULL) {
/* Not Found! */
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "Cannot find the pad, [%s], from the switch, [%s].",
+ dloge ("Cannot find the pad, [%s], from the switch, [%s].",
padname, elem->name);
ret = NNS_ERROR_INVALID_PARAMETER;
goto unlock_return;
g_object_set (G_OBJECT (elem->element), "active-pad", new_pad, NULL);
gst_object_unref (new_pad);
- dlog_print (DLOG_INFO, DLOG_TAG,
- "Switched to [%s] successfully at switch [%s].", padname, elem->name);
+ dlogi ("Switched to [%s] successfully at switch [%s].", padname, elem->name);
handle_exit (h);
}
else if (elem->type == NNSAPI_SWITCH_OUTPUT)
it = gst_element_iterate_src_pads (elem->element);
else {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The element, [%s], is supposed to be input/output switch, but it is not. Internal data structure is broken.",
+ dloge
+ ("The element, [%s], is supposed to be input/output switch, but it is not. Internal data structure is broken.",
elem->name);
ret = NNS_ERROR_STREAMS_PIPE;
goto unlock_return;
gst_iterator_resync (it);
break;
case GST_ITERATOR_ERROR:
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "Cannot access the list of pad properly of a switch, [%s].",
+ dloge ("Cannot access the list of pad properly of a switch, [%s].",
elem->name);
ret = NNS_ERROR_STREAMS_PIPE;
break;
g_list_free_full (dllist, g_free); /* This frees all strings as well */
g_free (list);
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "Internal data inconsistency. This could be a bug in nnstreamer. Switch [%s].",
+ dloge
+ ("Internal data inconsistency. This could be a bug in nnstreamer. Switch [%s].",
elem->name);
ret = NNS_ERROR_STREAMS_PIPE;
goto unlock_return;
int ret = NNS_ERROR_NONE;
if (pipe == NULL) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The first argument, pipeline handle, is not valid.");
+ dloge ("The first argument, pipeline handle, is not valid.");
return NNS_ERROR_INVALID_PARAMETER;
}
if (valvename == NULL) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "The second argument, valvename, is not valid.");
+ dloge ("The second argument, valvename, is not valid.");
return NNS_ERROR_INVALID_PARAMETER;
}
elem = g_hash_table_lookup (p->namednodes, valvename);
if (elem == NULL) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "There is no valve element named [%s] in the pipeline.", valvename);
+ dloge ("There is no valve element named [%s] in the pipeline.", valvename);
ret = NNS_ERROR_INVALID_PARAMETER;
goto unlock_return;
}
if (elem->type != NNSAPI_VALVE) {
- dlog_print (DLOG_ERROR, DLOG_TAG,
- "There is an element named [%s] in the pipeline, but it is not a valve",
+ dloge
+ ("There is an element named [%s] in the pipeline, but it is not a valve",
valvename);
ret = NNS_ERROR_INVALID_PARAMETER;
goto unlock_return;
if ((valve_drop != 0) == (drop != FALSE)) {
/* Nothing to do */
- dlog_print (DLOG_INFO, DLOG_TAG,
- "Valve is called, but there is no effective changes: %d->%d",
+ dlogi ("Valve is called, but there is no effective changes: %d->%d",
! !drop, ! !valve_drop);
goto unlock_return;
}
g_object_set (G_OBJECT (elem->element), "drop", ! !valve_drop, NULL);
- dlog_print (DLOG_INFO, DLOG_TAG,
- "Valve is changed: %d->%d", ! !drop, ! !valve_drop);
+ dlogi ("Valve is changed: %d->%d", ! !drop, ! !valve_drop);
handle_exit (h);
}