if (TRUE == force_reload && TRUE == conf.loaded) {
/* Do Clean Up */
g_free (conf.conffile);
+ conf.conffile = NULL;
for (t = 0; t < NNSCONF_PATH_END; t++) {
if (!g_file_test (conf.conffile, G_FILE_TEST_IS_REGULAR)) {
/* File not found or not configured */
g_free (conf.conffile);
+ conf.conffile = NULL;
if (g_file_test (NNSTREAMER_DEFAULT_CONF_FILE, G_FILE_TEST_IS_REGULAR)) {
conf.conffile = g_strdup (NNSTREAMER_DEFAULT_CONF_FILE);
g_free (strval);
return ret;
}
+
+#define STR_BOOL(x) ((x) ? "TRUE" : "FALSE")
+/**
+ * @brief Print out configurations
+ * @todo Add more configuration values to dump.
+ */
+void
+nnsconf_dump (gchar * str, gulong size)
+{
+ gchar *cur = str;
+ gulong _size = size;
+ gint len;
+
+ if (FALSE == conf.loaded)
+ nnsconf_loadconf (FALSE);
+
+ len = g_snprintf (cur, _size,
+ "Configuration Loaded: %s\n"
+ "Configuration file path: %s\n"
+ " Candidates: envvar(NNSTREAMER_CONF): %s\n"
+ " build-config: %s\n"
+ " hard-coded: %s\n"
+ "[Common]\n"
+ " Enable envvar: %s\n"
+ " Enable sym-linked subplugins: %s\n"
+ "[Filter]\n"
+ " Filter paths from .ini: %s\n"
+ " from envvar: %s\n"
+ " from hard-coded: %s\n", STR_BOOL (conf.loaded),
+ /* 1. Configuration file path */
+ (conf.conffile ? conf.conffile : "<error> config file not loaded"),
+#ifdef __TIZEN__
+ "Not available (Tizen)",
+#else
+ g_getenv (NNSTREAMER_ENVVAR_CONF_FILE),
+#endif
+ NNSTREAMER_CONF_FILE, NNSTREAMER_DEFAULT_CONF_FILE,
+ /* 2. [Common] */
+ STR_BOOL (conf.enable_envvar), STR_BOOL (conf.enable_symlink),
+ /* 3. [Filter] */
+ conf.conf[NNSCONF_PATH_FILTERS].path[CONF_SOURCE_INI],
+ (conf.enable_envvar) ?
+ conf.conf[NNSCONF_PATH_FILTERS].path[CONF_SOURCE_ENVVAR] : "<disabled>",
+ conf.conf[NNSCONF_PATH_FILTERS].path[CONF_SOURCE_HARDCODE]);
+
+ if (len <= 0)
+ g_printerr ("Config dump is too large. The results show partially.\n");
+}
extern gboolean
nnsconf_get_custom_value_bool (const gchar * group, const gchar * key, gboolean def);
+/**
+ * @brief NNStreamer configuration dump as string.
+ * @param[out] str Preallocated string for the output (dump).
+ * @param[in] size The size of given str.
+ */
+extern void
+nnsconf_dump (gchar * str, gulong size);
+
G_END_DECLS
#endif /* __GST_NNSTREAMER_CONF_H__ */
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-only */
+/**
+ * NNStreamer Configuration Checker Utility
+ * Copyright (C) 2020 MyungJoo Ham <myungjoo.ham@samsung.com>
+ */
+/**
+ * @file confchk.c
+ * @date 13 Aug 2020
+ * @brief NNStreamer configuration checker utility
+ * @see http://github.com/nnstreamer/nnstreamer
+ * @author MyungJoo Ham <myungjoo.ham@samsung.com>
+ * @bug No known bugs except for NYI items
+ *
+ * This is a utility for nnstreamer developers.
+ * This shows the effective nnstreamer configurations.
+ *
+ * Internal mechanism:
+ * Load up libnnstreamer.so with gstreamer
+ */
+#include <glib.h>
+#include <gst/gst.h>
+#include <dlfcn.h>
+
+#define STR_BOOL(x) ((x) ? "TRUE" : "FALSE")
+
+static int
+get_nnsconf_dump (const gchar * path)
+{
+ void *handle;
+ void (*nnsconf_dump) (gchar * str, gulong size);
+ gchar dump[8192];
+
+ handle = dlopen (path, RTLD_LAZY);
+ if (!handle) {
+ g_printerr ("Error opening %s: %s\n", path, dlerror ());
+ return -1;
+ }
+
+ nnsconf_dump = dlsym (handle, "nnsconf_dump");
+
+ if (!nnsconf_dump) {
+ g_printerr ("Error loading nnsconf_dump: %s\n", dlerror ());
+ dlclose (handle);
+ return -2;
+ }
+
+ nnsconf_dump (dump, 8192);
+
+ dlclose (handle);
+
+ g_print ("\n");
+ g_print ("NNStreamer configuration:\n");
+ g_print ("============================================================\n");
+ g_print ("%s\n", dump);
+ g_print ("============================================================\n");
+
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ GstPlugin *nnstreamer;
+
+ gst_init (&argc, &argv);
+
+ nnstreamer = gst_plugin_load_by_name ("nnstreamer");
+
+ if (!nnstreamer) {
+ g_printerr
+ ("Cannot load nnstreamer plugin. Please check if nnstreamer is installed and GST_PLUGIN_PATH is properly configured.\n");
+ return -1;
+ }
+
+ g_print ("NNStreamer version: %s\n", gst_plugin_get_version (nnstreamer));
+ g_print (" loaded : %s\n",
+ STR_BOOL (gst_plugin_is_loaded (nnstreamer)));
+ g_print (" path : %s\n", gst_plugin_get_filename (nnstreamer));
+
+ get_nnsconf_dump (gst_plugin_get_filename (nnstreamer));
+
+ return 0;
+}
--- /dev/null
+project('nnstreamer-check', 'c',
+ version: '1.0.0',
+ license: ['LGPL'],
+ meson_version: '>=0.50.0',
+ default_options: [
+ 'werror=true',
+ 'warning_level=1',
+ 'c_std=gnu89',
+ ]
+)
+
+cc = meson.get_compiler('c')
+gst_api_verision = '1.0'
+glib_dep = dependency('glib-2.0')
+gst_dep = dependency('gstreamer-' + gst_api_verision)
+gst_base_dep = dependency('gstreamer-base-' + gst_api_verision)
+libdl_dep = cc.find_library('dl') # DL library
+
+nnstchk_deps = [
+ glib_dep,
+ gst_dep,
+ gst_base_dep,
+ libdl_dep,
+]
+
+nnstchk_exec = executable('nnstreamer-check',
+ 'confchk.c',
+ dependencies: nnstchk_deps,
+ include_directories: ['../../../gst/nnstreamer', '../../../gst/nnstreamer/include'],
+)