4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
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>
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #ifndef __MM_PLAYER_INI_C__
24 #define __MM_PLAYER_INI_C__
29 #include "iniparser.h"
30 #include <mm_player_ini.h>
33 #include <glib/gstdio.h>
35 /* internal functions, macros here */
36 #ifdef MM_PLAYER_DEFAULT_INI
37 static gboolean __generate_default_ini(void);
39 static void __get_element_list(mm_player_ini_t* ini, gchar* str, int keyword_type);
41 static void __mm_player_ini_check_ini_status(void);
44 #define MMPLAYER_INI_GET_STRING( x_dict, x_item, x_ini, x_default ) \
47 gchar* str = iniparser_getstring(x_dict, x_ini, x_default); \
50 ( strlen( str ) > 0 ) && \
51 ( strlen( str ) < PLAYER_INI_MAX_STRLEN ) ) \
53 strcpy ( x_item, str ); \
57 strcpy ( x_item, x_default ); \
61 #define MMPLAYER_INI_GET_COLOR( x_dict, x_item, x_ini, x_default ) \
64 gchar* str = iniparser_getstring(x_dict, x_ini, x_default); \
67 ( strlen( str ) > 0 ) && \
68 ( strlen( str ) < PLAYER_INI_MAX_STRLEN ) ) \
70 x_item = (guint) strtoul(str, NULL, 16); \
74 x_item = (guint) strtoul(x_default, NULL, 16); \
78 /* x_ini is the list of index to set TRUE at x_list[index] */
79 #define MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( x_dict, x_list, x_list_max, x_ini, x_default ) \
83 const char *delimiters = " ,"; \
84 char *usr_ptr = NULL; \
86 gchar temp_arr[PLAYER_INI_MAX_STRLEN] = {0}; \
87 MMPLAYER_INI_GET_STRING( x_dict, temp_arr, x_ini, x_default); \
88 token = strtok_r( temp_arr, delimiters, &usr_ptr ); \
91 index = atoi(token); \
92 if (index < 0 || index > x_list_max -1) \
94 debug_warning("%d is not valid index\n", index); \
98 x_list[index] = TRUE; \
100 token = strtok_r( NULL, delimiters, &usr_ptr ); \
104 /* x_ini is the list of value to be set at x_list[index] */
105 #define MMPLAYER_INI_GET_INT_FROM_LIST( x_dict, x_list, x_list_max, x_ini, x_default ) \
110 const char *delimiters = " ,"; \
111 char *usr_ptr = NULL; \
112 char *token = NULL; \
113 gchar temp_arr[PLAYER_INI_MAX_STRLEN] = {0}; \
114 MMPLAYER_INI_GET_STRING(x_dict, temp_arr, x_ini, x_default); \
115 token = strtok_r( temp_arr, delimiters, &usr_ptr ); \
118 if ( index > x_list_max -1) \
120 debug_error("%d is not valid index\n", index); \
125 value = atoi(token); \
126 x_list[index] = value; \
129 token = strtok_r( NULL, delimiters, &usr_ptr ); \
134 mm_player_ini_load(mm_player_ini_t* ini)
136 dictionary * dict = NULL;
139 __mm_player_ini_check_ini_status();
141 /* first, try to load existing ini file */
142 dict = iniparser_load(MM_PLAYER_INI_DEFAULT_PATH);
144 /* if no file exists. create one with set of default values */
147 #ifdef MM_PLAYER_DEFAULT_INI
148 debug_log("No inifile found. player will create default inifile.\n");
149 if ( FALSE == __generate_default_ini() )
151 debug_warning("Creating default inifile failed. Player will use default values.\n");
155 /* load default ini */
156 dict = iniparser_load(MM_PLAYER_INI_DEFAULT_PATH);
159 debug_log("No ini file found. \n");
160 return MM_ERROR_FILE_NOT_FOUND;
165 memset( ini, 0, sizeof(mm_player_ini_t) );
167 if ( dict ) /* if dict is available */
170 ini->disable_segtrap = iniparser_getboolean(dict, "general:disable segtrap", DEFAULT_DISABLE_SEGTRAP);
171 ini->skip_rescan = iniparser_getboolean(dict, "general:skip rescan", DEFAULT_SKIP_RESCAN);
172 ini->generate_dot = iniparser_getboolean(dict, "general:generate dot", DEFAULT_GENERATE_DOT);
173 ini->provide_clock_for_music = iniparser_getboolean(dict, "general:provide clock for music", DEFAULT_PROVIDE_CLOCK_FOR_MUSIC);
174 ini->provide_clock_for_movie = iniparser_getboolean(dict, "general:provide clock for movie", DEFAULT_PROVIDE_CLOCK_FOR_MOVIE);
175 ini->live_state_change_timeout = iniparser_getint(dict, "general:live state change timeout", DEFAULT_LIVE_STATE_CHANGE_TIMEOUT);
176 ini->localplayback_state_change_timeout = iniparser_getint(dict, "general:localplayback state change timeout", DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT);
177 ini->eos_delay = iniparser_getint(dict, "general:eos delay", DEFAULT_EOS_DELAY);
178 ini->async_start = iniparser_getboolean(dict, "general:async start", DEFAULT_ASYNC_START);
179 ini->multiple_codec_supported = iniparser_getboolean(dict, "general:multiple codec supported", DEFAULT_MULTIPLE_CODEC_SUPPORTED);
181 ini->delay_before_repeat = iniparser_getint(dict, "general:delay before repeat", DEFAULT_DELAY_BEFORE_REPEAT);
183 MMPLAYER_INI_GET_STRING(dict, ini->videosink_element_x, "general:videosink element x", DEFAULT_VIDEOSINK_X);
184 MMPLAYER_INI_GET_STRING(dict, ini->videosink_element_evas, "general:videosink element evas", DEFAULT_VIDEOSINK_EVAS);
185 MMPLAYER_INI_GET_STRING(dict, ini->videosink_element_fake, "general:videosink element fake", DEFAULT_VIDEOSINK_FAKE);
186 MMPLAYER_INI_GET_STRING(dict, ini->name_of_drmsrc, "general:drmsrc element", DEFAULT_DRMSRC );
187 MMPLAYER_INI_GET_STRING(dict, ini->name_of_audio_resampler, "general:audio resampler element", DEFAULT_AUDIORESAMPLER );
188 MMPLAYER_INI_GET_STRING(dict, ini->name_of_audiosink, "general:audiosink element", DEFAULT_AUDIOSINK );
189 MMPLAYER_INI_GET_STRING(dict, ini->name_of_video_converter, "general:video converter element", DEFAULT_VIDEO_CONVERTER );
191 __get_element_list(ini,
192 iniparser_getstring(dict, "general:element exclude keyword", DEFAULT_EXCLUDE_KEYWORD), KEYWORD_EXCLUDE);
194 MMPLAYER_INI_GET_STRING(dict, ini->gst_param[0], "general:gstparam1", DEFAULT_GST_PARAM );
195 MMPLAYER_INI_GET_STRING(dict, ini->gst_param[1], "general:gstparam2", DEFAULT_GST_PARAM );
196 MMPLAYER_INI_GET_STRING(dict, ini->gst_param[2], "general:gstparam3", DEFAULT_GST_PARAM );
197 MMPLAYER_INI_GET_STRING(dict, ini->gst_param[3], "general:gstparam4", DEFAULT_GST_PARAM );
198 MMPLAYER_INI_GET_STRING(dict, ini->gst_param[4], "general:gstparam5", DEFAULT_GST_PARAM );
201 MMPLAYER_INI_GET_STRING( dict, ini->name_of_httpsrc, "http streaming:httpsrc element", DEFAULT_HTTPSRC );
202 MMPLAYER_INI_GET_STRING( dict, ini->http_file_buffer_path, "http streaming:http file buffer path", DEFAULT_HTTP_FILE_BUFFER_PATH );
203 ini->http_buffering_limit = iniparser_getdouble(dict, "http streaming:http buffering high limit", DEFAULT_HTTP_BUFFERING_LIMIT);
204 ini->http_max_size_bytes = iniparser_getint(dict, "http streaming:http max size bytes", DEFAULT_HTTP_MAX_SIZE_BYTES);
205 ini->http_buffering_time = iniparser_getdouble(dict, "http streaming:http buffering time", DEFAULT_HTTP_BUFFERING_TIME);
206 ini->http_timeout = iniparser_getint(dict, "http streaming:http timeout", DEFAULT_HTTP_TIMEOUT);
209 MMPLAYER_INI_GET_STRING( dict, ini->name_of_rtspsrc, "rtsp streaming:rtspsrc element", DEFAULT_RTSPSRC );
210 ini->rtsp_buffering_time = iniparser_getint(dict, "rtsp streaming:rtsp buffering time", DEFAULT_RTSP_BUFFERING);
211 ini->rtsp_rebuffering_time = iniparser_getint(dict, "rtsp streaming:rtsp rebuffering time", DEFAULT_RTSP_REBUFFERING);
212 ini->rtsp_do_typefinding = iniparser_getboolean(dict, "rtsp streaming:rtsp do typefinding", DEFAULT_RTSP_DO_TYPEFINDING);
213 ini->rtsp_error_concealment = iniparser_getboolean(dict, "rtsp streaming:rtsp error concealment", DEFAULT_RTSP_ERROR_CONCEALMENT);
216 ini->use_video_hw_accel = iniparser_getboolean(dict, "hw accelation:use video hw accel", DEFAULT_USE_VIDEO_HW_ACCEL);
219 ini->use_priority_setting = iniparser_getboolean(dict, "priority:use priority setting", DEFAULT_USE_PRIORITY_SETTING);
220 ini->demux_priority = iniparser_getint(dict, "priority:demux", DEFAULT_PRIORITY_DEMUX);
221 ini->videosink_priority = iniparser_getint(dict, "priority:videosink", DEFAULT_PRIORITY_VIDEO_SINK);
222 ini->audiosink_priority = iniparser_getint(dict, "priority:audiosink", DEFAULT_PRIORITY_AUDIO_SINK);
223 ini->ringbuffer_priority = iniparser_getint(dict, "priority:ringbuffer", DEFAULT_PRIORITY_RINGBUFFER);
225 /* dump buffer for debug */
226 __get_element_list(ini,
227 iniparser_getstring(dict, "general:dump element keyword", DEFAULT_EXCLUDE_KEYWORD), KEYWORD_DUMP);
229 MMPLAYER_INI_GET_STRING(dict, ini->dump_element_path, "general:dump element path", DEFAULT_DUMP_ELEMENT_PATH);
231 else /* if dict is not available just fill the structure with default value */
233 debug_warning("failed to load ini. using hardcoded default\n");
236 ini->disable_segtrap = DEFAULT_DISABLE_SEGTRAP;
237 ini->skip_rescan = DEFAULT_SKIP_RESCAN;
238 strncpy( ini->videosink_element_x, DEFAULT_VIDEOSINK_X, PLAYER_INI_MAX_STRLEN - 1 );
239 strncpy( ini->videosink_element_evas, DEFAULT_VIDEOSINK_EVAS, PLAYER_INI_MAX_STRLEN - 1 );
240 strncpy( ini->videosink_element_fake, DEFAULT_VIDEOSINK_FAKE, PLAYER_INI_MAX_STRLEN - 1 );
241 ini->generate_dot = DEFAULT_GENERATE_DOT;
242 ini->provide_clock_for_music = DEFAULT_PROVIDE_CLOCK_FOR_MUSIC;
243 ini->provide_clock_for_movie = DEFAULT_PROVIDE_CLOCK_FOR_MOVIE;
244 ini->live_state_change_timeout = DEFAULT_LIVE_STATE_CHANGE_TIMEOUT;
245 ini->localplayback_state_change_timeout = DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT;
246 ini->eos_delay = DEFAULT_EOS_DELAY;
247 ini->multiple_codec_supported = DEFAULT_MULTIPLE_CODEC_SUPPORTED;
248 ini->async_start = DEFAULT_ASYNC_START;
249 ini->delay_before_repeat = DEFAULT_DELAY_BEFORE_REPEAT;
251 strncpy( ini->name_of_drmsrc, DEFAULT_DRMSRC, PLAYER_INI_MAX_STRLEN - 1 );
252 strncpy( ini->name_of_audio_resampler, DEFAULT_AUDIORESAMPLER, PLAYER_INI_MAX_STRLEN -1 );
253 strncpy( ini->name_of_audiosink, DEFAULT_AUDIOSINK, PLAYER_INI_MAX_STRLEN -1 );
254 strncpy( ini->name_of_video_converter, DEFAULT_VIDEO_CONVERTER, PLAYER_INI_MAX_STRLEN -1 );
257 __get_element_list(ini, DEFAULT_EXCLUDE_KEYWORD, KEYWORD_EXCLUDE);
261 strncpy( ini->gst_param[0], DEFAULT_GST_PARAM, PLAYER_INI_MAX_PARAM_STRLEN - 1 );
262 strncpy( ini->gst_param[1], DEFAULT_GST_PARAM, PLAYER_INI_MAX_PARAM_STRLEN - 1 );
263 strncpy( ini->gst_param[2], DEFAULT_GST_PARAM, PLAYER_INI_MAX_PARAM_STRLEN - 1 );
264 strncpy( ini->gst_param[3], DEFAULT_GST_PARAM, PLAYER_INI_MAX_PARAM_STRLEN - 1 );
265 strncpy( ini->gst_param[4], DEFAULT_GST_PARAM, PLAYER_INI_MAX_PARAM_STRLEN - 1 );
268 strncpy( ini->name_of_httpsrc, DEFAULT_HTTPSRC, PLAYER_INI_MAX_STRLEN - 1 );
269 strncpy( ini->http_file_buffer_path, DEFAULT_HTTP_FILE_BUFFER_PATH, PLAYER_INI_MAX_STRLEN - 1 );
270 ini->http_buffering_limit = DEFAULT_HTTP_BUFFERING_LIMIT;
271 ini->http_max_size_bytes = DEFAULT_HTTP_MAX_SIZE_BYTES;
272 ini->http_buffering_time = DEFAULT_HTTP_BUFFERING_TIME;
273 ini->http_timeout = DEFAULT_HTTP_TIMEOUT;
276 strncpy( ini->name_of_rtspsrc, DEFAULT_RTSPSRC, PLAYER_INI_MAX_STRLEN - 1 );
277 ini->rtsp_buffering_time = DEFAULT_RTSP_BUFFERING;
278 ini->rtsp_rebuffering_time = DEFAULT_RTSP_REBUFFERING;
279 ini->rtsp_do_typefinding = DEFAULT_RTSP_DO_TYPEFINDING;
280 ini->rtsp_error_concealment = DEFAULT_RTSP_ERROR_CONCEALMENT;
283 ini->use_video_hw_accel = DEFAULT_USE_VIDEO_HW_ACCEL;
286 ini->use_priority_setting = DEFAULT_USE_PRIORITY_SETTING;
287 ini->demux_priority = DEFAULT_PRIORITY_DEMUX;
288 ini->videosink_priority = DEFAULT_PRIORITY_VIDEO_SINK;
289 ini->audiosink_priority = DEFAULT_PRIORITY_AUDIO_SINK;
290 ini->ringbuffer_priority = DEFAULT_PRIORITY_RINGBUFFER;
292 /* dump buffer for debug */
293 __get_element_list(ini, DEFAULT_DUMP_ELEMENT_KEYWORD, KEYWORD_DUMP);
294 strncpy(ini->dump_element_path, DEFAULT_DUMP_ELEMENT_PATH, PLAYER_INI_MAX_STRLEN - 1);
297 /* free dict as we got our own structure */
298 iniparser_freedict (dict);
301 debug_log("player settings -----------------------------------\n");
304 debug_log("disable_segtrap : %d\n", ini->disable_segtrap);
305 debug_log("skip rescan : %d\n", ini->skip_rescan);
306 debug_log("videosink element x: %s\n", ini->videosink_element_x);
307 debug_log("videosink element evas: %s\n", ini->videosink_element_evas);
308 debug_log("videosink element fake: %s\n", ini->videosink_element_fake);
309 debug_log("generate_dot : %d\n", ini->generate_dot);
310 debug_log("provide_clock for music : %d\n", ini->provide_clock_for_music);
311 debug_log("provide_clock for movie : %d\n", ini->provide_clock_for_movie);
312 debug_log("live_state_change_timeout(sec) : %d\n", ini->live_state_change_timeout);
313 debug_log("localplayback_state_change_timeout(sec) : %d\n", ini->localplayback_state_change_timeout);
314 debug_log("eos_delay(msec) : %d\n", ini->eos_delay);
315 debug_log("delay_before_repeat(msec) : %d\n", ini->delay_before_repeat);
316 debug_log("name_of_drmsrc : %s\n", ini->name_of_drmsrc);
317 debug_log("name_of_audioresampler : %s\n", ini->name_of_audio_resampler);
318 debug_log("name_of_audiosink : %s\n", ini->name_of_audiosink);
319 debug_log("name_of_video_converter : %s\n", ini->name_of_video_converter);
320 debug_log("async_start : %d\n", ini->async_start);
321 debug_log("multiple_codec_supported : %d\n", ini->multiple_codec_supported);
323 debug_log("gst_param1 : %s\n", ini->gst_param[0]);
324 debug_log("gst_param2 : %s\n", ini->gst_param[1]);
325 debug_log("gst_param3 : %s\n", ini->gst_param[2]);
326 debug_log("gst_param4 : %s\n", ini->gst_param[3]);
327 debug_log("gst_param5 : %s\n", ini->gst_param[4]);
329 for ( idx = 0; ini->exclude_element_keyword[idx][0] != '\0'; idx++ )
331 debug_log("exclude_element_keyword [%d] : %s\n", idx, ini->exclude_element_keyword[idx]);
334 for ( idx = 0; ini->dump_element_keyword[idx][0] != '\0'; idx++ )
336 debug_log("dump_element_keyword [%d] : %s\n", idx, ini->dump_element_keyword[idx]);
340 debug_log("name_of_httpsrc : %s\n", ini->name_of_httpsrc);
341 debug_log("http_file_buffer_path : %s \n", ini->http_file_buffer_path);
342 debug_log("http_buffering_limit : %f \n", ini->http_buffering_limit);
343 debug_log("http_max_size_bytes : %d \n", ini->http_max_size_bytes);
344 debug_log("http_buffering_time : %f \n", ini->http_buffering_time);
345 debug_log("http_timeout : %d \n", ini->http_timeout);
348 debug_log("name_of_rtspsrc : %s\n", ini->name_of_rtspsrc);
349 debug_log("rtsp_buffering_time(msec) : %d\n", ini->rtsp_buffering_time);
350 debug_log("rtsp_rebuffering_time(msec) : %d\n", ini->rtsp_rebuffering_time);
351 debug_log("rtsp_do_typefinding : %d \n", ini->rtsp_do_typefinding);
352 debug_log("rtsp_error_concealment : %d \n", ini->rtsp_error_concealment);
355 debug_log("use_video_hw_accel : %d\n", ini->use_video_hw_accel);
358 debug_log("use_priority_setting : %d\n", ini->use_priority_setting);
359 debug_log("demux_priority : %d\n", ini->demux_priority);
360 debug_log("audiosink_priority : %d\n", ini->audiosink_priority);
361 debug_log("videosink_priority : %d\n", ini->videosink_priority);
362 debug_log("ringbuffer_priority : %d\n", ini->ringbuffer_priority);
364 return MM_ERROR_NONE;
369 mm_player_audio_effect_ini_load(mm_player_ini_t* ini)
371 dictionary * dict_audioeffect = NULL;
373 dict_audioeffect = iniparser_load(MM_PLAYER_INI_DEFAULT_AUDIOEFFECT_PATH);
374 if ( !dict_audioeffect )
376 debug_error("No audio effect ini file found. \n");
377 return MM_ERROR_FILE_NOT_FOUND;
380 /* audio effect element name */
381 MMPLAYER_INI_GET_STRING( dict_audioeffect, ini->name_of_audio_effect, "audio effect:audio effect element", DEFAULT_AUDIO_EFFECT_ELEMENT );
382 if (!ini->name_of_audio_effect[0])
384 debug_warning("could not parse name of audio effect. \n");
385 iniparser_freedict (dict_audioeffect);
386 /* NOTE : in this case, we are not going to create audio filter element */
387 return MM_ERROR_NONE;
390 /* audio effect (Preset)*/
391 ini->use_audio_effect_preset = iniparser_getboolean(dict_audioeffect, "audio effect:audio effect preset", DEFAULT_USE_AUDIO_EFFECT_PRESET);
392 if (ini->use_audio_effect_preset)
394 MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( dict_audioeffect, ini->audio_effect_preset_list, MM_AUDIO_EFFECT_PRESET_NUM,
395 "audio effect:audio effect preset list", DEFAULT_AUDIO_EFFECT_PRESET_LIST );
396 MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( dict_audioeffect, ini->audio_effect_preset_earphone_only_list, MM_AUDIO_EFFECT_PRESET_NUM,
397 "audio effect:audio effect preset earphone only", DEFAULT_AUDIO_EFFECT_PRESET_LIST_EARPHONE_ONLY );
400 /* audio effect custom (EQ / Extension effects) */
401 ini->use_audio_effect_custom = iniparser_getboolean(dict_audioeffect, "audio effect:audio effect custom", DEFAULT_USE_AUDIO_EFFECT_CUSTOM);
402 if (ini->use_audio_effect_custom)
404 MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( dict_audioeffect, ini->audio_effect_custom_list, MM_AUDIO_EFFECT_CUSTOM_NUM,
405 "audio effect:audio effect custom list", DEFAULT_AUDIO_EFFECT_CUSTOM_LIST );
406 MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( dict_audioeffect, ini->audio_effect_custom_earphone_only_list, MM_AUDIO_EFFECT_CUSTOM_NUM,
407 "audio effect:audio effect custom earphone only", DEFAULT_AUDIO_EFFECT_CUSTOM_LIST_EARPHONE_ONLY );
409 /* audio effect custom : EQ */
410 if (ini->audio_effect_custom_list[MM_AUDIO_EFFECT_CUSTOM_EQ])
412 ini->audio_effect_custom_eq_band_num = iniparser_getint(dict_audioeffect, "audio effect:audio effect custom eq band num",
413 DEFAULT_AUDIO_EFFECT_CUSTOM_EQ_BAND_NUM);
414 if (ini->audio_effect_custom_eq_band_num < DEFAULT_AUDIO_EFFECT_CUSTOM_EQ_BAND_NUM ||
415 ini->audio_effect_custom_eq_band_num > MM_AUDIO_EFFECT_EQ_BAND_NUM_MAX)
417 debug_error("audio_effect_custom_eq_band_num(%d) is not valid range(%d - %d), set the value %d",
418 ini->audio_effect_custom_eq_band_num, DEFAULT_AUDIO_EFFECT_CUSTOM_EQ_BAND_NUM, MM_AUDIO_EFFECT_EQ_BAND_NUM_MAX, DEFAULT_AUDIO_EFFECT_CUSTOM_EQ_BAND_NUM);
419 ini->audio_effect_custom_eq_band_num = DEFAULT_AUDIO_EFFECT_CUSTOM_EQ_BAND_NUM;
421 iniparser_freedict (dict_audioeffect);
422 return MM_ERROR_PLAYER_INTERNAL;
426 if (ini->audio_effect_custom_eq_band_num)
428 MMPLAYER_INI_GET_INT_FROM_LIST( dict_audioeffect, ini->audio_effect_custom_eq_band_width, MM_AUDIO_EFFECT_EQ_BAND_NUM_MAX,
429 "audio effect:audio effect custom eq band width", DEFAULT_AUDIO_EFFECT_CUSTOM_EQ_BAND_WIDTH );
430 MMPLAYER_INI_GET_INT_FROM_LIST( dict_audioeffect, ini->audio_effect_custom_eq_band_freq, MM_AUDIO_EFFECT_EQ_BAND_NUM_MAX,
431 "audio effect:audio effect custom eq band freq", DEFAULT_AUDIO_EFFECT_CUSTOM_EQ_BAND_FREQ );
436 /* audio effect custom : Extension effects */
437 ini->audio_effect_custom_ext_num = iniparser_getint(dict_audioeffect, "audio effect:audio effect custom ext num",
438 DEFAULT_AUDIO_EFFECT_CUSTOM_EXT_NUM);
440 /* Min/Max value list of EQ / Extension effects */
441 if (ini->audio_effect_custom_eq_band_num || ini->audio_effect_custom_ext_num)
444 MMPLAYER_INI_GET_INT_FROM_LIST( dict_audioeffect, ini->audio_effect_custom_min_level_list, MM_AUDIO_EFFECT_CUSTOM_NUM,
445 "audio effect:audio effect custom min list", DEFAULT_AUDIO_EFFECT_CUSTOM_LIST );
446 MMPLAYER_INI_GET_INT_FROM_LIST( dict_audioeffect, ini->audio_effect_custom_max_level_list, MM_AUDIO_EFFECT_CUSTOM_NUM,
447 "audio effect:audio effect custom max list", DEFAULT_AUDIO_EFFECT_CUSTOM_LIST );
451 ini->use_audio_effect_square= iniparser_getboolean(dict_audioeffect, "audio effect:audio effect square", DEFAULT_USE_AUDIO_EFFECT_SQUARE);
452 if (ini->use_audio_effect_custom)
454 ini->audio_effect_square_max_row= iniparser_getint(dict_audioeffect, "audio effect:audio effect square max row",
455 DEFAULT_AUDIO_EFFECT_SQUARE_ROW_MAX);
456 ini->audio_effect_square_max_col= iniparser_getint(dict_audioeffect, "audio effect:audio effect square max col",
457 DEFAULT_AUDIO_EFFECT_SQUARE_COL_MAX);
460 /* audio effect element name */
461 MMPLAYER_INI_GET_STRING( dict_audioeffect, ini->name_of_audio_effect_sec, "audio effect:audio effect element sec", DEFAULT_AUDIO_EFFECT_ELEMENT );
462 if (!ini->name_of_audio_effect_sec[0])
464 debug_warning("could not parse name of secondary audio effect. \n");
468 debug_log("name_of_audio_effect : %s\n", ini->name_of_audio_effect);
469 debug_log("use_audio_effect_preset : %d\n", ini->use_audio_effect_preset);
470 debug_log("use_audio_effect_custom : %d\n", ini->use_audio_effect_custom);
471 debug_log("name_of_audio_effect_sec : %s\n", ini->name_of_audio_effect_sec);
472 debug_log("Use_audio_effect_square : %d\n", ini->use_audio_effect_square);
475 for (i=0; i<MM_AUDIO_EFFECT_PRESET_NUM; i++)
477 debug_log("audio_effect_preset_list: %d (is it for earphone only?(%d))\n", ini->audio_effect_preset_list[i], ini->audio_effect_preset_earphone_only_list[i]);
479 for (i=0; i<MM_AUDIO_EFFECT_CUSTOM_NUM; i++)
481 debug_log("audio_effect_custom_list : %d (is it for earphone only?(%d))\n", ini->audio_effect_custom_list[i], ini->audio_effect_custom_earphone_only_list[i]);
483 debug_log("audio_effect_custom : eq_band_num(%d), ext_num(%d)\n", ini->audio_effect_custom_eq_band_num, ini->audio_effect_custom_ext_num );
484 debug_log("audio_effect_custom_EQ : width(Hz) / central frequency(Hz)");
485 for (i=0; i<ini->audio_effect_custom_eq_band_num; i++)
487 debug_log(" EQ band index(%d) : %8d / %8d", i, ini->audio_effect_custom_eq_band_width[i], ini->audio_effect_custom_eq_band_freq[i]);
489 for (i=0; i<MM_AUDIO_EFFECT_CUSTOM_NUM; i++)
491 debug_log("audio_effect_custom_level_min_max(idx:%d) : Min(%d), Max(%d)\n", i, ini->audio_effect_custom_min_level_list[i], ini->audio_effect_custom_max_level_list[i]);
494 iniparser_freedict (dict_audioeffect);
496 return MM_ERROR_NONE;
502 void __mm_player_ini_check_ini_status(void)
504 struct stat ini_buff;
506 if ( g_stat(MM_PLAYER_INI_DEFAULT_PATH, &ini_buff) < 0 )
508 debug_warning("failed to get player ini status\n");
512 if ( ini_buff.st_size < 5 )
514 debug_warning("player.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size);
516 if ( g_remove( MM_PLAYER_INI_DEFAULT_PATH ) == -1)
518 debug_error("failed to delete corrupted ini");
524 #ifdef MM_PLAYER_DEFAULT_INI
526 gboolean __generate_default_ini(void)
529 gchar* default_ini = MM_PLAYER_DEFAULT_INI;
532 /* create new file */
533 fp = fopen(MM_PLAYER_INI_DEFAULT_PATH, "wt");
540 /* writing default ini file */
541 if ( strlen(default_ini) != fwrite(default_ini, 1, strlen(default_ini), fp) )
553 void __get_element_list(mm_player_ini_t* ini, gchar* str, int keyword_type)
558 gchar* strtmp = NULL;
563 if ( strlen( str ) < 1 )
566 strtmp = g_strdup (str);
568 /* trimming. it works inplace */
569 g_strstrip( strtmp );
573 list = g_strsplit( strtmp, ",", 10 );
584 switch (keyword_type)
586 case KEYWORD_EXCLUDE:
588 for( walk = list; *walk; walk++ )
590 strncpy( ini->exclude_element_keyword[i], *walk, (PLAYER_INI_MAX_STRLEN - 1) );
592 g_strstrip( ini->exclude_element_keyword[i] );
594 ini->exclude_element_keyword[i][PLAYER_INI_MAX_STRLEN -1]= '\0';
598 /* mark last item to NULL */
599 ini->exclude_element_keyword[i][0] = '\0';
605 for( walk = list; *walk; walk++ )
607 strncpy( ini->dump_element_keyword[i], *walk, (PLAYER_INI_MAX_STRLEN - 1) );
609 g_strstrip( ini->dump_element_keyword[i] );
611 ini->dump_element_keyword[i][PLAYER_INI_MAX_STRLEN -1]= '\0';
615 /* mark last item to NULL */
616 ini->dump_element_keyword[i][0] = '\0';