NNStreamer Configuration (conf file, env-var) Management. More...
#include <string.h>
#include <glib.h>
#include "nnstreamer_log.h"
#include "nnstreamer_conf.h"
#include "nnstreamer_subplugin.h"
Go to the source code of this file.
Classes | |
struct | subplugin_conf |
struct | confdata |
struct | vstr_helper |
Data structure for _g_list_foreach_vstr_helper. More... | |
struct | dump_buf |
Macros | |
#define | NNSTREAMER_PREFIX_DECODER "libnnstreamer_decoder_" |
#define | NNSTREAMER_PREFIX_FILTER "libnnstreamer_filter_" |
#define | NNSTREAMER_PREFIX_CUSTOMFILTERS "" |
#define | NNSTREAMER_PREFIX_CONVERTER "libnnstreamer_converter_" |
#define | NNSTREAMER_PREFIX_TRAINER "libnnstreamer_trainer_" |
#define | STR_BOOL(x) ((x) ? "TRUE" : "FALSE") |
Enumerations | |
enum | conf_sources { CONF_SOURCE_ENVVAR = 0, CONF_SOURCE_INI = 1, CONF_SOURCE_HARDCODE = 2, CONF_SOURCE_EXTRA_CONF = 3, CONF_SOURCE_END } |
Functions | |
static gboolean | _parse_bool_string (const gchar *strval, gboolean def) |
Parse string to get boolean value. More... | |
static gchar * | _strdup_getenv (const gchar *name) |
Private function to get strdup-ed env-var if it's valid. Otherwise, NULL. More... | |
static gboolean | _validate_file (nnsconf_type_path type, const gchar *fullpath) |
Private function to validate .so file can be added to the list. More... | |
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. More... | |
static gboolean | _get_subplugin_with_type (nnsconf_type_path type, gchar ***name, gchar ***filepath) |
Private function to get sub-plugins list with type. More... | |
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-list @user_data The struct to fill in vstr. More... | |
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. More... | |
static void | _fill_subplugin_path (confdata *cdata, GKeyFile *key_file, conf_sources src) |
Private function to fill subplugin path. More... | |
gboolean | nnsconf_loadconf (gboolean force_reload) |
Public function defined in the header. More... | |
const gchar * | nnsconf_get_fullpath (const gchar *subpluginname, nnsconf_type_path type) |
Public function defined in the header. More... | |
gboolean | nnsconf_validate_file (nnsconf_type_path type, const gchar *fullpath) |
Public function to validate sub-plugin library is available. More... | |
const gchar * | nnsconf_get_subplugin_name_prefix (nnsconf_type_path type) |
Get sub-plugin's name prefix. More... | |
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. More... | |
gchar * | nnsconf_get_custom_value_string (const gchar *group, const gchar *key) |
Public function defined in the header. More... | |
gboolean | nnsconf_get_custom_value_bool (const gchar *group, const gchar *key, gboolean def) |
Public function defined in the header. More... | |
void | nnsconf_dump (gchar *str, gulong size) |
Print out configurations. More... | |
static void | _foreach_custom_property (GQuark key_id, gpointer data, gpointer user_data) |
foreach callback for custom property More... | |
void | nnsconf_subplugin_dump (gchar *str, gulong size) |
Print out the information of registered sub-plugins. More... | |
Variables | |
static const gchar * | NNSTREAMER_ENVVAR [NNSCONF_PATH_END] |
static const gchar * | NNSTREAMER_PATH [NNSCONF_PATH_END] |
static const gchar * | subplugin_prefixes [] |
static confdata | conf = { 0 } |
static GHashTable * | custom_table = NULL |
Internal cache for the custom key-values. More... | |
NNStreamer Configuration (conf file, env-var) Management.
NNStreamer Configurations / Environmental Variable Manager. Copyright (C) 2018 MyungJoo Ham myung joo. ham@s amsu ng.co m
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 2.1 of the License.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
Definition in file nnstreamer_conf.c.
#define NNSTREAMER_PREFIX_CONVERTER "libnnstreamer_converter_" |
Definition at line 42 of file nnstreamer_conf.c.
#define NNSTREAMER_PREFIX_CUSTOMFILTERS "" |
Definition at line 41 of file nnstreamer_conf.c.
#define NNSTREAMER_PREFIX_DECODER "libnnstreamer_decoder_" |
Note that users still can place their custom filters anywhere if they designate them with the full path.
Definition at line 39 of file nnstreamer_conf.c.
#define NNSTREAMER_PREFIX_FILTER "libnnstreamer_filter_" |
Definition at line 40 of file nnstreamer_conf.c.
#define NNSTREAMER_PREFIX_TRAINER "libnnstreamer_trainer_" |
Definition at line 43 of file nnstreamer_conf.c.
#define STR_BOOL | ( | x | ) | ((x) ? "TRUE" : "FALSE") |
Definition at line 622 of file nnstreamer_conf.c.
enum conf_sources |
Enumerator | |
---|---|
CONF_SOURCE_ENVVAR | |
CONF_SOURCE_INI | |
CONF_SOURCE_HARDCODE | |
CONF_SOURCE_EXTRA_CONF | path from extra config file |
CONF_SOURCE_END |
Definition at line 73 of file nnstreamer_conf.c.
|
static |
Private function to fill in vstr.
Definition at line 280 of file nnstreamer_conf.c.
|
static |
Private function to fill subplugin path.
Definition at line 326 of file nnstreamer_conf.c.
|
static |
foreach callback for custom property
Definition at line 681 of file nnstreamer_conf.c.
|
static |
Private function to help convert linked-list to vstr with foreach @data The element data of linked-list @user_data The struct to fill in vstr.
library error? internal logic error?
Definition at line 268 of file nnstreamer_conf.c.
|
static |
Private function to fill in ".so/.dylib list" with fullpath-filenames in a directory.
[in] | type | conf type to scan. |
[in] | dir | Directory to be searched. |
[in/out] | listF The fullpath list to be updated. | |
[in/out] | listN The name list to be updated. | |
[in/out] | counter increased by the number of appended elements. |
Definition at line 183 of file nnstreamer_conf.c.
|
static |
Private function to get sub-plugins list with type.
Definition at line 229 of file nnstreamer_conf.c.
|
static |
Parse string to get boolean value.
Definition at line 115 of file nnstreamer_conf.c.
|
static |
Private function to get strdup-ed env-var if it's valid. Otherwise, NULL.
strdup-ed | env-var value |
[in] | name | Environmental variable name |
Definition at line 143 of file nnstreamer_conf.c.
|
static |
Private function to validate .so file can be added to the list.
Definition at line 158 of file nnstreamer_conf.c.
void nnsconf_dump | ( | gchar * | str, |
gulong | size | ||
) |
Print out configurations.
NNStreamer configuration dump as string.
Definition at line 628 of file nnstreamer_conf.c.
gboolean nnsconf_get_custom_value_bool | ( | const gchar * | group, |
const gchar * | key, | ||
gboolean | def | ||
) |
Public function defined in the header.
Get the custom configuration value from .ini and envvar. @detail For predefined configurations defined in this header, use the given enum for faster configuration processing. For custom configurations not defined in this header, you may use this API to access your own custom configurations. Configuration values may be loaded only once during runtime, thus, if the values are changed in run-time, the changes are not guaranteed to be reflected. The ENVVAR is supposed to be NNSTREAMER_${group}_${key}, which has higher priority than the .ini configuration. Be careful not to use special characters in group name ([, ], _).
Definition at line 609 of file nnstreamer_conf.c.
gchar* nnsconf_get_custom_value_string | ( | const gchar * | group, |
const gchar * | key | ||
) |
Public function defined in the header.
Get the custom configuration value from .ini and envvar. @detail For predefined configurations defined in this header, use the given enum for faster configuration processing. For custom configurations not defined in this header, you may use this API to access your own custom configurations. Configuration values may be loaded only once during runtime, thus, if the values are changed in run-time, the changes are not guaranteed to be reflected. The ENVVAR is supposed to be NNSTREAMER_${group}_${key}, which has higher priority than the .ini configuration. Be careful not to use special characters in group name ([, ], _).
Internal lib error? out-of-memory?
Definition at line 557 of file nnstreamer_conf.c.
const gchar* nnsconf_get_fullpath | ( | const gchar * | subpluginname, |
nnsconf_type_path | type | ||
) |
Public function defined in the header.
Get the configured paths for the type with sub-plugin name.
Definition at line 483 of file nnstreamer_conf.c.
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 at line 528 of file nnstreamer_conf.c.
const gchar* nnsconf_get_subplugin_name_prefix | ( | nnsconf_type_path | type | ) |
Get sub-plugin's name prefix.
[in] | type | The type (FILTERS/DECODERS/CUSTOM_FILTERS) |
Definition at line 516 of file nnstreamer_conf.c.
gboolean nnsconf_loadconf | ( | gboolean | force_reload | ) |
Public function defined in the header.
Load the .ini file.
if it's not Tizen, configuration from env-var has a higher priority
Priority of reading a conf file 1) read from NNSTREAMER_CONF_FILE 2) read from NNSTREAMER_DEFAULT_CONF_FILE 3) read from env-var
default value of 'sysconfdir' in meson is 'etc'
Internal lib error? out-of-memory?
Internal lib error? out-of-memory?
Failed to get the configuration. Note that Android API does not use the configuration.
Definition at line 342 of file nnstreamer_conf.c.
void nnsconf_subplugin_dump | ( | gchar * | str, |
gulong | size | ||
) |
Print out the information of registered sub-plugins.
Definition at line 695 of file nnstreamer_conf.c.
gboolean nnsconf_validate_file | ( | nnsconf_type_path | type, |
const gchar * | fullpath | ||
) |
Public function to validate sub-plugin library is available.
[in] | type | The type (FILTERS/DECODERS/CUSTOM_FILTERS) |
[in] | fullpath | The full path to the file. |
Definition at line 503 of file nnstreamer_conf.c.
|
static |
Definition at line 109 of file nnstreamer_conf.c.
|
static |
Internal cache for the custom key-values.
Definition at line 549 of file nnstreamer_conf.c.
|
static |
Definition at line 47 of file nnstreamer_conf.c.
|
static |
Definition at line 55 of file nnstreamer_conf.c.
|
static |
Definition at line 63 of file nnstreamer_conf.c.