webrtc_ini: Remove global varible for verbose log 31/275631/3 submit/tizen_6.5/20220531.104250
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 27 May 2022 09:56:04 +0000 (18:56 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 31 May 2022 06:01:23 +0000 (15:01 +0900)
It is replaced with new function.

[Version] 0.2.172
[Issue Type] Refactoring

Change-Id: I4591a4e588f080c625523d8c0d0c0542cace2afc
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_ini.c

index eff2e5673a02409eb0e921c35e4724cdea12dbff..f97a5e5530e169c78fb434753d5d14a2fa31aa1b 100644 (file)
@@ -53,10 +53,9 @@ extern "C" {
 #define FONT_COLOR_CYAN     "\033[36m"
 #define FONT_COLOR_GRAY     "\033[37m"
 
-extern bool g_verbose;
 #define LOG_VERBOSE(fmt, arg...) \
 do { \
-       if (g_verbose) \
+       if (_is_verbose_log()) \
                LOGD(FONT_COLOR_RESET""fmt""FONT_COLOR_RESET, ##arg); \
 } while (0)
 
@@ -582,6 +581,7 @@ void _load_ini(webrtc_s *webrtc);
 void _unload_ini(webrtc_s *webrtc);
 ini_item_media_source_s* _ini_get_source_by_type(webrtc_ini_s *ini, int type);
 bool _is_resource_required(webrtc_ini_s *ini);
+bool _is_verbose_log(void);
 
 int _webrtc_stop(webrtc_s *webrtc);
 int _gst_init(webrtc_s *webrtc);
index bb3cd9eb7049fd21ca6baab2c4f11d7a3b250938..819e6bf2f811d69f18c06c96f25329826787437f 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.171
+Version:    0.2.172
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 07a8beb87934570857a397e1b94bd1952f926509..ada526817ae00f2fe505b02187739430d0ff57d3 100644 (file)
@@ -17,8 +17,6 @@
 #include "webrtc_internal.h"
 #include "webrtc_private.h"
 
-bool g_verbose = false;
-
 #define WEBRTC_INI_PATH                   SYSCONFDIR"/multimedia/mmfw_webrtc.ini"
 #define DEFAULT_GENERATE_DOT              true
 #define DEFAULT_DOT_PATH                  "/tmp"
@@ -425,6 +423,24 @@ static void __apply_media_source_setting(webrtc_ini_s *ini, ini_item_media_sourc
                        is_default ? DEFAULT_FEC_PERCENTAGE : ini->media_source.fec_percentage);
 }
 
+bool _is_verbose_log(void)
+{
+       static bool verbose_log = false;
+       static bool read_from_ini = false;
+
+       if (!read_from_ini) {
+               dictionary *dict;
+               if (!(dict = iniparser_load(WEBRTC_INI_PATH)))
+                       LOG_WARNING("could not open ini[%s], use default values", WEBRTC_INI_PATH);
+               verbose_log = __ini_get_boolean(dict, INI_CATEGORY_GENERAL, INI_ITEM_VERBOSE_LOG, DEFAULT_VERBOSE_LOG);
+               if (dict)
+                       iniparser_freedict(dict);
+               read_from_ini = true;
+       }
+
+       return verbose_log;
+}
+
 void _load_ini(webrtc_s *webrtc)
 {
        webrtc_ini_s *ini;
@@ -449,7 +465,7 @@ void _load_ini(webrtc_s *webrtc)
                g_setenv("GST_DEBUG_DUMP_DOT_DIR", ini->general.dot_path, FALSE);
        }
        ini->general.stats_log_period = __ini_get_int(ini->dict, INI_CATEGORY_GENERAL, INI_ITEM_STATS_LOG_PERIOD, DEFAULT_STATS_LOG_PERIOD);
-       ini->general.verbose_log = g_verbose = __ini_get_boolean(ini->dict, INI_CATEGORY_GENERAL, INI_ITEM_VERBOSE_LOG, DEFAULT_VERBOSE_LOG);
+       ini->general.verbose_log = __ini_get_boolean(ini->dict, INI_CATEGORY_GENERAL, INI_ITEM_VERBOSE_LOG, DEFAULT_VERBOSE_LOG);
        ini->general.nice_verbose = __ini_get_boolean(ini->dict, INI_CATEGORY_GENERAL, INI_ITEM_NICE_VERBOSE, DEFAULT_NICE_VERBOSE);
        if (ini->general.nice_verbose)
                g_setenv("NICE_DEBUG", "nice-verbose", TRUE);