Set simple type at tv service
[platform/core/multimedia/mmsvc-core.git] / server / include / muse_server_private.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_PRIVATE_H__
23 #define __MUSE_SERVER_PRIVATE_H__
24
25 #include "muse_server.h"
26 #include "muse_server_config.h"
27 #include "muse_server_connection.h"
28 #include "muse_server_log.h"
29 #include "muse_server_module.h"
30 #include "muse_server_signal.h"
31 #include "muse_server_security.h"
32 #include "muse_server_system.h"
33 #include "muse_server_watchdog.h"
34 #include "muse_server_tool.h"
35 #include <systemd/sd-daemon.h>
36 #include <pwd.h>
37 #include <grp.h>
38 #include <dlfcn.h>
39
40 #ifdef MUSE_TTRACE_LOG
41 #include <trace.h>
42 #endif
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 #undef LOG_TAG
49 #define LOG_TAG                                         "MUSED_SERVER"
50 #define MSG_KEY_PID                                     "pid"
51 #define MS_TIMEOUT_SEC                          1
52 #define MS_TIMEOUT_MSEC                         MS_TIMEOUT_SEC * 1000
53 #define MS_RECV_TRY_COUNT_MAX           3
54 #define MSG_DONE                                        "DONE"
55
56 gboolean ms_ipc_create_msg_dispatch_worker(muse_module_h m);
57 gboolean ms_ipc_create_data_dispatch_worker(muse_module_h m);
58
59 typedef enum {
60         MUSE_SERVER_STATE_IDLE,
61         MUSE_SERVER_STATE_READY
62 } ms_state_e;
63
64 typedef struct _muse_server *muse_server_h;
65
66 typedef struct ms_diag_msg {
67         gboolean thread_stop;
68         int cmd;
69 } ms_diag_msg_t;
70
71 typedef struct ms_diag {
72         GThread *idle_state_thread;
73         GThread *conn_event_thread;
74         GAsyncQueue *msg_aq;
75 } ms_diag_t;
76
77 typedef struct _muse_server {
78         int msg_fd;
79         int data_fd;
80         int type;
81         int stop;
82         int retval;
83         int pid;
84         gboolean daemonize;
85         tbm_bufmgr bufmgr;
86         GMainLoop *main_loop;
87         ms_diag_t diag;
88         ms_config_t *conf;
89         ms_connection_t *connection;
90         ms_module_t *module[MUSE_MODULE_MAX];
91         ms_log_t *log;
92         ms_security_t *security;
93         ms_system_t *system;
94         ms_watchdog_t *watchdog;
95         ms_state_e state;
96         GMutex state_lock;
97         struct timespec tv;
98         char instance_pid_info[MUSE_MSG_LEN_MAX];
99 } muse_server_t;
100
101 typedef struct ms_cmd_dispatch_info {
102         muse_module_command_e cmd;
103         muse_external_storage_info_t storage;
104 } ms_cmd_dispatcher_info_t;
105
106 void ms_setup_syslog(void);
107 void ms_fork(int *notify_fd);
108 pid_t ms_daemonize(int *notify_fd);
109 void ms_daemonize_complete(int notify_fd);
110 void ms_gst_init(char **cmd);
111 void ms_gst_preload_plugin(void);
112 int ms_pidfile_create(const char *path, pid_t pid);
113 void ms_init(char **argv);
114 muse_server_h ms_get_instance(void);
115 gboolean ms_check_module_idx(int idx);
116 ms_module_t *ms_get_module_instance(int idx);
117 int ms_deinit(void);
118 void ms_check_cpu_memory(void);
119 void ms_new(void);
120 void ms_run(void);
121 void ms_cmd_dispatch(muse_module_h m, muse_module_command_e cmd);
122 void ms_terminate(int signo);
123 int ms_get_pid(muse_module_h m);
124 void ms_log_process_info(int pid);
125 void ms_log_user_group_info(void);
126 gboolean ms_is_log_enabled(void);
127 gboolean ms_init_bufmgr(void);
128 void ms_deinit_bufmgr(void);
129 void ms_cmd_dispatch_foreach_func(gpointer data, gpointer user_data);
130 void ms_set_state(ms_state_e state);
131 gboolean ms_is_server_ready(void);
132 gboolean ms_create_ready_file(void);
133 void ms_remove_ready_file(void);
134 const char *ms_get_command_string(int cmd);
135 gboolean ms_module_idx_is_valid(muse_module_h m);
136
137 #ifdef __cplusplus
138 }
139 #endif
140 #endif  /*__MUSE_SERVER_PRIVATE_H__*/