}
/** @brief Public function defined in the header */
+gchar **
+get_all_subplugins (subpluginType type)
+{
+ GString *names;
+ subplugin_info_s info;
+ gchar **list = NULL;
+ gchar *name;
+ guint i, total;
+
+ names = g_string_new (NULL);
+
+ /* get registered subplugins */
+ G_LOCK (splock);
+ if (subplugins[type]) {
+ list = (gchar **) g_hash_table_get_keys_as_array (subplugins[type], NULL);
+ }
+ G_UNLOCK (splock);
+
+ if (list) {
+ name = g_strjoinv (",", list);
+ g_string_append (names, name);
+ g_free (name);
+ }
+
+ /* get subplugins from configuration */
+ total = nnsconf_get_subplugin_info ((nnsconf_type_path) type, &info);
+
+ for (i = 0; i < total; i++) {
+ name = info.names[i];
+
+ if (!list || !g_strv_contains ((const gchar * const *) list, name)) {
+ if (list || i > 0)
+ g_string_append (names, ",");
+
+ g_string_append (names, name);
+ }
+ }
+
+ g_free (list);
+
+ /* finally get the list of subplugins */
+ name = g_string_free (names, FALSE);
+ list = g_strsplit (name, ",", -1);
+ g_free (name);
+
+ return list;
+}
+
+/** @brief Public function defined in the header */
gboolean
register_subplugin (subpluginType type, const char *name, const void *data)
{
GstElementClass *element_class;
GstPadTemplate *pad_template;
GstCaps *pad_caps;
+ gchar **str_array;
guint total, i;
const NNStreamerExternalConverter *ex;
- subplugin_info_s info;
GST_DEBUG_CATEGORY_INIT (gst_tensor_converter_debug, "tensor_converter", 0,
"Element to convert media stream to tensor stream");
append_octet_caps_template (pad_caps);
/* append sub-plugin template caps */
- total = nnsconf_get_subplugin_info (NNSCONF_PATH_CONVERTERS, &info);
- for (i = 0; i < total; i++) {
- ex = nnstreamer_converter_find (info.names[i]);
- if (ex && ex->query_caps)
- gst_caps_append (pad_caps, ex->query_caps (NULL));
+ str_array = get_all_subplugins (NNS_SUBPLUGIN_CONVERTER);
+ if (str_array) {
+ total = g_strv_length (str_array);
+
+ for (i = 0; i < total; i++) {
+ ex = nnstreamer_converter_find (str_array[i]);
+ if (ex && ex->query_caps)
+ gst_caps_append (pad_caps, ex->query_caps (NULL));
+ }
+
+ g_strfreev (str_array);
}
pad_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
break;
case PROP_SUBPLUGINS:
{
- subplugin_info_s sinfo;
+ gchar **str_array = get_all_subplugins (NNS_SUBPLUGIN_CONVERTER);
- nnsconf_get_subplugin_info (NNSCONF_PATH_CONVERTERS, &sinfo);
- g_value_take_string (value, g_strjoinv (",", sinfo.names));
+ if (str_array) {
+ g_value_take_string (value, g_strjoinv (",", str_array));
+ g_strfreev (str_array);
+ } else {
+ g_value_set_string (value, "");
+ }
break;
}
case PROP_SILENT:
static const NNStreamerExternalConverter *
findExternalConverter (const char *media_type)
{
+ gchar **str_array;
guint total, i, j, caps_size;
- subplugin_info_s info;
GstCaps *caps;
const gchar *caps_name;
const NNStreamerExternalConverter *ex;
- total = nnsconf_get_subplugin_info (NNSCONF_PATH_CONVERTERS, &info);
- for (i = 0; i < total; i++) {
- ex = nnstreamer_converter_find (info.names[i]);
+ str_array = get_all_subplugins (NNS_SUBPLUGIN_CONVERTER);
+ if (str_array) {
+ total = g_strv_length (str_array);
+
+ for (i = 0; i < total; i++) {
+ ex = nnstreamer_converter_find (str_array[i]);
- if (ex && ex->query_caps) {
- caps = ex->query_caps (NULL);
- caps_size = gst_caps_get_size (caps);
+ if (ex && ex->query_caps) {
+ caps = ex->query_caps (NULL);
+ caps_size = gst_caps_get_size (caps);
- for (j = 0; j < caps_size; j++) {
- caps_name = gst_structure_get_name (gst_caps_get_structure (caps, j));
- if (g_strcmp0 (media_type, caps_name) == 0) {
- /* found matched media type */
- gst_caps_unref (caps);
- return ex;
+ for (j = 0; j < caps_size; j++) {
+ caps_name = gst_structure_get_name (gst_caps_get_structure (caps, j));
+ if (g_strcmp0 (media_type, caps_name) == 0) {
+ /* found matched media type */
+ gst_caps_unref (caps);
+ g_strfreev (str_array);
+ return ex;
+ }
}
- }
- gst_caps_unref (caps);
+ gst_caps_unref (caps);
+ }
}
+
+ g_strfreev (str_array);
}
return NULL;
break;
case PROP_SUBPLUGINS:
{
- GString *subplugins;
- subplugin_info_s sinfo;
- guint i, total;
+ gchar **str_array = get_all_subplugins (NNS_SUBPLUGIN_FILTER);
- subplugins = g_string_new (NULL);
-
- /* add custom */
- /** @todo Let's not hardcode default subplugins */
- g_string_append (subplugins, "custom,custom-easy");
-
- total = nnsconf_get_subplugin_info (NNSCONF_PATH_FILTERS, &sinfo);
-
- for (i = 0; i < total; ++i) {
- g_string_append (subplugins, ",");
- g_string_append (subplugins, sinfo.names[i]);
+ if (str_array) {
+ g_value_take_string (value, g_strjoinv (",", str_array));
+ g_strfreev (str_array);
+ } else {
+ g_value_set_string (value, "");
}
-
- g_value_take_string (value, g_string_free (subplugins, FALSE));
break;
}
case PROP_ACCELERATOR: