*/
#define gst_tensor_filter_open_fw(filter) do { \
if (filter->prop.fw_opened == FALSE) { \
- if (filter->fw->open != NULL) \
- filter->fw->open (filter, &filter->privateData); \
- filter->prop.fw_opened = TRUE; \
+ if (filter->fw->open != NULL) {\
+ if (filter->fw->open (filter, &filter->privateData) == 0) \
+ filter->prop.fw_opened = TRUE; \
+ else \
+ filter->prop.fw_opened = FALSE; \
+ } else {\
+ filter->prop.fw_opened = TRUE; \
+ } \
} \
} while (0)
*/
#define gst_tensor_filter_call(filter,ret,funcname,...) do { \
gst_tensor_filter_open_fw (filter); \
+ if (filter->prop.fw_opened == FALSE) { \
+ ret = -1; \
+ break; \
+ } \
ret = filter->fw->funcname (filter, &filter->privateData, __VA_ARGS__); \
} while (0)
silent_debug ("Debug mode = %d", self->silent);
break;
case PROP_FRAMEWORK:
- g_assert (prop->nnfw == _T_F_UNDEFINED && value);
- /* Once configures, it cannot be changed in runtime */
+ if (prop->nnfw != _T_F_UNDEFINED) {
+ /** @todo CRITICAL: CLOSE IT before proceeding */
+ if (prop->fw_opened == TRUE)
+ gst_tensor_filter_close_fw (self);
+ }
prop->nnfw = find_key_strv (nnfw_names, g_value_get_string (value));
silent_debug ("Framework = %s\n", g_value_get_string (value));
- g_assert (prop->nnfw != -1);
- g_assert (prop->nnfw != _T_F_UNDEFINED);
- g_assert (tensor_filter_supported[prop->nnfw] != NULL);
+ if (prop->nnfw == -1 || prop->nnfw == _T_F_UNDEFINED) {
+ GST_WARNING ("Cannot identify the given neural network framework, %s\n",
+ g_value_get_string (value));
+ prop->nnfw = _T_F_UNDEFINED;
+ break;
+ }
+ if (tensor_filter_supported[prop->nnfw] == NULL) {
+ GST_WARNING
+ ("The given neural network framework is identified but not supported, %s\n",
+ g_value_get_string (value));
+ prop->nnfw = _T_F_UNDEFINED;
+ break;
+ }
self->fw = tensor_filter_supported[prop->nnfw];
g_assert (self->fw != NULL);
|| self->fw->setInputDimension);
break;
case PROP_MODEL:
- g_assert (prop->model_file == NULL && value);
+ if (prop->model_file) {
+ /** @todo CRITICAL: CLOSE IT before proceeding */
+ if (prop->fw_opened == TRUE)
+ gst_tensor_filter_close_fw (self);
+ g_free ((char *) prop->model_file); /* g_free cannot handle const * */
+ }
+ if (!value) {
+ break;
+ }
/* Once configures, it cannot be changed in runtime */
tmp = g_value_dup_string (value);
silent_debug ("Model = %s\n", tmp);
}
break;
case PROP_CUSTOM:
- g_assert (prop->custom_properties == NULL && value);
- /* Once configures, it cannot be changed in runtime */
+ /* In case updated custom properties in runtime! */
+ g_free ((char *) prop->custom_properties); /* g_free cannot handle const char * */
prop->custom_properties = g_value_dup_string (value);
silent_debug ("Custom Option = %s\n", prop->custom_properties);
break;
#include <stdint.h>
#include <gst/gst.h>
+#include <gst/gstinfo.h>
#include <gst/base/gstbasetransform.h>
#include <tensor_common.h>
* @return 0 if OK. non-zero if error.
*/
- void (*open) (const GstTensorFilter * filter, void **private_data);
+ int (*open) (const GstTensorFilter * filter, void **private_data);
/**< Optional. tensor_filter.c will call this before any of other callbacks and will call once before calling close
*
* @param[in] filter "this" pointer. Use this to read property values
* @param[in/out] private_data A subplugin may save its internal private data here. The subplugin is responsible for alloc/free of this pointer. Normally, open() allocates memory for private_data.
+ * @return 0 if ok. < 0 if error.
*/
void (*close) (const GstTensorFilter * filter, void **private_data);
return 1;
}
+ if (!filter->prop.model_file || filter->prop.model_file[0] == '\0') {
+ /* The .so file path is not given */
+ return -1;
+ }
+
ptr = g_new0 (internal_data, 1); /* Fill Zero! */
*private_data = ptr;
g_assert (*private_data == filter->privateData);
/**
* @brief The open callback for GstTensorFilterFramework. Called before anything else
*/
-static void
+static int
custom_open (const GstTensorFilter * filter, void **private_data)
{
int retval = custom_loadlib (filter, private_data);
internal_data *ptr;
- g_assert (retval == 0); /* This must be called only once */
+ /* This must be called only once */
+ if (retval != 0)
+ return -1;
ptr = *private_data;
g_assert (!ptr->methods->invoke != !ptr->methods->allocate_invoke); /* XOR! */
if (ptr->methods->allocate_invoke)
NNS_support_custom.allocate_in_invoke = TRUE;
+ return 0;
}
/**