Doxygen Book
nnstreamer_conf.c
Go to the documentation of this file.
1 
26 #include <string.h>
27 #include <glib.h>
28 
29 #include "nnstreamer_log.h"
30 #include "nnstreamer_conf.h"
31 #include "nnstreamer_subplugin.h"
32 
38 /* Subplugin Naming Rules */
39 #define NNSTREAMER_PREFIX_DECODER "libnnstreamer_decoder_"
40 #define NNSTREAMER_PREFIX_FILTER "libnnstreamer_filter_"
41 #define NNSTREAMER_PREFIX_CUSTOMFILTERS ""
42 #define NNSTREAMER_PREFIX_CONVERTER "libnnstreamer_converter_"
43 #define NNSTREAMER_PREFIX_TRAINER "libnnstreamer_trainer_"
44 /* Custom filter does not have prefix */
45 
46 /* Env-var names */
47 static const gchar *NNSTREAMER_ENVVAR[NNSCONF_PATH_END] = {
48  [NNSCONF_PATH_FILTERS] = "NNSTREAMER_FILTERS",
49  [NNSCONF_PATH_DECODERS] = "NNSTREAMER_DECODERS",
50  [NNSCONF_PATH_CUSTOM_FILTERS] = "NNSTREAMER_CUSTOMFILTERS",
51  [NNSCONF_PATH_CONVERTERS] = "NNSTREAMER_CONVERTERS",
52  [NNSCONF_PATH_TRAINERS] = "NNSTREAMER_TRAINERS"
53 };
54 
55 static const gchar *NNSTREAMER_PATH[NNSCONF_PATH_END] = {
56  [NNSCONF_PATH_FILTERS] = "/usr/lib/nnstreamer/filters/",
57  [NNSCONF_PATH_DECODERS] = "/usr/lib/nnstreamer/decoders/",
58  [NNSCONF_PATH_CUSTOM_FILTERS] = "/usr/lib/nnstreamer/customfilters/",
59  [NNSCONF_PATH_CONVERTERS] = "/usr/lib/nnstreamer/converters/",
60  [NNSCONF_PATH_TRAINERS] = "/usr/lib/nnstreamer/trainers/"
61 };
62 
63 static const gchar *subplugin_prefixes[] = {
70  [NNSCONF_PATH_END] = NULL
71 };
72 
73 typedef enum
74 {
80 } conf_sources;
81 
82 typedef struct
83 {
84  /*************************************************
85  * Cached Raw Values *
86  * 0: ENVVAR. 1: CONFFILE, 2: Hardcoded *
87  *************************************************/
88  gchar *path[CONF_SOURCE_END];
90  /*************************************************
91  * Processed Values *
92  *************************************************/
93  gchar **files;
94  gchar **names;
96 
97 typedef struct
98 {
99  gboolean loaded;
100  gboolean enable_envvar;
101  gboolean enable_symlink;
103  gchar *conffile;
104  gchar *extra_conffile;
107 } confdata;
108 
109 static confdata conf = { 0 };
110 
114 static gboolean
115 _parse_bool_string (const gchar * strval, gboolean def)
116 {
117  gboolean res = def;
118 
119  if (strval) {
120  /* 1/0, true/false, t/f, yes/no, on/off. case incensitive. */
121  if (strval[0] == '1' || strval[0] == 't' || strval[0] == 'T' ||
122  strval[0] == 'y' || strval[0] == 'Y' ||
123  g_ascii_strncasecmp ("on", strval, 2) == 0) {
124  res = TRUE;
125  } else if (strval[0] == '0' || strval[0] == 'f' || strval[0] == 'F' ||
126  strval[0] == 'n' || strval[0] == 'N' ||
127  g_ascii_strncasecmp ("of", strval, 2) == 0) {
128  res = FALSE;
129  }
130  }
131 
132  return res;
133 }
134 
142 static gchar *
143 _strdup_getenv (const gchar * name)
144 {
149  const gchar *tmp = g_getenv (name);
150 
151  return g_strdup (tmp);
152 }
153 
157 static gboolean
158 _validate_file (nnsconf_type_path type, const gchar * fullpath)
159 {
160  /* ignore directory */
161  if (!fullpath || !g_file_test (fullpath, G_FILE_TEST_IS_REGULAR))
162  return FALSE;
163  /* ignore symbol link file */
164  if (!conf.enable_symlink && g_file_test (fullpath, G_FILE_TEST_IS_SYMLINK))
165  return FALSE;
166  if (type < 0 || type >= NNSCONF_PATH_END)
167  return FALSE;
169  return TRUE;
170 }
171 
182 static gboolean
183 _get_filenames (nnsconf_type_path type, const gchar * dir, GSList ** listF,
184  GSList ** listN, guint * counter)
185 {
186  GDir *gdir;
187  const gchar *entry;
188  gchar *fullpath;
189  gchar *basename;
190  gchar *name;
191  gsize prefix, extension, len;
192 
193  if ((gdir = g_dir_open (dir, 0U, NULL)) == NULL)
194  return FALSE;
195 
196  prefix = strlen (subplugin_prefixes[type]);
197  extension = strlen (NNSTREAMER_SO_FILE_EXTENSION);
198 
199  while (NULL != (entry = g_dir_read_name (gdir))) {
200  /* check file prefix for given type, currently handle .so and .dylib. */
201  if (g_str_has_prefix (entry, subplugin_prefixes[type]) &&
202  g_str_has_suffix (entry, NNSTREAMER_SO_FILE_EXTENSION)) {
203  fullpath = g_build_filename (dir, entry, NULL);
204 
205  if (_validate_file (type, fullpath)) {
206  basename = g_path_get_basename (entry);
207  len = strlen (basename) - prefix - extension;
208  name = g_strndup (basename + prefix, len);
209 
210  *listF = g_slist_prepend (*listF, fullpath);
211  *listN = g_slist_prepend (*listN, name);
212  *counter = *counter + 1;
213 
214  g_free (basename);
215  } else {
216  g_free (fullpath);
217  }
218  }
219  }
220 
221  g_dir_close (gdir);
222  return TRUE;
223 }
224 
228 static gboolean
230  gchar *** filepath)
231 {
232  if (type >= NNSCONF_PATH_END) {
233  /* unknown type */
234  ml_loge ("Failed to get sub-plugins, unknown sub-plugin type.");
235  return FALSE;
236  }
237 
238  if (!conf.loaded) {
239  ml_loge ("Configuration file is not loaded.");
240  return FALSE;
241  }
242 
243  /* Easy custom uses the configuration of custom */
246 
247  *name = conf.conf[type].names;
248  *filepath = conf.conf[type].files;
249  return TRUE;
250 }
251 
255 typedef struct
256 {
257  gchar **vstr;
258  guint cursor;
259  guint size;
260 } vstr_helper;
261 
267 static void
268 _g_list_foreach_vstr_helper (gpointer data, gpointer user_data)
269 {
270  vstr_helper *helper = (vstr_helper *) user_data;
271  g_assert (helper->cursor < helper->size);
272  helper->vstr[helper->cursor] = data;
273  helper->cursor++;
274 }
275 
279 static void
280 _fill_in_vstr (gchar *** fullpath_vstr, gchar *** name_vstr,
281  gchar * searchpath[CONF_SOURCE_END], nnsconf_type_path type)
282 {
283  GSList *lstF = NULL, *lstN = NULL;
284  vstr_helper vstrF, vstrN;
285  guint i, j, counter;
286 
287  counter = 0;
288  for (i = 0; i < CONF_SOURCE_END; i++) {
289  if (searchpath[i]) {
290  /* skip duplicated paths */
291  for (j = i + 1; j < CONF_SOURCE_END; j++) {
292  if (searchpath[j] && !g_strcmp0 (searchpath[i], searchpath[j])) {
293  break;
294  }
295  }
296  if (j == CONF_SOURCE_END)
297  _get_filenames (type, searchpath[i], &lstF, &lstN, &counter);
298  }
299  }
300 
301  /* Because _get_* does "prepend", reverse them to have the correct order. */
302  lstF = g_slist_reverse (lstF);
303  lstN = g_slist_reverse (lstN);
304 
305  *fullpath_vstr = g_malloc0_n (counter + 1, sizeof (gchar *));
306  g_assert (*fullpath_vstr != NULL); /* This won't happen, but doesn't hurt either */
307  *name_vstr = g_malloc0_n (counter + 1, sizeof (gchar *));
308  g_assert (*name_vstr != NULL); /* This won't happen, but doesn't hurt either */
309 
310  vstrF.vstr = *fullpath_vstr;
311  vstrN.vstr = *name_vstr;
312  vstrF.size = counter;
313  vstrN.size = counter;
314  vstrF.cursor = 0;
315  vstrN.cursor = 0;
316  g_slist_foreach (lstF, _g_list_foreach_vstr_helper, (gpointer) & vstrF);
317  g_slist_foreach (lstN, _g_list_foreach_vstr_helper, (gpointer) & vstrN);
318 
319  /* Do not free elements. They are now at vstr */
320  g_slist_free (lstF);
321  g_slist_free (lstN);
322 }
323 
325 static void
326 _fill_subplugin_path (confdata * cdata, GKeyFile * key_file, conf_sources src)
327 {
328  cdata->conf[NNSCONF_PATH_FILTERS].path[src] =
329  g_key_file_get_string (key_file, "filter", "filters", NULL);
330  cdata->conf[NNSCONF_PATH_DECODERS].path[src] =
331  g_key_file_get_string (key_file, "decoder", "decoders", NULL);
332  cdata->conf[NNSCONF_PATH_CUSTOM_FILTERS].path[src] =
333  g_key_file_get_string (key_file, "filter", "customfilters", NULL);
334  cdata->conf[NNSCONF_PATH_CONVERTERS].path[src] =
335  g_key_file_get_string (key_file, "converter", "converters", NULL);
336  cdata->conf[NNSCONF_PATH_TRAINERS].path[src] =
337  g_key_file_get_string (key_file, "trainer", "trainer", NULL);
338 }
339 
341 gboolean
342 nnsconf_loadconf (gboolean force_reload)
343 {
344  const gchar root_path_prefix[] = NNSTREAMER_SYS_ROOT_PATH_PREFIX;
345  GKeyFile *key_file = NULL;
346  guint i, t;
347 
348  if (!force_reload && conf.loaded)
349  return TRUE;
350 
351  if (force_reload && conf.loaded) {
352  /* Do Clean Up */
353  g_free (conf.conffile);
354  conf.conffile = NULL;
356  conf.extra_conffile = NULL;
357 
358  for (t = 0; t < NNSCONF_PATH_END; t++) {
359 
360  for (i = 0; i < CONF_SOURCE_END; i++) {
361  g_free (conf.conf[t].path[i]);
362  }
363 
364  g_strfreev (conf.conf[t].files);
365  g_strfreev (conf.conf[t].names);
366  }
367 
368  /* init with 0 */
369  memset (&conf, 0, sizeof (confdata));
370  }
371 #ifndef __TIZEN__
372 
374  if (conf.conffile && !g_file_test (conf.conffile, G_FILE_TEST_IS_REGULAR)) {
375  g_free (conf.conffile);
376  conf.conffile = NULL;
377  }
378 #endif
379  if (conf.conffile == NULL) {
386  if (g_path_is_absolute (NNSTREAMER_CONF_FILE)) {
387  conf.conffile = g_strdup (NNSTREAMER_CONF_FILE);
388  } else {
390  conf.conffile = g_build_path (G_DIR_SEPARATOR_S, root_path_prefix,
391  NNSTREAMER_CONF_FILE, NULL);
392  }
393 
394  if (!g_file_test (conf.conffile, G_FILE_TEST_IS_REGULAR)) {
395  /* File not found or not configured */
396  g_free (conf.conffile);
397  conf.conffile = NULL;
398 
399  if (g_file_test (NNSTREAMER_DEFAULT_CONF_FILE, G_FILE_TEST_IS_REGULAR)) {
401  } else {
402  /* Try to read from Environmental Variables */
404  }
405  }
406  }
407 
408  if (conf.conffile) {
409  key_file = g_key_file_new ();
410  g_assert (key_file != NULL);
412  /* Read the conf file. It's ok even if we cannot load it. */
413  if (g_key_file_load_from_file (key_file, conf.conffile, G_KEY_FILE_NONE,
414  NULL)) {
415  gchar *value;
416 
417  value = g_key_file_get_string (key_file, "common", "enable_envvar", NULL);
419  g_free (value);
420 
421  value =
422  g_key_file_get_string (key_file, "common", "enable_symlink", NULL);
424  g_free (value);
425 
427  g_key_file_get_string (key_file, "common", "extra_config_path", NULL);
428 
430  }
431 
432  g_key_file_free (key_file);
433 
434  /* load from extra config file */
435  if (conf.extra_conffile) {
436  if (g_file_test (conf.extra_conffile, G_FILE_TEST_IS_REGULAR)) {
437  key_file = g_key_file_new ();
438  g_assert (key_file != NULL);
440  if (g_key_file_load_from_file (key_file, conf.extra_conffile,
441  G_KEY_FILE_NONE, NULL)) {
443  }
444 
445  g_key_file_free (key_file);
446  } else {
447  ml_logw
448  ("Cannot find config file '%s'. You should set a valid path to load extra configuration.",
450  }
451  }
452  } else {
457  ml_logw ("Failed to load the configuration, no config file found.");
458  }
459 
460  for (t = 0; t < NNSCONF_PATH_END; t++) {
462  continue; /* It does not have its own configuration */
463 
464  /* Read from env variables. */
465  if (conf.enable_envvar)
468 
469  /* Strdup the hardcoded */
470  conf.conf[t].path[CONF_SOURCE_HARDCODE] = g_strdup (NNSTREAMER_PATH[t]);
471 
472  /* Fill in conf.files* */
474  conf.conf[t].path, t);
475  }
476 
477  conf.loaded = TRUE;
478  return TRUE;
479 }
480 
482 const gchar *
483 nnsconf_get_fullpath (const gchar * subpluginname, nnsconf_type_path type)
484 {
485  subplugin_info_s info;
486  guint i, total;
487 
489 
490  total = nnsconf_get_subplugin_info (type, &info);
491  for (i = 0; i < total; i++) {
492  if (g_strcmp0 (info.names[i], subpluginname) == 0)
493  return info.paths[i];
494  }
495 
496  return NULL;
497 }
498 
502 gboolean
504 {
506 
507  return _validate_file (type, fullpath);
508 }
509 
515 const gchar *
517 {
518  g_return_val_if_fail (type >= 0 && type <= NNSCONF_PATH_END, NULL);
519  return subplugin_prefixes[type];
520 }
521 
527 guint
529 {
530  gchar **vstr, **vstrFull;
531 
532  g_return_val_if_fail (info != NULL, 0);
533  info->names = info->paths = NULL;
534 
536 
537  if (!_get_subplugin_with_type (type, &vstr, &vstrFull))
538  return 0;
539 
540  info->names = vstr;
541  info->paths = vstrFull;
542 
543  return g_strv_length (vstr);
544 }
545 
549 static GHashTable *custom_table = NULL;
550 
556 gchar *
557 nnsconf_get_custom_value_string (const gchar * group, const gchar * key)
558 {
559  gchar *hashkey = g_strdup_printf ("[%s]%s", group, key);
560  gchar *value = NULL;
561 
562  nnsconf_loadconf (FALSE); /* Load .ini file path */
563 
564  if (NULL == custom_table)
565  custom_table =
566  g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
567 
568  value = g_hash_table_lookup (custom_table, hashkey);
569 
570  if (NULL == value) {
571  /* 1. Read envvar */
572  if (conf.enable_envvar) {
573  gchar *envkey = g_strdup_printf ("NNSTREAMER_%s_%s", group, key);
574 
575  value = _strdup_getenv (envkey);
576  g_free (envkey);
577  }
578 
579  /* 2. Read ini */
580  if (NULL == value && conf.conffile) {
581  g_autoptr (GKeyFile) key_file = g_key_file_new ();
582 
583  g_assert (key_file != NULL);
585  if (g_key_file_load_from_file (key_file, conf.conffile, G_KEY_FILE_NONE,
586  NULL)) {
587  value = g_key_file_get_string (key_file, group, key, NULL);
588  }
589  }
590 
591  if (value) {
592  g_hash_table_insert (custom_table, hashkey, value);
593  } else {
594  g_free (hashkey);
595  }
596  } else {
597  g_free (hashkey);
598  }
599 
600  return g_strdup (value);
601 }
602 
608 gboolean
609 nnsconf_get_custom_value_bool (const gchar * group, const gchar * key,
610  gboolean def)
611 {
612  gchar *strval;
613  gboolean ret;
614 
615  strval = nnsconf_get_custom_value_string (group, key);
616  ret = _parse_bool_string (strval, def);
617 
618  g_free (strval);
619  return ret;
620 }
621 
622 #define STR_BOOL(x) ((x) ? "TRUE" : "FALSE")
623 
627 void
628 nnsconf_dump (gchar * str, gulong size)
629 {
630  gchar *cur = str;
631  gulong _size = size;
632  gint len;
633 
634  if (!conf.loaded)
636 
637  len = g_snprintf (cur, _size,
638  "Configuration Loaded: %s\n"
639  "Configuration file path: %s\n"
640  " Candidates: envvar(NNSTREAMER_CONF): %s\n"
641  " build-config: %s\n"
642  " hard-coded: %s\n"
643  "[Common]\n"
644  " Enable envvar: %s\n"
645  " Enable sym-linked subplugins: %s\n"
646  "[Filter]\n"
647  " Filter paths from .ini: %s\n"
648  " from envvar: %s\n"
649  " from hard-coded: %s\n", STR_BOOL (conf.loaded),
650  /* 1. Configuration file path */
651  (conf.conffile ? conf.conffile : "<error> config file not loaded"),
652 #ifdef __TIZEN__
653  "Not available (Tizen)",
654 #else
655  g_getenv (NNSTREAMER_ENVVAR_CONF_FILE),
656 #endif
658  /* 2. [Common] */
660  /* 3. [Filter] */
662  (conf.enable_envvar) ?
665 
666  if (len <= 0)
667  g_printerr ("Config dump is too large. The results show partially.\n");
668 }
669 
670 typedef struct
671 {
672  gchar *base;
673  gulong size;
674  gulong pos;
675 } dump_buf;
676 
680 static void
681 _foreach_custom_property (GQuark key_id, gpointer data, gpointer user_data)
682 {
683  dump_buf *buf = (dump_buf *) user_data;
684 
685  if (buf->size > buf->pos) {
686  buf->pos += g_snprintf (buf->base + buf->pos, buf->size - buf->pos,
687  " - %s: %s\n", g_quark_to_string (key_id), (gchar *) data);
688  }
689 }
690 
694 void
695 nnsconf_subplugin_dump (gchar * str, gulong size)
696 {
697  static const nnsconf_type_path dump_list_type[] = {
700  };
701  static const char *dump_list_str[] = {
702  "Filter", "Decoder", "Conterver", "Trainer"
703  };
704 
705  dump_buf buf;
706  subplugin_info_s info;
707  guint i, j, ret;
708 
709  if (!conf.loaded)
711 
712  buf.base = str;
713  buf.size = size;
714  buf.pos = 0;
715 
716  for (i = 0; i < sizeof (dump_list_type) / sizeof (nnsconf_type_path); i++) {
717  buf.pos += g_snprintf (buf.base + buf.pos, buf.size - buf.pos,
718  "\n[%s]\n", dump_list_str[i]);
719  if (buf.size <= buf.pos)
720  goto truncated;
721 
722  ret = nnsconf_get_subplugin_info (dump_list_type[i], &info);
723  for (j = 0; j < ret; j++) {
724  GData *data;
725  subpluginType stype = (subpluginType) dump_list_type[i];
726  gchar *sname = info.names[j];
727 
728  if (!get_subplugin (stype, sname))
729  break;
730 
731  buf.pos += g_snprintf (buf.base + buf.pos, buf.size - buf.pos,
732  " %s\n", sname);
733  if (buf.size <= buf.pos)
734  goto truncated;
735 
736  data = subplugin_get_custom_property_desc (stype, sname);
737  if (data) {
738  g_datalist_foreach (&data, _foreach_custom_property, &buf);
739  } else {
740  buf.pos += g_snprintf (buf.base + buf.pos, buf.size - buf.pos,
741  " - No custom property found\n");
742  }
743 
744  if (buf.size <= buf.pos)
745  goto truncated;
746  }
747  }
748  return;
749 
750 truncated:
751  g_printerr ("Config dump is too large. The results show partially.\n");
752 }
confdata::enable_symlink
gboolean enable_symlink
Definition: nnstreamer_conf.c:101
g_assert
g_assert(sizeof(DTYPE_UNSIGNED)==sizeof(DTYPE_SIGNED))
nnsconf_get_custom_value_bool
gboolean nnsconf_get_custom_value_bool(const gchar *group, const gchar *key, gboolean def)
Public function defined in the header.
Definition: nnstreamer_conf.c:609
data
svtc_1 data
Definition: gsttensor_if.c:844
ml_logw
#define ml_logw
Definition: nnstreamer_log.h:77
_strdup_getenv
static gchar * _strdup_getenv(const gchar *name)
Private function to get strdup-ed env-var if it's valid. Otherwise, NULL.
Definition: nnstreamer_conf.c:143
_g_list_foreach_vstr_helper
static void _g_list_foreach_vstr_helper(gpointer data, gpointer user_data)
Private function to help convert linked-list to vstr with foreach @data The element data of linked-li...
Definition: nnstreamer_conf.c:268
NNSTREAMER_PREFIX_FILTER
#define NNSTREAMER_PREFIX_FILTER
Definition: nnstreamer_conf.c:40
FALSE
return FALSE
Definition: gsttensor_transform.c:590
nnstreamer_subplugin.h
Subplugin Manager for NNStreamer.
nnstreamer_conf.h
Internal header for conf/env-var management.
NNSTREAMER_ENVVAR
static const gchar * NNSTREAMER_ENVVAR[NNSCONF_PATH_END]
Definition: nnstreamer_conf.c:47
NNSTREAMER_PREFIX_TRAINER
#define NNSTREAMER_PREFIX_TRAINER
Definition: nnstreamer_conf.c:43
STR_BOOL
#define STR_BOOL(x)
Definition: nnstreamer_conf.c:622
CONF_SOURCE_ENVVAR
@ CONF_SOURCE_ENVVAR
Definition: nnstreamer_conf.c:75
nnstreamer_log.h
Internal log util for NNStreamer plugins and native APIs.
nnsconf_loadconf
gboolean nnsconf_loadconf(gboolean force_reload)
Public function defined in the header.
Definition: nnstreamer_conf.c:342
NNSTREAMER_ENVVAR_CONF_FILE
#define NNSTREAMER_ENVVAR_CONF_FILE
Definition: nnstreamer_conf.h:61
confdata::extra_conffile
gchar * extra_conffile
Definition: nnstreamer_conf.c:104
NNSTREAMER_CONF_FILE
#define NNSTREAMER_CONF_FILE
Definition: nnstreamer_conf.h:59
NNSCONF_PATH_CONVERTERS
@ NNSCONF_PATH_CONVERTERS
Definition: nnstreamer_conf.h:68
NNSCONF_PATH_FILTERS
@ NNSCONF_PATH_FILTERS
Definition: nnstreamer_conf.h:64
vstr_helper::vstr
gchar ** vstr
Definition: nnstreamer_conf.c:257
nnsconf_get_subplugin_name_prefix
const gchar * nnsconf_get_subplugin_name_prefix(nnsconf_type_path type)
Get sub-plugin's name prefix.
Definition: nnstreamer_conf.c:516
dump_buf
Definition: nnstreamer_conf.c:670
CONF_SOURCE_END
@ CONF_SOURCE_END
Definition: nnstreamer_conf.c:79
CONF_SOURCE_INI
@ CONF_SOURCE_INI
Definition: nnstreamer_conf.c:76
NNSCONF_PATH_EASY_CUSTOM_FILTERS
@ NNSCONF_PATH_EASY_CUSTOM_FILTERS
Definition: nnstreamer_conf.h:67
g_free
g_free(self->option[(opnum) - 1])
opnum: \
NNSTREAMER_PATH
static const gchar * NNSTREAMER_PATH[NNSCONF_PATH_END]
Definition: nnstreamer_conf.c:55
NNSCONF_PATH_END
@ NNSCONF_PATH_END
Definition: nnstreamer_conf.h:71
subplugin_info_s::names
gchar ** names
Definition: nnstreamer_conf.h:77
subplugin_conf::names
gchar ** names
Definition: nnstreamer_conf.c:94
nnsconf_validate_file
gboolean nnsconf_validate_file(nnsconf_type_path type, const gchar *fullpath)
Public function to validate sub-plugin library is available.
Definition: nnstreamer_conf.c:503
NNSCONF_PATH_CUSTOM_FILTERS
@ NNSCONF_PATH_CUSTOM_FILTERS
Definition: nnstreamer_conf.h:66
NNSTREAMER_PREFIX_DECODER
#define NNSTREAMER_PREFIX_DECODER
Definition: nnstreamer_conf.c:39
nnsconf_subplugin_dump
void nnsconf_subplugin_dump(gchar *str, gulong size)
Print out the information of registered sub-plugins.
Definition: nnstreamer_conf.c:695
_foreach_custom_property
static void _foreach_custom_property(GQuark key_id, gpointer data, gpointer user_data)
foreach callback for custom property
Definition: nnstreamer_conf.c:681
NNSCONF_PATH_TRAINERS
@ NNSCONF_PATH_TRAINERS
Definition: nnstreamer_conf.h:69
custom_table
static GHashTable * custom_table
Internal cache for the custom key-values.
Definition: nnstreamer_conf.c:549
_get_subplugin_with_type
static gboolean _get_subplugin_with_type(nnsconf_type_path type, gchar ***name, gchar ***filepath)
Private function to get sub-plugins list with type.
Definition: nnstreamer_conf.c:229
confdata::conf
subplugin_conf conf[NNSCONF_PATH_END]
Definition: nnstreamer_conf.c:106
NNSTREAMER_DEFAULT_CONF_FILE
#define NNSTREAMER_DEFAULT_CONF_FILE
Definition: nnstreamer_conf.h:57
nnsconf_type_path
nnsconf_type_path
Definition: nnstreamer_conf.h:63
subpluginType
subpluginType
Definition: nnstreamer_subplugin.h:40
vstr_helper::cursor
guint cursor
Definition: nnstreamer_conf.c:258
dump_buf::size
gulong size
Definition: nnstreamer_conf.c:673
_get_filenames
static gboolean _get_filenames(nnsconf_type_path type, const gchar *dir, GSList **listF, GSList **listN, guint *counter)
Private function to fill in ".so/.dylib list" with fullpath-filenames in a directory.
Definition: nnstreamer_conf.c:183
_fill_in_vstr
static void _fill_in_vstr(gchar ***fullpath_vstr, gchar ***name_vstr, gchar *searchpath[CONF_SOURCE_END], nnsconf_type_path type)
Private function to fill in vstr.
Definition: nnstreamer_conf.c:280
subplugin_conf::files
gchar ** files
Definition: nnstreamer_conf.c:93
conf
static confdata conf
Definition: nnstreamer_conf.c:109
NNSTREAMER_PREFIX_CUSTOMFILTERS
#define NNSTREAMER_PREFIX_CUSTOMFILTERS
Definition: nnstreamer_conf.c:41
confdata
Definition: nnstreamer_conf.c:97
subplugin_conf::path
gchar * path[CONF_SOURCE_END]
Definition: nnstreamer_conf.c:88
ml_loge
#define ml_loge
Definition: nnstreamer_log.h:78
TRUE
return TRUE
Definition: gsttensor_if.c:897
conf_sources
conf_sources
Definition: nnstreamer_conf.c:73
subplugin_prefixes
static const gchar * subplugin_prefixes[]
Definition: nnstreamer_conf.c:63
nnsconf_get_subplugin_info
guint nnsconf_get_subplugin_info(nnsconf_type_path type, subplugin_info_s *info)
Public function to get the list of sub-plugins name and path.
Definition: nnstreamer_conf.c:528
subplugin_info_s
Definition: nnstreamer_conf.h:75
confdata::conffile
gchar * conffile
Definition: nnstreamer_conf.c:103
subplugin_conf
Definition: nnstreamer_conf.c:82
confdata::enable_envvar
gboolean enable_envvar
Definition: nnstreamer_conf.c:100
CONF_SOURCE_HARDCODE
@ CONF_SOURCE_HARDCODE
Definition: nnstreamer_conf.c:77
NNSCONF_PATH_DECODERS
@ NNSCONF_PATH_DECODERS
Definition: nnstreamer_conf.h:65
CONF_SOURCE_EXTRA_CONF
@ CONF_SOURCE_EXTRA_CONF
Definition: nnstreamer_conf.c:78
NNSTREAMER_SO_FILE_EXTENSION
#define NNSTREAMER_SO_FILE_EXTENSION
Definition: nnstreamer_conf.h:53
dump_buf::base
gchar * base
Definition: nnstreamer_conf.c:672
NNSTREAMER_SYS_ROOT_PATH_PREFIX
#define NNSTREAMER_SYS_ROOT_PATH_PREFIX
Definition: nnstreamer_conf.h:43
_fill_subplugin_path
static void _fill_subplugin_path(confdata *cdata, GKeyFile *key_file, conf_sources src)
Private function to fill subplugin path.
Definition: nnstreamer_conf.c:326
_validate_file
static gboolean _validate_file(nnsconf_type_path type, const gchar *fullpath)
Private function to validate .so file can be added to the list.
Definition: nnstreamer_conf.c:158
vstr_helper
Data structure for _g_list_foreach_vstr_helper.
Definition: nnstreamer_conf.c:255
nnsconf_get_custom_value_string
gchar * nnsconf_get_custom_value_string(const gchar *group, const gchar *key)
Public function defined in the header.
Definition: nnstreamer_conf.c:557
dump_buf::pos
gulong pos
Definition: nnstreamer_conf.c:674
confdata::loaded
gboolean loaded
Definition: nnstreamer_conf.c:99
subplugin_get_custom_property_desc
GData * subplugin_get_custom_property_desc(subpluginType type, const char *name)
common interface to get custom property description of a sub-plugin.
Definition: nnstreamer_subplugin.c:359
type
svtc_1 type
Definition: gsttensor_if.c:843
vstr_helper::size
guint size
Definition: nnstreamer_conf.c:259
subplugin_info_s::paths
gchar ** paths
Definition: nnstreamer_conf.h:78
nnsconf_get_fullpath
const gchar * nnsconf_get_fullpath(const gchar *subpluginname, nnsconf_type_path type)
Public function defined in the header.
Definition: nnstreamer_conf.c:483
nnsconf_dump
void nnsconf_dump(gchar *str, gulong size)
Print out configurations.
Definition: nnstreamer_conf.c:628
_parse_bool_string
static gboolean _parse_bool_string(const gchar *strval, gboolean def)
Parse string to get boolean value.
Definition: nnstreamer_conf.c:115
get_subplugin
const void * get_subplugin(subpluginType type, const char *name)
Public function defined in the header.
Definition: nnstreamer_subplugin.c:141
NNSTREAMER_PREFIX_CONVERTER
#define NNSTREAMER_PREFIX_CONVERTER
Definition: nnstreamer_conf.c:42