2.0 beta init
[platform/core/multimedia/libmm-player.git] / src / mm_player_ini.c
1 /*
2  * libmm-player
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
7  * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #ifndef __MM_PLAYER_INI_C__
24 #define __MM_PLAYER_INI_C__
25
26 /* includes here */
27 #include <glib.h>
28 #include <stdlib.h>
29 #include "iniparser.h"
30 #include <mm_player_ini.h>
31 #include "mm_debug.h"
32 #include <mm_error.h>
33 #include <glib/gstdio.h>
34
35 /* global variables here */
36 static mm_player_ini_t g_player_ini;
37
38 /* internal functions, macros here */
39 static gboolean __generate_default_ini(void);
40 static void     __get_string_list(gchar** out_list, gchar* str);
41
42 static void __mm_player_ini_force_setting(void);
43 static void __mm_player_ini_check_ini_status(void);
44
45 /* macro */
46 #define MMPLAYER_INI_GET_STRING( x_item, x_ini, x_default ) \
47 do \
48 { \
49         gchar* str = iniparser_getstring(dict, x_ini, x_default); \
50  \
51         if ( str &&  \
52                 ( strlen( str ) > 0 ) && \
53                 ( strlen( str ) < PLAYER_INI_MAX_STRLEN ) ) \
54         { \
55                 strcpy ( x_item, str ); \
56         } \
57         else \
58         { \
59                 strcpy ( x_item, x_default ); \
60         } \
61 }while(0)
62
63 /* x_ini is the list of index to set TRUE at x_list[index] */
64 #define MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( x_list, x_list_max, x_ini, x_default ) \
65 do \
66 { \
67                 int index = 0; \
68                 const char *delimiters = " ,"; \
69                 char *usr_ptr = NULL; \
70                 char *token = NULL; \
71                 gchar temp_arr[PLAYER_INI_MAX_STRLEN] = {0}; \
72                 MMPLAYER_INI_GET_STRING(temp_arr, x_ini, x_default); \
73                 token = strtok_r( temp_arr, delimiters, &usr_ptr ); \
74                 while (token) \
75                 { \
76                         index = atoi(token); \
77                         if (index < 0 || index > x_list_max -1) \
78                         { \
79                                 debug_warning("%d is not valid index\n", index); \
80                         } \
81                         else \
82                         { \
83                                 x_list[index] = TRUE; \
84                         } \
85                         token = strtok_r( NULL, delimiters, &usr_ptr ); \
86                 } \
87 }while(0)
88
89 /* x_ini is the list of value to be set at x_list[index] */
90 #define MMPLAYER_INI_GET_INT_FROM_LIST( x_list, x_list_max, x_ini, x_default ) \
91 do \
92 { \
93                 int index = 0; \
94                 int value = 0; \
95                 const char *delimiters = " ,"; \
96                 char *usr_ptr = NULL; \
97                 char *token = NULL; \
98                 gchar temp_arr[PLAYER_INI_MAX_STRLEN] = {0}; \
99                 MMPLAYER_INI_GET_STRING(temp_arr, x_ini, x_default); \
100                 token = strtok_r( temp_arr, delimiters, &usr_ptr ); \
101                 while (token) \
102                 { \
103                         if ( index > x_list_max -1) \
104                         { \
105                                 debug_error("%d is not valid index\n", index); \
106                                 break; \
107                         } \
108                         else \
109                         { \
110                                 value = atoi(token); \
111                                 x_list[index] = value; \
112                                 index++; \
113                         } \
114                         token = strtok_r( NULL, delimiters, &usr_ptr ); \
115                 } \
116 }while(0)
117
118 int 
119 mm_player_ini_load(void)
120 {
121         static gboolean loaded = FALSE;
122         dictionary * dict = NULL;
123         gint idx = 0;
124
125         if ( loaded )
126                 return MM_ERROR_NONE;
127
128         dict = NULL;
129
130         /* disabling ini parsing for launching */
131 #if 1 //debianize
132         /* get player ini status because system will be crashed 
133          * if ini file is corrupted. 
134          */
135         /* FIXIT : the api actually deleting illregular ini. but the function name said it's just checking. */
136         __mm_player_ini_check_ini_status();
137
138         /* first, try to load existing ini file */
139         dict = iniparser_load(MM_PLAYER_INI_DEFAULT_PATH);
140
141         /* if no file exists. create one with set of default values */
142         if ( !dict )
143         {
144                 #if 0
145                 debug_log("No inifile found. player will create default inifile.\n");
146                 if ( FALSE == __generate_default_ini() )
147                 {       
148                         debug_warning("Creating default inifile failed. Player will use default values.\n");
149                 }
150                 else
151                 {
152                         /* load default ini */
153                         dict = iniparser_load(MM_PLAYER_INI_DEFAULT_PATH);      
154                 }
155                 #else
156                 debug_log("No inifile found. \n");
157
158                 return MM_ERROR_FILE_NOT_FOUND;
159                 #endif
160         }
161 #endif
162
163         /* get ini values */
164         memset( &g_player_ini, 0, sizeof(mm_player_ini_t) );
165
166         if ( dict ) /* if dict is available */
167         {
168                 /* general */
169                 g_player_ini.use_decodebin = iniparser_getboolean(dict, "general:use decodebin", DEFAULT_USE_DECODEBIN);
170                 g_player_ini.disable_segtrap = iniparser_getboolean(dict, "general:disable segtrap", DEFAULT_DISABLE_SEGTRAP);
171                 g_player_ini.skip_rescan = iniparser_getboolean(dict, "general:skip rescan", DEFAULT_SKIP_RESCAN);
172                 g_player_ini.video_surface = DEFAULT_VIDEO_SURFACE;
173                 g_player_ini.generate_dot = iniparser_getboolean(dict, "general:generate dot", DEFAULT_GENERATE_DOT);
174                 g_player_ini.provide_clock= iniparser_getboolean(dict, "general:provide clock", DEFAULT_PROVIDE_CLOCK);
175                 g_player_ini.live_state_change_timeout = iniparser_getint(dict, "general:live state change timeout", DEFAULT_LIVE_STATE_CHANGE_TIMEOUT);
176                 g_player_ini.localplayback_state_change_timeout = iniparser_getint(dict, "general:localplayback state change timeout", DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT);
177                 g_player_ini.eos_delay = iniparser_getint(dict, "general:eos delay", DEFAULT_EOS_DELAY);
178                 g_player_ini.async_start = iniparser_getboolean(dict, "general:async start", DEFAULT_ASYNC_START);
179                 g_player_ini.multiple_codec_supported = iniparser_getboolean(dict, "general:multiple codec supported", DEFAULT_MULTIPLE_CODEC_SUPPORTED);
180
181                 g_player_ini.delay_before_repeat = iniparser_getint(dict, "general:delay before repeat", DEFAULT_DELAY_BEFORE_REPEAT);
182
183                 MMPLAYER_INI_GET_STRING( g_player_ini.videosink_element_x, "general:videosink element x", DEFAULT_VIDEOSINK_X);
184                 MMPLAYER_INI_GET_STRING( g_player_ini.videosink_element_evas, "general:videosink element evas", DEFAULT_VIDEOSINK_EVAS);
185                 MMPLAYER_INI_GET_STRING( g_player_ini.videosink_element_fake, "general:videosink element fake", DEFAULT_VIDEOSINK_FAKE);
186                 MMPLAYER_INI_GET_STRING( g_player_ini.name_of_drmsrc, "general:drmsrc element", DEFAULT_DRMSRC );
187                 MMPLAYER_INI_GET_STRING( g_player_ini.name_of_audiosink, "general:audiosink element", DEFAULT_AUDIOSINK );
188                 MMPLAYER_INI_GET_STRING( g_player_ini.name_of_video_converter, "general:video converter element", DEFAULT_VIDEO_CONVERTER );
189
190                 __get_string_list( (gchar**) g_player_ini.exclude_element_keyword, 
191                         iniparser_getstring(dict, "general:element exclude keyword", DEFAULT_EXCLUDE_KEYWORD));
192
193                 MMPLAYER_INI_GET_STRING( g_player_ini.gst_param[0], "general:gstparam1", DEFAULT_GST_PARAM );
194                 MMPLAYER_INI_GET_STRING( g_player_ini.gst_param[1], "general:gstparam2", DEFAULT_GST_PARAM );
195                 MMPLAYER_INI_GET_STRING( g_player_ini.gst_param[2], "general:gstparam3", DEFAULT_GST_PARAM );
196                 MMPLAYER_INI_GET_STRING( g_player_ini.gst_param[3], "general:gstparam4", DEFAULT_GST_PARAM );
197                 MMPLAYER_INI_GET_STRING( g_player_ini.gst_param[4], "general:gstparam5", DEFAULT_GST_PARAM );
198
199                 /* audio filter (Preset)*/
200                 g_player_ini.use_audio_filter_preset = iniparser_getboolean(dict, "sound effect:audio filter preset", DEFAULT_USE_AUDIO_FILTER_PRESET);
201                 if (g_player_ini.use_audio_filter_preset)
202                 {
203                         MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( g_player_ini.audio_filter_preset_list, MM_AUDIO_FILTER_PRESET_NUM,
204                                         "sound effect:audio filter preset list", DEFAULT_AUDIO_FILTER_PRESET_LIST );
205                         MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( g_player_ini.audio_filter_preset_earphone_only_list, MM_AUDIO_FILTER_PRESET_NUM,
206                                         "sound effect:audio filter preset earphone only", DEFAULT_AUDIO_FILTER_PRESET_LIST_EARPHONE_ONLY );
207                 }
208                 /* for audio filter custom (EQ / Extension filters) */
209                 g_player_ini.use_audio_filter_custom = iniparser_getboolean(dict, "sound effect:audio filter custom", DEFAULT_USE_AUDIO_FILTER_CUSTOM);
210                 if (g_player_ini.use_audio_filter_custom)
211                 {
212                         MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( g_player_ini.audio_filter_custom_list, MM_AUDIO_FILTER_CUSTOM_NUM,
213                                         "sound effect:audio filter custom list", DEFAULT_AUDIO_FILTER_CUSTOM_LIST );
214                         MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( g_player_ini.audio_filter_custom_earphone_only_list, MM_AUDIO_FILTER_CUSTOM_NUM,
215                                         "sound effect:audio filter custom earphone only", DEFAULT_AUDIO_FILTER_CUSTOM_LIST_EARPHONE_ONLY );
216                         /* for audio filter custom : EQ */
217                         if (g_player_ini.audio_filter_custom_list[MM_AUDIO_FILTER_CUSTOM_EQ])
218                         {
219                                 g_player_ini.audio_filter_custom_eq_num = iniparser_getint(dict, "sound effect:audio filter eq num",
220                                                 DEFAULT_AUDIO_FILTER_CUSTOM_EQ_NUM);
221                                 if (g_player_ini.audio_filter_custom_eq_num < DEFAULT_AUDIO_FILTER_CUSTOM_EQ_NUM || g_player_ini.audio_filter_custom_eq_num > MM_AUDIO_FILTER_EQ_BAND_MAX)
222                                 {
223                                         debug_error("audio_filter_custom_eq_num(%d) is not valid range(%d - %d), set the value %d",
224                                                 g_player_ini.audio_filter_custom_eq_num, DEFAULT_AUDIO_FILTER_CUSTOM_EQ_NUM, MM_AUDIO_FILTER_EQ_BAND_MAX, DEFAULT_AUDIO_FILTER_CUSTOM_EQ_NUM);
225                                         g_player_ini.audio_filter_custom_eq_num = DEFAULT_AUDIO_FILTER_CUSTOM_EQ_NUM;
226                                 }
227                         }
228                         /* for audio filter custom : extension filters */
229                         g_player_ini.audio_filter_custom_ext_num = iniparser_getint(dict, "sound effect:audio filter ext num",
230                                         DEFAULT_AUDIO_FILTER_CUSTOM_EXT_NUM);
231                         if (g_player_ini.audio_filter_custom_ext_num > 0)
232                         {
233                                 MMPLAYER_INI_GET_INT_FROM_LIST( g_player_ini.audio_filter_custom_min_level_list, MM_AUDIO_FILTER_CUSTOM_NUM,
234                                                 "sound effect:audio filter custom min list", DEFAULT_AUDIO_FILTER_CUSTOM_LIST );
235                                 MMPLAYER_INI_GET_INT_FROM_LIST( g_player_ini.audio_filter_custom_max_level_list, MM_AUDIO_FILTER_CUSTOM_NUM,
236                                                 "sound effect:audio filter custom max list", DEFAULT_AUDIO_FILTER_CUSTOM_LIST );
237                         }
238                 }
239 #if 0
240                 int i;
241                 for (i=0; i<MM_AUDIO_FILTER_PRESET_NUM; i++)
242                 {
243                         debug_log("audio_filter_preset_list: %d (is it for earphone only?(%d))\n", g_player_ini.audio_filter_preset_list[i], g_player_ini.audio_filter_preset_earphone_only_list[i]);
244                 }
245                 for (i=0; i<MM_AUDIO_FILTER_CUSTOM_NUM; i++)
246                 {
247                         debug_log("audio_filter_custom_list : %d (is it for earphone only?(%d))\n", g_player_ini.audio_filter_custom_list[i], g_player_ini.audio_filter_custom_earphone_only_list[i]);
248                 }
249                 debug_log("audio_filter_custom : eq_num(%d), ext_num(%d)\n", g_player_ini.audio_filter_custom_eq_num, g_player_ini.audio_filter_custom_ext_num )
250                 for (i=0; i<MM_AUDIO_FILTER_CUSTOM_NUM; i++)
251                 {
252                         debug_log("aaudio_filter_custom_level_min_max_list : min(%d), max(%d)\n", g_player_ini.audio_filter_custom_min_level_list[i], g_player_ini.audio_filter_custom_max_level_list[i]);
253                 }
254 #endif
255
256                 /* http streaming */
257                 MMPLAYER_INI_GET_STRING( g_player_ini.name_of_httpsrc, "http streaming:httpsrc element", DEFAULT_HTTPSRC );
258                 MMPLAYER_INI_GET_STRING( g_player_ini.http_file_buffer_path, "http streaming:http file buffer path", DEFAULT_HTTP_FILE_BUFFER_PATH );
259                 g_player_ini.http_buffering_limit = iniparser_getdouble(dict, "http streaming:http buffering high limit", DEFAULT_HTTP_BUFFERING_LIMIT);
260                 g_player_ini.http_max_size_bytes = iniparser_getint(dict, "http streaming:http max size bytes", DEFAULT_HTTP_MAX_SIZE_BYTES);
261                 g_player_ini.http_buffering_time = iniparser_getdouble(dict, "http streaming:http buffering time", DEFAULT_HTTP_BUFFERING_TIME);                
262                 g_player_ini.http_timeout = iniparser_getint(dict, "http streaming:http timeout", DEFAULT_HTTP_TIMEOUT);
263
264                 /* rtsp streaming */
265                 MMPLAYER_INI_GET_STRING( g_player_ini.name_of_rtspsrc, "rtsp streaming:rtspsrc element", DEFAULT_RTSPSRC );
266                 g_player_ini.rtsp_buffering_time = iniparser_getint(dict, "rtsp streaming:rtsp buffering time", DEFAULT_RTSP_BUFFERING);
267                 g_player_ini.rtsp_rebuffering_time = iniparser_getint(dict, "rtsp streaming:rtsp rebuffering time", DEFAULT_RTSP_REBUFFERING);
268                 g_player_ini.rtsp_do_typefinding = iniparser_getboolean(dict, "rtsp streaming:rtsp do typefinding", DEFAULT_RTSP_DO_TYPEFINDING);
269                 g_player_ini.rtsp_error_concealment = iniparser_getboolean(dict, "rtsp streaming:rtsp error concealment", DEFAULT_RTSP_ERROR_CONCEALMENT);
270
271                 /* hw accelation */
272                 g_player_ini.use_video_hw_accel = iniparser_getboolean(dict, "hw accelation:use video hw accel", DEFAULT_USE_VIDEO_HW_ACCEL);
273                 
274                 /* priority */
275                 g_player_ini.use_priority_setting = iniparser_getboolean(dict, "priority:use priority setting", DEFAULT_USE_PRIORITY_SETTING);
276                 g_player_ini.demux_priority = iniparser_getint(dict, "priority:demux", DEFAULT_PRIORITY_DEMUX);
277                 g_player_ini.videosink_priority = iniparser_getint(dict, "priority:videosink", DEFAULT_PRIORITY_VIDEO_SINK);
278                 g_player_ini.audiosink_priority = iniparser_getint(dict, "priority:audiosink", DEFAULT_PRIORITY_AUDIO_SINK);
279                 g_player_ini.ringbuffer_priority = iniparser_getint(dict, "priority:ringbuffer", DEFAULT_PRIORITY_RINGBUFFER);
280         }       
281         else /* if dict is not available just fill the structure with default value */
282         {
283                 debug_warning("failed to load ini. using hardcoded default\n");
284
285                 /* general */
286                 g_player_ini.use_decodebin = DEFAULT_USE_DECODEBIN;
287                 g_player_ini.use_sink_handler = DEFAULT_USE_SINK_HANDLER;
288                 g_player_ini.disable_segtrap = DEFAULT_DISABLE_SEGTRAP;
289                 g_player_ini.use_audio_filter_preset = DEFAULT_USE_AUDIO_FILTER_PRESET;
290                 g_player_ini.use_audio_filter_custom = DEFAULT_USE_AUDIO_FILTER_CUSTOM;
291                 g_player_ini.skip_rescan = DEFAULT_SKIP_RESCAN;
292                 g_player_ini.video_surface = DEFAULT_VIDEO_SURFACE;
293                 strncpy( g_player_ini.videosink_element_x, DEFAULT_VIDEOSINK_X, PLAYER_INI_MAX_STRLEN - 1 );
294                 strncpy( g_player_ini.videosink_element_evas, DEFAULT_VIDEOSINK_EVAS, PLAYER_INI_MAX_STRLEN - 1 );
295                 strncpy( g_player_ini.videosink_element_fake, DEFAULT_VIDEOSINK_FAKE, PLAYER_INI_MAX_STRLEN - 1 );
296                 g_player_ini.generate_dot = DEFAULT_GENERATE_DOT;
297                 g_player_ini.provide_clock= DEFAULT_PROVIDE_CLOCK;
298                 g_player_ini.live_state_change_timeout = DEFAULT_LIVE_STATE_CHANGE_TIMEOUT;
299                 g_player_ini.localplayback_state_change_timeout = DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT;
300                 g_player_ini.eos_delay = DEFAULT_EOS_DELAY;
301                 g_player_ini.multiple_codec_supported = DEFAULT_MULTIPLE_CODEC_SUPPORTED;
302                 g_player_ini.async_start = DEFAULT_ASYNC_START;
303                 g_player_ini.delay_before_repeat = DEFAULT_DELAY_BEFORE_REPEAT;
304
305
306                 strncpy( g_player_ini.name_of_drmsrc, DEFAULT_DRMSRC, PLAYER_INI_MAX_STRLEN - 1 );
307                 strncpy( g_player_ini.name_of_audiosink, DEFAULT_AUDIOSINK, PLAYER_INI_MAX_STRLEN -1 );
308                 strncpy( g_player_ini.name_of_video_converter, DEFAULT_VIDEO_CONVERTER, PLAYER_INI_MAX_STRLEN -1 );
309
310                 {
311                         __get_string_list( (gchar**) g_player_ini.exclude_element_keyword, DEFAULT_EXCLUDE_KEYWORD);
312                 }
313
314
315                 strncpy( g_player_ini.gst_param[0], DEFAULT_GST_PARAM, PLAYER_INI_MAX_PARAM_STRLEN - 1 );
316                 strncpy( g_player_ini.gst_param[1], DEFAULT_GST_PARAM, PLAYER_INI_MAX_PARAM_STRLEN - 1 );
317                 strncpy( g_player_ini.gst_param[2], DEFAULT_GST_PARAM, PLAYER_INI_MAX_PARAM_STRLEN - 1 );
318                 strncpy( g_player_ini.gst_param[3], DEFAULT_GST_PARAM, PLAYER_INI_MAX_PARAM_STRLEN - 1 );
319                 strncpy( g_player_ini.gst_param[4], DEFAULT_GST_PARAM, PLAYER_INI_MAX_PARAM_STRLEN - 1 );
320
321                 /* http streaming */
322                 strncpy( g_player_ini.name_of_httpsrc, DEFAULT_HTTPSRC, PLAYER_INI_MAX_STRLEN - 1 );
323                 strncpy( g_player_ini.http_file_buffer_path, DEFAULT_HTTP_FILE_BUFFER_PATH, PLAYER_INI_MAX_STRLEN - 1 );
324                 g_player_ini.http_buffering_limit = DEFAULT_HTTP_BUFFERING_LIMIT;
325                 g_player_ini.http_max_size_bytes = DEFAULT_HTTP_MAX_SIZE_BYTES;
326                 g_player_ini.http_buffering_time = DEFAULT_HTTP_BUFFERING_TIME;         
327                 g_player_ini.http_timeout = DEFAULT_HTTP_TIMEOUT;
328                 
329                 /* rtsp streaming */
330                 strncpy( g_player_ini.name_of_rtspsrc, DEFAULT_RTSPSRC, PLAYER_INI_MAX_STRLEN - 1 );
331                 g_player_ini.rtsp_buffering_time = DEFAULT_RTSP_BUFFERING;
332                 g_player_ini.rtsp_rebuffering_time = DEFAULT_RTSP_REBUFFERING;
333                 g_player_ini.rtsp_do_typefinding = DEFAULT_RTSP_DO_TYPEFINDING;
334                 g_player_ini.rtsp_error_concealment = DEFAULT_RTSP_ERROR_CONCEALMENT;
335
336                 /* hw accelation */
337                 g_player_ini.use_video_hw_accel = DEFAULT_USE_VIDEO_HW_ACCEL;
338
339                 /* priority  */
340                 g_player_ini.use_priority_setting = DEFAULT_USE_PRIORITY_SETTING;
341                 g_player_ini.demux_priority = DEFAULT_PRIORITY_DEMUX;
342                 g_player_ini.videosink_priority = DEFAULT_PRIORITY_VIDEO_SINK;
343                 g_player_ini.audiosink_priority = DEFAULT_PRIORITY_AUDIO_SINK;
344                 g_player_ini.ringbuffer_priority = DEFAULT_PRIORITY_RINGBUFFER;
345         }
346
347         /* free dict as we got our own structure */
348         iniparser_freedict (dict);
349
350         loaded = TRUE;
351
352         /* The simulator uses a separate ini file. */
353         //__mm_player_ini_force_setting();
354
355
356         /* dump structure */
357         debug_log("player settings -----------------------------------\n");
358
359         /* general */
360         debug_log("use_decodebin : %d\n", g_player_ini.use_decodebin);
361         debug_log("use_audio_filter_preset : %d\n", g_player_ini.use_audio_filter_preset);
362         debug_log("use_audio_filter_custom : %d\n", g_player_ini.use_audio_filter_custom);
363         debug_log("use_sink_handler : %d\n", g_player_ini.use_sink_handler);
364         debug_log("disable_segtrap : %d\n", g_player_ini.disable_segtrap);
365         debug_log("skip rescan : %d\n", g_player_ini.skip_rescan);
366         debug_log("video surface(0:X, 1:EVAS, 2:GL, 3:NULL) : %d\n", g_player_ini.video_surface);
367         debug_log("videosink element x: %s\n", g_player_ini.videosink_element_x);
368         debug_log("videosink element evas: %s\n", g_player_ini.videosink_element_evas);
369         debug_log("videosink element fake: %s\n", g_player_ini.videosink_element_fake);
370         debug_log("generate_dot : %d\n", g_player_ini.generate_dot);
371         debug_log("provide_clock : %d\n", g_player_ini.provide_clock);
372         debug_log("live_state_change_timeout(sec) : %d\n", g_player_ini.live_state_change_timeout);
373         debug_log("localplayback_state_change_timeout(sec) : %d\n", g_player_ini.localplayback_state_change_timeout);   
374         debug_log("eos_delay(msec) : %d\n", g_player_ini.eos_delay);
375         debug_log("delay_before_repeat(msec) : %d\n", g_player_ini.delay_before_repeat);
376         debug_log("name_of_drmsrc : %s\n", g_player_ini.name_of_drmsrc);
377         debug_log("name_of_audiosink : %s\n", g_player_ini.name_of_audiosink);
378         debug_log("name_of_video_converter : %s\n", g_player_ini.name_of_video_converter);
379         debug_log("async_start : %d\n", g_player_ini.async_start);
380         debug_log("multiple_codec_supported : %d\n", g_player_ini.multiple_codec_supported);    
381
382         debug_log("gst_param1 : %s\n", g_player_ini.gst_param[0]);
383         debug_log("gst_param2 : %s\n", g_player_ini.gst_param[1]);
384         debug_log("gst_param3 : %s\n", g_player_ini.gst_param[2]);
385         debug_log("gst_param4 : %s\n", g_player_ini.gst_param[3]);
386         debug_log("gst_param5 : %s\n", g_player_ini.gst_param[4]);
387
388         for ( idx = 0; g_player_ini.exclude_element_keyword[idx][0] != '\0'; idx++ )
389         {
390                 debug_log("exclude_element_keyword [%d] : %s\n", idx, g_player_ini.exclude_element_keyword[idx]);
391         }
392         
393         /* http streaming */
394         debug_log("name_of_httpsrc : %s\n", g_player_ini.name_of_httpsrc);
395         debug_log("http_file_buffer_path : %s \n", g_player_ini.http_file_buffer_path);
396         debug_log("http_buffering_limit : %f \n", g_player_ini.http_buffering_limit);
397         debug_log("http_max_size_bytes : %d \n", g_player_ini.http_max_size_bytes);
398         debug_log("http_buffering_time : %f \n", g_player_ini.http_buffering_time);
399         debug_log("http_timeout : %d \n", g_player_ini.http_timeout);
400         
401         /* rtsp streaming */
402         debug_log("name_of_rtspsrc : %s\n", g_player_ini.name_of_rtspsrc);
403         debug_log("rtsp_buffering_time(msec) : %d\n", g_player_ini.rtsp_buffering_time);
404         debug_log("rtsp_rebuffering_time(msec) : %d\n", g_player_ini.rtsp_rebuffering_time);
405         debug_log("rtsp_do_typefinding : %d \n", g_player_ini.rtsp_do_typefinding);
406         debug_log("rtsp_error_concealment : %d \n", g_player_ini.rtsp_error_concealment);
407
408         /* hw accel */
409         debug_log("use_video_hw_accel : %d\n", g_player_ini.use_video_hw_accel);
410
411         /* priority */
412         debug_log("use_priority_setting : %d\n", g_player_ini.use_priority_setting);
413         debug_log("demux_priority : %d\n", g_player_ini.demux_priority);
414         debug_log("audiosink_priority : %d\n", g_player_ini.audiosink_priority);
415         debug_log("videosink_priority : %d\n", g_player_ini.videosink_priority);
416         debug_log("ringbuffer_priority : %d\n", g_player_ini.ringbuffer_priority);
417
418         debug_log("---------------------------------------------------\n");     
419
420         return MM_ERROR_NONE;
421 }
422
423
424 static
425 void __mm_player_ini_check_ini_status(void)
426 {
427         struct stat ini_buff;
428         
429         if ( g_stat(MM_PLAYER_INI_DEFAULT_PATH, &ini_buff) < 0 )
430         {
431                 debug_warning("failed to get player ini status\n");
432         }
433         else
434         {
435                 if ( ini_buff.st_size < 5 )
436                 {
437                         debug_warning("player.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size);
438                         
439                         g_remove( MM_PLAYER_INI_DEFAULT_PATH );
440                 }
441         }
442 }
443
444 static 
445 void __mm_player_ini_force_setting(void)
446 {
447         /* FIXIT : remove it when all other elements are available on simulator, SDK */
448         
449         #if ! defined(__arm__)
450                 debug_warning("player is running on simulator. force to use ximagesink\n");
451                 //g_player_ini.videosink_element = PLAYER_INI_VSINK_XIMAGESINK;
452                 g_player_ini.use_audio_filter_preset = FALSE;
453                 g_player_ini.use_audio_filter_custom = FALSE;
454
455                 strcpy( g_player_ini.name_of_drmsrc, "filesrc" );
456
457                 // Force setting for simulator :+:091218 
458                 strcpy( g_player_ini.name_of_audiosink, "alsasink" );
459
460                 
461 //              __get_string_list( (gchar**) g_player_ini.exclude_element_keyword, "");
462                 
463         #endif
464
465         #if defined(VDF_SDK) || defined (SEC_SDK)
466                 debug_warning("player is running on SDK.\n");
467                 debug_warning("So, it seems like that some plugin values are not same with those\n");
468                 debug_warning("which are written in default ini file.\n");
469
470                 //g_player_ini.videosink_element = PLAYER_INI_VSINK_XIMAGESINK;
471                 g_player_ini.use_audio_filter_preset = FALSE;
472                 g_player_ini.use_audio_filter_custom = FALSE;
473
474                 strcpy( g_player_ini.name_of_drmsrc, "filesrc" );
475         #endif
476
477         #if defined(NEW_SOUND) 
478                 strcpy (g_player_ini.name_of_audiosink, "soundsink"); // :+:090707
479         #endif
480
481         /* FIXIT : The HW quality of volans is not better than protector.
482          * So, it can't use same timeout value because state change(resume) is sometimes failed in volans.
483          * Thus, it should be set more than 10sec. 
484          */
485         #if defined(_MM_PROJECT_VOLANS)
486                 g_player_ini.localplayback_state_change_timeout = 10;
487                 debug_log("localplayback_state_change_timeout is set as 30sec by force\n");
488         #endif
489
490         #if 0
491         #if defined(_MM_PROJECT_VOLANS)
492                 debug_warning("player is running on VOLANS\n");
493                 g_player_ini.use_audio_filter = FALSE;          // (+)090702, disabled temporally
494         #endif
495         #endif
496         
497 }
498
499 mm_player_ini_t* 
500 mm_player_ini_get_structure(void)
501 {
502         return &g_player_ini;
503 }
504
505 static 
506 gboolean __generate_default_ini(void)
507 {
508         FILE* fp = NULL;
509         gchar* default_ini = MM_PLAYER_DEFAULT_INI;
510
511
512         /* create new file */
513         fp = fopen(MM_PLAYER_INI_DEFAULT_PATH, "wt");
514
515         if ( !fp )
516         {
517                 return FALSE;
518         }
519
520         /* writing default ini file */
521         if ( strlen(default_ini) != fwrite(default_ini, 1, strlen(default_ini), fp) )
522         {
523                 fclose(fp);
524                 return FALSE;
525         }
526
527         fclose(fp);
528         return TRUE;
529 }
530
531 static 
532 void    __get_string_list(gchar** out_list, gchar* str)
533 {
534         gchar** list = NULL;
535         gchar** walk = NULL;
536         gint i = 0;
537         gchar* strtmp = NULL;
538
539
540         if ( ! str )
541                 return;
542
543         if ( strlen( str ) < 1 )
544                 return;
545
546         strtmp = g_strdup (str);
547
548         /* trimming. it works inplace */
549         g_strstrip( strtmp );
550
551
552         /* split */
553         list = g_strsplit( strtmp, ",", 10 );
554
555         if ( !list )
556         {
557                 if (strtmp)
558                         g_free(strtmp);
559
560                 return;
561         }
562
563         /* copy list */
564         for( walk = list; *walk; walk++ )
565         {
566                 strncpy( g_player_ini.exclude_element_keyword[i], *walk, (PLAYER_INI_MAX_STRLEN - 1) );
567
568                 g_strstrip( g_player_ini.exclude_element_keyword[i] );
569
570                 g_player_ini.exclude_element_keyword[i][PLAYER_INI_MAX_STRLEN - 1] = '\0';
571
572                 i++;
573         }
574
575         /* mark last item to NULL */
576         g_player_ini.exclude_element_keyword[i][0] = '\0';
577
578         g_strfreev( list );
579         if (strtmp)
580                 g_free (strtmp);
581 }
582
583 #endif
584
585
586