4 * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: YoungHun Kim <yh8004.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __MUSE_SERVER_CONFIG_H__
23 #define __MUSE_SERVER_CONFIG_H__
29 #include "muse_core_internal.h"
30 #include <iniparser.h>
32 #define MUSE_LOG "muse:logfile"
33 #define MUSE_LOCK "muse:lockfile"
34 #define MUSE_LOG_PERIOD "muse:log_period"
35 #define MUSE_WATCHDOG_MIN_TIMEOUT "muse:min_timeout"
36 #define MUSE_WATCHDOG_MAX_TIMEOUT "muse:max_timeout"
37 #define MUSE_MEMORY_THRESHOLD "muse:memory_threshold"
38 #define MUSE_CPU_THRESHOLD "muse:cpu_threshold"
39 #define MUSE_WATCH_EXTERNAL_STORAGE "muse:enable_watch_external_storage"
40 #define MUSE_ON_DEMAND_LAUNCH "muse:on_demand"
41 #define MUSE_ON_DEMAND_MAX_IDLE_TIME "muse:on_demand_max_idle_time"
42 #define MUSE_ON_DEMAND_MAX_IDLE_MEMORY "muse:on_demand_max_idle_memory"
43 #define IDLE_STATE_WAIT_TIME "muse:idle_state_wait_time"
44 #define MUSE_GST_PARAM "muse:gstparam"
45 #define MUSE_GST_PRELOAD "muse:gstpreload"
46 #define INI_PARSER_COLON ":"
48 #define PRELOADED "preloaded"
49 #define TIMEOUT "timeout"
50 #define DISABLE_WATCHDOG_API_INDEX "disable_watchdog_api"
51 #define MAX_INSTANCE "max_instance"
52 #define CAUTION_INSTANCE "caution_instance"
54 #define DEFAULT_LOG_PERIOD 900 /* 15 minute */
55 #define DEFAULT_WATCHDOG_MIN_TIMEOUT 5
56 #define DEFAULT_WATCHDOG_MAX_TIMEOUT 60
57 #define DEFAULT_DISPATCH_WATCHDOG_TIMEOUT 10
58 #define DEFAULT_MEMORY_LEAK_THRESHOLD 50000 /* 50MB */
59 #define DEFAULT_CPU_THRESHOLD 100 /* 100% */
60 #define DEFAULT_WATCHDOG_DISABLED_API_INDEX -1 /* Watchdog is applied to all dispatcher functions */
61 #define DEFAULT_MAX_INSTANCE -1 /* Unlimited */
62 #define DEFAULT_CAUTION_INSTANCE -1
63 #define DEFAULT_ON_DEMAND_MAX_IDLE_TIME 600 /* 10 minute */
64 #define DEFAULT_ON_DEMAND_MAX_IDLE_MEMORY 30000 /* 30MB */
65 #define DEFAULT_IDLE_STATE_WAIT_TIME 10 /* seconds */
67 typedef struct host_info {
71 int disable_watchdog_api;
76 typedef struct ms_config {
77 char *host[MUSE_MODULE_MAX];
86 gboolean is_watch_external_storage_enabled;
87 char *gst_param_str[MUSE_PARAM_MAX];
89 host_info_t *host_infos[MUSE_MODULE_MAX];
90 dictionary *muse_dict;
91 gboolean is_on_demand;
94 int idle_state_wait_time;
95 char *gst_preload_plugins;
98 void ms_config_init(ms_config_t *conf);
99 void ms_config_deinit(ms_config_t *conf);
100 char *ms_config_get_host_name(int idx);
101 int ms_config_get_host_cnt(void);
102 int ms_config_get_gst_param_cnt(void);
103 char *ms_config_get_gst_param_str(int idx);
104 char *ms_config_get_gst_preload_plugins(void);
105 char *ms_config_get_path(int idx);
106 char *ms_config_get_preloaded_value(int idx);
107 char *ms_config_get_lockfile(void);
108 gboolean ms_config_is_log_enabled(void);
109 void ms_config_remove_lockfile(void);
110 int ms_config_get_log_period(void);
111 int ms_config_get_min_timeout(void);
112 int ms_config_get_max_timeout(void);
113 int ms_config_get_memory_threshold(void);
114 int ms_config_get_cpu_threshold(void);
115 gboolean ms_config_is_on_demand(void);
116 int ms_config_get_max_idle_time(void);
117 int ms_config_get_idle_state_wait_time(void);
118 int ms_config_get_timeout(int module_idx);
119 int ms_config_get_disable_watchdog_api(int module_idx);
120 int ms_config_get_max_instance(int module_idx);
121 int ms_config_get_caution_instance(int module_idx);
122 gboolean ms_config_is_external_storage_enabled(void);
127 #endif /* __MUSE_SERVER_CONFIG_H__ */