tizen 2.4 release
[framework/multimedia/libmm-camcorder.git] / src / mm_camcorder_configure.c
1 /*
2  * libmm-camcorder
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jeongmo Yang <jm80.yang@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 /*=======================================================================================
23 |  INCLUDE FILES                                                                        |
24 =======================================================================================*/
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29
30 #include "mm_camcorder_internal.h"
31 #include "mm_camcorder_configure.h"
32
33 /*-----------------------------------------------------------------------
34 |    MACRO DEFINITIONS:                                                 |
35 -----------------------------------------------------------------------*/
36 #define CONFIGURE_PATH          "/usr/etc"
37 #define CONFIGURE_PATH_RETRY    "/opt/etc"
38
39 /*-----------------------------------------------------------------------
40 |    GLOBAL VARIABLE DEFINITIONS                                        |
41 -----------------------------------------------------------------------*/
42
43 /*-----------------------------------------------------------------------
44 |    LOCAL VARIABLE DEFINITIONS                                         |
45 -----------------------------------------------------------------------*/
46 static int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM] = { 0, };
47 static int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM] = { 0, };
48
49 static conf_info_table* conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM] = { NULL, };
50 static conf_info_table* conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM] = { NULL, };
51
52 /*
53  * Videosrc element default value
54  */
55 static type_element _videosrc_element_default = {
56         "VideosrcElement",
57         "videotestsrc",
58         NULL,
59         0,
60         NULL,
61         0,
62 };
63
64 /*
65  * Audiosrc element default value
66  */
67 static type_int  ___audiosrc_default_channel            = { "Channel", 1 };
68 static type_int  ___audiosrc_default_bitrate            = { "BitRate", 8000 };
69 static type_int  ___audiosrc_default_depth              = { "Depth", 16 };
70 static type_int  ___audiosrc_default_blocksize  = { "BlockSize", 1280 };
71 static type_int* __audiosrc_default_int_array[] = {
72         &___audiosrc_default_channel,
73         &___audiosrc_default_bitrate,
74         &___audiosrc_default_depth,
75         &___audiosrc_default_blocksize,
76 };
77 static type_string  ___audiosrc_default_device  = { "Device", "default" };
78 static type_string* __audiosrc_default_string_array[]   = {
79         &___audiosrc_default_device,
80 };
81 static type_element _audiosrc_element_default = {
82         "AudiosrcElement",
83         "audiotestsrc",
84         __audiosrc_default_int_array,
85         sizeof( __audiosrc_default_int_array ) / sizeof( type_int* ),
86         __audiosrc_default_string_array,
87         sizeof( __audiosrc_default_string_array ) / sizeof( type_string* ),
88 };
89
90 static type_element _audiomodemsrc_element_default = {
91         "AudiomodemsrcElement",
92         "audiotestsrc",
93         __audiosrc_default_int_array,
94         sizeof( __audiosrc_default_int_array ) / sizeof( type_int* ),
95         __audiosrc_default_string_array,
96         sizeof( __audiosrc_default_string_array ) / sizeof( type_string* ),
97 };
98
99
100 /*
101  * Videosink element default value
102  */
103 static type_int  ___videosink_default_display_id        = { "display-id", 3 };
104 static type_int  ___videosink_default_x                 = { "x", 0 };
105 static type_int  ___videosink_default_y                 = { "y", 0 };
106 static type_int  ___videosink_default_width             = { "width", 800 };
107 static type_int  ___videosink_default_height    = { "height", 480 };
108 static type_int  ___videosink_default_rotation  = { "rotation", 1 };
109 static type_int* __videosink_default_int_array[]        = {
110         &___videosink_default_display_id,
111         &___videosink_default_x,
112         &___videosink_default_y,
113         &___videosink_default_width,
114         &___videosink_default_height,
115         &___videosink_default_rotation,
116 };
117 static type_string* __videosink_default_string_array[]  = { NULL };
118 static type_element _videosink_element_x_default = {
119         "VideosinkElementX",
120         "xvimagesink",
121         __videosink_default_int_array,
122         sizeof( __videosink_default_int_array ) / sizeof( type_int* ),
123         __videosink_default_string_array,
124         sizeof( __videosink_default_string_array ) / sizeof( type_string* ),
125 };
126 static type_element _videosink_element_evas_default = {
127         "VideosinkElementEvas",
128         "evasimagesink",
129         __videosink_default_int_array,
130         sizeof( __videosink_default_int_array ) / sizeof( type_int* ),
131         __videosink_default_string_array,
132         sizeof( __videosink_default_string_array ) / sizeof( type_string* ),
133 };
134 static type_element _videosink_element_gl_default = {
135         "VideosinkElementGL",
136         "glimagesink",
137         __videosink_default_int_array,
138         sizeof( __videosink_default_int_array ) / sizeof( type_int* ),
139         __videosink_default_string_array,
140         sizeof( __videosink_default_string_array ) / sizeof( type_string* ),
141 };
142 static type_element _videosink_element_null_default = {
143         "VideosinkElementNull",
144         "fakesink",
145         __videosink_default_int_array,
146         sizeof( __videosink_default_int_array ) / sizeof( type_int* ),
147         __videosink_default_string_array,
148         sizeof( __videosink_default_string_array ) / sizeof( type_string* ),
149 };
150
151 /*
152  * Videoscale element default value
153  */
154 static type_element _videoscale_element_default = {
155         "VideoscaleElement",
156         "videoscale",
157         NULL,
158         0,
159         NULL,
160         0,
161 };
162
163 /*
164  * Videoconvert element default value
165  */
166 static type_element _videoconvert_element_default = {
167         "VideoconvertElement",
168         "videoconvert",
169         NULL,
170         0,
171         NULL,
172         0,
173 };
174
175 /*
176  * Record sink element default value
177  */
178 static type_element _recordsink_element_default = {
179         "RecordsinkElement",
180         "fakesink",
181         NULL,
182         0,
183         NULL,
184         0,
185 };
186
187 /*
188  *  H263 element default value
189  */
190 static type_element _h263_element_default = {
191         "H263",
192         "ffenc_h263",
193         NULL,
194         0,
195         NULL,
196         0,
197 };
198
199 /*
200  *  H264 element default value
201  */
202 static type_element _h264_element_default = {
203         "H264",
204         NULL,
205         NULL,
206         0,
207         NULL,
208         0,
209 };
210
211 /*
212  *  H26L element default value
213  */
214 static type_element _h26l_element_default = {
215         "H26L",
216         NULL,
217         NULL,
218         0,
219         NULL,
220         0,
221 };
222
223 /*
224  *  MPEG4 element default value
225  */
226 static type_element _mpeg4_element_default = {
227         "MPEG4",
228         "ffenc_mpeg4",
229         NULL,
230         0,
231         NULL,
232         0,
233 };
234
235 /*
236  *  MPEG1 element default value
237  */
238 static type_element _mpeg1_element_default = {
239         "MPEG1",
240         "ffenc_mpeg1video",
241         NULL,
242         0,
243         NULL,
244         0,
245 };
246
247 /*
248  *  THEORA element default value
249  */
250 static type_element _theora_element_default = {
251         "THEORA",
252         "theoraenc",
253         NULL,
254         0,
255         NULL,
256         0,
257 };
258
259 /*
260  *  AMR element default value
261  */
262 static type_element _amr_element_default = {
263         "AMR",
264         "amrnbenc",
265         NULL,
266         0,
267         NULL,
268         0,
269 };
270
271 /*
272  *  G723_1 element default value
273  */
274 static type_element _g723_1_element_default = {
275         "G723_1",
276         NULL,
277         NULL,
278         0,
279         NULL,
280         0,
281 };
282
283 /*
284  *  MP3 element default value
285  */
286 static type_element _mp3_element_default = {
287         "MP3",
288         "lame",
289         NULL,
290         0,
291         NULL,
292         0,
293 };
294
295 /*
296  *  AAC element default value
297  */
298 static type_element _aac_element_default = {
299         "AAC",
300         NULL,
301         NULL,
302         0,
303         NULL,
304         0,
305 };
306
307 /*
308  *  MMF element default value
309  */
310 static type_element _mmf_element_default = {
311         "MMF",
312         NULL,
313         NULL,
314         0,
315         NULL,
316         0,
317 };
318
319 /*
320  *  ADPCM element default value
321  */
322 static type_element _adpcm_element_default = {
323         "ADPCM",
324         "ffenc_adpcm_ima_qt",
325         NULL,
326         0,
327         NULL,
328         0,
329 };
330
331 /*
332  *  WAVE element default value
333  */
334 static type_element _wave_element_default = {
335         "WAVE",
336         "wavenc",
337         NULL,
338         0,
339         NULL,
340         0,
341 };
342
343 static type_element _vorbis_element_default = {
344         "VORBIS",
345         "vorbisenc",
346         NULL,
347         0,
348         NULL,
349         0,
350 };
351
352 /*
353  *  MIDI element default value
354  */
355 static type_element _midi_element_default = {
356         "MIDI",
357         NULL,
358         NULL,
359         0,
360         NULL,
361         0,
362 };
363
364 /*
365  *  IMELODY element default value
366  */
367 static type_element _imelody_element_default = {
368         "IMELODY",
369         NULL,
370         NULL,
371         0,
372         NULL,
373         0,
374 };
375
376 /*
377  *  JPEG element default value
378  */
379 static type_element _jpeg_element_default = {
380         "JPEG",
381         "secjpeg_enc",
382         NULL,
383         0,
384         NULL,
385         0,
386 };
387
388 /*
389  *  PNG element default value
390  */
391 static type_element _png_element_default = {
392         "PNG",
393         "pngenc",
394         NULL,
395         0,
396         NULL,
397         0,
398 };
399
400 /*
401  *  BMP element default value
402  */
403 static type_element _bmp_element_default = {
404         "BMP",
405         NULL,
406         NULL,
407         0,
408         NULL,
409         0,
410 };
411
412 /*
413  *  WBMP element default value
414  */
415 static type_element _wbmp_element_default = {
416         "WBMP",
417         NULL,
418         NULL,
419         0,
420         NULL,
421         0,
422 };
423
424 /*
425  *  TIFF element default value
426  */
427 static type_element _tiff_element_default = {
428         "TIFF",
429         NULL,
430         NULL,
431         0,
432         NULL,
433         0,
434 };
435
436 /*
437  *  PCX element default value
438  */
439 static type_element _pcx_element_default = {
440         "PCX",
441         NULL,
442         NULL,
443         0,
444         NULL,
445         0,
446 };
447
448 /*
449  *  GIF element default value
450  */
451 static type_element _gif_element_default = {
452         "GIF",
453         NULL,
454         NULL,
455         0,
456         NULL,
457         0,
458 };
459
460 /*
461  *  ICO element default value
462  */
463 static type_element _ico_element_default = {
464         "ICO",
465         NULL,
466         NULL,
467         0,
468         NULL,
469         0,
470 };
471
472 /*
473  *  RAS element default value
474  */
475 static type_element _ras_element_default = {
476         "RAS",
477         NULL,
478         NULL,
479         0,
480         NULL,
481         0,
482 };
483
484 /*
485  *  TGA element default value
486  */
487 static type_element _tga_element_default = {
488         "TGA",
489         NULL,
490         NULL,
491         0,
492         NULL,
493         0,
494 };
495
496 /*
497  *  XBM element default value
498  */
499 static type_element _xbm_element_default = {
500         "XBM",
501         NULL,
502         NULL,
503         0,
504         NULL,
505         0,
506 };
507
508 /*
509  *  XPM element default value
510  */
511 static type_element _xpm_element_default = {
512         "XPM",
513         NULL,
514         NULL,
515         0,
516         NULL,
517         0,
518 };
519
520 /*
521  *  3GP element default value
522  */
523 static type_element _3gp_element_default = {
524         "3GP",
525         "ffmux_3gp",
526         NULL,
527         0,
528         NULL,
529         0,
530 };
531
532 /*
533  *  AMR mux element default value
534  */
535 static type_element _amrmux_element_default = {
536         "AMR",
537         "ffmux_amr",
538         NULL,
539         0,
540         NULL,
541         0,
542 };
543
544 /*
545  *  MP4 element default value
546  */
547 static type_element _mp4_element_default = {
548         "MP4",
549         "ffmux_mp4",
550         NULL,
551         0,
552         NULL,
553         0,
554 };
555
556 /*
557  *  AAC mux element default value
558  */
559 static type_element _aacmux_element_default = {
560         "AAC",
561         NULL,
562         NULL,
563         0,
564         NULL,
565         0,
566 };
567
568 /*
569  *  MP3 mux element default value
570  */
571 static type_element _mp3mux_element_default = {
572         "MP3",
573         NULL,
574         NULL,
575         0,
576         NULL,
577         0,
578 };
579
580 /*
581  *  OGG element default value
582  */
583 static type_element _ogg_element_default = {
584         "OGG",
585         "oggmux",
586         NULL,
587         0,
588         NULL,
589         0,
590 };
591
592 /*
593  *  WAV element default value
594  */
595 static type_element _wav_element_default = {
596         "WAV",
597         NULL,
598         NULL,
599         0,
600         NULL,
601         0,
602 };
603
604 /*
605  *  AVI element default value
606  */
607 static type_element _avi_element_default = {
608         "AVI",
609         "avimux",
610         NULL,
611         0,
612         NULL,
613         0,
614 };
615
616 /*
617  *  WMA element default value
618  */
619 static type_element _wma_element_default = {
620         "WMA",
621         NULL,
622         NULL,
623         0,
624         NULL,
625         0,
626 };
627
628 /*
629  *  WMV element default value
630  */
631 static type_element _wmv_element_default = {
632         "WMV",
633         NULL,
634         NULL,
635         0,
636         NULL,
637         0,
638 };
639
640 /*
641  *  MID element default value
642  */
643 static type_element _mid_element_default = {
644         "MID",
645         NULL,
646         NULL,
647         0,
648         NULL,
649         0,
650 };
651
652 /*
653  *  MMF mux element default value
654  */
655 static type_element _mmfmux_element_default = {
656         "MMF",
657         "ffmux_mmf",
658         NULL,
659         0,
660         NULL,
661         0,
662 };
663
664 /*
665  *  MATROSKA element default value
666  */
667 static type_element _matroska_element_default = {
668         "MATROSKA",
669         "matroskamux",
670         NULL,
671         0,
672         NULL,
673         0,
674 };
675
676 /*
677  *  M2TS element default value
678  */
679 static type_element _m2ts_element_default = {
680         "M2TS",
681         "mpegtsmux",
682         NULL,
683         0,
684         NULL,
685         0,
686 };
687
688 /*
689  * [General] matching table
690  */
691 static conf_info_table conf_main_general_table[] = {
692         { "SyncStateChange", CONFIGURE_VALUE_INT,           {1} },
693         { "GSTInitOption",   CONFIGURE_VALUE_STRING_ARRAY,  {(int)NULL} },
694         { "ModelName",       CONFIGURE_VALUE_STRING,        {(int)"Samsung Camera"} },
695         { "DisabledAttributes", CONFIGURE_VALUE_STRING_ARRAY,  {(int)NULL} },
696 };
697
698 /*
699  * [VideoInput] matching table
700  */
701 static conf_info_table conf_main_video_input_table[] = {
702         { "UseConfCtrl",        CONFIGURE_VALUE_INT,            {1} },
703         { "ConfCtrlFile0",      CONFIGURE_VALUE_STRING,         {(int)"mmfw_camcorder_dev_video_pri.ini"} },
704         { "ConfCtrlFile1",      CONFIGURE_VALUE_STRING,         {(int)"mmfw_camcorder_dev_video_sec.ini"} },
705         { "VideosrcElement",    CONFIGURE_VALUE_ELEMENT,        {(int)&_videosrc_element_default} },
706         { "UseVideoscale",      CONFIGURE_VALUE_INT,            {0} },
707         { "VideoscaleElement",  CONFIGURE_VALUE_ELEMENT,        {(int)&_videoscale_element_default} },
708         { "UseZeroCopyFormat",  CONFIGURE_VALUE_INT,            {0} },
709         { "DeviceCount",        CONFIGURE_VALUE_INT,            {MM_VIDEO_DEVICE_NUM} },
710         { "SupportMediaPacketPreviewCb",  CONFIGURE_VALUE_INT,  {0} },
711 };
712
713 /*
714  * [AudioInput] matching table
715  */
716 static conf_info_table conf_main_audio_input_table[] = {
717         { "AudioDevice",          CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
718         { "AudiosrcElement",      CONFIGURE_VALUE_ELEMENT, {(int)&_audiosrc_element_default} },
719         { "AudiomodemsrcElement", CONFIGURE_VALUE_ELEMENT, {(int)&_audiomodemsrc_element_default} },
720 };
721
722 /*
723  * [VideoOutput] matching table
724  */
725 static conf_info_table conf_main_video_output_table[] = {
726         { "DisplayDevice",         CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
727         { "DisplayMode",           CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
728         { "Videosink",             CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
729         { "VideosinkElementX",     CONFIGURE_VALUE_ELEMENT,   {(int)&_videosink_element_x_default} },
730         { "VideosinkElementEvas",  CONFIGURE_VALUE_ELEMENT,   {(int)&_videosink_element_evas_default} },
731         { "VideosinkElementGL",    CONFIGURE_VALUE_ELEMENT,   {(int)&_videosink_element_gl_default} },
732         { "VideosinkElementNull",  CONFIGURE_VALUE_ELEMENT,   {(int)&_videosink_element_null_default} },
733         { "UseVideoscale",         CONFIGURE_VALUE_INT,       {0} },
734         { "VideoscaleElement",     CONFIGURE_VALUE_ELEMENT,   {(int)&_videoscale_element_default} },
735         { "VideoconvertElement",   CONFIGURE_VALUE_ELEMENT,   {(int)&_videoconvert_element_default} },
736 };
737
738 /*
739  * [Capture] matching table
740  */
741 static conf_info_table conf_main_capture_table[] = {
742         { "UseEncodebin",           CONFIGURE_VALUE_INT,     {0} },
743         { "UseCaptureMode",         CONFIGURE_VALUE_INT,     {0} },
744         { "VideoscaleElement",      CONFIGURE_VALUE_ELEMENT, {(int)&_videoscale_element_default} },
745         { "PlayCaptureSound",       CONFIGURE_VALUE_INT,     {1} },
746 };
747
748 /*
749  * [Record] matching table
750  */
751 static conf_info_table conf_main_record_table[] = {
752         { "UseAudioEncoderQueue",   CONFIGURE_VALUE_INT,     {1} },
753         { "UseVideoEncoderQueue",   CONFIGURE_VALUE_INT,     {1} },
754         { "VideoProfile",           CONFIGURE_VALUE_INT,     {0} },
755         { "VideoAutoAudioConvert",  CONFIGURE_VALUE_INT,     {0} },
756         { "VideoAutoAudioResample", CONFIGURE_VALUE_INT,     {0} },
757         { "VideoAutoColorSpace",    CONFIGURE_VALUE_INT,     {0} },
758         { "AudioProfile",           CONFIGURE_VALUE_INT,     {0} },
759         { "AudioAutoAudioConvert",  CONFIGURE_VALUE_INT,     {0} },
760         { "AudioAutoAudioResample", CONFIGURE_VALUE_INT,     {0} },
761         { "AudioAutoColorSpace",    CONFIGURE_VALUE_INT,     {0} },
762         { "ImageProfile",           CONFIGURE_VALUE_INT,     {0} },
763         { "ImageAutoAudioConvert",  CONFIGURE_VALUE_INT,     {0} },
764         { "ImageAutoAudioResample", CONFIGURE_VALUE_INT,     {0} },
765         { "ImageAutoColorSpace",    CONFIGURE_VALUE_INT,     {0} },
766         { "RecordsinkElement",      CONFIGURE_VALUE_ELEMENT, {(int)&_recordsink_element_default} },
767         { "UseNoiseSuppressor",     CONFIGURE_VALUE_INT,     {0} },
768         { "DropVideoFrame",         CONFIGURE_VALUE_INT,     {0} },
769         { "PassFirstVideoFrame",    CONFIGURE_VALUE_INT,     {0} },
770         { "SupportDualStream",      CONFIGURE_VALUE_INT,     {FALSE} },
771 };
772
773 /*
774  * [VideoEncoder] matching table
775  */
776 static conf_info_table conf_main_video_encoder_table[] = {
777         { "H263",    CONFIGURE_VALUE_ELEMENT, {(int)&_h263_element_default} },
778         { "H264",    CONFIGURE_VALUE_ELEMENT, {(int)&_h264_element_default} },
779         { "H26L",    CONFIGURE_VALUE_ELEMENT, {(int)&_h26l_element_default} },
780         { "MPEG4",   CONFIGURE_VALUE_ELEMENT, {(int)&_mpeg4_element_default} },
781         { "MPEG1",   CONFIGURE_VALUE_ELEMENT, {(int)&_mpeg1_element_default} },
782         { "THEORA",  CONFIGURE_VALUE_ELEMENT, {(int)&_theora_element_default} },
783 };
784
785 /*
786  * [AudioEncoder] matching table
787  */
788 static conf_info_table conf_main_audio_encoder_table[] = {
789         { "AMR",     CONFIGURE_VALUE_ELEMENT, {(int)&_amr_element_default} },
790         { "G723_1",  CONFIGURE_VALUE_ELEMENT, {(int)&_g723_1_element_default} },
791         { "MP3",     CONFIGURE_VALUE_ELEMENT, {(int)&_mp3_element_default} },
792         { "AAC",     CONFIGURE_VALUE_ELEMENT, {(int)&_aac_element_default} },
793         { "MMF",     CONFIGURE_VALUE_ELEMENT, {(int)&_mmf_element_default} },
794         { "ADPCM",   CONFIGURE_VALUE_ELEMENT, {(int)&_adpcm_element_default} },
795         { "WAVE",    CONFIGURE_VALUE_ELEMENT, {(int)&_wave_element_default} },
796         { "MIDI",    CONFIGURE_VALUE_ELEMENT, {(int)&_midi_element_default} },
797         { "IMELODY", CONFIGURE_VALUE_ELEMENT, {(int)&_imelody_element_default} },
798         { "VORBIS",  CONFIGURE_VALUE_ELEMENT, {(int)&_vorbis_element_default} },
799 };
800
801 /*
802  * [ImageEncoder] matching table
803  */
804 static conf_info_table conf_main_image_encoder_table[] = {
805         { "JPEG", CONFIGURE_VALUE_ELEMENT, {(int)&_jpeg_element_default} },
806         { "PNG",  CONFIGURE_VALUE_ELEMENT, {(int)&_png_element_default} },
807         { "BMP",  CONFIGURE_VALUE_ELEMENT, {(int)&_bmp_element_default} },
808         { "WBMP", CONFIGURE_VALUE_ELEMENT, {(int)&_wbmp_element_default} },
809         { "TIFF", CONFIGURE_VALUE_ELEMENT, {(int)&_tiff_element_default} },
810         { "PCX",  CONFIGURE_VALUE_ELEMENT, {(int)&_pcx_element_default} },
811         { "GIF",  CONFIGURE_VALUE_ELEMENT, {(int)&_gif_element_default} },
812         { "ICO",  CONFIGURE_VALUE_ELEMENT, {(int)&_ico_element_default} },
813         { "RAS",  CONFIGURE_VALUE_ELEMENT, {(int)&_ras_element_default} },
814         { "TGA",  CONFIGURE_VALUE_ELEMENT, {(int)&_tga_element_default} },
815         { "XBM",  CONFIGURE_VALUE_ELEMENT, {(int)&_xbm_element_default} },
816         { "XPM",  CONFIGURE_VALUE_ELEMENT, {(int)&_xpm_element_default} },
817 };
818
819 /*
820  * [Mux] matching table
821  */
822 static conf_info_table conf_main_mux_table[] = {
823         { "3GP",      CONFIGURE_VALUE_ELEMENT, {(int)&_3gp_element_default} },
824         { "AMR",      CONFIGURE_VALUE_ELEMENT, {(int)&_amrmux_element_default} },
825         { "MP4",      CONFIGURE_VALUE_ELEMENT, {(int)&_mp4_element_default} },
826         { "AAC",      CONFIGURE_VALUE_ELEMENT, {(int)&_aacmux_element_default} },
827         { "MP3",      CONFIGURE_VALUE_ELEMENT, {(int)&_mp3mux_element_default} },
828         { "OGG",      CONFIGURE_VALUE_ELEMENT, {(int)&_ogg_element_default} },
829         { "WAV",      CONFIGURE_VALUE_ELEMENT, {(int)&_wav_element_default} },
830         { "AVI",      CONFIGURE_VALUE_ELEMENT, {(int)&_avi_element_default} },
831         { "WMA",      CONFIGURE_VALUE_ELEMENT, {(int)&_wma_element_default} },
832         { "WMV",      CONFIGURE_VALUE_ELEMENT, {(int)&_wmv_element_default} },
833         { "MID",      CONFIGURE_VALUE_ELEMENT, {(int)&_mid_element_default} },
834         { "MMF",      CONFIGURE_VALUE_ELEMENT, {(int)&_mmfmux_element_default} },
835         { "MATROSKA", CONFIGURE_VALUE_ELEMENT, {(int)&_matroska_element_default} },
836         { "M2TS",     CONFIGURE_VALUE_ELEMENT, {(int)&_m2ts_element_default} },
837 };
838
839
840 /*******************
841  *  Camera control *
842  *******************/
843
844 /*
845  * [Camera] matching table
846  */
847 static conf_info_table conf_ctrl_camera_table[] = {
848         { "InputIndex",        CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
849         { "DeviceName",        CONFIGURE_VALUE_STRING,         {(int)NULL} },
850         { "PreviewResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {(int)NULL} },
851         { "CaptureResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {(int)NULL} },
852         { "VideoResolution",   CONFIGURE_VALUE_INT_PAIR_ARRAY, {(int)NULL} },
853         { "FPS0",               CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
854         { "FPS1",               CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
855         { "FPS2",               CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
856         { "FPS3",               CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
857         { "FPS4",               CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
858         { "FPS5",               CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
859         { "FPS6",               CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
860         { "FPS7",               CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
861         { "FPS8",               CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
862         { "FPS9",               CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
863         { "PictureFormat",     CONFIGURE_VALUE_INT_ARRAY,      {(int)NULL} },
864         { "Overlay",           CONFIGURE_VALUE_INT_RANGE,      {(int)NULL} },
865         { "RecommendDisplayRotation", CONFIGURE_VALUE_INT,     {3}    },
866         { "RecommendPreviewFormatCapture", CONFIGURE_VALUE_INT, {MM_PIXEL_FORMAT_YUYV} },
867         { "RecommendPreviewFormatRecord",  CONFIGURE_VALUE_INT, {MM_PIXEL_FORMAT_NV12} },
868         { "RecommendPreviewResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {(int)NULL} },
869         { "FacingDirection", CONFIGURE_VALUE_INT, {MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR} },
870 };
871
872 /*
873  * [Strobe] matching table
874  */
875 static conf_info_table conf_ctrl_strobe_table[] = {
876         { "StrobeControl",        CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
877         { "StrobeMode",           CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
878         { "StrobeEV",             CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
879 };
880
881 /*
882  * [Effect] matching table
883  */
884 static conf_info_table conf_ctrl_effect_table[] = {
885         { "Brightness",           CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
886         { "BrightnessStepDenominator", CONFIGURE_VALUE_INT, {(int)2} },
887         { "Contrast",             CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
888         { "Saturation",           CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
889         { "Sharpness",            CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
890         { "WhiteBalance",         CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
891         { "ColorTone",            CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
892         { "Flip",                 CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
893         { "Rotation",             CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
894         { "WDR",                  CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
895         { "PartColorMode",        CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
896         { "PartColor",            CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
897 };
898
899 /*
900  * [Photograph] matching table
901  */
902 static conf_info_table conf_ctrl_photograph_table[] = {
903         { "LensInit",             CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
904         { "DigitalZoom",          CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
905         { "OpticalZoom",          CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
906         { "FocusMode",            CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
907         { "AFType",               CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
908         { "AEType",               CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
909         { "ExposureValue",        CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
910         { "FNumber",              CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
911         { "ShutterSpeed",         CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
912         { "ISO",                  CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
913         { "ProgramMode",          CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
914         { "AntiHandshake",        CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
915         { "VideoStabilization",   CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
916         { "FaceZoomMode",         CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
917         { "FaceZoomLevel",        CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
918 };
919
920 /*
921  * [Capture] matching table
922  */
923 static conf_info_table conf_ctrl_capture_table[] = {
924         { "OutputMode",           CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
925         { "JpegQuality",          CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
926         { "MultishotNumber",      CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
927         { "SensorEncodedCapture", CONFIGURE_VALUE_INT,       {1} },
928         { "SupportHDR",           CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
929         { "SupportZSL",           CONFIGURE_VALUE_INT,       {FALSE} },
930 };
931
932 /*
933  * [Detect] matching table
934  */
935 static conf_info_table conf_ctrl_detect_table[] = {
936         { "DetectMode",         CONFIGURE_VALUE_INT_ARRAY, {(int)NULL} },
937         { "DetectNumber",       CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
938         { "DetectSelect",       CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
939         { "DetectSelectNumber", CONFIGURE_VALUE_INT_RANGE, {(int)NULL} },
940 };
941
942
943
944 char*
945 get_new_string( char* src_string )
946 {
947         return strdup(src_string);
948 }
949
950 void _mmcamcorder_conf_init(int type, camera_conf** configure_info)
951 {
952         int i = 0;
953         int info_table_size = sizeof(conf_info_table);
954
955         /*_mmcam_dbg_log("Entered...");*/
956
957         if (type == CONFIGURE_TYPE_MAIN) {
958                 conf_main_info_table[CONFIGURE_CATEGORY_MAIN_GENERAL]       = conf_main_general_table;
959                 conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT]   = conf_main_video_input_table;
960                 conf_main_info_table[CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT]   = conf_main_audio_input_table;
961                 conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT]  = conf_main_video_output_table;
962                 conf_main_info_table[CONFIGURE_CATEGORY_MAIN_CAPTURE]       = conf_main_capture_table;
963                 conf_main_info_table[CONFIGURE_CATEGORY_MAIN_RECORD]        = conf_main_record_table;
964                 conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER] = conf_main_video_encoder_table;
965                 conf_main_info_table[CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER] = conf_main_audio_encoder_table;
966                 conf_main_info_table[CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER] = conf_main_image_encoder_table;
967                 conf_main_info_table[CONFIGURE_CATEGORY_MAIN_MUX]           = conf_main_mux_table;
968
969                 conf_main_category_size[CONFIGURE_CATEGORY_MAIN_GENERAL]       = sizeof( conf_main_general_table ) / info_table_size;
970                 conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT]   = sizeof( conf_main_video_input_table ) / info_table_size;
971                 conf_main_category_size[CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT]   = sizeof( conf_main_audio_input_table ) / info_table_size;
972                 conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT]  = sizeof( conf_main_video_output_table ) / info_table_size;
973                 conf_main_category_size[CONFIGURE_CATEGORY_MAIN_CAPTURE]       = sizeof( conf_main_capture_table ) / info_table_size;
974                 conf_main_category_size[CONFIGURE_CATEGORY_MAIN_RECORD]        = sizeof( conf_main_record_table ) / info_table_size;
975                 conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER] = sizeof( conf_main_video_encoder_table ) / info_table_size;
976                 conf_main_category_size[CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER] = sizeof( conf_main_audio_encoder_table ) / info_table_size;
977                 conf_main_category_size[CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER] = sizeof( conf_main_image_encoder_table ) / info_table_size;
978                 conf_main_category_size[CONFIGURE_CATEGORY_MAIN_MUX]           = sizeof( conf_main_mux_table ) / info_table_size;
979
980                 (*configure_info)->info = (conf_detail**)g_malloc0( sizeof( conf_detail* ) * CONFIGURE_CATEGORY_MAIN_NUM );
981
982                 for (i = 0 ; i < CONFIGURE_CATEGORY_MAIN_NUM ; i++) {
983                         (*configure_info)->info[i]      = NULL;
984                 }
985         } else {
986                 conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_CAMERA]     = conf_ctrl_camera_table;
987                 conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_STROBE]     = conf_ctrl_strobe_table;
988                 conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_EFFECT]     = conf_ctrl_effect_table;
989                 conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH] = conf_ctrl_photograph_table;
990                 conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_CAPTURE]    = conf_ctrl_capture_table;
991                 conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_DETECT]     = conf_ctrl_detect_table;
992
993                 conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_CAMERA]     = sizeof( conf_ctrl_camera_table ) / info_table_size;
994                 conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_STROBE]     = sizeof( conf_ctrl_strobe_table ) / info_table_size;
995                 conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_EFFECT]     = sizeof( conf_ctrl_effect_table ) / info_table_size;
996                 conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH] = sizeof( conf_ctrl_photograph_table ) / info_table_size;
997                 conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_CAPTURE]    = sizeof( conf_ctrl_capture_table ) / info_table_size;
998                 conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_DETECT]     = sizeof( conf_ctrl_detect_table ) / info_table_size;
999
1000                 (*configure_info)->info = (conf_detail**)g_malloc0( sizeof( conf_detail* ) * CONFIGURE_CATEGORY_CTRL_NUM );
1001
1002                 for (i = 0 ; i < CONFIGURE_CATEGORY_CTRL_NUM ; i++) {
1003                         (*configure_info)->info[i] = NULL;
1004                 }
1005         }
1006
1007         _mmcam_dbg_log("Done.");
1008
1009         return;
1010 }
1011
1012
1013 int
1014 _mmcamcorder_conf_get_info( int type, const char* ConfFile, camera_conf** configure_info )
1015 {
1016         int ret         = MM_ERROR_NONE;
1017         FILE* fd        = NULL;
1018         char* conf_path = NULL;
1019
1020         _mmcam_dbg_log( "Opening...[%s]", ConfFile );
1021
1022         mmf_return_val_if_fail( ConfFile, FALSE );
1023
1024         conf_path = (char*)malloc( strlen(ConfFile)+strlen(CONFIGURE_PATH)+3 );
1025
1026         if( conf_path == NULL )
1027         {
1028                 _mmcam_dbg_err( "malloc failed." );
1029                 return MM_ERROR_CAMCORDER_LOW_MEMORY;
1030         }
1031
1032         snprintf( conf_path, strlen(ConfFile)+strlen(CONFIGURE_PATH)+2, "%s/%s", CONFIGURE_PATH, ConfFile );
1033         /*_mmcam_dbg_log( "Try open Configure File[%s]", conf_path );*/
1034
1035         fd = fopen( conf_path, "r" );
1036         if( fd == NULL )
1037         {
1038                 _mmcam_dbg_warn( "File open failed.[%s] retry...", conf_path );
1039                 snprintf( conf_path, strlen(ConfFile)+strlen(CONFIGURE_PATH_RETRY)+2, "%s/%s", CONFIGURE_PATH_RETRY, ConfFile );
1040                 /*_mmcam_dbg_log( "Try open Configure File[%s]", conf_path );*/
1041                 fd = fopen( conf_path, "r" );
1042                 if( fd == NULL )
1043                 {
1044                         _mmcam_dbg_warn( "File open failed.[%s] But keep going... All value will be returned as default.Type[%d]", 
1045                                 conf_path, type );
1046                 }
1047         }
1048
1049         if( fd != NULL )
1050         {
1051                 ret = _mmcamcorder_conf_parse_info( type, fd, configure_info );
1052                 fclose( fd );
1053         }
1054         else
1055         {
1056                 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
1057         }
1058
1059         if( conf_path != NULL )
1060         {
1061                 free( conf_path );
1062                 conf_path = NULL;
1063         }
1064
1065         /*_mmcam_dbg_log( "Leave..." );*/
1066
1067         return ret;
1068 }
1069
1070 int
1071 _mmcamcorder_conf_parse_info( int type, FILE* fd, camera_conf** configure_info )
1072 {
1073         const unsigned int BUFFER_NUM_DETAILS = 256;
1074         const unsigned int BUFFER_NUM_TOKEN = 20;
1075         size_t BUFFER_LENGTH_STRING = 256;
1076         const char* delimiters = " |=,\t\n";
1077
1078         int category = 0;
1079         int count_main_category = 0;
1080         int count_details = 0;
1081         int length_read = 0;
1082         int count_token = 0;
1083         int read_main = 0;
1084
1085         char *buffer_string = NULL;
1086         char *buffer_details[BUFFER_NUM_DETAILS];
1087         char *buffer_token[BUFFER_NUM_TOKEN];
1088         char *token = NULL;
1089         char *category_name = NULL;
1090         char *detail_string = NULL;
1091         char *user_ptr = NULL;
1092
1093         _mmcam_dbg_log( "" );
1094
1095         camera_conf* new_conf = (camera_conf *)g_malloc0(sizeof(camera_conf));
1096         if (new_conf == NULL) {
1097                 _mmcam_dbg_err("new_conf alloc failed : %d", sizeof(camera_conf));
1098                 *configure_info = NULL;
1099                 return MM_ERROR_CAMCORDER_LOW_MEMORY;
1100         }
1101
1102         buffer_string = (char*)g_malloc0(sizeof(char) * BUFFER_LENGTH_STRING);
1103         if (buffer_string == NULL) {
1104                 _mmcam_dbg_err("buffer_string alloc failed : %d", sizeof(char) * BUFFER_LENGTH_STRING);
1105                 *configure_info = NULL;
1106                 g_free(new_conf);
1107                 return MM_ERROR_CAMCORDER_LOW_MEMORY;
1108         }
1109
1110         new_conf->type  = type;
1111         *configure_info = new_conf;
1112
1113         _mmcamcorder_conf_init( type, &new_conf );
1114
1115         if (fd == NULL) {
1116                 _mmcam_dbg_err("failed file descriptor fail");
1117                 *configure_info = NULL;
1118                 g_free(buffer_string);
1119                 g_free(new_conf);
1120                 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1121         }
1122
1123         read_main = 0;
1124         count_main_category = 0;
1125
1126         while( !feof( fd ) )
1127         {
1128                 if( read_main == 0 )
1129                 {
1130                         length_read = getline( &buffer_string, &BUFFER_LENGTH_STRING, fd );
1131                         /*_mmcam_dbg_log( "Read Line : [%s]", buffer_string );*/
1132
1133                         count_token = 0;
1134                         token = strtok_r( buffer_string, delimiters, &user_ptr );
1135
1136                         if ((token) && (token[0] == ';') && (length_read > -1))
1137                         {
1138                                 /*_mmcam_dbg_log( "Comment - Nothing to do" );*/
1139                                 continue;
1140                         }
1141
1142                         while( token )
1143                         {
1144                                 /*_mmcam_dbg_log( "token : [%s]", token );*/
1145                                 buffer_token[count_token] = token;
1146                                 count_token++;
1147                                 token = strtok_r( NULL, delimiters, &user_ptr );
1148                         }
1149
1150                         if( count_token == 0 )
1151                         {
1152                                 continue;
1153                         }
1154                 }
1155
1156                 read_main = 0;
1157
1158                 /* Comment */
1159                 if( *buffer_token[0] == ';' )
1160                 {
1161                         /*_mmcam_dbg_log( "Comment - Nothing to do" );*/
1162                 }
1163                 /* Main Category */
1164                 else if( *buffer_token[0] == '[' )
1165                 {
1166                         category_name = get_new_string( buffer_token[0] );
1167
1168                         count_main_category++;
1169                         count_details = 0;
1170
1171                         while( !feof( fd ) )
1172                         {
1173                                 length_read = getline( &buffer_string, &BUFFER_LENGTH_STRING, fd );
1174                                 /*_mmcam_dbg_log( "Read Detail Line : [%s], read length : [%d]", buffer_string, length_read );*/
1175
1176                                 detail_string = get_new_string( buffer_string );
1177
1178                                 token = strtok_r( buffer_string, delimiters, &user_ptr );
1179
1180                                 if( token && token[0] != ';' && length_read > -1 )
1181                                 {
1182                                         /*_mmcam_dbg_log( "token : [%s]", token );*/
1183                                         if( token[0] == '[' )
1184                                         {
1185                                                 read_main = 1;
1186                                                 buffer_token[0] = token;
1187                                                 SAFE_FREE( detail_string );
1188                                                 break;
1189                                         }
1190
1191                                         buffer_details[count_details++] = detail_string;
1192                                 }
1193                                 else
1194                                 {
1195                                         SAFE_FREE( detail_string );
1196                                 }
1197                         }
1198
1199                         /*_mmcam_dbg_log( "type : %d, category_name : %s, count : [%d]", type, category_name, count_details );*/
1200
1201                         if( count_details == 0 )
1202                         {
1203                                 _mmcam_dbg_warn( "category %s has no detail value... skip this category...", category_name );
1204                                 SAFE_FREE(category_name);
1205                                 continue;
1206                         }
1207
1208                         category = -1;
1209
1210                         /* Details */
1211                         if( type == CONFIGURE_TYPE_MAIN )
1212                         {
1213                                 if( !strcmp( "[General]", category_name ) )
1214                                 {
1215                                         category = CONFIGURE_CATEGORY_MAIN_GENERAL;
1216                                 }
1217                                 else if( !strcmp( "[VideoInput]", category_name ) )
1218                                 {
1219                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT;
1220                                 }
1221                                 else if( !strcmp( "[AudioInput]", category_name ) )
1222                                 {
1223                                         category = CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT;
1224                                 }
1225                                 else if( !strcmp( "[VideoOutput]", category_name ) )
1226                                 {
1227                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT;
1228                                 }
1229                                 else if( !strcmp( "[Capture]", category_name ) )
1230                                 {
1231                                         category = CONFIGURE_CATEGORY_MAIN_CAPTURE;
1232                                 }
1233                                 else if( !strcmp( "[Record]", category_name ) )
1234                                 {
1235                                         category = CONFIGURE_CATEGORY_MAIN_RECORD;
1236                                 }
1237                                 else if( !strcmp( "[VideoEncoder]", category_name ) )
1238                                 {
1239                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER;
1240                                 }
1241                                 else if( !strcmp( "[AudioEncoder]", category_name ) )
1242                                 {
1243                                         category = CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER;
1244                                 }
1245                                 else if( !strcmp( "[ImageEncoder]", category_name ) )
1246                                 {
1247                                         category = CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER;
1248                                 }
1249                                 else if( !strcmp( "[Mux]", category_name ) )
1250                                 {
1251                                         category = CONFIGURE_CATEGORY_MAIN_MUX;
1252                                 }
1253                         }
1254                         else
1255                         {
1256                                 if( !strcmp( "[Camera]", category_name ) )
1257                                 {
1258                                         category = CONFIGURE_CATEGORY_CTRL_CAMERA;
1259                                 }
1260                                 else if( !strcmp( "[Strobe]", category_name ) )
1261                                 {
1262                                         category = CONFIGURE_CATEGORY_CTRL_STROBE;
1263                                 }
1264                                 else if( !strcmp( "[Effect]", category_name ) )
1265                                 {
1266                                         category = CONFIGURE_CATEGORY_CTRL_EFFECT;
1267                                 }
1268                                 else if( !strcmp( "[Photograph]", category_name ) )
1269                                 {
1270                                         category = CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH;
1271                                 }
1272                                 else if( !strcmp( "[Capture]", category_name ) )
1273                                 {
1274                                         category = CONFIGURE_CATEGORY_CTRL_CAPTURE;
1275                                 }
1276                                 else if( !strcmp( "[Detect]", category_name ) )
1277                                 {
1278                                         category = CONFIGURE_CATEGORY_CTRL_DETECT;
1279                                 }
1280                         }
1281
1282                         if( category != -1 )
1283                         {
1284                                 _mmcamcorder_conf_add_info( type, &(new_conf->info[category]),
1285                                                 buffer_details, category, count_details );
1286                         }
1287                         else
1288                         {
1289                                 _mmcam_dbg_warn( "No matched category[%s],type[%d]... check it.", category_name, type );
1290                         }
1291
1292                         // Free memory
1293                         {
1294                                 int i;
1295
1296                                 for( i = 0 ; i < count_details ; i++ )
1297                                 {
1298                                         SAFE_FREE( buffer_details[i] );
1299                                 }
1300                         }
1301                 }
1302
1303                 SAFE_FREE(category_name);
1304         }
1305
1306         //(*configure_info) = new_conf;
1307
1308         SAFE_FREE( buffer_string );
1309
1310         /*_mmcam_dbg_log( "Done." );*/
1311
1312         return MM_ERROR_NONE;
1313 }
1314
1315
1316 void _mmcamcorder_conf_release_info(camera_conf **configure_info)
1317 {
1318         int i = 0;
1319         int j = 0;
1320         int k = 0;
1321         int type = CONFIGURE_VALUE_INT;
1322         int count = 0;
1323         int category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1324         camera_conf *temp_conf = (*configure_info);
1325
1326         type_int2 *temp_int = NULL;
1327         type_int_range *temp_int_range = NULL;
1328         type_int_array *temp_int_array = NULL;
1329         type_int_pair_array *temp_int_pair_array = NULL;
1330         type_string2 *temp_string = NULL;
1331         type_string_array *temp_string_array = NULL;
1332         type_element2 *temp_element = NULL;
1333
1334         _mmcam_dbg_log("Entered...");
1335
1336         mmf_return_if_fail(temp_conf);
1337
1338         if ((*configure_info)->type == CONFIGURE_TYPE_MAIN) {
1339                 category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1340         } else {
1341                 category_num = CONFIGURE_CATEGORY_CTRL_NUM;
1342         }
1343
1344         for (i = 0 ; i < category_num ; i++) {
1345                 if (temp_conf->info[i]) {
1346                         for (j = 0 ; j < temp_conf->info[i]->count ; j++) {
1347                                 if (temp_conf->info[i]->detail_info[j] == NULL) {
1348                                         continue;
1349                                 }
1350
1351                                 if (_mmcamcorder_conf_get_value_type(temp_conf->type, i, ((type_element*)(temp_conf->info[i]->detail_info[j]))->name, &type)) {
1352                                         switch (type) {
1353                                         case CONFIGURE_VALUE_INT:
1354                                                 temp_int = (type_int2*)(temp_conf->info[i]->detail_info[j]);
1355                                                 SAFE_FREE(temp_int->name);
1356                                                 break;
1357                                         case CONFIGURE_VALUE_INT_RANGE:
1358                                                 temp_int_range = (type_int_range*)(temp_conf->info[i]->detail_info[j]);
1359                                                 SAFE_FREE(temp_int_range->name);
1360                                                 break;
1361                                         case CONFIGURE_VALUE_INT_ARRAY:
1362                                                 temp_int_array = (type_int_array*)(temp_conf->info[i]->detail_info[j]);
1363                                                 SAFE_FREE(temp_int_array->name);
1364                                                 SAFE_FREE(temp_int_array->value);
1365                                                 break;
1366                                         case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1367                                                 temp_int_pair_array = (type_int_pair_array*)(temp_conf->info[i]->detail_info[j]);
1368                                                 SAFE_FREE(temp_int_pair_array->name);
1369                                                 SAFE_FREE(temp_int_pair_array->value[0]);
1370                                                 SAFE_FREE(temp_int_pair_array->value[1]);
1371                                                 break;
1372                                         case CONFIGURE_VALUE_STRING:
1373                                                 temp_string = (type_string2*)(temp_conf->info[i]->detail_info[j]);
1374                                                 SAFE_FREE(temp_string->name);
1375                                                 SAFE_FREE(temp_string->value);
1376                                                 break;
1377                                         case CONFIGURE_VALUE_STRING_ARRAY:
1378                                                 temp_string_array = (type_string_array*)(temp_conf->info[i]->detail_info[j]);
1379                                                 SAFE_FREE(temp_string_array->name);
1380                                                 if (temp_string_array->value) {
1381                                                         count = temp_string_array->count;
1382                                                         for (k = 0 ; k < count ; k++) {
1383                                                                 SAFE_FREE(temp_string_array->value[k]);
1384                                                         }
1385                                                         g_free(temp_string_array->value);
1386                                                         temp_string_array->value = NULL;
1387                                                 }
1388                                                 SAFE_FREE(temp_string_array->default_value);
1389                                                 break;
1390                                         case CONFIGURE_VALUE_ELEMENT:
1391                                                 temp_element = (type_element2*)(temp_conf->info[i]->detail_info[j]);
1392                                                 SAFE_FREE(temp_element->name);
1393                                                 SAFE_FREE(temp_element->element_name);
1394
1395                                                 if (temp_element->value_int) {
1396                                                         count = temp_element->count_int;
1397                                                         for (k = 0 ; k < count ; k++) {
1398                                                                 SAFE_FREE(temp_element->value_int[k]->name);
1399                                                                 SAFE_FREE(temp_element->value_int[k]);
1400                                                         }
1401                                                         g_free(temp_element->value_int);
1402                                                 }
1403
1404                                                 if (temp_element->value_string) {
1405                                                         count = temp_element->count_string;
1406                                                         for (k = 0 ; k < count ; k++) {
1407                                                                 SAFE_FREE(temp_element->value_string[k]->name);
1408                                                                 SAFE_FREE(temp_element->value_string[k]->value);
1409                                                                 SAFE_FREE(temp_element->value_string[k]);
1410                                                         }
1411                                                         g_free(temp_element->value_string);
1412                                                 }
1413                                                 break;
1414                                         default:
1415                                                 _mmcam_dbg_warn("unknown type %d", type);
1416                                                 break;
1417                                         }
1418                                 }
1419
1420                                 SAFE_FREE(temp_conf->info[i]->detail_info[j]);
1421                                 temp_conf->info[i]->detail_info[j] = NULL;
1422                         }
1423
1424                         SAFE_FREE(temp_conf->info[i]->detail_info);
1425                         temp_conf->info[i]->detail_info = NULL;
1426
1427                         SAFE_FREE(temp_conf->info[i]);
1428                         temp_conf->info[i] = NULL;
1429                 }
1430         }
1431
1432         SAFE_FREE((*configure_info)->info);
1433         SAFE_FREE((*configure_info));
1434
1435         _mmcam_dbg_log("Done.");
1436 }
1437
1438
1439 int
1440 _mmcamcorder_conf_get_value_type( int type, int category, const char* name, int* value_type )
1441 {
1442         int i = 0;
1443         int count_value = 0;
1444
1445         /*_mmcam_dbg_log( "Entered..." );*/
1446
1447         mmf_return_val_if_fail( name, FALSE );
1448
1449         if( !_mmcamcorder_conf_get_category_size( type, category, &count_value ) )
1450         {
1451                 _mmcam_dbg_warn( "No matched category... check it... categoty[%d]", category );
1452                 return FALSE;
1453         }
1454
1455         /*_mmcam_dbg_log( "Number of value : [%d]", count_value );*/
1456
1457         if( type == CONFIGURE_TYPE_MAIN )
1458         {
1459                 for( i = 0 ; i < count_value ; i++ )
1460                 {
1461                         if( !strcmp( conf_main_info_table[category][i].name, name ) )
1462                         {
1463                                 *value_type = conf_main_info_table[category][i].value_type;
1464                                 /*_mmcam_dbg_log( "Category[%d],Name[%s],Type[%d]", category, name, *value_type );*/
1465                                 return TRUE;
1466                         }
1467                 }
1468         }
1469         else
1470         {
1471                 for( i = 0 ; i < count_value ; i++ )
1472                 {
1473                         if( !strcmp( conf_ctrl_info_table[category][i].name, name ) )
1474                         {
1475                                 *value_type = conf_ctrl_info_table[category][i].value_type;
1476                                 /*_mmcam_dbg_log( "Category[%d],Name[%s],Type[%d]", category, name, *value_type );*/
1477                                 return TRUE;
1478                         }
1479                 }
1480         }
1481
1482         return FALSE;
1483 }
1484
1485
1486 int
1487 _mmcamcorder_conf_add_info( int type, conf_detail** info, char** buffer_details, int category, int count_details )
1488 {
1489         const int BUFFER_NUM_TOKEN = 256;
1490
1491         int i = 0;
1492         int j = 0;
1493         int count_token;
1494         int value_type;
1495         char *token = NULL;
1496         char *buffer_token[BUFFER_NUM_TOKEN];
1497         char *user_ptr = NULL;
1498
1499         const char *delimiters     = " |=,\t\n";
1500         const char *delimiters_sub = " |\t\n";
1501         const char *delimiters_3rd = "|\n";
1502
1503         mmf_return_val_if_fail( buffer_details, FALSE );
1504
1505         (*info) = (conf_detail*)g_malloc0( sizeof(conf_detail) );
1506         if (*info == NULL) {
1507                 _mmcam_dbg_err("allocation failed");
1508                 return FALSE;
1509         }
1510         (*info)->detail_info = (void**)g_malloc0(sizeof(void*) * count_details);
1511         (*info)->count = count_details;
1512
1513         for ( i = 0 ; i < count_details ; i++ ) {
1514                 /*_mmcam_dbg_log("Read line\"%s\"", buffer_details[i]);*/
1515                 count_token = 0;
1516                 token = strtok_r( buffer_details[i], delimiters, &user_ptr );
1517
1518                 if (token) {
1519                         buffer_token[count_token] = token;
1520                         count_token++;
1521                 } else {
1522                         (*info)->detail_info[i] = NULL;
1523                         _mmcam_dbg_warn( "No token... check it.[%s]", buffer_details[i] );
1524                         continue;
1525                 }
1526
1527                 if (!_mmcamcorder_conf_get_value_type(type, category, buffer_token[0], &value_type)) {
1528                         (*info)->detail_info[i] = NULL;
1529                         _mmcam_dbg_warn( "Failed to get value type... check it. Category[%d],Name[%s]", category, buffer_token[0] );
1530                         continue;
1531                 }
1532
1533                 if (value_type != CONFIGURE_VALUE_STRING && value_type != CONFIGURE_VALUE_STRING_ARRAY) {
1534                         token = strtok_r( NULL, delimiters, &user_ptr );
1535                         while (token) {
1536                                 buffer_token[count_token] = token;
1537                                 /*_mmcam_dbg_log("token : [%s]", buffer_token[count_token]);*/
1538                                 count_token++;
1539                                 token = strtok_r( NULL, delimiters, &user_ptr );
1540                         }
1541
1542                         if (count_token < 2) {
1543                                 (*info)->detail_info[i] = NULL;
1544                                 _mmcam_dbg_warn( "Number of token is too small... check it.[%s]", buffer_details[i] );
1545                                 continue;
1546                         }
1547                 } else { /* CONFIGURE_VALUE_STRING or CONFIGURE_VALUE_STRING_ARRAY */
1548                         /* skip "=" */
1549                         strtok_r( NULL, delimiters_sub, &user_ptr );
1550
1551                         if (value_type == CONFIGURE_VALUE_STRING_ARRAY) {
1552                                 token = strtok_r( NULL, delimiters_sub, &user_ptr );
1553                                 while (token) {
1554                                         buffer_token[count_token] = token;
1555                                         /*_mmcam_dbg_log("token : [%s]", buffer_token[count_token]);*/
1556                                         count_token++;
1557                                         token = strtok_r( NULL, delimiters_sub, &user_ptr );
1558                                 }
1559                         } else { /* CONFIGURE_VALUE_STRING */
1560                                 token = strtok_r( NULL, delimiters_3rd, &user_ptr );
1561                                 if (token) {
1562                                         g_strchug( token );
1563                                         buffer_token[count_token] = token;
1564                                         /*_mmcam_dbg_log("token : [%s]", buffer_token[count_token]);*/
1565                                         count_token++;
1566                                 }
1567                         }
1568
1569                         if (count_token < 2) {
1570                                 (*info)->detail_info[i] = NULL;
1571                                 _mmcam_dbg_warn( "No string value... check it.[%s]", buffer_details[i] );
1572                                 continue;
1573                         }
1574                 }
1575
1576                 switch (value_type)
1577                 {
1578                         case CONFIGURE_VALUE_INT:
1579                         {
1580                                 type_int2* new_int;
1581
1582                                 new_int        = (type_int2*)g_malloc0( sizeof(type_int2) );
1583                                 if ( new_int == NULL ) {
1584                                         _mmcam_dbg_err("allocation failed");
1585                                         break;
1586                                 }
1587                                 new_int->name  = get_new_string( buffer_token[0] );
1588                                 new_int->value = atoi( buffer_token[1] );
1589                                 (*info)->detail_info[i] = (void*)new_int;
1590                                 /*_mmcam_dbg_log("INT - name[%s],value[%d]", new_int->name, new_int->value);*/
1591                                 break;
1592                         }
1593                         case CONFIGURE_VALUE_INT_RANGE:
1594                         {
1595                                 type_int_range* new_int_range;
1596
1597                                 new_int_range                = (type_int_range*)g_malloc0( sizeof(type_int_range) );
1598                                 if ( new_int_range == NULL ) {
1599                                         _mmcam_dbg_err("allocation failed");
1600                                         break;
1601                                 }
1602                                 new_int_range->name          = get_new_string( buffer_token[0] );
1603                                 new_int_range->min           = atoi( buffer_token[1] );
1604                                 new_int_range->max           = atoi( buffer_token[2] );
1605                                 new_int_range->default_value = atoi( buffer_token[3] );
1606                                 (*info)->detail_info[i]      = (void*)new_int_range;
1607                                 /*
1608                                 _mmcam_dbg_log("INT RANGE - name[%s],min[%d],max[%d],default[%d]",
1609                                                 new_int_range->name,
1610                                                 new_int_range->min,
1611                                                 new_int_range->max,
1612                                                 new_int_range->default_value);
1613                                 */
1614                                 break;
1615                         }
1616                         case CONFIGURE_VALUE_INT_ARRAY:
1617                         {
1618                                 int count_value = count_token - 2;
1619                                 type_int_array* new_int_array;
1620
1621                                 new_int_array = (type_int_array*)g_malloc0( sizeof(type_int_array) );
1622                                 if (new_int_array == NULL) {
1623                                         _mmcam_dbg_err("allocation failed");
1624                                         break;
1625                                 }
1626                                 new_int_array->name = get_new_string( buffer_token[0] );
1627                                 new_int_array->value = (int*)g_malloc0( sizeof(int)*count_value );
1628                                 if (new_int_array->value == NULL) {
1629                                         if (new_int_array->name) {
1630                                                 free(new_int_array->name);
1631                                                 new_int_array->name = NULL;
1632                                         }
1633                                         free(new_int_array);
1634                                         new_int_array = NULL;
1635                                         _mmcam_dbg_err("allocation failed");
1636                                         break;
1637                                 }
1638                                 new_int_array->count = count_value;
1639
1640                                 /*_mmcam_dbg_log("INT ARRAY - name[%s]", new_int_array->name);*/
1641                                 for ( j = 0 ; j < count_value ; j++ ) {
1642                                         new_int_array->value[j] = atoi( buffer_token[j+1] );
1643                                         /*_mmcam_dbg_log("   index[%d] - value[%d]", j, new_int_array->value[j]);*/
1644                                 }
1645
1646                                 new_int_array->default_value = atoi( buffer_token[count_token-1] );
1647                                 /*_mmcam_dbg_log("   default value[%d]", new_int_array->default_value);*/
1648
1649                                 (*info)->detail_info[i] = (void*)new_int_array;
1650                                 break;
1651                         }
1652                         case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1653                         {
1654                                 int count_value = ( count_token - 3 ) >> 1;
1655                                 type_int_pair_array* new_int_pair_array;
1656
1657                                 new_int_pair_array = (type_int_pair_array*)g_malloc0( sizeof(type_int_pair_array) );
1658                                 if ( new_int_pair_array == NULL ) {
1659                                         _mmcam_dbg_err("allocation failed");
1660                                         break;
1661                                 }
1662                                 new_int_pair_array->name     = get_new_string( buffer_token[0] );
1663                                 new_int_pair_array->value[0] = (int*)g_malloc( sizeof(int)*(count_value) );
1664                                 if ( new_int_pair_array->value[0] == NULL ) {
1665                                         if (new_int_pair_array->name) {
1666                                                 free( new_int_pair_array->name );
1667                                                 new_int_pair_array->name = NULL;
1668                                         }
1669                                         free( new_int_pair_array );
1670                                         new_int_pair_array = NULL;
1671                                         _mmcam_dbg_err("allocation failed");
1672                                         break;
1673                                 }
1674                                 new_int_pair_array->value[1] = (int*)g_malloc( sizeof(int)*(count_value) );
1675                                 if ( new_int_pair_array->value[1] == NULL ) {
1676                                         free( new_int_pair_array->value[0] );
1677                                         new_int_pair_array->value[0] = NULL;
1678                                         if (new_int_pair_array->name) {
1679                                                 free( new_int_pair_array->name );
1680                                                 new_int_pair_array->name = NULL;
1681                                         }
1682                                         free( new_int_pair_array );
1683                                         new_int_pair_array = NULL;
1684                                         _mmcam_dbg_err("allocation failed");
1685                                         break;
1686                                 }
1687                                 new_int_pair_array->count    = count_value;
1688
1689                                 /*_mmcam_dbg_log("INT PAIR ARRAY - name[%s],count[%d]", new_int_pair_array->name, count_value);*/
1690                                 for ( j = 0 ; j < count_value ; j++ ) {
1691                                         new_int_pair_array->value[0][j] = atoi( buffer_token[(j<<1)+1] );
1692                                         new_int_pair_array->value[1][j] = atoi( buffer_token[(j<<1)+2] );
1693                                         /*
1694                                         _mmcam_dbg_log("   index[%d] - value[%d,%d]", j,
1695                                                         new_int_pair_array->value[0][j],
1696                                                         new_int_pair_array->value[1][j]);
1697                                         */
1698                                 }
1699
1700                                 new_int_pair_array->default_value[0] = atoi( buffer_token[count_token-2] );
1701                                 new_int_pair_array->default_value[1] = atoi( buffer_token[count_token-1] );
1702                                 /*
1703                                 _mmcam_dbg_log("   default value[%d,%d]",
1704                                                 new_int_pair_array->default_value[0],
1705                                                 new_int_pair_array->default_value[1]);
1706                                 */
1707                                 (*info)->detail_info[i] = (void*)new_int_pair_array;
1708                                 break;
1709                         }
1710                         case CONFIGURE_VALUE_STRING:
1711                         {
1712                                 type_string2* new_string;
1713
1714                                 new_string = (type_string2*)g_malloc0( sizeof(type_string2) );
1715                                 if (new_string == NULL) {
1716                                         _mmcam_dbg_err("allocation failed");
1717                                         break;
1718                                 }
1719                                 new_string->name  = get_new_string( buffer_token[0] );
1720                                 new_string->value = get_new_string( buffer_token[1] );
1721                                 (*info)->detail_info[i] = (void*)new_string;
1722
1723                                 /*_mmcam_dbg_log("STRING - name[%s],value[%s]", new_string->name, new_string->value);*/
1724                                 break;
1725                         }
1726                         case CONFIGURE_VALUE_STRING_ARRAY:
1727                         {
1728                                 int count_value = count_token - 2;
1729                                 type_string_array* new_string_array;
1730
1731                                 new_string_array = (type_string_array*)g_malloc0( sizeof(type_string_array) );
1732                                 if ( new_string_array == NULL ) {
1733                                         break;
1734                                 }
1735                                 new_string_array->name  = get_new_string( buffer_token[0] );
1736                                 new_string_array->count = count_value;
1737                                 new_string_array->value = (char**)g_malloc0( sizeof(char*)*count_value );
1738                                 if ( new_string_array->value == NULL ) {
1739                                         if (new_string_array->name) {
1740                                                 free(new_string_array->name);
1741                                                 new_string_array->name = NULL;
1742                                         }
1743                                         free(new_string_array);
1744                                         new_string_array = NULL;
1745                                         _mmcam_dbg_err("allocation failed");
1746                                         break;
1747                                 }
1748                                 /*_mmcam_dbg_log("STRING ARRAY - name[%s]", new_string_array->name);*/
1749                                 for ( j = 0 ; j < count_value ; j++ ) {
1750                                         new_string_array->value[j] = get_new_string( buffer_token[j+1] );
1751                                         /*_mmcam_dbg_log("   index[%d] - value[%s]", j, new_string_array->value[j]);*/
1752                                 }
1753
1754                                 new_string_array->default_value = get_new_string( buffer_token[count_token-1] );
1755                                 /*_mmcam_dbg_log("   default value[%s]", new_string_array->default_value);*/
1756                                 (*info)->detail_info[i] = (void*)new_string_array;
1757                                 break;
1758                         }
1759                         case CONFIGURE_VALUE_ELEMENT:
1760                         {
1761                                 type_element2* new_element;
1762
1763                                 new_element = (type_element2*)g_malloc0( sizeof(type_element2) );
1764                                 if ( new_element == NULL ) {
1765                                         _mmcam_dbg_err("allocation failed");
1766                                         break;
1767                                 }
1768                                 new_element->name         = get_new_string( buffer_token[0] );
1769                                 new_element->element_name = get_new_string( buffer_token[1] );
1770                                 new_element->count_int    = atoi( buffer_token[2] );
1771                                 new_element->value_int    = NULL;
1772                                 new_element->count_string = atoi( buffer_token[3] );
1773                                 new_element->value_string = NULL;
1774                                 /*
1775                                 _mmcam_dbg_log("Element - name[%s],element_name[%s],count_int[%d],count_string[%d]",
1776                                                new_element->name, new_element->element_name, new_element->count_int, new_element->count_string);
1777                                 */
1778
1779                                 /* add int values */
1780                                 if ( new_element->count_int > 0 ) {
1781                                         new_element->value_int = (type_int2**)g_malloc0( sizeof(type_int2*)*(new_element->count_int) );
1782                                         if ( new_element->value_int) {
1783                                                 for ( j = 0 ; j < new_element->count_int ; j++ ) {
1784                                                         new_element->value_int[j]        = (type_int2*)g_malloc( sizeof(type_int2) );
1785                                                         if ( new_element->value_int[j] ) {
1786                                                                 new_element->value_int[j]->name  = get_new_string( buffer_token[4+(j<<1)] );
1787                                                                 new_element->value_int[j]->value = atoi( buffer_token[5+(j<<1)] );
1788                                                         } else {
1789                                                                 _mmcam_dbg_err("allocation failed");
1790                                                         }
1791                                                         /*
1792                                                         _mmcam_dbg_log("   Element INT[%d] - name[%s],value[%d]",
1793                                                                        j, new_element->value_int[j]->name, new_element->value_int[j]->value);
1794                                                         */
1795                                                 }
1796                                         } else {
1797                                                 _mmcam_dbg_err("allocation failed");
1798                                         }
1799                                 }
1800                                 else
1801                                 {
1802                                         new_element->value_int = NULL;
1803                                 }
1804
1805                                 /* add string values */
1806                                 if ( new_element->count_string > 0 ) {
1807                                         new_element->value_string = (type_string2**)g_malloc0( sizeof(type_string2*)*(new_element->count_string) );
1808                                         if (new_element->value_string) {
1809                                                 for ( ; j < new_element->count_string + new_element->count_int ; j++ ) {
1810                                                         new_element->value_string[j-new_element->count_int]     = (type_string2*)g_malloc0( sizeof(type_string2) );
1811                                                         if(new_element->value_string[j-new_element->count_int]) {
1812                                                                 new_element->value_string[j-new_element->count_int]->name       = get_new_string( buffer_token[4+(j<<1)] );
1813                                                                 new_element->value_string[j-new_element->count_int]->value      = get_new_string( buffer_token[5+(j<<1)] );
1814                                                                 /*
1815                                                                 _mmcam_dbg_log("   Element STRING[%d] - name[%s],value[%s]",
1816                                                                                j-new_element->count_int, new_element->value_string[j-new_element->count_int]->name, new_element->value_string[j-new_element->count_int]->value);
1817                                                                 */
1818                                                         } else {
1819                                                                 _mmcam_dbg_err("allocation failed");
1820                                                         }
1821                                                 }
1822                                         } else {
1823                                                 _mmcam_dbg_err("malloc failed : %d", sizeof(type_string2*)*(new_element->count_string));
1824                                         }
1825                                 } else {
1826                                         new_element->value_string = NULL;
1827                                 }
1828
1829                                 (*info)->detail_info[i] = (void*)new_element;
1830                                 break;
1831                         }
1832                         default:
1833                                 break;
1834                 }
1835         }
1836
1837         return TRUE;
1838 }
1839
1840
1841 int
1842 _mmcamcorder_conf_get_value_int( camera_conf* configure_info, int category, const char* name, int* value )
1843 {
1844         int i, count;
1845         conf_detail* info;
1846
1847         //_mmcam_dbg_log( "Entered... category[%d],name[%s]", category, name );
1848
1849         mmf_return_val_if_fail( configure_info, FALSE );
1850         mmf_return_val_if_fail( name, FALSE );
1851
1852         if( configure_info->info[category] )
1853         {
1854                 count = configure_info->info[category]->count;
1855                 info = configure_info->info[category];
1856
1857                 for( i = 0 ; i < count ; i++ )
1858                 {
1859                         if( info->detail_info[i] == NULL )
1860                         {
1861                                 continue;
1862                         }
1863
1864                         if( !strcmp( ((type_int*)(info->detail_info[i]))->name , name ) )
1865                         {
1866                                 *value = ((type_int*)(info->detail_info[i]))->value;
1867                                 //_mmcam_dbg_log( "Get[%s] int[%d]", name, *value );
1868                                 return TRUE;
1869                         }
1870                 }
1871         }
1872
1873         if( _mmcamcorder_conf_get_default_value_int( configure_info->type, category, name, value ) )
1874         {
1875                 //_mmcam_dbg_log( "Get[%s] int[%d]", name, *value );
1876                 return TRUE;
1877         }
1878
1879         _mmcam_dbg_warn( "Faild to get int... check it...Category[%d],Name[%s]", category, name );
1880
1881         return FALSE;
1882 }
1883
1884 int
1885 _mmcamcorder_conf_get_value_int_range( camera_conf* configure_info, int category, const char* name, type_int_range** value )
1886 {
1887         int i, count;
1888         conf_detail* info;
1889
1890         //_mmcam_dbg_log( "Entered... category[%d],name[%s]", category, name );
1891
1892         mmf_return_val_if_fail( configure_info, FALSE );
1893         mmf_return_val_if_fail( name, FALSE );
1894
1895         if( configure_info->info[category] )
1896         {
1897                 count = configure_info->info[category]->count;
1898                 info = configure_info->info[category];
1899
1900                 for( i = 0 ; i < count ; i++ )
1901                 {
1902                         if( info->detail_info[i] == NULL )
1903                         {
1904                                 continue;
1905                         }
1906
1907                         if( !strcmp( ((type_int_range*)(info->detail_info[i]))->name , name ) )
1908                         {
1909                                 *value = (type_int_range*)(info->detail_info[i]);
1910                                 /*
1911                                 _mmcam_dbg_log( "Get[%s] int range - min[%d],max[%d],default[%d]",
1912                                                 name, (*value)->min, (*value)->max, (*value)->default_value );
1913                                 */
1914                                 return TRUE;
1915                         }
1916                 }
1917         }
1918
1919         *value = NULL;
1920
1921         /*_mmcam_dbg_warn( "Faild to get int range... check it...Category[%d],Name[%s]", category, name );*/
1922
1923         return FALSE;
1924 }
1925
1926 int
1927 _mmcamcorder_conf_get_value_int_array( camera_conf* configure_info, int category, const char* name, type_int_array** value )
1928 {
1929         int i, count;
1930         conf_detail* info;
1931
1932         /*_mmcam_dbg_log( "Entered... category[%d],name[%s]", category, name );*/
1933
1934         mmf_return_val_if_fail( configure_info, FALSE );
1935         mmf_return_val_if_fail( name, FALSE );
1936
1937         if( configure_info->info[category] )
1938         {
1939                 count   = configure_info->info[category]->count;
1940                 info    = configure_info->info[category];
1941
1942                 for( i = 0 ; i < count ; i++ )
1943                 {
1944                         if( info->detail_info[i] == NULL )
1945                         {
1946                                 continue;
1947                         }
1948
1949                         if( !strcmp( ((type_int_array*)(info->detail_info[i]))->name , name ) )
1950                         {
1951                                 *value = (type_int_array*)(info->detail_info[i]);
1952                                 /*
1953                                 _mmcam_dbg_log( "Get[%s] int array - [%x],count[%d],default[%d]",
1954                                                 name, (*value)->value, (*value)->count, (*value)->default_value );
1955                                 */
1956                                 return TRUE;
1957                         }
1958                 }
1959         }
1960
1961         *value = NULL;
1962
1963         /*_mmcam_dbg_warn( "Faild to get int array... check it...Category[%d],Name[%s]", category, name );*/
1964
1965         return FALSE;
1966 }
1967
1968 int
1969 _mmcamcorder_conf_get_value_int_pair_array( camera_conf* configure_info, int category, const char* name, type_int_pair_array** value )
1970 {
1971         int i, count;
1972         conf_detail* info;
1973
1974         //_mmcam_dbg_log( "Entered... category[%d],name[%s]", category, name );
1975
1976         mmf_return_val_if_fail( configure_info, FALSE );
1977         mmf_return_val_if_fail( name, FALSE );
1978
1979         if( configure_info->info[category] )
1980         {
1981                 count = configure_info->info[category]->count;
1982                 info = configure_info->info[category];
1983
1984                 for( i = 0 ; i < count ; i++ )
1985                 {
1986                         if( info->detail_info[i] == NULL )
1987                         {
1988                                 continue;
1989                         }
1990
1991                         if( !strcmp( ((type_int_pair_array*)(info->detail_info[i]))->name , name ) )
1992                         {
1993                                 *value = (type_int_pair_array*)(info->detail_info[i]);
1994                                 /*
1995                                 _mmcam_dbg_log( "Get[%s] int pair array - [%x][%x],count[%d],default[%d][%d]",
1996                                                 name, (*value)->value[0], (*value)->value[1], (*value)->count,
1997                                                 (*value)->default_value[0], (*value)->default_value[1] );
1998                                 */
1999                                 return TRUE;
2000                         }
2001                 }
2002         }
2003
2004         *value = NULL;
2005
2006         _mmcam_dbg_warn( "Faild to get int pair array... check it...Category[%d],Name[%s]", category, name );
2007
2008         return FALSE;
2009 }
2010
2011 int
2012 _mmcamcorder_conf_get_value_string( camera_conf* configure_info, int category, const char* name, const char** value )
2013 {
2014         int i, count;
2015         conf_detail* info;
2016
2017         //_mmcam_dbg_log( "Entered... category[%d],name[%s]", category, name );
2018
2019         mmf_return_val_if_fail( configure_info, FALSE );
2020         mmf_return_val_if_fail( name, FALSE );
2021
2022         if( configure_info->info[category] )
2023         {
2024                 count = configure_info->info[category]->count;
2025                 info = configure_info->info[category];
2026
2027                 for( i = 0 ; i < count ; i++ )
2028                 {
2029                         if( info->detail_info[i] == NULL )
2030                         {
2031                                 continue;
2032                         }
2033
2034                         if( !strcmp( ((type_string*)(info->detail_info[i]))->name , name ) )
2035                         {
2036                                 *value = ((type_string*)(info->detail_info[i]))->value;
2037                                 //_mmcam_dbg_log( "Get[%s] string[%s]", name, *value );
2038                                 return TRUE;
2039                         }
2040                 }
2041         }
2042
2043         if( _mmcamcorder_conf_get_default_value_string( configure_info->type, category, name, value ) )
2044         {
2045                 //_mmcam_dbg_log( "Get[%s]string[%s]", name, *value );
2046                 return TRUE;
2047         }
2048
2049         _mmcam_dbg_warn( "Faild to get string... check it...Category[%d],Name[%s]", category, name );
2050
2051         return FALSE;
2052 }
2053
2054 int
2055 _mmcamcorder_conf_get_value_string_array( camera_conf* configure_info, int category, const char* name, type_string_array** value )
2056 {
2057         int i, count;
2058         conf_detail* info;
2059
2060         //_mmcam_dbg_log( "Entered... category[%d],name[%s]", category, name );
2061
2062         mmf_return_val_if_fail( configure_info, FALSE );
2063         mmf_return_val_if_fail( name, FALSE );
2064
2065         if( configure_info->info[category] )
2066         {
2067                 count = configure_info->info[category]->count;
2068                 info = configure_info->info[category];
2069
2070                 for( i = 0 ; i < count ; i++ )
2071                 {
2072                         if( info->detail_info[i] == NULL )
2073                         {
2074                                 continue;
2075                         }
2076
2077                         if( !strcmp( ((type_string_array*)(info->detail_info[i]))->name , name ) )
2078                         {
2079                                 *value = (type_string_array*)(info->detail_info[i]);
2080                                 /*
2081                                 _mmcam_dbg_log( "Get[%s] string array - [%x],count[%d],default[%s]",
2082                                                 name, (*value)->value, (*value)->count, (*value)->default_value );
2083                                 */
2084                                 return TRUE;
2085                         }
2086                 }
2087         }
2088
2089         *value = NULL;
2090
2091         /*_mmcam_dbg_warn( "Faild to get string array... check it...Category[%d],Name[%s]", category, name );*/
2092
2093         return FALSE;
2094 }
2095
2096 int
2097 _mmcamcorder_conf_get_element( camera_conf* configure_info, int category, const char* name, type_element** element )
2098 {
2099         int i, count;
2100         conf_detail* info;
2101
2102         //_mmcam_dbg_log( "Entered... category[%d],name[%s]", category, name );
2103
2104         mmf_return_val_if_fail( configure_info, FALSE );
2105         mmf_return_val_if_fail( name, FALSE );
2106
2107         if( configure_info->info[category] )
2108         {
2109                 count = configure_info->info[category]->count;
2110                 info = configure_info->info[category];
2111
2112                 for( i = 0 ; i < count ; i++ )
2113                 {
2114                         if( info->detail_info[i] == NULL )
2115                         {
2116                                 continue;
2117                         }
2118
2119                         if( !strcmp( ((type_element*)(info->detail_info[i]))->name , name ) )
2120                         {
2121                                 *element = (type_element*)(info->detail_info[i]);
2122                                 //_mmcam_dbg_log( "Get[%s] element[%x]", name, *element );
2123                                 return TRUE;
2124                         }
2125                 }
2126         }
2127
2128         if( _mmcamcorder_conf_get_default_element( configure_info->type, category, name, element ) )
2129         {
2130                 //_mmcam_dbg_log( "Get[%s] element[%x]", name, *element );
2131                 return TRUE;
2132         }
2133
2134         _mmcam_dbg_warn( "Faild to get element name... check it...Category[%d],Name[%s]", category, name );
2135
2136         return FALSE;
2137 }
2138
2139 int
2140 _mmcamcorder_conf_get_value_element_name( type_element* element, const char** value )
2141 {
2142         //_mmcam_dbg_log( "Entered..." );
2143
2144         mmf_return_val_if_fail( element, FALSE );
2145
2146         *value = element->element_name;
2147
2148         //_mmcam_dbg_log( "Get element name : [%s]", *value );
2149
2150         return TRUE;
2151 }
2152
2153 int
2154 _mmcamcorder_conf_get_value_element_int( type_element* element, const char* name, int* value )
2155 {
2156         int i;
2157
2158         //_mmcam_dbg_log( "Entered..." );
2159
2160         mmf_return_val_if_fail( element, FALSE );
2161         mmf_return_val_if_fail( name, FALSE );
2162
2163         for( i = 0 ; i < element->count_int ; i++ )
2164         {
2165                 if( !strcmp( element->value_int[i]->name , name ) )
2166                 {
2167                         *value = element->value_int[i]->value;
2168                         //_mmcam_dbg_log( "Get[%s] element int[%d]", name, *value );
2169                         return TRUE;
2170                 }
2171         }
2172
2173         _mmcam_dbg_warn( "Faild to get int in element... ElementName[%p],Name[%s],Count[%d]",
2174                 element->name, name, element->count_int );
2175
2176         return FALSE;
2177 }
2178
2179 int
2180 _mmcamcorder_conf_get_value_element_string( type_element* element, const char* name, const char** value )
2181 {
2182         int i;
2183
2184         //_mmcam_dbg_log( "Entered..." );
2185
2186         mmf_return_val_if_fail( element, FALSE );
2187         mmf_return_val_if_fail( name, FALSE );
2188
2189         for( i = 0 ; i < element->count_string ; i++ )
2190         {
2191                 if( !strcmp( element->value_string[i]->name , name ) )
2192                 {
2193                         *value = element->value_string[i]->value;
2194                         //_mmcam_dbg_log( "Get[%s] element string[%s]", name, *value );
2195                         return TRUE;
2196                 }
2197         }
2198
2199         _mmcam_dbg_warn( "Faild to get int in element... ElementName[%p],Name[%s],Count[%d]",
2200                 element->name, name, element->count_string );
2201
2202         return FALSE;
2203 }
2204
2205 int
2206 _mmcamcorder_conf_set_value_element_property( GstElement* gst, type_element* element )
2207 {
2208         int i;
2209
2210         //_mmcam_dbg_log( "Entered..." );
2211
2212         mmf_return_val_if_fail( gst, FALSE );
2213         mmf_return_val_if_fail( element, FALSE );
2214
2215         if( element->count_int == 0 )
2216         {
2217                 /*_mmcam_dbg_log( "There is no integer property to set in INI file[%s].", element->name );*/
2218         }
2219         else
2220         {
2221                 if( element->value_int == NULL )
2222                 {
2223                         _mmcam_dbg_warn( "count_int[%d] is NOT zero, but value_int is NULL", element->count_int );
2224                         return FALSE;
2225                 }
2226
2227                 for( i = 0 ; i < element->count_int ; i++ )
2228                 {
2229                         MMCAMCORDER_G_OBJECT_SET( gst, element->value_int[i]->name, element->value_int[i]->value );
2230                         
2231                         /*
2232                         _mmcam_dbg_log( "Element[%s] Set[%s] -> integer[%d]",
2233                                 element->element_name,
2234                                 element->value_int[i]->name,
2235                                 element->value_int[i]->value );
2236                                 */
2237                 }
2238         }
2239
2240         if( element->count_string == 0 )
2241         {
2242                 _mmcam_dbg_log( "There is no string property to set in INI file[%s].", element->name );
2243         }
2244         else
2245         {
2246                 if( element->value_string == NULL )
2247                 {
2248                         _mmcam_dbg_warn( "count_string[%d] is NOT zero, but value_string is NULL", element->count_string );
2249                         return FALSE;
2250                 }
2251
2252                 for( i = 0 ; i < element->count_string ; i++ )
2253                 {
2254                         MMCAMCORDER_G_OBJECT_SET_POINTER( gst, element->value_string[i]->name, element->value_string[i]->value );
2255
2256                         _mmcam_dbg_log( "Element[%s] Set[%s] -> string[%s]",
2257                                 element->element_name,
2258                                 element->value_string[i]->name,
2259                                 element->value_string[i]->value );
2260                 }
2261         }
2262
2263         //_mmcam_dbg_log( "Done." );
2264
2265         return TRUE;
2266 }
2267
2268 int
2269 _mmcamcorder_conf_get_default_value_int( int type, int category, const char* name, int* value )
2270 {
2271         int i = 0;
2272         int count_value = 0;
2273
2274         //_mmcam_dbg_log( "Entered..." );
2275
2276         mmf_return_val_if_fail( name, FALSE );
2277
2278         if( !_mmcamcorder_conf_get_category_size( type, category, &count_value ) )
2279         {
2280                 _mmcam_dbg_warn( "No matched category... check it... categoty[%d]", category );
2281                 return FALSE;
2282         }
2283
2284         if( type == CONFIGURE_TYPE_MAIN )
2285         {
2286                 for( i = 0 ; i < count_value ; i++ )
2287                 {
2288                         if( !strcmp( conf_main_info_table[category][i].name, name ) )
2289                         {
2290                                 *value = conf_main_info_table[category][i].value_int;
2291                                 return TRUE;
2292                         }
2293                 }
2294         }
2295         else
2296         {
2297                 for( i = 0 ; i < count_value ; i++ )
2298                 {
2299                         if( !strcmp( conf_ctrl_info_table[category][i].name, name ) )
2300                         {
2301                                 *value = conf_ctrl_info_table[category][i].value_int;
2302                                 return TRUE;
2303                         }
2304                 }
2305         }
2306
2307         _mmcam_dbg_warn( "Failed to get default int... check it... Type[%d],Category[%d],Name[%s]", type, category, name );
2308
2309         return FALSE;
2310 }
2311
2312 int
2313 _mmcamcorder_conf_get_default_value_string( int type, int category, const char* name, const char** value )
2314 {
2315         int i = 0;
2316         int count_value = 0;
2317
2318         //_mmcam_dbg_log( "Entered..." );
2319
2320         mmf_return_val_if_fail( name, FALSE );
2321
2322         if( !_mmcamcorder_conf_get_category_size( type, category, &count_value ) )
2323         {
2324                 _mmcam_dbg_warn( "No matched category... check it... categoty[%d]", category );
2325                 return FALSE;
2326         }
2327
2328         if( type == CONFIGURE_TYPE_MAIN )
2329         {
2330                 for( i = 0 ; i < count_value ; i++ )
2331                 {
2332                         if( !strcmp( conf_main_info_table[category][i].name, name ) )
2333                         {
2334                                 *value = conf_main_info_table[category][i].value_string;
2335                                 _mmcam_dbg_log( "Get[%s] default string[%s]", name, *value );
2336                                 return TRUE;
2337                         }
2338                 }
2339         }
2340         else
2341         {
2342                 for( i = 0 ; i < count_value ; i++ )
2343                 {
2344                         if( !strcmp( conf_ctrl_info_table[category][i].name, name ) )
2345                         {
2346                                 *value = conf_ctrl_info_table[category][i].value_string;
2347                                 _mmcam_dbg_log( "Get[%s] default string[%s]", name, *value );
2348                                 return TRUE;
2349                         }
2350                 }
2351         }
2352
2353         _mmcam_dbg_warn( "Failed to get default string... check it... Type[%d],Category[%d],Name[%s]", type, category, name );
2354
2355         return FALSE;
2356 }
2357
2358 int
2359 _mmcamcorder_conf_get_default_element( int type, int category, const char* name, type_element** element )
2360 {
2361         int i = 0;
2362         int count_value = 0;
2363
2364         //_mmcam_dbg_log( "Entered..." );
2365
2366         mmf_return_val_if_fail( name, FALSE );
2367
2368         if( !_mmcamcorder_conf_get_category_size( type, category, &count_value ) )
2369         {
2370                 _mmcam_dbg_warn( "No matched category... check it... categoty[%d]", category );
2371                 return FALSE;
2372         }
2373
2374         if( type == CONFIGURE_TYPE_MAIN )
2375         {
2376                 for( i = 0 ; i < count_value ; i++ )
2377                 {
2378                         if( !strcmp( conf_main_info_table[category][i].name, name ) )
2379                         {
2380                                 *element = conf_main_info_table[category][i].value_element;
2381                                 _mmcam_dbg_log( "Get[%s] element[%p]", name, *element );
2382                                 return TRUE;
2383                         }
2384                 }
2385         }
2386         else
2387         {
2388                 for( i = 0 ; i < count_value ; i++ )
2389                 {
2390                         if( !strcmp( conf_ctrl_info_table[category][i].name, name ) )
2391                         {
2392                                 *element = conf_ctrl_info_table[category][i].value_element;
2393                                 _mmcam_dbg_log( "Get[%s] element[%p]", name, *element );
2394                                 return TRUE;
2395                         }
2396                 }
2397         }
2398
2399         _mmcam_dbg_warn( "Failed to get default element... check it... Type[%d],Category[%d],Name[%s]", type, category, name );
2400
2401         return FALSE;
2402 }
2403
2404 int
2405 _mmcamcorder_conf_get_category_size( int type, int category, int* size )
2406 {
2407 //      mmf_return_val_if_fail( conf_main_category_size, FALSE );
2408 //      mmf_return_val_if_fail( conf_ctrl_category_size, FALSE );
2409
2410         if( type == CONFIGURE_TYPE_MAIN )
2411         {
2412                 mmf_return_val_if_fail( category < CONFIGURE_CATEGORY_MAIN_NUM, FALSE );
2413
2414                 *size = (int)conf_main_category_size[category];
2415         }
2416         else
2417         {
2418                 mmf_return_val_if_fail( category < CONFIGURE_CATEGORY_CTRL_NUM, FALSE );
2419
2420                 *size = (int)conf_ctrl_category_size[category];
2421         }
2422
2423         return TRUE;
2424 }
2425
2426 void
2427 _mmcamcorder_conf_print_info( camera_conf** configure_info )
2428 {
2429         int i, j, k, type, category_type;
2430
2431         type_int                *temp_int;
2432         type_int_range          *temp_int_range;
2433         type_int_array          *temp_int_array;
2434         type_int_pair_array     *temp_int_pair_array;
2435         type_string             *temp_string;
2436         type_element            *temp_element;
2437
2438         g_print( "[ConfigureInfoPrint] : Entered.\n" );
2439
2440         mmf_return_if_fail( *configure_info );
2441
2442         if( (*configure_info)->type == CONFIGURE_TYPE_MAIN )
2443         {
2444                 category_type = CONFIGURE_CATEGORY_MAIN_NUM;
2445         }
2446         else
2447         {
2448                 category_type = CONFIGURE_CATEGORY_CTRL_NUM;
2449         }
2450
2451         for( i = 0 ; i < category_type ; i++ )
2452         {
2453                 if( (*configure_info)->info[i] )
2454                 {
2455                         g_print( "[ConfigureInfo] : Category [%d]\n", i );
2456                         for( j = 0 ; j < (*configure_info)->info[i]->count ; j++ )
2457                         {
2458                                 if( _mmcamcorder_conf_get_value_type( (*configure_info)->type, i, ((type_int*)((*configure_info)->info[i]->detail_info[j]))->name, &type ) )
2459                                 {
2460                                         switch( type )
2461                                         {
2462                                                 case CONFIGURE_VALUE_INT:
2463                                                         temp_int = (type_int*)((*configure_info)->info[i]->detail_info[j]);
2464                                                         g_print( "[ConfigureInfo] : INT - Name[%s],Value [%d]\n", temp_int->name, temp_int->value );
2465                                                         break;
2466                                                 case CONFIGURE_VALUE_INT_RANGE:
2467                                                         temp_int_range = (type_int_range*)((*configure_info)->info[i]->detail_info[j]);
2468                                                         g_print( "[ConfigureInfo] : INT_RANGE - Name[%s],Value [%d]~[%d], default [%d]\n",
2469                                                                  temp_int_range->name, temp_int_range->min, temp_int_range->max, temp_int_range->default_value );
2470                                                         break;
2471                                                 case CONFIGURE_VALUE_INT_ARRAY:
2472                                                         temp_int_array = (type_int_array*)((*configure_info)->info[i]->detail_info[j]);
2473                                                         g_print( "[ConfigureInfo] : INT_ARRAY - Name[%s], default [%d]\n                            - ",
2474                                                                  temp_int_array->name, temp_int_array->default_value );
2475                                                         for( k = 0 ; k < temp_int_array->count ; k++ )
2476                                                         {
2477                                                                 g_print( "[%d] ", temp_int_array->value[k] );
2478                                                         }
2479                                                         g_print( "\n" );
2480                                                         break;
2481                                                 case CONFIGURE_VALUE_INT_PAIR_ARRAY:
2482                                                         temp_int_pair_array = (type_int_pair_array*)((*configure_info)->info[i]->detail_info[j]);
2483                                                         g_print( "[ConfigureInfo] : INT_PAIR_ARRAY - Name[%s], default [%d][%d]\n                            - ",
2484                                                                  temp_int_pair_array->name, temp_int_pair_array->default_value[0], temp_int_pair_array->default_value[0] );
2485                                                         for( k = 0 ; k < temp_int_pair_array->count ; k++ )
2486                                                         {
2487                                                                 g_print( "[%d,%d] ", temp_int_pair_array->value[0][k], temp_int_pair_array->value[1][k] );
2488                                                         }
2489                                                         g_print( "\n" );
2490                                                         break;
2491                                                 case CONFIGURE_VALUE_STRING:
2492                                                         temp_string = (type_string*)((*configure_info)->info[i]->detail_info[j]);
2493                                                         g_print( "[ConfigureInfo] : STRING - Name[%s],Value[%s]\n", temp_string->name, temp_string->value );
2494                                                         break;
2495                                                 case CONFIGURE_VALUE_ELEMENT:
2496                                                         temp_element = (type_element*)((*configure_info)->info[i]->detail_info[j]);
2497                                                         g_print( "[ConfigureInfo] : Element - Name[%s],Element_Name[%s]\n", temp_element->name, temp_element->element_name );
2498                                                         for( k = 0 ; k < temp_element->count_int ; k++ )
2499                                                         {
2500                                                                 g_print( "                          - INT[%d] Name[%s],Value[%d]\n", k, temp_element->value_int[k]->name, temp_element->value_int[k]->value );
2501                                                         }
2502                                                         for( k = 0 ; k < temp_element->count_string ; k++ )
2503                                                         {
2504                                                                 g_print( "                          - STRING[%d] Name[%s],Value[%s]\n", k, temp_element->value_string[k]->name, temp_element->value_string[k]->value );
2505                                                         }
2506                                                         break;
2507                                                 default:
2508                                                         g_print( "[ConfigureInfo] : Not matched value type... So can not print data... check it... Name[%s],type[%d]\n", ((type_int*)((*configure_info)->info[i]->detail_info[j]))->name, type );
2509                                                         break;
2510                                         }
2511                                 }
2512                                 else
2513                                 {
2514                                         g_print( "[ConfigureInfo] : Failed to get value type." );
2515                                 }
2516                         }
2517                 }
2518         }
2519
2520         g_print( "[ConfigureInfoPrint] : Done.\n" );
2521 }
2522
2523
2524 static type_element *
2525 __mmcamcorder_get_audio_codec_element(MMHandleType handle)
2526 {
2527         type_element *telement = NULL;
2528         const char *codec_type_str = NULL;
2529         int codec_type = MM_AUDIO_CODEC_INVALID;
2530         mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
2531         _MMCamcorderSubContext *sc = NULL;
2532
2533         mmf_return_val_if_fail(hcamcorder, NULL);
2534         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2535
2536         mmf_return_val_if_fail(sc, NULL);
2537
2538         _mmcam_dbg_log("");
2539
2540         /* Check element availability */
2541         mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &codec_type, NULL);
2542
2543         switch( codec_type )
2544         {
2545                 case MM_AUDIO_CODEC_AMR:
2546                         codec_type_str = "AMR";
2547                         break;
2548                 case MM_AUDIO_CODEC_G723_1:
2549                         codec_type_str = "G723_1";
2550                         break;
2551                 case MM_AUDIO_CODEC_MP3:
2552                         codec_type_str = "MP3";
2553                         break;
2554                 case MM_AUDIO_CODEC_AAC:
2555                         codec_type_str = "AAC";
2556                         break;
2557                 case MM_AUDIO_CODEC_MMF:
2558                         codec_type_str = "MMF";
2559                         break;
2560                 case MM_AUDIO_CODEC_ADPCM:
2561                         codec_type_str = "ADPCM";
2562                         break;
2563                 case MM_AUDIO_CODEC_WAVE:
2564                         codec_type_str = "WAVE";
2565                         break;
2566                 case MM_AUDIO_CODEC_MIDI:
2567                         codec_type_str = "MIDI";
2568                         break;
2569                 case MM_AUDIO_CODEC_IMELODY:
2570                         codec_type_str = "IMELODY";
2571                         break;
2572                 case MM_AUDIO_CODEC_VORBIS:
2573                         codec_type_str = "VORBIS";
2574                         break;
2575                 default:
2576                         _mmcam_dbg_err( "Not supported audio codec[%d]", codec_type );
2577                         return NULL;
2578         }
2579
2580         _mmcamcorder_conf_get_element( hcamcorder->conf_main,
2581                                 CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER,
2582                                 codec_type_str,
2583                                 &telement );
2584
2585         return telement;
2586 }
2587
2588
2589 static type_element *
2590 __mmcamcorder_get_video_codec_element(MMHandleType handle)
2591 {
2592         type_element *telement = NULL;
2593         const char *codec_type_str = NULL;
2594         int codec_type = MM_VIDEO_CODEC_INVALID;
2595         mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
2596         _MMCamcorderSubContext *sc = NULL;
2597
2598         mmf_return_val_if_fail(hcamcorder, NULL);
2599         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2600
2601         mmf_return_val_if_fail(sc, NULL);
2602
2603         _mmcam_dbg_log("");
2604
2605         /* Check element availability */
2606         mm_camcorder_get_attributes(handle, NULL, MMCAM_VIDEO_ENCODER, &codec_type, NULL);
2607
2608         switch( codec_type )
2609         {
2610                 case MM_VIDEO_CODEC_H263:
2611                         codec_type_str = "H263";
2612                         break;
2613                 case MM_VIDEO_CODEC_H264:
2614                         codec_type_str = "H264";
2615                         break;
2616                 case MM_VIDEO_CODEC_H26L:
2617                         codec_type_str = "H26L";
2618                         break;
2619                 case MM_VIDEO_CODEC_MPEG4:
2620                         codec_type_str = "MPEG4";
2621                         break;
2622                 case MM_VIDEO_CODEC_MPEG1:
2623                         codec_type_str = "MPEG1";
2624                         break;
2625                 case MM_VIDEO_CODEC_THEORA:
2626                         codec_type_str = "THEORA";
2627                         break;
2628                 default:
2629                         _mmcam_dbg_err( "Not supported video codec[%d]", codec_type );
2630                         return NULL;
2631         }
2632
2633         _mmcamcorder_conf_get_element( hcamcorder->conf_main,
2634                                 CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER,
2635                                 codec_type_str,
2636                                 &telement );
2637
2638         return telement;
2639 }
2640
2641
2642 static type_element *
2643 __mmcamcorder_get_image_codec_element(MMHandleType handle)
2644 {
2645         type_element *telement = NULL;
2646         const char *codec_type_str = NULL;
2647         int codec_type = MM_IMAGE_CODEC_INVALID;
2648         mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
2649         _MMCamcorderSubContext *sc = NULL;
2650
2651         mmf_return_val_if_fail(hcamcorder, NULL);
2652         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2653
2654         mmf_return_val_if_fail(sc, NULL);
2655
2656         _mmcam_dbg_log("");
2657
2658         /* Check element availability */
2659         mm_camcorder_get_attributes(handle, NULL, MMCAM_IMAGE_ENCODER, &codec_type, NULL);
2660
2661         switch( codec_type )
2662         {
2663                 case MM_IMAGE_CODEC_JPEG:
2664                         codec_type_str = "JPEG";
2665                         break;
2666                 case MM_IMAGE_CODEC_SRW:
2667                         codec_type_str = "SRW";
2668                         break;
2669                 case MM_IMAGE_CODEC_JPEG_SRW:
2670                         codec_type_str = "JPEG_SRW";
2671                         break;
2672                 case MM_IMAGE_CODEC_PNG:
2673                         codec_type_str = "PNG";
2674                         break;
2675                 case MM_IMAGE_CODEC_BMP:
2676                         codec_type_str = "BMP";
2677                         break;
2678                 case MM_IMAGE_CODEC_WBMP:
2679                         codec_type_str = "WBMP";
2680                         break;
2681                 case MM_IMAGE_CODEC_TIFF:
2682                         codec_type_str = "TIFF";
2683                         break;
2684                 case MM_IMAGE_CODEC_PCX:
2685                         codec_type_str = "PCX";
2686                         break;
2687                 case MM_IMAGE_CODEC_GIF:
2688                         codec_type_str = "GIF";
2689                         break;
2690                 case MM_IMAGE_CODEC_ICO:
2691                         codec_type_str = "ICO";
2692                         break;
2693                 case MM_IMAGE_CODEC_RAS:
2694                         codec_type_str = "RAS";
2695                         break;
2696                 case MM_IMAGE_CODEC_TGA:
2697                         codec_type_str = "TGA";
2698                         break;
2699                 case MM_IMAGE_CODEC_XBM:
2700                         codec_type_str = "XBM";
2701                         break;
2702                 case MM_IMAGE_CODEC_XPM:
2703                         codec_type_str = "XPM";
2704                         break;
2705                 default:
2706                         _mmcam_dbg_err( "Not supported image codec[%d]", codec_type );
2707                         return NULL;
2708         }
2709
2710         _mmcamcorder_conf_get_element( hcamcorder->conf_main,
2711                                 CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER,
2712                                 codec_type_str,
2713                                 &telement );
2714
2715         return telement;
2716 }
2717
2718
2719 static type_element *
2720 __mmcamcorder_get_file_format_element(MMHandleType handle)
2721 {
2722         type_element *telement = NULL;
2723         const char *mux_type_str = NULL;
2724         int file_type = MM_FILE_FORMAT_INVALID;
2725         mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
2726         _MMCamcorderSubContext *sc = NULL;
2727
2728         mmf_return_val_if_fail(hcamcorder, NULL);
2729         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2730
2731         mmf_return_val_if_fail(sc, NULL);
2732
2733         _mmcam_dbg_log("");
2734
2735         /* Check element availability */
2736         mm_camcorder_get_attributes(handle, NULL, MMCAM_FILE_FORMAT, &file_type, NULL);
2737
2738         switch( file_type )
2739         {
2740                 case MM_FILE_FORMAT_3GP:
2741                         mux_type_str = "3GP";
2742                         break;
2743                 case MM_FILE_FORMAT_AMR:
2744                         mux_type_str = "AMR";
2745                         break;
2746                 case MM_FILE_FORMAT_MP4:
2747                         mux_type_str = "MP4";
2748                         break;
2749                 case MM_FILE_FORMAT_AAC:
2750                         mux_type_str = "AAC";
2751                         break;
2752                 case MM_FILE_FORMAT_MP3:
2753                         mux_type_str = "MP3";
2754                         break;
2755                 case MM_FILE_FORMAT_OGG:
2756                         mux_type_str = "OGG";
2757                         break;
2758                 case MM_FILE_FORMAT_WAV:
2759                         mux_type_str = "WAV";
2760                         break;
2761                 case MM_FILE_FORMAT_AVI:
2762                         mux_type_str = "AVI";
2763                         break;
2764                 case MM_FILE_FORMAT_WMA:
2765                         mux_type_str = "WMA";
2766                         break;
2767                 case MM_FILE_FORMAT_WMV:
2768                         mux_type_str = "WMV";
2769                         break;
2770                 case MM_FILE_FORMAT_MID:
2771                         mux_type_str = "MID";
2772                         break;
2773                 case MM_FILE_FORMAT_MMF:
2774                         mux_type_str = "MMF";
2775                         break;
2776                 case MM_FILE_FORMAT_MATROSKA:
2777                         mux_type_str = "MATROSKA";
2778                         break;
2779                 case MM_FILE_FORMAT_M2TS:
2780                         mux_type_str = "M2TS";
2781                         break;
2782                 default:
2783                         _mmcam_dbg_err( "Not supported file format[%d]", file_type );
2784                         return NULL;
2785         }
2786
2787         _mmcamcorder_conf_get_element( hcamcorder->conf_main,
2788                                 CONFIGURE_CATEGORY_MAIN_MUX,
2789                                 mux_type_str,
2790                                 &telement );
2791
2792         return telement;
2793 }
2794
2795
2796 type_element *
2797 _mmcamcorder_get_type_element(MMHandleType handle, int type)
2798 {
2799         type_element *telement = NULL;
2800
2801         _mmcam_dbg_log("type:%d", type);
2802
2803         switch(type)
2804         {
2805                 case MM_CAM_AUDIO_ENCODER:
2806                         telement = __mmcamcorder_get_audio_codec_element(handle);
2807                         break;
2808                 case MM_CAM_VIDEO_ENCODER:
2809                         telement = __mmcamcorder_get_video_codec_element(handle);
2810                         break;
2811                 case MM_CAM_IMAGE_ENCODER:
2812                         telement = __mmcamcorder_get_image_codec_element(handle);
2813                         break;
2814                 case MM_CAM_FILE_FORMAT:
2815                         telement = __mmcamcorder_get_file_format_element(handle);
2816                         break;
2817                 default :
2818                         _mmcam_dbg_log("Can't get element type form this profile.(%d)", type);
2819         }
2820
2821         return telement;
2822 }
2823
2824
2825 int _mmcamcorder_get_audio_codec_format(MMHandleType handle, const char *name)
2826 {
2827         int codec_index = MM_AUDIO_CODEC_INVALID;
2828
2829         if (!name) {
2830                 _mmcam_dbg_err("name is NULL");
2831                 return MM_AUDIO_CODEC_INVALID;
2832         }
2833
2834         if (!strcmp(name, "AMR")) {
2835                 codec_index = MM_AUDIO_CODEC_AMR;
2836         } else if (!strcmp(name, "G723_1")) {
2837                 codec_index = MM_AUDIO_CODEC_G723_1;
2838         } else if (!strcmp(name, "MP3")) {
2839                 codec_index = MM_AUDIO_CODEC_MP3;
2840         } else if (!strcmp(name, "AAC")) {
2841                 codec_index = MM_AUDIO_CODEC_AAC;
2842         } else if (!strcmp(name, "MMF")) {
2843                 codec_index = MM_AUDIO_CODEC_MMF;
2844         } else if (!strcmp(name, "ADPCM")) {
2845                 codec_index = MM_AUDIO_CODEC_ADPCM;
2846         } else if (!strcmp(name, "WAVE")) {
2847                 codec_index = MM_AUDIO_CODEC_WAVE;
2848         } else if (!strcmp(name, "MIDI")) {
2849                 codec_index = MM_AUDIO_CODEC_MIDI;
2850         } else if (!strcmp(name, "IMELODY")) {
2851                 codec_index = MM_AUDIO_CODEC_IMELODY;
2852         } else if (!strcmp(name, "VORBIS")) {
2853                 codec_index = MM_AUDIO_CODEC_VORBIS;
2854         }
2855
2856         /*_mmcam_dbg_log("audio codec index %d", codec_index);*/
2857
2858         return codec_index;
2859 }
2860
2861
2862
2863 int _mmcamcorder_get_video_codec_format(MMHandleType handle, const char *name)
2864 {
2865         int codec_index = MM_VIDEO_CODEC_INVALID;
2866
2867         if (!name) {
2868                 _mmcam_dbg_err("name is NULL");
2869                 return MM_VIDEO_CODEC_INVALID;
2870         }
2871
2872         if (!strcmp(name, "H263")) {
2873                 codec_index = MM_VIDEO_CODEC_H263;
2874         } else if (!strcmp(name, "H264")) {
2875                 codec_index = MM_VIDEO_CODEC_H264;
2876         } else if (!strcmp(name, "H26L")) {
2877                 codec_index = MM_VIDEO_CODEC_H26L;
2878         } else if (!strcmp(name, "MPEG4")) {
2879                 codec_index = MM_VIDEO_CODEC_MPEG4;
2880         } else if (!strcmp(name, "MPEG1")) {
2881                 codec_index = MM_VIDEO_CODEC_MPEG1;
2882         } else if (!strcmp(name, "THEORA")) {
2883                 codec_index = MM_VIDEO_CODEC_THEORA;
2884         }
2885
2886         /*_mmcam_dbg_log("video codec index %d", codec_index);*/
2887
2888         return codec_index;
2889 }
2890
2891
2892
2893 int _mmcamcorder_get_image_codec_format(MMHandleType handle, const char *name)
2894 {
2895         int codec_index = MM_IMAGE_CODEC_INVALID;
2896
2897         if (!name) {
2898                 _mmcam_dbg_err("name is NULL");
2899                 return MM_IMAGE_CODEC_INVALID;
2900         }
2901
2902         if (!strcmp(name, "JPEG")) {
2903                 codec_index = MM_IMAGE_CODEC_JPEG;
2904         } else if (!strcmp(name, "PNG")) {
2905                 codec_index = MM_IMAGE_CODEC_PNG;
2906         } else if (!strcmp(name, "BMP")) {
2907                 codec_index = MM_IMAGE_CODEC_BMP;
2908         } else if (!strcmp(name, "WBMP")) {
2909                 codec_index = MM_IMAGE_CODEC_WBMP;
2910         } else if (!strcmp(name, "TIFF")) {
2911                 codec_index = MM_IMAGE_CODEC_TIFF;
2912         } else if (!strcmp(name, "PCX")) {
2913                 codec_index = MM_IMAGE_CODEC_PCX;
2914         } else if (!strcmp(name, "GIF")) {
2915                 codec_index = MM_IMAGE_CODEC_GIF;
2916         } else if (!strcmp(name, "ICO")) {
2917                 codec_index = MM_IMAGE_CODEC_ICO;
2918         } else if (!strcmp(name, "RAS")) {
2919                 codec_index = MM_IMAGE_CODEC_RAS;
2920         } else if (!strcmp(name, "TGA")) {
2921                 codec_index = MM_IMAGE_CODEC_TGA;
2922         } else if (!strcmp(name, "XBM")) {
2923                 codec_index = MM_IMAGE_CODEC_XBM;
2924         } else if (!strcmp(name, "XPM")) {
2925                 codec_index = MM_IMAGE_CODEC_XPM;
2926         }
2927
2928         _mmcam_dbg_log("image codec index %d", codec_index);
2929
2930         return codec_index;
2931 }
2932
2933
2934 int _mmcamcorder_get_mux_format(MMHandleType handle, const char *name)
2935 {
2936         int mux_index = MM_FILE_FORMAT_INVALID;
2937
2938         if (!name) {
2939                 _mmcam_dbg_err("name is NULL");
2940                 return MM_FILE_FORMAT_INVALID;
2941         }
2942
2943         if (!strcmp(name, "3GP")) {
2944                 mux_index = MM_FILE_FORMAT_3GP;
2945         } else if (!strcmp(name, "AMR")) {
2946                 mux_index = MM_FILE_FORMAT_AMR;
2947         } else if (!strcmp(name, "MP4")) {
2948                 mux_index = MM_FILE_FORMAT_MP4;
2949         } else if (!strcmp(name, "AAC")) {
2950                 mux_index = MM_FILE_FORMAT_AAC;
2951         } else if (!strcmp(name, "MP3")) {
2952                 mux_index = MM_FILE_FORMAT_MP3;
2953         } else if (!strcmp(name, "OGG")) {
2954                 mux_index = MM_FILE_FORMAT_OGG;
2955         } else if (!strcmp(name, "WAV")) {
2956                 mux_index = MM_FILE_FORMAT_WAV;
2957         } else if (!strcmp(name, "AVI")) {
2958                 mux_index = MM_FILE_FORMAT_AVI;
2959         } else if (!strcmp(name, "WMA")) {
2960                 mux_index = MM_FILE_FORMAT_WMA;
2961         } else if (!strcmp(name, "WMV")) {
2962                 mux_index = MM_FILE_FORMAT_WMV;
2963         } else if (!strcmp(name, "MID")) {
2964                 mux_index = MM_FILE_FORMAT_MID;
2965         } else if (!strcmp(name, "MMF")) {
2966                 mux_index = MM_FILE_FORMAT_MMF;
2967         } else if (!strcmp(name, "MATROSKA")) {
2968                 mux_index = MM_FILE_FORMAT_MATROSKA;
2969         } else if (!strcmp(name, "M2TS")) {
2970                 mux_index = MM_FILE_FORMAT_M2TS;
2971
2972         }
2973
2974         /*_mmcam_dbg_log("mux index %d", mux_index);*/
2975
2976         return mux_index;
2977 }
2978
2979
2980 int
2981 _mmcamcorder_get_format(MMHandleType handle, int conf_category, const char *name)
2982 {
2983         int fmt = -1;
2984
2985         mmf_return_val_if_fail(name, -1);
2986
2987         switch(conf_category)
2988         {
2989                 case CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER:
2990                         fmt = _mmcamcorder_get_audio_codec_format(handle, name);
2991                         break;
2992                 case CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER:
2993                         fmt = _mmcamcorder_get_video_codec_format(handle, name);
2994                         break;
2995                 case CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER:
2996                         fmt = _mmcamcorder_get_image_codec_format(handle, name);
2997                         break;
2998                 case CONFIGURE_CATEGORY_MAIN_MUX:
2999                         fmt = _mmcamcorder_get_mux_format(handle, name);
3000                         break;
3001                 default :
3002                         _mmcam_dbg_log("Can't get format from this category.(%d)", conf_category);
3003         }
3004
3005         return fmt;
3006 }
3007
3008 int
3009 _mmcamcorder_get_available_format(MMHandleType handle, int conf_category, int ** format)
3010 {
3011         mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
3012         camera_conf* configure_info = NULL;
3013         int *arr = NULL;
3014         int total_count = 0;
3015
3016         mmf_return_val_if_fail(hcamcorder, 0);
3017
3018         /*_mmcam_dbg_log("conf_category:%d", conf_category);*/
3019
3020         configure_info = hcamcorder->conf_main;
3021
3022         if (configure_info->info[conf_category]) {
3023                 int i = 0;
3024                 int fmt = 0;
3025                 const char *name = NULL;
3026                 int count = configure_info->info[conf_category]->count;
3027                 conf_detail *info = configure_info->info[conf_category];
3028
3029                 /*_mmcam_dbg_log("count[%d], info[%p]", count, info);*/
3030
3031                 if (count <= 0 || !info) {
3032                         return total_count;
3033                 }
3034
3035                 arr = (int*) g_malloc0(count * sizeof(int));
3036                 if (arr == NULL) {
3037                         _mmcam_dbg_err("malloc failed : %d", count * sizeof(int));
3038                         return 0;
3039                 }
3040
3041                 for (i = 0 ; i < count ; i++) {
3042                         if (info->detail_info[i] == NULL) {
3043                                 continue;
3044                         }
3045
3046                         name = ((type_element*)(info->detail_info[i]))->name;
3047                         fmt = _mmcamcorder_get_format(handle, conf_category, name);
3048                         if (fmt >= 0) {
3049                                 arr[total_count++] = fmt;
3050                         }
3051
3052                         /*_mmcam_dbg_log("name:%s, fmt:%d", name, fmt);*/
3053                 }
3054         }
3055
3056         *format = arr;
3057
3058         return total_count;
3059 }