Check the value at idle time for debugging the cpu usage issue
[platform/core/multimedia/mmsvc-core.git] / server / include / muse_server_config.h
1 /*
2  * muse-server
3  *
4  * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: YoungHun Kim <yh8004.kim@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22 #ifndef __MUSE_SERVER_CONFIG_H__
23 #define __MUSE_SERVER_CONFIG_H__
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include "muse_core_internal.h"
30 #include <iniparser.h>
31
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                                                ":"
47 #define PATH                                                                    "path"
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"
53
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 */
66
67 typedef struct host_info {
68         char *path;
69         char *preloaded;
70         int timeout;
71         int disable_watchdog_api;
72         int max_instance;
73         int caution_instance;
74 } host_info_t;
75
76 typedef struct ms_config {
77         char *host[MUSE_MODULE_MAX];
78         int host_cnt;
79         gboolean log_enabled;
80         char *lockfile;
81         int log_period;
82         int min_timeout;
83         int max_timeout;
84         int memory_threshold;
85         int cpu_threshold;
86         gboolean is_watch_external_storage_enabled;
87         char *gst_param_str[MUSE_PARAM_MAX];
88         int gst_param_cnt;
89         host_info_t *host_infos[MUSE_MODULE_MAX];
90         dictionary *muse_dict;
91         gboolean is_on_demand;
92         int max_idle_time;
93         int max_idle_memory;
94         int idle_state_wait_time;
95         char *gst_preload_plugins;
96 } ms_config_t;
97
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);
123
124 #ifdef __cplusplus
125 }
126 #endif
127 #endif /* __MUSE_SERVER_CONFIG_H__ */